public boolean commit() throws LoginException {
if (resourcePrincipalName == null || userName == null || password == null) {
return false;
}
resourcePrincipal = new ResourcePrincipal(resourcePrincipalName);
subject.getPrincipals().add(resourcePrincipal);
passwordCredential = new PasswordCredential(userName, password);
passwordCredential.setManagedConnectionFactory(managedConnectionFactory);
subject.getPrivateCredentials().add(passwordCredential);