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 |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 8 | :title="$t('pageCertificates.modal.generateACertificateSigningRequest')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 9 | @ok="onOkGenerateCsrModal" |
| 10 | @cancel="resetForm" |
| 11 | @hidden="$v.$reset()" |
| 12 | > |
Chandra Harkude | 373d243 | 2022-12-15 20:51:02 +0530 | [diff] [blame^] | 13 | <b-form id="generate-csr-form" novalidate> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 14 | <b-container fluid> |
| 15 | <b-row> |
| 16 | <b-col lg="9"> |
| 17 | <b-row> |
| 18 | <b-col lg="6"> |
| 19 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 20 | :label="$t('pageCertificates.modal.certificateType')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 21 | label-for="certificate-type" |
| 22 | > |
| 23 | <b-form-select |
| 24 | id="certificate-type" |
| 25 | v-model="form.certificateType" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 26 | data-test-id="modalGenerateCsr-select-certificateType" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 27 | :options="certificateOptions" |
| 28 | :state="getValidationState($v.form.certificateType)" |
| 29 | @input="$v.form.certificateType.$touch()" |
| 30 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 31 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 32 | <b-form-select-option :value="null" disabled> |
| 33 | {{ $t('global.form.selectAnOption') }} |
| 34 | </b-form-select-option> |
| 35 | </template> |
| 36 | </b-form-select> |
| 37 | <b-form-invalid-feedback role="alert"> |
| 38 | {{ $t('global.form.fieldRequired') }} |
| 39 | </b-form-invalid-feedback> |
| 40 | </b-form-group> |
| 41 | </b-col> |
| 42 | <b-col lg="6"> |
| 43 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 44 | :label="$t('pageCertificates.modal.country')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 45 | label-for="country" |
| 46 | > |
| 47 | <b-form-select |
| 48 | id="country" |
| 49 | v-model="form.country" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 50 | data-test-id="modalGenerateCsr-select-country" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 51 | :options="countryOptions" |
| 52 | :state="getValidationState($v.form.country)" |
| 53 | @input="$v.form.country.$touch()" |
| 54 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 55 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 56 | <b-form-select-option :value="null" disabled> |
| 57 | {{ $t('global.form.selectAnOption') }} |
| 58 | </b-form-select-option> |
| 59 | </template> |
| 60 | </b-form-select> |
| 61 | <b-form-invalid-feedback role="alert"> |
| 62 | {{ $t('global.form.fieldRequired') }} |
| 63 | </b-form-invalid-feedback> |
| 64 | </b-form-group> |
| 65 | </b-col> |
| 66 | </b-row> |
| 67 | <b-row> |
| 68 | <b-col lg="6"> |
| 69 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 70 | :label="$t('pageCertificates.modal.state')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 71 | label-for="state" |
| 72 | > |
| 73 | <b-form-input |
| 74 | id="state" |
| 75 | v-model="form.state" |
| 76 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 77 | data-test-id="modalGenerateCsr-input-state" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 78 | :state="getValidationState($v.form.state)" |
| 79 | /> |
| 80 | <b-form-invalid-feedback role="alert"> |
| 81 | {{ $t('global.form.fieldRequired') }} |
| 82 | </b-form-invalid-feedback> |
| 83 | </b-form-group> |
| 84 | </b-col> |
| 85 | <b-col lg="6"> |
| 86 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 87 | :label="$t('pageCertificates.modal.city')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 88 | label-for="city" |
| 89 | > |
| 90 | <b-form-input |
| 91 | id="city" |
| 92 | v-model="form.city" |
| 93 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 94 | data-test-id="modalGenerateCsr-input-city" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 95 | :state="getValidationState($v.form.city)" |
| 96 | /> |
| 97 | <b-form-invalid-feedback role="alert"> |
| 98 | {{ $t('global.form.fieldRequired') }} |
| 99 | </b-form-invalid-feedback> |
| 100 | </b-form-group> |
| 101 | </b-col> |
| 102 | </b-row> |
| 103 | <b-row> |
| 104 | <b-col lg="6"> |
| 105 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 106 | :label="$t('pageCertificates.modal.companyName')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 107 | label-for="company-name" |
| 108 | > |
| 109 | <b-form-input |
| 110 | id="company-name" |
| 111 | v-model="form.companyName" |
| 112 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 113 | data-test-id="modalGenerateCsr-input-companyName" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 114 | :state="getValidationState($v.form.companyName)" |
| 115 | /> |
| 116 | <b-form-invalid-feedback role="alert"> |
| 117 | {{ $t('global.form.fieldRequired') }} |
| 118 | </b-form-invalid-feedback> |
| 119 | </b-form-group> |
| 120 | </b-col> |
| 121 | <b-col lg="6"> |
| 122 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 123 | :label="$t('pageCertificates.modal.companyUnit')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 124 | label-for="company-unit" |
| 125 | > |
| 126 | <b-form-input |
| 127 | id="company-unit" |
| 128 | v-model="form.companyUnit" |
| 129 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 130 | data-test-id="modalGenerateCsr-input-companyUnit" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 131 | :state="getValidationState($v.form.companyUnit)" |
| 132 | /> |
| 133 | <b-form-invalid-feedback role="alert"> |
| 134 | {{ $t('global.form.fieldRequired') }} |
| 135 | </b-form-invalid-feedback> |
| 136 | </b-form-group> |
| 137 | </b-col> |
| 138 | </b-row> |
| 139 | <b-row> |
| 140 | <b-col lg="6"> |
| 141 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 142 | :label="$t('pageCertificates.modal.commonName')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 143 | label-for="common-name" |
| 144 | > |
| 145 | <b-form-input |
| 146 | id="common-name" |
| 147 | v-model="form.commonName" |
| 148 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 149 | data-test-id="modalGenerateCsr-input-commonName" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 150 | :state="getValidationState($v.form.commonName)" |
| 151 | /> |
| 152 | <b-form-invalid-feedback role="alert"> |
| 153 | {{ $t('global.form.fieldRequired') }} |
| 154 | </b-form-invalid-feedback> |
| 155 | </b-form-group> |
| 156 | </b-col> |
| 157 | <b-col lg="6"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 158 | <b-form-group label-for="challenge-password"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 159 | <template #label> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 160 | {{ $t('pageCertificates.modal.challengePassword') }} - |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 161 | <span class="form-text d-inline"> |
| 162 | {{ $t('global.form.optional') }} |
| 163 | </span> |
| 164 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 165 | <b-form-input |
| 166 | id="challenge-password" |
| 167 | v-model="form.challengePassword" |
| 168 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 169 | data-test-id="modalGenerateCsr-input-challengePassword" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 170 | /> |
| 171 | </b-form-group> |
| 172 | </b-col> |
| 173 | </b-row> |
| 174 | <b-row> |
| 175 | <b-col lg="6"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 176 | <b-form-group label-for="contact-person"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 177 | <template #label> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 178 | {{ $t('pageCertificates.modal.contactPerson') }} - |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 179 | <span class="form-text d-inline"> |
| 180 | {{ $t('global.form.optional') }} |
| 181 | </span> |
| 182 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 183 | <b-form-input |
| 184 | id="contact-person" |
| 185 | v-model="form.contactPerson" |
| 186 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 187 | data-test-id="modalGenerateCsr-input-contactPerson" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 188 | /> |
| 189 | </b-form-group> |
| 190 | </b-col> |
| 191 | <b-col lg="6"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 192 | <b-form-group label-for="email-address"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 193 | <template #label> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 194 | {{ $t('pageCertificates.modal.emailAddress') }} - |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 195 | <span class="form-text d-inline"> |
| 196 | {{ $t('global.form.optional') }} |
| 197 | </span> |
| 198 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 199 | <b-form-input |
| 200 | id="email-address" |
| 201 | v-model="form.emailAddress" |
| 202 | type="text" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 203 | data-test-id="modalGenerateCsr-input-emailAddress" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 204 | /> |
| 205 | </b-form-group> |
| 206 | </b-col> |
| 207 | </b-row> |
| 208 | <b-row> |
| 209 | <b-col lg="12"> |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 210 | <b-form-group label-for="alternate-name"> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 211 | <template #label> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 212 | {{ $t('pageCertificates.modal.alternateName') }} - |
Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 213 | <span class="form-text d-inline"> |
| 214 | {{ $t('global.form.optional') }} |
| 215 | </span> |
| 216 | </template> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 217 | <b-form-text id="alternate-name-help-block"> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 218 | {{ $t('pageCertificates.modal.alternateNameHelperText') }} |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 219 | </b-form-text> |
| 220 | <b-form-tags |
| 221 | v-model="form.alternateName" |
| 222 | :remove-on-delete="true" |
| 223 | :tag-pills="true" |
| 224 | input-id="alternate-name" |
| 225 | size="lg" |
| 226 | separator=" " |
| 227 | :input-attrs="{ |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 228 | 'aria-describedby': 'alternate-name-help-block', |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 229 | }" |
| 230 | :duplicate-tag-text=" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 231 | $t('pageCertificates.modal.duplicateAlternateName') |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 232 | " |
| 233 | placeholder="" |
Sandeepa Singh | 92f8755 | 2021-02-12 18:13:46 +0530 | [diff] [blame] | 234 | data-test-id="modalGenerateCsr-input-alternateName" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 235 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 236 | <template #add-button-text> |
Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 237 | <icon-add /> {{ $t('global.action.add') }} |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 238 | </template> |
| 239 | </b-form-tags> |
| 240 | </b-form-group> |
| 241 | </b-col> |
| 242 | </b-row> |
| 243 | </b-col> |
| 244 | <b-col lg="3"> |
| 245 | <b-row> |
| 246 | <b-col lg="12"> |
| 247 | <p class="col-form-label"> |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 248 | {{ $t('pageCertificates.modal.privateKey') }} |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 249 | </p> |
| 250 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 251 | :label="$t('pageCertificates.modal.keyPairAlgorithm')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 252 | label-for="key-pair-algorithm" |
| 253 | > |
| 254 | <b-form-select |
| 255 | id="key-pair-algorithm" |
| 256 | v-model="form.keyPairAlgorithm" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 257 | data-test-id="modalGenerateCsr-select-keyPairAlgorithm" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 258 | :options="keyPairAlgorithmOptions" |
| 259 | :state="getValidationState($v.form.keyPairAlgorithm)" |
| 260 | @input="$v.form.keyPairAlgorithm.$touch()" |
| 261 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 262 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 263 | <b-form-select-option :value="null" disabled> |
| 264 | {{ $t('global.form.selectAnOption') }} |
| 265 | </b-form-select-option> |
| 266 | </template> |
| 267 | </b-form-select> |
| 268 | <b-form-invalid-feedback role="alert"> |
| 269 | {{ $t('global.form.fieldRequired') }} |
| 270 | </b-form-invalid-feedback> |
| 271 | </b-form-group> |
| 272 | </b-col> |
| 273 | </b-row> |
| 274 | <b-row> |
| 275 | <b-col lg="12"> |
| 276 | <template v-if="$v.form.keyPairAlgorithm.$model === 'EC'"> |
| 277 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 278 | :label="$t('pageCertificates.modal.keyCurveId')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 279 | label-for="key-curve-id" |
| 280 | > |
| 281 | <b-form-select |
| 282 | id="key-curve-id" |
| 283 | v-model="form.keyCurveId" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 284 | data-test-id="modalGenerateCsr-select-keyCurveId" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 285 | :options="keyCurveIdOptions" |
| 286 | :state="getValidationState($v.form.keyCurveId)" |
| 287 | @input="$v.form.keyCurveId.$touch()" |
| 288 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 289 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 290 | <b-form-select-option :value="null" disabled> |
| 291 | {{ $t('global.form.selectAnOption') }} |
| 292 | </b-form-select-option> |
| 293 | </template> |
| 294 | </b-form-select> |
| 295 | <b-form-invalid-feedback role="alert"> |
| 296 | {{ $t('global.form.fieldRequired') }} |
| 297 | </b-form-invalid-feedback> |
| 298 | </b-form-group> |
| 299 | </template> |
| 300 | <template v-if="$v.form.keyPairAlgorithm.$model === 'RSA'"> |
| 301 | <b-form-group |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 302 | :label="$t('pageCertificates.modal.keyBitLength')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 303 | label-for="key-bit-length" |
| 304 | > |
| 305 | <b-form-select |
| 306 | id="key-bit-length" |
| 307 | v-model="form.keyBitLength" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 308 | data-test-id="modalGenerateCsr-select-keyBitLength" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 309 | :options="keyBitLengthOptions" |
| 310 | :state="getValidationState($v.form.keyBitLength)" |
| 311 | @input="$v.form.keyBitLength.$touch()" |
| 312 | > |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 313 | <template #first> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 314 | <b-form-select-option :value="null" disabled> |
| 315 | {{ $t('global.form.selectAnOption') }} |
| 316 | </b-form-select-option> |
| 317 | </template> |
| 318 | </b-form-select> |
| 319 | <b-form-invalid-feedback role="alert"> |
| 320 | {{ $t('global.form.fieldRequired') }} |
| 321 | </b-form-invalid-feedback> |
| 322 | </b-form-group> |
| 323 | </template> |
| 324 | </b-col> |
| 325 | </b-row> |
| 326 | </b-col> |
| 327 | </b-row> |
| 328 | </b-container> |
| 329 | </b-form> |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 330 | <template #modal-footer="{ ok, cancel }"> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 331 | <b-button variant="secondary" @click="cancel()"> |
| 332 | {{ $t('global.action.cancel') }} |
| 333 | </b-button> |
| 334 | <b-button |
| 335 | form="generate-csr-form" |
| 336 | type="submit" |
| 337 | variant="primary" |
SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 338 | data-test-id="modalGenerateCsr-button-ok" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 339 | @click="ok()" |
| 340 | > |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 341 | {{ $t('pageCertificates.generateCsr') }} |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 342 | </b-button> |
| 343 | </template> |
| 344 | </b-modal> |
| 345 | <b-modal |
| 346 | id="csr-string" |
| 347 | no-stacking |
| 348 | size="lg" |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 349 | :title="$t('pageCertificates.modal.certificateSigningRequest')" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 350 | @hidden="onHiddenCsrStringModal" |
| 351 | > |
| 352 | {{ csrString }} |
Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 353 | <template #modal-footer> |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 354 | <b-btn variant="secondary" @click="copyCsrString"> |
| 355 | <template v-if="csrStringCopied"> |
| 356 | <icon-checkmark /> |
| 357 | {{ $t('global.status.copied') }} |
| 358 | </template> |
| 359 | <template v-else> |
| 360 | {{ $t('global.action.copy') }} |
| 361 | </template> |
| 362 | </b-btn> |
| 363 | <a |
Sivaprabu Ganesan | c72f1e3 | 2023-01-06 20:06:04 +0530 | [diff] [blame] | 364 | :href=" |
| 365 | `data:application/json;charset=utf-8,` + |
| 366 | encodeURIComponent(`${csrString}`) |
| 367 | " |
| 368 | download="certificate.csr" |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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'; |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 385 | import { CERTIFICATE_TYPES } from '@/store/modules/SecurityAndAccess/CertificatesStore'; |
SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 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 |
Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 461 | .dispatch('certificates/generateCsr', this.form) |
Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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> |