Search in sources :

Example 1 with StartUpgradeResponse

use of com.wultra.security.powerauth.client.v3.StartUpgradeResponse in project powerauth-restful-integration by lime-company.

the class UpgradeService method upgradeStart.

/**
 * Start upgrade of activation to version 3.
 * @param request ECIES encrypted upgrade start request.
 * @param header PowerAuth encryption HTTP header.
 * @return ECIES encrypted upgrade activation response.
 * @throws PowerAuthUpgradeException In case upgrade start fails.
 */
public EciesEncryptedResponse upgradeStart(EciesEncryptedRequest request, PowerAuthEncryptionHttpHeader header) throws PowerAuthUpgradeException {
    try {
        // Fetch data from the request
        final String ephemeralPublicKey = request.getEphemeralPublicKey();
        final String encryptedData = request.getEncryptedData();
        final String mac = request.getMac();
        final String nonce = request.getNonce();
        // Get ECIES headers
        final String activationId = header.getActivationId();
        final String applicationKey = header.getApplicationKey();
        // Start upgrade on PowerAuth server
        final StartUpgradeResponse upgradeResponse = powerAuthClient.startUpgrade(activationId, applicationKey, ephemeralPublicKey, encryptedData, mac, nonce);
        // Prepare a response
        final EciesEncryptedResponse response = new EciesEncryptedResponse();
        response.setMac(upgradeResponse.getMac());
        response.setEncryptedData(upgradeResponse.getEncryptedData());
        return response;
    } catch (Exception ex) {
        logger.warn("PowerAuth upgrade start failed, error: {}", ex.getMessage());
        logger.debug(ex.getMessage(), ex);
        throw new PowerAuthUpgradeException();
    }
}
Also used : StartUpgradeResponse(com.wultra.security.powerauth.client.v3.StartUpgradeResponse) PowerAuthUpgradeException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthUpgradeException) EciesEncryptedResponse(io.getlime.security.powerauth.rest.api.model.response.v3.EciesEncryptedResponse) PowerAuthUpgradeException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthUpgradeException) PowerAuthAuthenticationException(io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthAuthenticationException) PowerAuthInvalidRequestException(io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthInvalidRequestException) PowerAuthSignatureInvalidException(io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthSignatureInvalidException)

Aggregations

StartUpgradeResponse (com.wultra.security.powerauth.client.v3.StartUpgradeResponse)1 EciesEncryptedResponse (io.getlime.security.powerauth.rest.api.model.response.v3.EciesEncryptedResponse)1 PowerAuthAuthenticationException (io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthAuthenticationException)1 PowerAuthUpgradeException (io.getlime.security.powerauth.rest.api.spring.exception.PowerAuthUpgradeException)1 PowerAuthInvalidRequestException (io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthInvalidRequestException)1 PowerAuthSignatureInvalidException (io.getlime.security.powerauth.rest.api.spring.exception.authentication.PowerAuthSignatureInvalidException)1