Class UnsupportedRoleException

All Implemented Interfaces:
Serializable

public class UnsupportedRoleException extends RuntimeException
Exception indicating that an algorithm does not support the requested role.

This is thrown when a CryptoAlgorithm (or helpers such as CryptoAlgorithms) is asked to create a context for a KeyUsage that the algorithm never advertises. In other words, the operation is unavailable regardless of the provided key or spec.

When it is thrown

Contrast with UnsupportedSpecException, which means the role exists but no binding accepts the supplied key/spec types.

Example

// Suppose "SHA-256" supports DIGEST only.
zeroecho.sdk.ZeroEchoSession session = new zeroecho.sdk.ZeroEchoSession();
try {
    // Asking for ENCRYPT on a digest algorithm will fail with UnsupportedRoleException.
    session.createContext("SHA-256", zeroecho.core.KeyUsage.ENCRYPT,
        zeroecho.core.NullKey.INSTANCE, null);
} catch (UnsupportedRoleException e) {
    // Handle: algorithm does not implement the ENCRYPT role.
}
Since:
1.0
See Also:
  • Constructor Details

    • UnsupportedRoleException

      public UnsupportedRoleException(String m)
      Creates a new exception with a detail message.
      Parameters:
      m - detail message describing the missing role for the algorithm