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 Aug 14, 2024
1 parent 7a8fd8c commit 75745b5
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] found.", 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] found.", 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] found.", 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] found.", principal);
}

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

0 comments on commit 75745b5

Please sign in to comment.