use of io.getlime.security.powerauth.rest.api.spring.model.ActivationContext in project powerauth-restful-integration by lime-company.
the class ActivationService method getActivationStatus.
/**
* Get activation status.
*
* @param request Activation status request.
* @return Activation status response.
* @throws PowerAuthActivationException In case retrieving activation status fails.
*/
public ActivationStatusResponse getActivationStatus(ActivationStatusRequest request) throws PowerAuthActivationException {
try {
final String activationId = request.getActivationId();
final String challenge = request.getChallenge();
final GetActivationStatusResponse paResponse = powerAuthClient.getActivationStatusWithEncryptedStatusBlob(activationId, challenge);
final ActivationStatusResponse response = new ActivationStatusResponse();
response.setActivationId(paResponse.getActivationId());
response.setEncryptedStatusBlob(paResponse.getEncryptedStatusBlob());
response.setNonce(paResponse.getEncryptedStatusBlobNonce());
if (applicationConfiguration != null) {
final ActivationContext activationContext = activationContextConverter.fromActivationDetailResponse(paResponse);
response.setCustomObject(applicationConfiguration.statusServiceCustomObject(activationContext));
}
return response;
} catch (Exception ex) {
logger.warn("PowerAuth activation status check failed, error: {}", ex.getMessage());
logger.debug(ex.getMessage(), ex);
throw new PowerAuthActivationException();
}
}
use of io.getlime.security.powerauth.rest.api.spring.model.ActivationContext in project powerauth-restful-integration by lime-company.
the class ActivationContextConverter method fromActivationDetailResponse.
/**
* Convert new activation context from activation status response.
*
* @param source Activation status response.
* @return Activation context.
*/
public ActivationContext fromActivationDetailResponse(GetActivationStatusResponse source) {
final ActivationContext destination = new ActivationContext();
destination.setActivationId(source.getActivationId());
destination.setActivationName(source.getActivationName());
destination.setActivationStatus(activationStatusConverter.convertFrom(source.getActivationStatus()));
destination.setBlockedReason(source.getBlockedReason());
destination.setApplicationId(source.getApplicationId());
destination.setUserId(source.getUserId());
destination.setVersion(source.getVersion());
destination.setPlatform(source.getPlatform());
destination.setDeviceInfo(source.getDeviceInfo());
destination.setExtras(source.getExtras());
final List<String> activationFlags = source.getActivationFlags();
if (activationFlags != null) {
destination.getActivationFlags().addAll(activationFlags);
}
final XMLGregorianCalendar timestampCreated = source.getTimestampCreated();
if (timestampCreated != null) {
destination.setTimestampCreated(timestampCreated.toGregorianCalendar().toInstant());
}
final XMLGregorianCalendar timestampLastUsed = source.getTimestampLastUsed();
if (timestampLastUsed != null) {
destination.setTimestampLastUsed(timestampLastUsed.toGregorianCalendar().toInstant());
}
final XMLGregorianCalendar timestampLastChange = source.getTimestampLastChange();
if (timestampLastChange != null) {
destination.setTimestampLastChange(timestampLastChange.toGregorianCalendar().toInstant());
}
return destination;
}
Aggregations