Search in sources :

Example 1 with ActivationContext

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();
    }
}
Also used : PowerAuthActivationException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthActivationException) ActivationContext(io.getlime.security.powerauth.rest.api.spring.model.ActivationContext) PowerAuthActivationException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthActivationException) PowerAuthInvalidRequestException(io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthInvalidRequestException) PowerAuthClientException(com.wultra.security.powerauth.client.model.error.PowerAuthClientException) PowerAuthRecoveryException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthRecoveryException) ActivationStatusResponse(io.getlime.security.powerauth.rest.api.model.response.v3.ActivationStatusResponse)

Example 2 with ActivationContext

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;
}
Also used : XMLGregorianCalendar(javax.xml.datatype.XMLGregorianCalendar) ActivationContext(io.getlime.security.powerauth.rest.api.spring.model.ActivationContext)

Aggregations

ActivationContext (io.getlime.security.powerauth.rest.api.spring.model.ActivationContext)2 PowerAuthClientException (com.wultra.security.powerauth.client.model.error.PowerAuthClientException)1 ActivationStatusResponse (io.getlime.security.powerauth.rest.api.model.response.v3.ActivationStatusResponse)1 PowerAuthActivationException (io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthActivationException)1 PowerAuthRecoveryException (io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthRecoveryException)1 PowerAuthInvalidRequestException (io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthInvalidRequestException)1 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)1