| 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 11 |       @hidden="v$.$reset()" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 28 |                       :state="getValidationState(v$.form.certificateType)" | 
 | 29 |                       @input="v$.form.certificateType.$touch()" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 52 |                       :state="getValidationState(v$.form.country)" | 
 | 53 |                       @input="v$.form.country.$touch()" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 78 |                       :state="getValidationState(v$.form.state)" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 95 |                       :state="getValidationState(v$.form.city)" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 114 |                       :state="getValidationState(v$.form.companyName)" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 131 |                       :state="getValidationState(v$.form.companyUnit)" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 150 |                       :state="getValidationState(v$.form.commonName)" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 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="contact-person"> | 
| 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.contactPerson') }} - | 
| 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="contact-person" | 
 | 167 |                       v-model="form.contactPerson" | 
 | 168 |                       type="text" | 
| SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 169 |                       data-test-id="modalGenerateCsr-input-contactPerson" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 170 |                     /> | 
 | 171 |                   </b-form-group> | 
 | 172 |                 </b-col> | 
| Vedangi Mittal | dfba4e5 | 2024-04-23 14:13:23 +0530 | [diff] [blame] | 173 |               </b-row> | 
 | 174 |               <b-row> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 175 |                 <b-col lg="6"> | 
| Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 176 |                   <b-form-group label-for="email-address"> | 
| 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.emailAddress') }} - | 
| 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="email-address" | 
 | 185 |                       v-model="form.emailAddress" | 
 | 186 |                       type="text" | 
| SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 187 |                       data-test-id="modalGenerateCsr-input-emailAddress" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 188 |                     /> | 
 | 189 |                   </b-form-group> | 
 | 190 |                 </b-col> | 
 | 191 |               </b-row> | 
 | 192 |               <b-row> | 
 | 193 |                 <b-col lg="12"> | 
| Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 194 |                   <b-form-group label-for="alternate-name"> | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 195 |                     <template #label> | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 196 |                       {{ $t('pageCertificates.modal.alternateName') }} - | 
| Dixsie Wolmers | 46f17ef | 2020-09-08 14:53:25 -0500 | [diff] [blame] | 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-text id="alternate-name-help-block"> | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 202 |                       {{ $t('pageCertificates.modal.alternateNameHelperText') }} | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 203 |                     </b-form-text> | 
 | 204 |                     <b-form-tags | 
 | 205 |                       v-model="form.alternateName" | 
 | 206 |                       :remove-on-delete="true" | 
 | 207 |                       :tag-pills="true" | 
 | 208 |                       input-id="alternate-name" | 
 | 209 |                       size="lg" | 
 | 210 |                       separator=" " | 
 | 211 |                       :input-attrs="{ | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 212 |                         'aria-describedby': 'alternate-name-help-block', | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 213 |                       }" | 
 | 214 |                       :duplicate-tag-text=" | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 215 |                         $t('pageCertificates.modal.duplicateAlternateName') | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 216 |                       " | 
 | 217 |                       placeholder="" | 
| Sandeepa Singh | 92f8755 | 2021-02-12 18:13:46 +0530 | [diff] [blame] | 218 |                       data-test-id="modalGenerateCsr-input-alternateName" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 219 |                     > | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 220 |                       <template #add-button-text> | 
| Dixsie Wolmers | 30f11f8 | 2020-11-10 16:07:56 -0600 | [diff] [blame] | 221 |                         <icon-add /> {{ $t('global.action.add') }} | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 222 |                       </template> | 
 | 223 |                     </b-form-tags> | 
 | 224 |                   </b-form-group> | 
 | 225 |                 </b-col> | 
 | 226 |               </b-row> | 
 | 227 |             </b-col> | 
 | 228 |             <b-col lg="3"> | 
 | 229 |               <b-row> | 
 | 230 |                 <b-col lg="12"> | 
 | 231 |                   <p class="col-form-label"> | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 232 |                     {{ $t('pageCertificates.modal.privateKey') }} | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 233 |                   </p> | 
 | 234 |                   <b-form-group | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 235 |                     :label="$t('pageCertificates.modal.keyPairAlgorithm')" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 236 |                     label-for="key-pair-algorithm" | 
 | 237 |                   > | 
 | 238 |                     <b-form-select | 
 | 239 |                       id="key-pair-algorithm" | 
 | 240 |                       v-model="form.keyPairAlgorithm" | 
| SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 241 |                       data-test-id="modalGenerateCsr-select-keyPairAlgorithm" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 242 |                       :options="keyPairAlgorithmOptions" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 243 |                       :state="getValidationState(v$.form.keyPairAlgorithm)" | 
 | 244 |                       @input="v$.form.keyPairAlgorithm.$touch()" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 245 |                     > | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 246 |                       <template #first> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 247 |                         <b-form-select-option :value="null" disabled> | 
 | 248 |                           {{ $t('global.form.selectAnOption') }} | 
 | 249 |                         </b-form-select-option> | 
 | 250 |                       </template> | 
 | 251 |                     </b-form-select> | 
 | 252 |                     <b-form-invalid-feedback role="alert"> | 
 | 253 |                       {{ $t('global.form.fieldRequired') }} | 
 | 254 |                     </b-form-invalid-feedback> | 
 | 255 |                   </b-form-group> | 
 | 256 |                 </b-col> | 
 | 257 |               </b-row> | 
 | 258 |               <b-row> | 
 | 259 |                 <b-col lg="12"> | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 260 |                   <template v-if="v$.form.keyPairAlgorithm.$model === 'EC'"> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 261 |                     <b-form-group | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 262 |                       :label="$t('pageCertificates.modal.keyCurveId')" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 263 |                       label-for="key-curve-id" | 
 | 264 |                     > | 
 | 265 |                       <b-form-select | 
 | 266 |                         id="key-curve-id" | 
 | 267 |                         v-model="form.keyCurveId" | 
| SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 268 |                         data-test-id="modalGenerateCsr-select-keyCurveId" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 269 |                         :options="keyCurveIdOptions" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 270 |                         :state="getValidationState(v$.form.keyCurveId)" | 
 | 271 |                         @input="v$.form.keyCurveId.$touch()" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 272 |                       > | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 273 |                         <template #first> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 274 |                           <b-form-select-option :value="null" disabled> | 
 | 275 |                             {{ $t('global.form.selectAnOption') }} | 
 | 276 |                           </b-form-select-option> | 
 | 277 |                         </template> | 
 | 278 |                       </b-form-select> | 
 | 279 |                       <b-form-invalid-feedback role="alert"> | 
 | 280 |                         {{ $t('global.form.fieldRequired') }} | 
 | 281 |                       </b-form-invalid-feedback> | 
 | 282 |                     </b-form-group> | 
 | 283 |                   </template> | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 284 |                   <template v-if="v$.form.keyPairAlgorithm.$model === 'RSA'"> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 285 |                     <b-form-group | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 286 |                       :label="$t('pageCertificates.modal.keyBitLength')" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 287 |                       label-for="key-bit-length" | 
 | 288 |                     > | 
 | 289 |                       <b-form-select | 
 | 290 |                         id="key-bit-length" | 
 | 291 |                         v-model="form.keyBitLength" | 
| SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 292 |                         data-test-id="modalGenerateCsr-select-keyBitLength" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 293 |                         :options="keyBitLengthOptions" | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 294 |                         :state="getValidationState(v$.form.keyBitLength)" | 
 | 295 |                         @input="v$.form.keyBitLength.$touch()" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 296 |                       > | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 297 |                         <template #first> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 298 |                           <b-form-select-option :value="null" disabled> | 
 | 299 |                             {{ $t('global.form.selectAnOption') }} | 
 | 300 |                           </b-form-select-option> | 
 | 301 |                         </template> | 
 | 302 |                       </b-form-select> | 
 | 303 |                       <b-form-invalid-feedback role="alert"> | 
 | 304 |                         {{ $t('global.form.fieldRequired') }} | 
 | 305 |                       </b-form-invalid-feedback> | 
 | 306 |                     </b-form-group> | 
 | 307 |                   </template> | 
 | 308 |                 </b-col> | 
 | 309 |               </b-row> | 
 | 310 |             </b-col> | 
 | 311 |           </b-row> | 
 | 312 |         </b-container> | 
 | 313 |       </b-form> | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 314 |       <template #modal-footer="{ ok, cancel }"> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 315 |         <b-button variant="secondary" @click="cancel()"> | 
 | 316 |           {{ $t('global.action.cancel') }} | 
 | 317 |         </b-button> | 
 | 318 |         <b-button | 
 | 319 |           form="generate-csr-form" | 
 | 320 |           type="submit" | 
 | 321 |           variant="primary" | 
| SurenNeware | d0df7d2 | 2020-07-22 16:41:20 +0530 | [diff] [blame] | 322 |           data-test-id="modalGenerateCsr-button-ok" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 323 |           @click="ok()" | 
 | 324 |         > | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 325 |           {{ $t('pageCertificates.generateCsr') }} | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 326 |         </b-button> | 
 | 327 |       </template> | 
 | 328 |     </b-modal> | 
 | 329 |     <b-modal | 
 | 330 |       id="csr-string" | 
 | 331 |       no-stacking | 
 | 332 |       size="lg" | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 333 |       :title="$t('pageCertificates.modal.certificateSigningRequest')" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 334 |       @hidden="onHiddenCsrStringModal" | 
 | 335 |     > | 
 | 336 |       {{ csrString }} | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 337 |       <template #modal-footer> | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 338 |         <b-btn variant="secondary" @click="copyCsrString"> | 
 | 339 |           <template v-if="csrStringCopied"> | 
 | 340 |             <icon-checkmark /> | 
 | 341 |             {{ $t('global.status.copied') }} | 
 | 342 |           </template> | 
 | 343 |           <template v-else> | 
 | 344 |             {{ $t('global.action.copy') }} | 
 | 345 |           </template> | 
 | 346 |         </b-btn> | 
 | 347 |         <a | 
| Sivaprabu Ganesan | c72f1e3 | 2023-01-06 20:06:04 +0530 | [diff] [blame] | 348 |           :href=" | 
 | 349 |             `data:application/json;charset=utf-8,` + | 
 | 350 |             encodeURIComponent(`${csrString}`) | 
 | 351 |           " | 
 | 352 |           download="certificate.csr" | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 353 |           class="btn btn-primary" | 
 | 354 |         > | 
 | 355 |           {{ $t('global.action.download') }} | 
 | 356 |         </a> | 
 | 357 |       </template> | 
 | 358 |     </b-modal> | 
 | 359 |   </div> | 
 | 360 | </template> | 
 | 361 |  | 
 | 362 | <script> | 
 | 363 | import IconAdd from '@carbon/icons-vue/es/add--alt/20'; | 
 | 364 | import IconCheckmark from '@carbon/icons-vue/es/checkmark/20'; | 
 | 365 |  | 
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 366 | import { required, requiredIf } from '@vuelidate/validators'; | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 367 |  | 
 | 368 | import { COUNTRY_LIST } from './CsrCountryCodes'; | 
| SurenNeware | 6185909 | 2020-10-01 09:37:32 +0530 | [diff] [blame] | 369 | import BVToastMixin from '@/components/Mixins/BVToastMixin'; | 
 | 370 | import VuelidateMixin from '@/components/Mixins/VuelidateMixin.js'; | 
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 371 | import { useVuelidate } from '@vuelidate/core'; | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 372 | import { useI18n } from 'vue-i18n'; | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 373 |  | 
 | 374 | export default { | 
 | 375 |   name: 'ModalGenerateCsr', | 
 | 376 |   components: { IconAdd, IconCheckmark }, | 
 | 377 |   mixins: [BVToastMixin, VuelidateMixin], | 
| Ed Tanous | 7d6b44c | 2024-03-23 14:56:34 -0700 | [diff] [blame] | 378 |   setup() { | 
 | 379 |     return { | 
 | 380 |       v$: useVuelidate(), | 
 | 381 |     }; | 
 | 382 |   }, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 383 |   data() { | 
 | 384 |     return { | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 385 |       $t: useI18n().t, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 386 |       form: { | 
 | 387 |         certificateType: null, | 
 | 388 |         country: null, | 
 | 389 |         state: null, | 
 | 390 |         city: null, | 
 | 391 |         companyName: null, | 
 | 392 |         companyUnit: null, | 
 | 393 |         commonName: null, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 394 |         contactPerson: null, | 
 | 395 |         emailAddress: null, | 
 | 396 |         alternateName: [], | 
 | 397 |         keyPairAlgorithm: null, | 
 | 398 |         keyCurveId: null, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 399 |         keyBitLength: null, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 400 |       }, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 401 |       countryOptions: COUNTRY_LIST.map((country) => ({ | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 402 |         text: country.label, | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 403 |         value: country.code, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 404 |       })), | 
 | 405 |       keyPairAlgorithmOptions: ['EC', 'RSA'], | 
 | 406 |       keyCurveIdOptions: ['prime256v1', 'secp521r1', 'secp384r1'], | 
 | 407 |       keyBitLengthOptions: [2048], | 
 | 408 |       csrString: '', | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 409 |       csrStringCopied: false, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 410 |     }; | 
 | 411 |   }, | 
| Sean Zhang | 8841b7d | 2024-06-15 08:42:41 +0300 | [diff] [blame] | 412 |   computed: { | 
 | 413 |     certificateTypes() { | 
 | 414 |       return this.$store.getters['certificates/certificateTypes']; | 
 | 415 |     }, | 
 | 416 |     certificateOptions() { | 
 | 417 |       return this.certificateTypes.reduce((arr, cert) => { | 
 | 418 |         if (cert.type === 'TrustStore Certificate') return arr; | 
 | 419 |         arr.push({ | 
 | 420 |           text: cert.label, | 
 | 421 |           value: cert.type, | 
 | 422 |         }); | 
 | 423 |         return arr; | 
 | 424 |       }, []); | 
 | 425 |     }, | 
 | 426 |   }, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 427 |   validations: { | 
 | 428 |     form: { | 
 | 429 |       certificateType: { required }, | 
 | 430 |       country: { required }, | 
 | 431 |       state: { required }, | 
 | 432 |       city: { required }, | 
 | 433 |       companyName: { required }, | 
 | 434 |       companyUnit: { required }, | 
 | 435 |       commonName: { required }, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 436 |       contactPerson: {}, | 
 | 437 |       emailAddress: {}, | 
 | 438 |       alternateName: {}, | 
 | 439 |       keyPairAlgorithm: { required }, | 
 | 440 |       keyCurveId: { | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 441 |         reuired: requiredIf(function (form) { | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 442 |           return form.keyPairAlgorithm === 'EC'; | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 443 |         }), | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 444 |       }, | 
 | 445 |       keyBitLength: { | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 446 |         reuired: requiredIf(function (form) { | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 447 |           return form.keyPairAlgorithm === 'RSA'; | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 448 |         }), | 
 | 449 |       }, | 
 | 450 |     }, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 451 |   }, | 
 | 452 |   methods: { | 
 | 453 |     handleSubmit() { | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 454 |       this.v$.$touch(); | 
 | 455 |       if (this.v$.$invalid) return; | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 456 |       this.$store | 
| Sandeepa Singh | b440616 | 2021-07-26 15:05:39 +0530 | [diff] [blame] | 457 |         .dispatch('certificates/generateCsr', this.form) | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 458 |         .then(({ data: { CSRString } }) => { | 
 | 459 |           this.csrString = CSRString; | 
 | 460 |           this.$bvModal.show('csr-string'); | 
| Surya V | de23ea2 | 2024-07-11 15:19:46 +0530 | [diff] [blame] | 461 |           this.v$.$reset(); | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 462 |         }); | 
 | 463 |     }, | 
 | 464 |     resetForm() { | 
 | 465 |       for (let key of Object.keys(this.form)) { | 
 | 466 |         if (key === 'alternateName') { | 
 | 467 |           this.form[key] = []; | 
 | 468 |         } else { | 
 | 469 |           this.form[key] = null; | 
 | 470 |         } | 
 | 471 |       } | 
 | 472 |     }, | 
 | 473 |     onOkGenerateCsrModal(bvModalEvt) { | 
 | 474 |       // prevent modal close | 
 | 475 |       bvModalEvt.preventDefault(); | 
 | 476 |       this.handleSubmit(); | 
 | 477 |     }, | 
 | 478 |     onHiddenCsrStringModal() { | 
 | 479 |       this.csrString = ''; | 
 | 480 |       this.resetForm(); | 
 | 481 |     }, | 
 | 482 |     copyCsrString(bvModalEvt) { | 
 | 483 |       // prevent modal close | 
 | 484 |       bvModalEvt.preventDefault(); | 
 | 485 |       navigator.clipboard.writeText(this.csrString).then(() => { | 
 | 486 |         // Show copied text for 5 seconds | 
 | 487 |         this.csrStringCopied = true; | 
 | 488 |         setTimeout(() => { | 
 | 489 |           this.csrStringCopied = false; | 
 | 490 |         }, 5000 /*5 seconds*/); | 
 | 491 |       }); | 
| Derick Montague | 602e98a | 2020-10-21 16:20:00 -0500 | [diff] [blame] | 492 |     }, | 
 | 493 |   }, | 
| Yoshie Muranaka | 532a4b0 | 2020-03-27 11:00:50 -0700 | [diff] [blame] | 494 | }; | 
 | 495 | </script> |