Merge pull request #167 from dBucik/fix_storing_saved_user_auth

fix: 🐛 Fix storing SavedUserAuth
pull/1580/head
Dominik František Bučík 2022-04-06 12:42:25 +02:00 committed by GitHub
commit 2fd0d8963d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 4 deletions

View File

@ -100,17 +100,21 @@ public class SavedUserAuthentication implements Authentication {
setAuthorities(new HashSet<>(src.getAuthorities()));
setAuthenticated(src.isAuthenticated());
if (src instanceof SavedUserAuthentication) {
this.setAcr(((SavedUserAuthentication) src).getAcr());
SavedUserAuthentication source = (SavedUserAuthentication) src;
this.setAcr(source.getAcr());
this.setAuthenticationDetails(source.getAuthenticationDetails());
} else if (src instanceof ExpiringUsernameAuthenticationToken) {
ExpiringUsernameAuthenticationToken token = (ExpiringUsernameAuthenticationToken) src;
this.acr = ((SamlPrincipal) token.getPrincipal()).getSamlCredential()
SAMLCredential credential = ((SamlPrincipal) token.getPrincipal()).getSamlCredential();
this.setAcr(credential
.getAuthenticationAssertion()
.getAuthnStatements().stream()
.map(AuthnStatement::getAuthnContext)
.map(AuthnContext::getAuthnContextClassRef)
.map(AuthnContextClassRef::getAuthnContextClassRef)
.collect(Collectors.joining());
this.authenticationDetails = new SamlAuthenticationDetails((SAMLCredential) src.getCredentials());
.collect(Collectors.joining())
);
this.setAuthenticationDetails(new SamlAuthenticationDetails(credential));
}
}