Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ELY-1747] If programmatic authentication is successful associate the credential with the identity. #1223

Merged
merged 2 commits into from Jan 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -46,9 +46,11 @@
import org.wildfly.security.auth.server.SecurityDomain;
import org.wildfly.security.auth.server.SecurityIdentity;
import org.wildfly.security.auth.server.ServerAuthenticationContext;
import org.wildfly.security.credential.PasswordCredential;
import org.wildfly.security.evidence.Evidence;
import org.wildfly.security.evidence.PasswordGuessEvidence;
import org.wildfly.security.manager.WildFlySecurityManager;
import org.wildfly.security.password.interfaces.ClearPassword;


/**
Expand Down Expand Up @@ -130,6 +132,10 @@ private SecurityIdentity login(String username, Evidence evidence, String mechan
try (ServerAuthenticationContext authenticationContext = createServerAuthenticationContext()) {
authenticationContext.setAuthenticationName(username);
if (authenticationContext.verifyEvidence(evidence)) {
if (evidence instanceof PasswordGuessEvidence) {
authenticationContext.addPrivateCredential(
new PasswordCredential(ClearPassword.createRaw(ClearPassword.ALGORITHM_CLEAR, ((PasswordGuessEvidence) evidence).getGuess())));
}
if (authenticationContext.authorize()) {
SecurityIdentity authorizedIdentity = authenticationContext.getAuthorizedIdentity();
HttpScope sessionScope = httpExchangeSpi.getScope(Scope.SESSION);
Expand Down