Search in sources :

Example 1 with PowerAuthApiAuthenticationImpl

use of io.getlime.security.powerauth.rest.api.jaxrs.authentication.PowerAuthApiAuthenticationImpl in project powerauth-restful-integration by lime-company.

the class PowerAuthAuthenticationProvider method copyAuthenticationAttributes.

/**
 * Prepare API initialized authentication object with provided authentication attributes.
 *
 * @param activationId Activation ID.
 * @param userId User ID.
 * @param applicationId Application ID.
 * @param signatureType Signature Type.
 * @return Initialized instance of API authentication.
 */
private PowerAuthApiAuthentication copyAuthenticationAttributes(String activationId, String userId, Long applicationId, PowerAuthSignatureTypes signatureType) {
    PowerAuthApiAuthentication apiAuthentication = new PowerAuthApiAuthenticationImpl();
    apiAuthentication.setActivationId(activationId);
    apiAuthentication.setUserId(userId);
    apiAuthentication.setApplicationId(applicationId);
    apiAuthentication.setSignatureFactors(signatureType);
    return apiAuthentication;
}
Also used : PowerAuthApiAuthenticationImpl(io.getlime.security.powerauth.rest.api.jaxrs.authentication.PowerAuthApiAuthenticationImpl) PowerAuthApiAuthentication(io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication)

Example 2 with PowerAuthApiAuthenticationImpl

use of io.getlime.security.powerauth.rest.api.jaxrs.authentication.PowerAuthApiAuthenticationImpl in project powerauth-restful-integration by lime-company.

the class PowerAuthAuthenticationProvider method validateSignatureAuthentication.

/**
 * Validate signature based authentication.
 *
 * @param authentication Signature based authentication object.
 * @return API authentication object in case of successful authentication, null otherwise.
 */
private PowerAuthApiAuthentication validateSignatureAuthentication(PowerAuthSignatureAuthentication authentication) throws RemoteException {
    if (authentication.getSignatureType() != null) {
        SignatureTypeConverter converter = new SignatureTypeConverter();
        final PowerAuthPortServiceStub.SignatureType signatureType = converter.convertFrom(authentication.getSignatureType());
        PowerAuthPortServiceStub.VerifySignatureRequest soapRequest = new PowerAuthPortServiceStub.VerifySignatureRequest();
        soapRequest.setActivationId(authentication.getActivationId());
        soapRequest.setApplicationKey(authentication.getApplicationKey());
        soapRequest.setSignature(authentication.getSignature());
        soapRequest.setSignatureType(signatureType);
        soapRequest.setData(PowerAuthHttpBody.getSignatureBaseString(authentication.getHttpMethod(), authentication.getRequestUri(), authentication.getNonce(), authentication.getData()));
        PowerAuthPortServiceStub.VerifySignatureResponse soapResponse = powerAuthClient.verifySignature(soapRequest);
        if (soapResponse.getSignatureValid()) {
            PowerAuthApiAuthentication apiAuthentication = new PowerAuthApiAuthenticationImpl();
            apiAuthentication.setActivationId(soapResponse.getActivationId());
            apiAuthentication.setUserId(soapResponse.getUserId());
            apiAuthentication.setApplicationId(soapResponse.getApplicationId());
            apiAuthentication.setSignatureFactors(PowerAuthSignatureTypes.getEnumFromString(soapResponse.getSignatureType().getValue()));
            return apiAuthentication;
        } else {
            return null;
        }
    } else {
        return null;
    }
}
Also used : PowerAuthApiAuthenticationImpl(io.getlime.security.powerauth.rest.api.jaxrs.authentication.PowerAuthApiAuthenticationImpl) PowerAuthPortServiceStub(io.getlime.powerauth.soap.PowerAuthPortServiceStub) PowerAuthApiAuthentication(io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication) SignatureTypeConverter(io.getlime.security.powerauth.rest.api.jaxrs.converter.SignatureTypeConverter)

Aggregations

PowerAuthApiAuthentication (io.getlime.security.powerauth.rest.api.base.authentication.PowerAuthApiAuthentication)2 PowerAuthApiAuthenticationImpl (io.getlime.security.powerauth.rest.api.jaxrs.authentication.PowerAuthApiAuthenticationImpl)2 PowerAuthPortServiceStub (io.getlime.powerauth.soap.PowerAuthPortServiceStub)1 SignatureTypeConverter (io.getlime.security.powerauth.rest.api.jaxrs.converter.SignatureTypeConverter)1