Class PowerAuthAuthenticationProvider

  • All Implemented Interfaces:
    org.springframework.security.authentication.AuthenticationProvider

    @Component
    public class PowerAuthAuthenticationProvider
    extends io.getlime.security.powerauth.rest.api.base.provider.PowerAuthAuthenticationProviderBase
    implements org.springframework.security.authentication.AuthenticationProvider
    Implementation of PowerAuth authentication provider.
    Author:
    Petr Dvorak, petr@wultra.com
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      org.springframework.security.core.Authentication authenticate​(org.springframework.security.core.Authentication authentication)  
      void setApplicationConfiguration​(io.getlime.security.powerauth.rest.api.base.application.PowerAuthApplicationConfiguration applicationConfiguration)  
      void setPowerAuthClient​(io.getlime.security.powerauth.soap.spring.client.PowerAuthServiceClient powerAuthClient)  
      boolean supports​(java.lang.Class<?> authentication)  
      io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication validateRequestSignature​(java.lang.String httpMethod, byte[] httpBody, java.lang.String requestUriIdentifier, java.lang.String httpAuthorizationHeader, java.util.List<io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureTypes> allowedSignatureTypes, java.lang.Integer forcedSignatureVersion)
      Validate the signature from the PowerAuth HTTP header against the provided HTTP method, request body and URI identifier.
      io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication validateToken​(java.lang.String tokenHeader, java.util.List<io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureTypes> allowedSignatureTypes)  
      • Methods inherited from class io.getlime.security.powerauth.rest.api.base.provider.PowerAuthAuthenticationProviderBase

        extractRequestBodyBytes, validateRequestSignature, validateRequestSignature, validateRequestSignature, validateRequestSignature, validateToken
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PowerAuthAuthenticationProvider

        public PowerAuthAuthenticationProvider()
    • Method Detail

      • setPowerAuthClient

        @Autowired
        public void setPowerAuthClient​(io.getlime.security.powerauth.soap.spring.client.PowerAuthServiceClient powerAuthClient)
      • setApplicationConfiguration

        @Autowired(required=false)
        public void setApplicationConfiguration​(io.getlime.security.powerauth.rest.api.base.application.PowerAuthApplicationConfiguration applicationConfiguration)
      • authenticate

        public org.springframework.security.core.Authentication authenticate​(org.springframework.security.core.Authentication authentication)
                                                                      throws org.springframework.security.core.AuthenticationException
        Specified by:
        authenticate in interface org.springframework.security.authentication.AuthenticationProvider
        Throws:
        org.springframework.security.core.AuthenticationException
      • supports

        public boolean supports​(java.lang.Class<?> authentication)
        Specified by:
        supports in interface org.springframework.security.authentication.AuthenticationProvider
      • validateRequestSignature

        public io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication validateRequestSignature​(java.lang.String httpMethod,
                                                                                                                              byte[] httpBody,
                                                                                                                              java.lang.String requestUriIdentifier,
                                                                                                                              java.lang.String httpAuthorizationHeader,
                                                                                                                              java.util.List<io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureTypes> allowedSignatureTypes,
                                                                                                                              @Nullable
                                                                                                                              java.lang.Integer forcedSignatureVersion)
                                                                                                                       throws io.getlime.security.powerauth.rest.api.base.exception.PowerAuthAuthenticationException
        Validate the signature from the PowerAuth HTTP header against the provided HTTP method, request body and URI identifier. Make sure to accept only allowed signatures.
        Specified by:
        validateRequestSignature in class io.getlime.security.powerauth.rest.api.base.provider.PowerAuthAuthenticationProviderBase
        Parameters:
        httpMethod - HTTP method (GET, POST, ...)
        httpBody - Body of the HTTP request.
        requestUriIdentifier - Request URI identifier.
        httpAuthorizationHeader - PowerAuth HTTP authorization header.
        allowedSignatureTypes - Allowed types of the signature.
        forcedSignatureVersion - Forced signature version, optional parameter used during upgrade.
        Returns:
        Instance of a PowerAuthApiAuthenticationImpl on successful authorization.
        Throws:
        io.getlime.security.powerauth.rest.api.base.exception.PowerAuthAuthenticationException - In case authorization fails, exception is raised.
      • validateToken

        public io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication validateToken​(java.lang.String tokenHeader,
                                                                                                                   java.util.List<io.getlime.security.powerauth.crypto.lib.enums.PowerAuthSignatureTypes> allowedSignatureTypes)
                                                                                                            throws io.getlime.security.powerauth.rest.api.base.exception.PowerAuthAuthenticationException
        Specified by:
        validateToken in class io.getlime.security.powerauth.rest.api.base.provider.PowerAuthAuthenticationProviderBase
        Throws:
        io.getlime.security.powerauth.rest.api.base.exception.PowerAuthAuthenticationException