Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 1 | <template> |
| 2 | <div> |
| 3 | <b-modal |
| 4 | id="generate-csr" |
| 5 | ref="modal" |
| 6 | size="lg" |
| 7 | no-stacking |
| 8 | :title=" |
| 9 | $t('pageSslCertificates.modal.generateACertificateSigningRequest') |
| 10 | " |
| 11 | @ok="onOkGenerateCsrModal" |
| 12 | @cancel="resetForm" |
| 13 | @hidden="$v.$reset()" |
| 14 | > |
Yoshie Muranaka | c77fdaf | 2020-05-04 09:33:51 -0700 | [diff] [blame] | 15 | <b-form id="generate-csr-form" novalidate @submit.prevent="handleSubmit"> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 16 | <b-container fluid> |
| 17 | <b-row> |
| 18 | <b-col lg="9"> |
| 19 | <b-row> |
| 20 | <b-col lg="6"> |
| 21 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 22 | :label="$t('pageSslCertificates.modal.certificateType')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 23 | label-for="certificate-type" |
| 24 | > |
| 25 | <b-form-select |
| 26 | id="certificate-type" |
| 27 | v-model="form.certificateType" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 28 | data-test-id="modalGenerateCsr-select-certificateType" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 29 | :options="certificateOptions" |
| 30 | :state="getValidationState($v.form.certificateType)" |
| 31 | @input="$v.form.certificateType.$touch()" |
| 32 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 33 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 34 | <b-form-select-option :value="null" disabled> |
| 35 | {{ $t('global.form.selectAnOption') }} |
| 36 | </b-form-select-option> |
| 37 | </template> |
| 38 | </b-form-select> |
| 39 | <b-form-invalid-feedback role="alert"> |
| 40 | {{ $t('global.form.fieldRequired') }} |
| 41 | </b-form-invalid-feedback> |
| 42 | </b-form-group> |
| 43 | </b-col> |
| 44 | <b-col lg="6"> |
| 45 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 46 | :label="$t('pageSslCertificates.modal.country')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 47 | label-for="country" |
| 48 | > |
| 49 | <b-form-select |
| 50 | id="country" |
| 51 | v-model="form.country" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 52 | data-test-id="modalGenerateCsr-select-country" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 53 | :options="countryOptions" |
| 54 | :state="getValidationState($v.form.country)" |
| 55 | @input="$v.form.country.$touch()" |
| 56 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 57 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 58 | <b-form-select-option :value="null" disabled> |
| 59 | {{ $t('global.form.selectAnOption') }} |
| 60 | </b-form-select-option> |
| 61 | </template> |
| 62 | </b-form-select> |
| 63 | <b-form-invalid-feedback role="alert"> |
| 64 | {{ $t('global.form.fieldRequired') }} |
| 65 | </b-form-invalid-feedback> |
| 66 | </b-form-group> |
| 67 | </b-col> |
| 68 | </b-row> |
| 69 | <b-row> |
| 70 | <b-col lg="6"> |
| 71 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 72 | :label="$t('pageSslCertificates.modal.state')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 73 | label-for="state" |
| 74 | > |
| 75 | <b-form-input |
| 76 | id="state" |
| 77 | v-model="form.state" |
| 78 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 79 | data-test-id="modalGenerateCsr-input-state" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 80 | :state="getValidationState($v.form.state)" |
| 81 | /> |
| 82 | <b-form-invalid-feedback role="alert"> |
| 83 | {{ $t('global.form.fieldRequired') }} |
| 84 | </b-form-invalid-feedback> |
| 85 | </b-form-group> |
| 86 | </b-col> |
| 87 | <b-col lg="6"> |
| 88 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 89 | :label="$t('pageSslCertificates.modal.city')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 90 | label-for="city" |
| 91 | > |
| 92 | <b-form-input |
| 93 | id="city" |
| 94 | v-model="form.city" |
| 95 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 96 | data-test-id="modalGenerateCsr-input-city" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 97 | :state="getValidationState($v.form.city)" |
| 98 | /> |
| 99 | <b-form-invalid-feedback role="alert"> |
| 100 | {{ $t('global.form.fieldRequired') }} |
| 101 | </b-form-invalid-feedback> |
| 102 | </b-form-group> |
| 103 | </b-col> |
| 104 | </b-row> |
| 105 | <b-row> |
| 106 | <b-col lg="6"> |
| 107 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 108 | :label="$t('pageSslCertificates.modal.companyName')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 109 | label-for="company-name" |
| 110 | > |
| 111 | <b-form-input |
| 112 | id="company-name" |
| 113 | v-model="form.companyName" |
| 114 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 115 | data-test-id="modalGenerateCsr-input-companyName" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 116 | :state="getValidationState($v.form.companyName)" |
| 117 | /> |
| 118 | <b-form-invalid-feedback role="alert"> |
| 119 | {{ $t('global.form.fieldRequired') }} |
| 120 | </b-form-invalid-feedback> |
| 121 | </b-form-group> |
| 122 | </b-col> |
| 123 | <b-col lg="6"> |
| 124 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 125 | :label="$t('pageSslCertificates.modal.companyUnit')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 126 | label-for="company-unit" |
| 127 | > |
| 128 | <b-form-input |
| 129 | id="company-unit" |
| 130 | v-model="form.companyUnit" |
| 131 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 132 | data-test-id="modalGenerateCsr-input-companyUnit" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 133 | :state="getValidationState($v.form.companyUnit)" |
| 134 | /> |
| 135 | <b-form-invalid-feedback role="alert"> |
| 136 | {{ $t('global.form.fieldRequired') }} |
| 137 | </b-form-invalid-feedback> |
| 138 | </b-form-group> |
| 139 | </b-col> |
| 140 | </b-row> |
| 141 | <b-row> |
| 142 | <b-col lg="6"> |
| 143 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 144 | :label="$t('pageSslCertificates.modal.commonName')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 145 | label-for="common-name" |
| 146 | > |
| 147 | <b-form-input |
| 148 | id="common-name" |
| 149 | v-model="form.commonName" |
| 150 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 151 | data-test-id="modalGenerateCsr-input-commonName" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 152 | :state="getValidationState($v.form.commonName)" |
| 153 | /> |
| 154 | <b-form-invalid-feedback role="alert"> |
| 155 | {{ $t('global.form.fieldRequired') }} |
| 156 | </b-form-invalid-feedback> |
| 157 | </b-form-group> |
| 158 | </b-col> |
| 159 | <b-col lg="6"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 160 | <b-form-group label-for="challenge-password"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 161 | <template #label> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 162 | {{ $t('pageSslCertificates.modal.challengePassword') }} - |
| 163 | <span class="form-text d-inline"> |
| 164 | {{ $t('global.form.optional') }} |
| 165 | </span> |
| 166 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 167 | <b-form-input |
| 168 | id="challenge-password" |
| 169 | v-model="form.challengePassword" |
| 170 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 171 | data-test-id="modalGenerateCsr-input-challengePassword" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 172 | /> |
| 173 | </b-form-group> |
| 174 | </b-col> |
| 175 | </b-row> |
| 176 | <b-row> |
| 177 | <b-col lg="6"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 178 | <b-form-group label-for="contact-person"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 179 | <template #label> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 180 | {{ $t('pageSslCertificates.modal.contactPerson') }} - |
| 181 | <span class="form-text d-inline"> |
| 182 | {{ $t('global.form.optional') }} |
| 183 | </span> |
| 184 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 185 | <b-form-input |
| 186 | id="contact-person" |
| 187 | v-model="form.contactPerson" |
| 188 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 189 | data-test-id="modalGenerateCsr-input-contactPerson" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 190 | /> |
| 191 | </b-form-group> |
| 192 | </b-col> |
| 193 | <b-col lg="6"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 194 | <b-form-group label-for="email-address"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 195 | <template #label> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 196 | {{ $t('pageSslCertificates.modal.emailAddress') }} - |
| 197 | <span class="form-text d-inline"> |
| 198 | {{ $t('global.form.optional') }} |
| 199 | </span> |
| 200 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 201 | <b-form-input |
| 202 | id="email-address" |
| 203 | v-model="form.emailAddress" |
| 204 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 205 | data-test-id="modalGenerateCsr-input-emailAddress" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 206 | /> |
| 207 | </b-form-group> |
| 208 | </b-col> |
| 209 | </b-row> |
| 210 | <b-row> |
| 211 | <b-col lg="12"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 212 | <b-form-group label-for="alternate-name"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 213 | <template #label> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 214 | {{ $t('pageSslCertificates.modal.alternateName') }} - |
| 215 | <span class="form-text d-inline"> |
| 216 | {{ $t('global.form.optional') }} |
| 217 | </span> |
| 218 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 219 | <b-form-text id="alternate-name-help-block"> |
| 220 | {{ |
| 221 | $t('pageSslCertificates.modal.alternateNameHelperText') |
| 222 | }} |
| 223 | </b-form-text> |
| 224 | <b-form-tags |
| 225 | v-model="form.alternateName" |
| 226 | :remove-on-delete="true" |
| 227 | :tag-pills="true" |
| 228 | input-id="alternate-name" |
| 229 | size="lg" |
| 230 | separator=" " |
| 231 | :input-attrs="{ |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 232 | 'aria-describedby': 'alternate-name-help-block', |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 233 | }" |
| 234 | :duplicate-tag-text=" |
| 235 | $t('pageSslCertificates.modal.duplicateAlternateName') |
| 236 | " |
| 237 | placeholder="" |
| 238 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 239 | <template #add-button-text> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 240 | {{ $t('global.action.add') }} <icon-add /> |
| 241 | </template> |
| 242 | </b-form-tags> |
| 243 | </b-form-group> |
| 244 | </b-col> |
| 245 | </b-row> |
| 246 | </b-col> |
| 247 | <b-col lg="3"> |
| 248 | <b-row> |
| 249 | <b-col lg="12"> |
| 250 | <p class="col-form-label"> |
| 251 | {{ $t('pageSslCertificates.modal.privateKey') }} |
| 252 | </p> |
| 253 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 254 | :label="$t('pageSslCertificates.modal.keyPairAlgorithm')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 255 | label-for="key-pair-algorithm" |
| 256 | > |
| 257 | <b-form-select |
| 258 | id="key-pair-algorithm" |
| 259 | v-model="form.keyPairAlgorithm" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 260 | data-test-id="modalGenerateCsr-select-keyPairAlgorithm" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 261 | :options="keyPairAlgorithmOptions" |
| 262 | :state="getValidationState($v.form.keyPairAlgorithm)" |
| 263 | @input="$v.form.keyPairAlgorithm.$touch()" |
| 264 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 265 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 266 | <b-form-select-option :value="null" disabled> |
| 267 | {{ $t('global.form.selectAnOption') }} |
| 268 | </b-form-select-option> |
| 269 | </template> |
| 270 | </b-form-select> |
| 271 | <b-form-invalid-feedback role="alert"> |
| 272 | {{ $t('global.form.fieldRequired') }} |
| 273 | </b-form-invalid-feedback> |
| 274 | </b-form-group> |
| 275 | </b-col> |
| 276 | </b-row> |
| 277 | <b-row> |
| 278 | <b-col lg="12"> |
| 279 | <template v-if="$v.form.keyPairAlgorithm.$model === 'EC'"> |
| 280 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 281 | :label="$t('pageSslCertificates.modal.keyCurveId')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 282 | label-for="key-curve-id" |
| 283 | > |
| 284 | <b-form-select |
| 285 | id="key-curve-id" |
| 286 | v-model="form.keyCurveId" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 287 | data-test-id="modalGenerateCsr-select-keyCurveId" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 288 | :options="keyCurveIdOptions" |
| 289 | :state="getValidationState($v.form.keyCurveId)" |
| 290 | @input="$v.form.keyCurveId.$touch()" |
| 291 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 292 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 293 | <b-form-select-option :value="null" disabled> |
| 294 | {{ $t('global.form.selectAnOption') }} |
| 295 | </b-form-select-option> |
| 296 | </template> |
| 297 | </b-form-select> |
| 298 | <b-form-invalid-feedback role="alert"> |
| 299 | {{ $t('global.form.fieldRequired') }} |
| 300 | </b-form-invalid-feedback> |
| 301 | </b-form-group> |
| 302 | </template> |
| 303 | <template v-if="$v.form.keyPairAlgorithm.$model === 'RSA'"> |
| 304 | <b-form-group |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 305 | :label="$t('pageSslCertificates.modal.keyBitLength')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 306 | label-for="key-bit-length" |
| 307 | > |
| 308 | <b-form-select |
| 309 | id="key-bit-length" |
| 310 | v-model="form.keyBitLength" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 311 | data-test-id="modalGenerateCsr-select-keyBitLength" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 312 | :options="keyBitLengthOptions" |
| 313 | :state="getValidationState($v.form.keyBitLength)" |
| 314 | @input="$v.form.keyBitLength.$touch()" |
| 315 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 316 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 317 | <b-form-select-option :value="null" disabled> |
| 318 | {{ $t('global.form.selectAnOption') }} |
| 319 | </b-form-select-option> |
| 320 | </template> |
| 321 | </b-form-select> |
| 322 | <b-form-invalid-feedback role="alert"> |
| 323 | {{ $t('global.form.fieldRequired') }} |
| 324 | </b-form-invalid-feedback> |
| 325 | </b-form-group> |
| 326 | </template> |
| 327 | </b-col> |
| 328 | </b-row> |
| 329 | </b-col> |
| 330 | </b-row> |
| 331 | </b-container> |
| 332 | </b-form> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 333 | <template #modal-footer="{ ok, cancel }"> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 334 | <b-button variant="secondary" @click="cancel()"> |
| 335 | {{ $t('global.action.cancel') }} |
| 336 | </b-button> |
| 337 | <b-button |
| 338 | form="generate-csr-form" |
| 339 | type="submit" |
| 340 | variant="primary" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 341 | data-test-id="modalGenerateCsr-button-ok" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 342 | @click="ok()" |
| 343 | > |
| 344 | {{ $t('pageSslCertificates.generateCsr') }} |
| 345 | </b-button> |
| 346 | </template> |
| 347 | </b-modal> |
| 348 | <b-modal |
| 349 | id="csr-string" |
| 350 | no-stacking |
| 351 | size="lg" |
| 352 | :title="$t('pageSslCertificates.modal.certificateSigningRequest')" |
| 353 | @hidden="onHiddenCsrStringModal" |
| 354 | > |
| 355 | {{ csrString }} |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 356 | <template #modal-footer> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 357 | <b-btn variant="secondary" @click="copyCsrString"> |
| 358 | <template v-if="csrStringCopied"> |
| 359 | <icon-checkmark /> |
| 360 | {{ $t('global.status.copied') }} |
| 361 | </template> |
| 362 | <template v-else> |
| 363 | {{ $t('global.action.copy') }} |
| 364 | </template> |
| 365 | </b-btn> |
| 366 | <a |
| 367 | :href="`data:text/json;charset=utf-8,${csrString}`" |
| 368 | download="certificate.txt" |
| 369 | class="btn btn-primary" |
| 370 | > |
| 371 | {{ $t('global.action.download') }} |
| 372 | </a> |
| 373 | </template> |
| 374 | </b-modal> |
| 375 | </div> |
| 376 | </template> |
| 377 | |
| 378 | <script> |
| 379 | import IconAdd from '@carbon/icons-vue/es/add--alt/20'; |
| 380 | import IconCheckmark from '@carbon/icons-vue/es/checkmark/20'; |
| 381 | |
| 382 | import { required, requiredIf } from 'vuelidate/lib/validators'; |
| 383 | |
| 384 | import { COUNTRY_LIST } from './CsrCountryCodes'; |
SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 385 | import { CERTIFICATE_TYPES } from '@/store/modules/AccessControl/SslCertificatesStore'; |
| 386 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; |
| 387 | import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 388 | |
| 389 | export default { |
| 390 | name: 'ModalGenerateCsr', |
| 391 | components: { IconAdd, IconCheckmark }, |
| 392 | mixins: [BVToastMixin, VuelidateMixin], |
| 393 | data() { |
| 394 | return { |
| 395 | form: { |
| 396 | certificateType: null, |
| 397 | country: null, |
| 398 | state: null, |
| 399 | city: null, |
| 400 | companyName: null, |
| 401 | companyUnit: null, |
| 402 | commonName: null, |
| 403 | challengePassword: null, |
| 404 | contactPerson: null, |
| 405 | emailAddress: null, |
| 406 | alternateName: [], |
| 407 | keyPairAlgorithm: null, |
| 408 | keyCurveId: null, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 409 | keyBitLength: null, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 410 | }, |
| 411 | certificateOptions: CERTIFICATE_TYPES.reduce((arr, cert) => { |
| 412 | if (cert.type === 'TrustStore Certificate') return arr; |
| 413 | arr.push({ |
| 414 | text: cert.label, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 415 | value: cert.type, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 416 | }); |
| 417 | return arr; |
| 418 | }, []), |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 419 | countryOptions: COUNTRY_LIST.map((country) => ({ |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 420 | text: country.label, |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 421 | value: country.code, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 422 | })), |
| 423 | keyPairAlgorithmOptions: ['EC', 'RSA'], |
| 424 | keyCurveIdOptions: ['prime256v1', 'secp521r1', 'secp384r1'], |
| 425 | keyBitLengthOptions: [2048], |
| 426 | csrString: '', |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 427 | csrStringCopied: false, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 428 | }; |
| 429 | }, |
| 430 | validations: { |
| 431 | form: { |
| 432 | certificateType: { required }, |
| 433 | country: { required }, |
| 434 | state: { required }, |
| 435 | city: { required }, |
| 436 | companyName: { required }, |
| 437 | companyUnit: { required }, |
| 438 | commonName: { required }, |
| 439 | challengePassword: {}, |
| 440 | contactPerson: {}, |
| 441 | emailAddress: {}, |
| 442 | alternateName: {}, |
| 443 | keyPairAlgorithm: { required }, |
| 444 | keyCurveId: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 445 | reuired: requiredIf(function (form) { |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 446 | return form.keyPairAlgorithm === 'EC'; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 447 | }), |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 448 | }, |
| 449 | keyBitLength: { |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 450 | reuired: requiredIf(function (form) { |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 451 | return form.keyPairAlgorithm === 'RSA'; |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 452 | }), |
| 453 | }, |
| 454 | }, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 455 | }, |
| 456 | methods: { |
| 457 | handleSubmit() { |
| 458 | this.$v.$touch(); |
| 459 | if (this.$v.$invalid) return; |
| 460 | this.$store |
| 461 | .dispatch('sslCertificates/generateCsr', this.form) |
| 462 | .then(({ data: { CSRString } }) => { |
| 463 | this.csrString = CSRString; |
| 464 | this.$bvModal.show('csr-string'); |
| 465 | this.$v.$reset(); |
| 466 | }); |
| 467 | }, |
| 468 | resetForm() { |
| 469 | for (let key of Object.keys(this.form)) { |
| 470 | if (key === 'alternateName') { |
| 471 | this.form[key] = []; |
| 472 | } else { |
| 473 | this.form[key] = null; |
| 474 | } |
| 475 | } |
| 476 | }, |
| 477 | onOkGenerateCsrModal(bvModalEvt) { |
| 478 | // prevent modal close |
| 479 | bvModalEvt.preventDefault(); |
| 480 | this.handleSubmit(); |
| 481 | }, |
| 482 | onHiddenCsrStringModal() { |
| 483 | this.csrString = ''; |
| 484 | this.resetForm(); |
| 485 | }, |
| 486 | copyCsrString(bvModalEvt) { |
| 487 | // prevent modal close |
| 488 | bvModalEvt.preventDefault(); |
| 489 | navigator.clipboard.writeText(this.csrString).then(() => { |
| 490 | // Show copied text for 5 seconds |
| 491 | this.csrStringCopied = true; |
| 492 | setTimeout(() => { |
| 493 | this.csrStringCopied = false; |
| 494 | }, 5000 /*5 seconds*/); |
| 495 | }); |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame^] | 496 | }, |
| 497 | }, |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 498 | }; |
| 499 | </script> |