Skip to content

Commit 798d56a

Browse files
committed
added documentation
1 parent 46d93bc commit 798d56a

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

common4j/src/main/com/microsoft/identity/common/java/platform/AbstractDevicePopManager.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import static com.microsoft.identity.common.java.exception.ClientException.NO_SUCH_PADDING;
4040
import static com.microsoft.identity.common.java.exception.ClientException.SIGNING_FAILURE;
4141
import static com.microsoft.identity.common.java.exception.ClientException.THUMBPRINT_COMPUTATION_FAILURE;
42+
import static com.microsoft.identity.common.java.exception.ClientException.UNKNOWN_CRYPTO_ERROR;
4243
import static com.microsoft.identity.common.java.exception.ClientException.UNKNOWN_EXPORT_FORMAT;
4344
import static com.microsoft.identity.common.java.marker.PerfConstants.CodeMarkerConstants.GENERATE_AT_POP_ASYMMETRIC_KEYPAIR_END;
4445
import static com.microsoft.identity.common.java.marker.PerfConstants.CodeMarkerConstants.GENERATE_AT_POP_ASYMMETRIC_KEYPAIR_START;
@@ -626,6 +627,15 @@ public byte[] encrypt(@NonNull final Cipher cipher, @NonNull final byte[] plaint
626627
}
627628
}
628629

630+
/**
631+
* Maps cryptographic exceptions to corresponding ClientException error code constants.
632+
* This helper method is used by both encrypt and decrypt operations to provide consistent
633+
* error code mappings for various cryptographic failure scenarios.
634+
*
635+
* @param e The exception to map to an error code. Must be non-null.
636+
* @return The corresponding ClientException error code constant.
637+
* Note : Returns {@link ClientException#UNKNOWN_CRYPTO_ERROR} as the default fallback when the exception type doesn't match any known types.
638+
*/
629639
private String mapCryptoExceptionToErrorCode(@NonNull final Exception e) {
630640
if (e instanceof NoSuchAlgorithmException) {
631641
return NO_SUCH_ALGORITHM;
@@ -644,7 +654,7 @@ private String mapCryptoExceptionToErrorCode(@NonNull final Exception e) {
644654
} else if (e instanceof InvalidAlgorithmParameterException) {
645655
return INVALID_ALG_PARAMETER;
646656
}
647-
return INVALID_KEY; // default fallback
657+
return UNKNOWN_CRYPTO_ERROR; // default fallback
648658
}
649659

650660
@Override

0 commit comments

Comments
 (0)