3434import static com .formkiq .stacks .dynamodb .ConfigService .MAX_WEBHOOKS ;
3535import static com .formkiq .stacks .dynamodb .ConfigService .NOTIFICATION_EMAIL ;
3636
37- import java .io .IOException ;
38- import java .io .StringReader ;
3937import java .security .KeyFactory ;
4038import java .security .NoSuchAlgorithmException ;
4139import java .security .PrivateKey ;
4745import java .util .HashMap ;
4846import java .util .Map ;
4947import java .util .Optional ;
50- import java .util .Properties ;
5148
5249import com .amazonaws .services .lambda .runtime .LambdaLogger ;
5350import com .formkiq .aws .dynamodb .DynamicObject ;
@@ -211,9 +208,9 @@ public ApiRequestHandlerResponse patch(final LambdaLogger logger,
211208 if (body .containsKey ("docusign" )) {
212209
213210 Map <String , String > google = (Map <String , String >) body .get ("docusign" );
214- String docusignUserId = google .getOrDefault ("userId" , "" );
215- String docusignIntegrationKey = google .getOrDefault ("integrationKey" , "" );
216- String docusignRsaPrivateKey = google .getOrDefault ("rsaPrivateKey" , "" );
211+ String docusignUserId = google .getOrDefault ("userId" , "" ). trim () ;
212+ String docusignIntegrationKey = google .getOrDefault ("integrationKey" , "" ). trim () ;
213+ String docusignRsaPrivateKey = google .getOrDefault ("rsaPrivateKey" , "" ). trim () ;
217214
218215 map .put (KEY_DOCUSIGN_USER_ID , docusignUserId );
219216 map .put (KEY_DOCUSIGN_INTEGRATION_KEY , docusignIntegrationKey );
@@ -304,9 +301,10 @@ private void validateDocusign(final Map<String, Object> map,
304301 private boolean isValidRsaPrivateKey (final String privateKeyPem ) {
305302 try {
306303 // Remove the PEM header and footer
307- String privateKeyPemStripped = decodeUnicode (privateKeyPem )
308- .replace ("-----BEGIN RSA PRIVATE KEY-----" , "" )
309- .replace ("-----END RSA PRIVATE KEY-----" , "" ).replace ("\\ n" , "" ).replaceAll ("\\ s+" , "" );
304+ String privateKeyPemStripped =
305+ privateKeyPem .replace ("\\ u003d" , "=" ).replace ("-----BEGIN RSA PRIVATE KEY-----" , "" )
306+ .replace ("-----END RSA PRIVATE KEY-----" , "" ).replace ("\\ n" , "" )
307+ .replaceAll ("\\ s+" , "" ).trim ();
310308
311309 byte [] privateKeyBytes = Base64 .getDecoder ().decode (privateKeyPemStripped );
312310
@@ -320,26 +318,4 @@ private boolean isValidRsaPrivateKey(final String privateKeyPem) {
320318 return false ;
321319 }
322320 }
323-
324- /**
325- * Decode Unicode sequences.
326- *
327- * @param input {@link String}
328- * @return String
329- */
330- private String decodeUnicode (final String input ) {
331-
332- String result = input ;
333- if (input != null ) {
334- Properties properties = new Properties ();
335- try {
336- properties .load (new StringReader ("key=" + input ));
337- result = properties .getProperty ("key" );
338- } catch (IOException e ) {
339- // ignore
340- }
341- }
342-
343- return result ;
344- }
345321}
0 commit comments