Skip to content

Commit

Permalink
Fix #1720: Rename CallbackUrlAuthenticationCryptor (#1729)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnpsk authored Oct 8, 2024
1 parent f5689c2 commit 34b2120
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import io.getlime.security.powerauth.app.server.database.model.enumeration.CallbackUrlType;
import io.getlime.security.powerauth.app.server.database.repository.ApplicationRepository;
import io.getlime.security.powerauth.app.server.database.repository.CallbackUrlRepository;
import io.getlime.security.powerauth.app.server.service.callbacks.CallbackUrlAuthenticationCryptor;
import io.getlime.security.powerauth.app.server.service.callbacks.CallbackUrlAuthenticationEncryptor;
import io.getlime.security.powerauth.app.server.service.callbacks.CallbackUrlEventService;
import io.getlime.security.powerauth.app.server.service.callbacks.CallbackUrlRestClientManager;
import io.getlime.security.powerauth.app.server.service.encryption.EncryptableString;
Expand Down Expand Up @@ -71,7 +71,7 @@ public class CallbackUrlBehavior {
private final CallbackUrlEventService callbackUrlEventService;
private final CallbackUrlEventQueueService callbackUrlEventQueueService;
private LocalizationProvider localizationProvider;
private final CallbackUrlAuthenticationCryptor callbackUrlAuthenticationCryptor;
private final CallbackUrlAuthenticationEncryptor callbackUrlAuthenticationEncryptor;
private final CallbackUrlRestClientManager callbackUrlRestClientManager;
private final PowerAuthCallbacksConfiguration powerAuthCallbacksConfiguration;

Expand Down Expand Up @@ -110,7 +110,7 @@ public CreateCallbackUrlResponse createCallbackUrl(CreateCallbackUrlRequest requ
entity.setCallbackUrl(request.getCallbackUrl());
entity.setAttributes(request.getAttributes());
entity.setFailureCount(0);
final EncryptableString encrypted = callbackUrlAuthenticationCryptor.encrypt(request.getAuthentication(), entity.getApplication().getId());
final EncryptableString encrypted = callbackUrlAuthenticationEncryptor.encrypt(request.getAuthentication(), entity.getApplication().getId());
entity.setAuthentication(encrypted.encryptedData());
entity.setEncryptionMode(encrypted.encryptionMode());
entity.setRetentionPeriod(request.getRetentionPeriod());
Expand All @@ -127,7 +127,7 @@ public CreateCallbackUrlResponse createCallbackUrl(CreateCallbackUrlRequest requ
if (entity.getAttributes() != null) {
response.getAttributes().addAll(entity.getAttributes());
}
response.setAuthentication(callbackUrlAuthenticationCryptor.decryptToPublic(entity));
response.setAuthentication(callbackUrlAuthenticationEncryptor.decryptToPublic(entity));
response.setRetentionPeriod(Objects.requireNonNullElse(entity.getRetentionPeriod(), powerAuthCallbacksConfiguration.getDefaultRetentionPeriod()));
response.setInitialBackoff(Objects.requireNonNullElse(entity.getInitialBackoff(), powerAuthCallbacksConfiguration.getDefaultInitialBackoff()));
response.setMaxAttempts(Objects.requireNonNullElse(entity.getMaxAttempts(), powerAuthCallbacksConfiguration.getDefaultMaxAttempts()));
Expand Down Expand Up @@ -177,7 +177,7 @@ public UpdateCallbackUrlResponse updateCallbackUrl(UpdateCallbackUrlRequest requ
entity.setType(CallbackUrlTypeConverter.convert(request.getType()));
// Retain existing passwords in case new password is not set
final HttpAuthenticationPrivate authRequest = request.getAuthentication();
final CallbackUrlAuthentication authExisting = callbackUrlAuthenticationCryptor.decrypt(entity);
final CallbackUrlAuthentication authExisting = callbackUrlAuthenticationEncryptor.decrypt(entity);
if (authRequest != null) {
if (authRequest.getCertificate() != null && authExisting.getCertificate() != null) {
if (authExisting.getCertificate().getKeyStorePassword() != null && authRequest.getCertificate().getKeyStorePassword() == null) {
Expand All @@ -199,7 +199,7 @@ public UpdateCallbackUrlResponse updateCallbackUrl(UpdateCallbackUrlRequest requ
authRequest.getOAuth2().setClientSecret(authExisting.getOAuth2().getClientSecret());
}
}
final EncryptableString encrypted = callbackUrlAuthenticationCryptor.encrypt(authRequest, entity.getApplication().getId());
final EncryptableString encrypted = callbackUrlAuthenticationEncryptor.encrypt(authRequest, entity.getApplication().getId());
entity.setAuthentication(encrypted.encryptedData());
entity.setEncryptionMode(encrypted.encryptionMode());
entity.setRetentionPeriod(request.getRetentionPeriod());
Expand All @@ -216,7 +216,7 @@ public UpdateCallbackUrlResponse updateCallbackUrl(UpdateCallbackUrlRequest requ
if (entity.getAttributes() != null) {
response.getAttributes().addAll(entity.getAttributes());
}
response.setAuthentication(callbackUrlAuthenticationCryptor.decryptToPublic(entity));
response.setAuthentication(callbackUrlAuthenticationEncryptor.decryptToPublic(entity));
response.setRetentionPeriod(Objects.requireNonNullElse(entity.getRetentionPeriod(), powerAuthCallbacksConfiguration.getDefaultRetentionPeriod()));
response.setInitialBackoff(Objects.requireNonNullElse(entity.getInitialBackoff(), powerAuthCallbacksConfiguration.getDefaultInitialBackoff()));
response.setMaxAttempts(Objects.requireNonNullElse(entity.getMaxAttempts(), powerAuthCallbacksConfiguration.getDefaultMaxAttempts()));
Expand Down Expand Up @@ -253,7 +253,7 @@ public GetCallbackUrlListResponse getCallbackUrlList(GetCallbackUrlListRequest r
if (callbackUrl.getAttributes() != null) {
item.getAttributes().addAll(callbackUrl.getAttributes());
}
item.setAuthentication(callbackUrlAuthenticationCryptor.decryptToPublic(callbackUrl));
item.setAuthentication(callbackUrlAuthenticationEncryptor.decryptToPublic(callbackUrl));
item.setRetentionPeriod(Objects.requireNonNullElse(callbackUrl.getRetentionPeriod(), powerAuthCallbacksConfiguration.getDefaultRetentionPeriod()));
item.setInitialBackoff(Objects.requireNonNullElse(callbackUrl.getInitialBackoff(), powerAuthCallbacksConfiguration.getDefaultInitialBackoff()));
item.setMaxAttempts(Objects.requireNonNullElse(callbackUrl.getMaxAttempts(), powerAuthCallbacksConfiguration.getDefaultMaxAttempts()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
*/
@Component
@AllArgsConstructor
public final class CallbackUrlAuthenticationCryptor {
public final class CallbackUrlAuthenticationEncryptor {

private CallbackAuthenticationConverter callbackAuthenticationConverter;
private EncryptionService encryptionService;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
public class CallbackUrlRestClientManager {

private final PowerAuthServiceConfiguration powerAuthServiceConfiguration;
private final CallbackUrlAuthenticationCryptor callbackUrlAuthenticationCryptor;
private final CallbackUrlAuthenticationEncryptor callbackUrlAuthenticationEncryptor;
private final CallbackUrlEventRepository callbackUrlEventRepository;

// Store REST clients in cache with their callback ID as a key
Expand Down Expand Up @@ -135,7 +135,7 @@ private RestClient initializeRestClient(final CallbackUrlEntity callbackUrlEntit
.username(powerAuthServiceConfiguration.getHttpProxyUsername())
.password(powerAuthServiceConfiguration.getHttpProxyPassword());
}
final CallbackUrlAuthentication authentication = callbackUrlAuthenticationCryptor.decrypt(callbackUrlEntity);
final CallbackUrlAuthentication authentication = callbackUrlAuthenticationEncryptor.decrypt(callbackUrlEntity);
final CallbackUrlAuthentication.Certificate certificateAuth = authentication.getCertificate();
if (certificateAuth != null && certificateAuth.isEnabled()) {
final DefaultRestClient.CertificateAuthBuilder certificateAuthBuilder = builder.certificateAuth();
Expand Down

0 comments on commit 34b2120

Please sign in to comment.