use of org.jboss.security.auth.callback.ObjectCallback in project wildfly by wildfly.
the class GuestDelegationLoginModule method login.
// Public methods --------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public boolean login() throws LoginException {
if (super.login() == true) {
log.debug("super.login()==true");
return true;
}
// Time to see if this is a delegation request.
NameCallback ncb = new NameCallback("Username:");
ObjectCallback ocb = new ObjectCallback("Password:");
try {
callbackHandler.handle(new Callback[] { ncb, ocb });
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
// If the CallbackHandler can not handle the required callbacks then no chance.
return false;
}
String name = ncb.getName();
Object credential = ocb.getCredential();
if (credential instanceof CurrentUserCredential) {
// This credential type will only be seen for a delegation request, if not seen then the request is not for us.
final CurrentUserCredential cuCredential = (CurrentUserCredential) credential;
// only the "guest" can be switched to another identity
if ("guest".equals(cuCredential.getUser())) {
identity = new SimplePrincipal(name);
if (getUseFirstPass()) {
String userName = identity.getName();
if (log.isDebugEnabled())
log.debug("Storing username '" + userName + "' and empty password");
// Add the username and an empty password to the shared state map
sharedState.put("javax.security.auth.login.name", identity);
sharedState.put("javax.security.auth.login.password", "");
}
loginOk = true;
return true;
}
}
// Attempted login but not successful.
return false;
}
use of org.jboss.security.auth.callback.ObjectCallback in project wildfly by wildfly.
the class ExternalLoginModule method login.
// Public methods --------------------------------------------------------
@SuppressWarnings("unchecked")
@Override
public boolean login() throws LoginException {
if (super.login()) {
log.debug("super.login()==true");
return true;
}
// Time to see if this is a delegation request.
NameCallback ncb = new NameCallback("Username:");
ObjectCallback ocb = new ObjectCallback("Credential:");
try {
callbackHandler.handle(new Callback[] { ncb, ocb });
} catch (Exception e) {
if (e instanceof RuntimeException) {
throw (RuntimeException) e;
}
// If the CallbackHandler can not handle the required callbacks then no chance.
return false;
}
String name = ncb.getName();
Object credential = ocb.getCredential();
if (credential instanceof ExternalCredential) {
identity = new SimplePrincipal(name);
loginOk = true;
return true;
}
// Attempted login but not successful.
return false;
}
use of org.jboss.security.auth.callback.ObjectCallback in project wildfly by wildfly.
the class RealmDirectLoginModule method getDigestCredential.
private DigestCredential getDigestCredential() {
ObjectCallback oc = new ObjectCallback("Credential:");
try {
super.callbackHandler.handle(new Callback[] { oc });
} catch (IOException | UnsupportedCallbackException e) {
return null;
}
Object credential = oc.getCredential();
if (credential instanceof DigestCredential) {
/*
* This change is an intermediate change to allow the use of a DigestCredential until we are ready to switch to
* JAAS.
*
* However we only wish to accept trusted implementations so perform this final check.
*/
if (credential.getClass().getName().equals("org.wildfly.extension.undertow.security.DigestCredentialImpl")) {
return (DigestCredential) credential;
}
}
return null;
}
use of org.jboss.security.auth.callback.ObjectCallback in project wildfly by wildfly.
the class RemotingLoginModule method getCredential.
protected Object getCredential() throws LoginException {
NameCallback nc = new NameCallback("Alias: ");
ObjectCallback oc = new ObjectCallback("Credential: ");
Callback[] callbacks = { nc, oc };
try {
callbackHandler.handle(callbacks);
return oc.getCredential();
} catch (IOException ioe) {
LoginException le = new LoginException();
le.initCause(ioe);
throw le;
} catch (UnsupportedCallbackException uce) {
LoginException le = new LoginException();
le.initCause(uce);
throw le;
}
}
Aggregations