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;
}
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;
}
}
Aggregations