@@ -98,13 +98,10 @@ func GenerateBaseString(httpMethod string, apiURL string, appId string, params P
98
98
return baseString
99
99
}
100
100
101
- /**
102
- * Get Private Key
103
- *
104
- * This methods will decrypt P12 Certificate and retrieve the Private key with the passphrase
105
-
106
- * Returns private key from p12
107
- */
101
+ /*
102
+ This methods will decrypt P12 Certificate and retrieve the Private key with the passphrase.
103
+ Returns private key from p12.
104
+ */
108
105
func DecryptPrivateKey (secureCertLocation string , passphrase string ) (* rsa.PrivateKey , error ) {
109
106
fileData , err := ioutil .ReadFile (secureCertLocation )
110
107
if err != nil {
@@ -123,13 +120,10 @@ func DecryptPrivateKey(secureCertLocation string, passphrase string) (*rsa.Priva
123
120
return privateKey , nil
124
121
}
125
122
126
- /**
127
- * Generate Random Hex
128
- *
129
- * This method helps to generate unique Transaction ID(txnNo)
130
- *
131
- * Returns random hex(txnNo)
132
- */
123
+ /*
124
+ This method helps to generate unique Transaction ID(txnNo).
125
+ Returns random hex(txnNo).
126
+ */
133
127
func GenerateRandomHex (count int ) (string , error ) {
134
128
bytes := make ([]byte , count )
135
129
_ , err := rand .Read (bytes )
@@ -140,14 +134,11 @@ func GenerateRandomHex(count int) (string, error) {
140
134
return randomHex , nil
141
135
}
142
136
143
- /**
144
- * Generate Authorization Header
145
- *
146
- * This method helps to generate the authorization header and sign it
147
- * using the private key. This is required to be used for both Token and Person API
148
- *
149
- * Returns Signed Header
150
- */
137
+ /*
138
+ This method helps to generate the authorization header and sign it using the private key.
139
+ This is required to be used for both Token and Person API.
140
+ Returns Signed Header
141
+ */
151
142
func GenerateAuthorizationHeader (apiURL string , params ParamsSort , httpMethod string , contentType string , environment string , appId string , privateKey * rsa.PrivateKey , clientSecret string ) (string , error ) {
152
143
nonceValue , err := GenerateRandomHex (20 )
153
144
if err != nil {
@@ -176,13 +167,10 @@ func GenerateAuthorizationHeader(apiURL string, params ParamsSort, httpMethod st
176
167
}
177
168
}
178
169
179
- /**
180
- * Decode
181
- *
182
- * This method helps to decode the payload data into normal form.
183
- *
184
- * Returns normalized(decoded) []byte.
185
- */
170
+ /*
171
+ This method helps to decode the payload data into normal form.
172
+ Returns normalized(decoded) []byte.
173
+ */
186
174
func Decode (payload string ) ([]byte , error ) {
187
175
s := strings .Split (payload , "." )
188
176
if len (s ) < 2 {
@@ -196,16 +184,13 @@ func Decode(payload string) ([]byte, error) {
196
184
return decodedData , err
197
185
}
198
186
199
- /**
200
- * Verify JWS
201
- *
202
- * This method takes in a JSON Web Signature and will check against
203
- * the public key for its validity and to retrieve the decoded data.
204
- * This verification is required for the decoding of the access token and
205
- * response from Person API
206
- *
207
- * Returns decoded data
208
- */
187
+ /*
188
+ This method takes in a JSON Web Signature and will check against
189
+ the public key for its validity and to retrieve the decoded data.
190
+ This verification is required for the decoding of the access token and
191
+ response from Person API.
192
+ Returns decoded data.
193
+ */
209
194
func VerifyJWS (publicCert string , accessToken string ) ([]byte , error ) {
210
195
keyData , err := ioutil .ReadFile (publicCert )
211
196
if err != nil {
@@ -234,14 +219,11 @@ func VerifyJWS(publicCert string, accessToken string) ([]byte, error) {
234
219
return claimSet , nil
235
220
}
236
221
237
- /**
238
- * Decypt JWE
239
- *
240
- * This method takes in a JSON Web Encrypted string and will decrypt it using the
241
- * private key. This is required to decrypt the data from Person API
242
- *
243
- * Returns decrypted data
244
- */
222
+ /*
223
+ This method takes in a JSON Web Encrypted string and will decrypt it using the private key.
224
+ This is required to decrypt the data from Person API.
225
+ Returns decrypted data.
226
+ */
245
227
func DecryptJWE (pemPrivaKey * rsa.PrivateKey , compactJWE string ) (string , error ) {
246
228
payload , err := jose .ParseEncrypted (compactJWE )
247
229
if err != nil {
@@ -263,13 +245,10 @@ func Unmarshal(data []byte, v interface{}) error {
263
245
return nil
264
246
}
265
247
266
- /**
267
- * AuthHeader
268
- *
269
- * This method removes the duplication use of environment based condition for generating auth header.
270
- *
271
- * Returns fully generated auth Header as string.
272
- */
248
+ /*
249
+ This method removes the duplication use of environment based condition for generating auth header.
250
+ Returns fully generated auth Header as string.
251
+ */
273
252
func AuthHeader (apiURL string , params ParamsSort , httpMethod string , contentType string , environment string , appId string , privateKey * rsa.PrivateKey , clientSecret string ) (string , error ) {
274
253
var authHeader string
275
254
var err error
0 commit comments