use of com.sun.enterprise.security.auth.login.common.PasswordCredential in project Payara by payara.
the class RealmIdentityStore method login.
protected Subject login(UsernamePasswordCredential credential, String realmName) {
String username = credential.getCaller();
char[] password = credential.getPassword().getValue();
Subject subject = new Subject();
privileged(() -> subject.getPrivateCredentials().add(new PasswordCredential(username, password, getValidRealm(realmName))));
WebAndEjbToJaasBridge.login(subject, PasswordCredential.class);
return subject;
}
use of com.sun.enterprise.security.auth.login.common.PasswordCredential in project javaee7-samples by javaee-samples.
the class PayaraEJBContextProvider method getContextWithCredentialsSet.
@Override
public Context getContextWithCredentialsSet(String username, String password) {
// Create a new subject with a password credential
Subject subject = new Subject();
subject.getPrivateCredentials().add(new PasswordCredential(username, password.toCharArray(), "default"));
// Store this subject into a global variable where the CORBA/IIOP code will pick it up.
ClientSecurityContext.setCurrent(new ClientSecurityContext(username, subject));
// by jndi.properties in the glassfish-naming.jar on the classpath.
try {
return new InitialContext();
} catch (NamingException e) {
throw new IllegalStateException(e);
}
}
Aggregations