-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix #322: Process cancelation by user not recorded in DB
Remove activation (if present) during onboarding cleanup
- Loading branch information
Showing
3 changed files
with
88 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...oarding/src/main/java/com/wultra/app/onboardingserver/impl/service/ActivationService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* PowerAuth Enrollment Server | ||
* Copyright (C) 2022 Wultra s.r.o. | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Affero General Public License as published | ||
* by the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Affero General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Affero General Public License | ||
* along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
package com.wultra.app.onboardingserver.impl.service; | ||
|
||
import com.wultra.app.onboardingserver.errorhandling.RemoteCommunicationException; | ||
import com.wultra.security.powerauth.client.PowerAuthClient; | ||
import com.wultra.security.powerauth.client.model.error.PowerAuthClientException; | ||
import com.wultra.security.powerauth.client.v3.RemoveActivationRequest; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.stereotype.Service; | ||
|
||
/** | ||
* Service for working with activations. | ||
* | ||
* @author Lubos Racansky, lubos.racansky@wultra.com | ||
*/ | ||
@Service | ||
@Slf4j | ||
public class ActivationService { | ||
|
||
private final PowerAuthClient powerAuthClient; | ||
|
||
/** | ||
* All-arg constructor. | ||
* | ||
* @param powerAuthClient PowerAuth service client. | ||
*/ | ||
public ActivationService(final PowerAuthClient powerAuthClient) { | ||
this.powerAuthClient = powerAuthClient; | ||
} | ||
|
||
/** | ||
* Remove activation. | ||
* | ||
* @param activationId Activation ID. | ||
* @throws RemoteCommunicationException Thrown when communication with PowerAuth server fails. | ||
*/ | ||
public void removeActivation(final String activationId) throws RemoteCommunicationException { | ||
final RemoveActivationRequest request = new RemoveActivationRequest(); | ||
request.setActivationId(activationId); | ||
logger.info("Removing activation ID: {}", activationId); | ||
|
||
try { | ||
powerAuthClient.removeActivation(request); | ||
} catch (PowerAuthClientException e) { | ||
throw new RemoteCommunicationException("Communication with PowerAuth server failed: " + e.getMessage(), e); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters