Skip to content

Commit

Permalink
[ELY-2780] Logging in aggregaterealm changes authentication and autho…
Browse files Browse the repository at this point in the history
…rization flow
  • Loading branch information
lvydra committed Sep 16, 2024
1 parent 7a8fd8c commit 84324b0
Showing 1 changed file with 5 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,15 @@ public AggregateSecurityRealm(final SecurityRealm authenticationRealm, Function<
public RealmIdentity getRealmIdentity(final Evidence evidence) throws RealmUnavailableException {
boolean ok = false;
final RealmIdentity authenticationIdentity = authenticationRealm.getRealmIdentity(evidence);
if (authenticationIdentity.exists()) {
log.tracef("Authentication identity for principal [%s] found.", evidence.getDecodedPrincipal());
}
log.tracef("Authentication identity for principal [%s] obtained.", evidence.getDecodedPrincipal());

final RealmIdentity[] authorizationIdentities = new RealmIdentity[authorizationRealms.length];
try {
for (int i = 0; i < authorizationIdentities.length; i++) {
SecurityRealm authorizationRealm = authorizationRealms[i];
authorizationIdentities[i] = (authorizationRealm == authenticationRealm) ? authenticationIdentity
: getAuthorizationIdentity(authorizationRealm, evidence, principalTransformer, authenticationIdentity);
if (authorizationIdentities[i].exists()) {
log.tracef("Authorization identity for principal [%s] found.", evidence.getDecodedPrincipal());
}
log.tracef("Authorization identity for principal [%s] obtained.", evidence.getDecodedPrincipal());
}

final Identity identity = new Identity(authenticationIdentity, authorizationIdentities);
Expand All @@ -111,9 +108,7 @@ public RealmIdentity getRealmIdentity(final Evidence evidence) throws RealmUnava
public RealmIdentity getRealmIdentity(final Principal principal) throws RealmUnavailableException {
boolean ok = false;
final RealmIdentity authenticationIdentity = authenticationRealm.getRealmIdentity(principal);
if (authenticationIdentity.exists()) {
log.tracef("Authentication identity for principal [%s] found.", principal);
}
log.tracef("Authentication identity for principal [%s] obtained.", principal);
Principal authorizationPrincipal = principal;
if (principalTransformer != null) {
authorizationPrincipal = principalTransformer.apply(authorizationPrincipal);
Expand All @@ -125,9 +120,7 @@ public RealmIdentity getRealmIdentity(final Principal principal) throws RealmUna
for (int i = 0; i < authorizationIdentities.length; i++) {
SecurityRealm authorizationRealm = authorizationRealms[i];
authorizationIdentities[i] = (authorizationRealm == authenticationRealm) && (principalTransformer == null) ? authenticationIdentity : authorizationRealm.getRealmIdentity(authorizationPrincipal);
if (authorizationIdentities[i].exists()) {
log.tracef("Authorization identity for principal [%s] found.", principal);
}
log.tracef("Authorization identity for principal [%s] obtained.", principal);
}

final Identity identity = new Identity(authenticationIdentity, authorizationIdentities);
Expand Down

0 comments on commit 84324b0

Please sign in to comment.