Interface CustomActivationProvider


public interface CustomActivationProvider
Interface which enables implementation of custom activations. The interface defines a method for obtaining a user ID based on arbitrary identity attributes, processing of custom activation attributes and configuration of auto-commit mode.
Author:
Petr Dvorak, petr@wultra.com, Roman Strobl, roman.strobl@wultra.com
  • Method Summary

    Modifier and Type Method Description
    default void activationWasCommitted​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String activationId, java.lang.String userId, ActivationType activationType)
    Method is called when activation commit succeeds.
    default void activationWasRemoved​(java.lang.String activationId, java.lang.String userId, java.lang.Long appId)
    Method is called after activation was just removed using the standard removal endpoint.
    default java.lang.Integer getMaxFailedAttemptCount​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String userId, ActivationType activationType)
    Get maximum failed attempt count for activations.
    default java.lang.Integer getValidityPeriodDuringActivation​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String userId, ActivationType activationType)
    Get length of the period of activation record validity during activation in milliseconds.
    java.lang.String lookupUserIdForAttributes​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes)
    This method is responsible for looking user ID up based on a provided set of identity attributes.
    default java.util.Map<java.lang.String,​java.lang.Object> processCustomActivationAttributes​(java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String activationId, java.lang.String userId, ActivationType activationType)
    Process custom attributes, in any way that is suitable for the purpose of your application.
    default boolean shouldAutoCommitActivation​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String activationId, java.lang.String userId, ActivationType activationType)
    Variable that specifies if the activation should be automatically committed based on provided attributes.
    default boolean shouldRevokeRecoveryCodeOnRemove​(java.lang.String activationId, java.lang.String userId, java.lang.Long appId)
    Method that indicates if the recovery codes should be revoked when an activation is removed.
  • Method Details

    • lookupUserIdForAttributes

      java.lang.String lookupUserIdForAttributes​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes) throws PowerAuthActivationException
      This method is responsible for looking user ID up based on a provided set of identity attributes.

      This method is called for the CUSTOM activation type only.
      Parameters:
      identityAttributes - Attributes that uniquely identify user with given ID.
      Returns:
      User ID value.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.
    • processCustomActivationAttributes

      default java.util.Map<java.lang.String,​java.lang.Object> processCustomActivationAttributes​(java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String activationId, java.lang.String userId, ActivationType activationType) throws PowerAuthActivationException
      Process custom attributes, in any way that is suitable for the purpose of your application.

      This method is called for all activation types. Default implementation returns unmodified attributes.
      Parameters:
      customAttributes - Custom attributes (not related to identity) to be processed.
      activationId - Activation ID of created activation.
      userId - User ID of user who created the activation.
      activationType - Activation type.
      Returns:
      Custom attributes after processing.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.
    • shouldAutoCommitActivation

      default boolean shouldAutoCommitActivation​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String activationId, java.lang.String userId, ActivationType activationType) throws PowerAuthActivationException
      Variable that specifies if the activation should be automatically committed based on provided attributes. Return true in case you would like to create an activation that is ready to be used for signing (ACTIVE), and false for the cases when you need activation to remain in PENDING_COMMIT state.

      Note that this setting only affects CUSTOM or RECOVERY activation types. On CODE activation type, auto-commit is always disabled. Default implementation returns false.
      Parameters:
      identityAttributes - Identity related attributes.
      customAttributes - Custom attributes, not related to identity.
      activationId - Activation ID of created activation.
      userId - User ID of user who created the activation.
      activationType - Activation type.
      Returns:
      True in case activation should be committed, false otherwise.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.
    • activationWasCommitted

      default void activationWasCommitted​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String activationId, java.lang.String userId, ActivationType activationType) throws PowerAuthActivationException
      Method is called when activation commit succeeds.

      Note that this method is only called for CUSTOM or RECOVERY activation types, and only in the case activation was successfully committed on the server side. Method is not called in case commit fails on server. On CODE activation type, auto-commit is always disabled and hence this method is not called. Default implementation is no-op.
      Parameters:
      identityAttributes - Identity related attributes.
      customAttributes - Custom attributes, not related to identity.
      activationId - Activation ID of created activation.
      userId - User ID of user who created the activation.
      activationType - Activation type.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.
    • shouldRevokeRecoveryCodeOnRemove

      default boolean shouldRevokeRecoveryCodeOnRemove​(java.lang.String activationId, java.lang.String userId, java.lang.Long appId)
      Method that indicates if the recovery codes should be revoked when an activation is removed.
      Parameters:
      activationId - Activation ID.
      userId - User ID.
      appId - Application ID.
      Returns:
      True in case the recovery codes should be revoked on remove, false otherwise.
    • activationWasRemoved

      default void activationWasRemoved​(java.lang.String activationId, java.lang.String userId, java.lang.Long appId) throws PowerAuthActivationException
      Method is called after activation was just removed using the standard removal endpoint.

      This method is called for all activations. Default implementation is no-op.
      Parameters:
      activationId - Activation ID.
      userId - User ID.
      appId - Application ID.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.
    • getMaxFailedAttemptCount

      default java.lang.Integer getMaxFailedAttemptCount​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String userId, ActivationType activationType) throws PowerAuthActivationException
      Get maximum failed attempt count for activations. Use null value for using value which is configured on PowerAuth server.

      Note that this method is only called for CUSTOM or RECOVERY activation types, since for CODE activation, the number of max. failed attempts is set earlier while creating the activation code. Default implementation returns null (use the server configured value).
      Parameters:
      identityAttributes - Identity related attributes.
      customAttributes - Custom attributes, not related to identity.
      userId - User ID of user who created the activation.
      activationType - Activation type.
      Returns:
      Maximum failed attempt count for activations.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.
    • getValidityPeriodDuringActivation

      default java.lang.Integer getValidityPeriodDuringActivation​(java.util.Map<java.lang.String,​java.lang.String> identityAttributes, java.util.Map<java.lang.String,​java.lang.Object> customAttributes, java.lang.String userId, ActivationType activationType) throws PowerAuthActivationException
      Get length of the period of activation record validity during activation in milliseconds. Use null value for using value which is configured on PowerAuth server.

      Note that this method is only called for CUSTOM or RECOVERY activation types, since for CODE activation, the expiration period for activation is set earlier while creating the activation code. Default implementation returns null (use the server configured value).
      Parameters:
      identityAttributes - Identity related attributes.
      customAttributes - Custom attributes, not related to identity.
      userId - User ID of user who created the activation.
      activationType - Activation type.
      Returns:
      Period in milliseconds during which activation is valid before it expires.
      Throws:
      PowerAuthActivationException - In case of error in custom activation business logic that should terminate the rest of the activation.