use of org.apereo.portal.security.IPortalPasswordService in project uPortal by Jasig.
the class SimpleSecurityContext method authenticate.
/**
* Authenticate user.
*
* @exception PortalSecurityException
*/
public synchronized void authenticate() throws PortalSecurityException {
this.isauth = false;
if (this.myPrincipal.UID != null && this.myOpaqueCredentials.credentialstring != null) {
try {
ILocalAccountDao accountStore = LocalAccountDaoLocator.getLocalAccountDao();
IPortalPasswordService passwordService = PortalPasswordServiceLocator.getPortalPasswordService();
// retrieve the account from the local user store
ILocalAccountPerson account = accountStore.getPerson(this.myPrincipal.UID);
if (account != null) {
// get the account password as an ASCII string
String loginPassword = new String(this.myOpaqueCredentials.credentialstring);
// account password, authenticate the user
if (passwordService.validatePassword(loginPassword, account.getPassword())) {
// set the full name for this user
String fullName = (String) account.getAttributeValue("displayName");
this.myPrincipal.FullName = fullName;
if (log.isInfoEnabled())
log.info("User " + this.myPrincipal.UID + " is authenticated");
this.isauth = true;
} else {
log.info("Password Invalid");
}
} else {
if (log.isInfoEnabled())
log.info("No such user: " + this.myPrincipal.UID);
}
} catch (Exception e) {
log.error("Error authenticating user", e);
throw new RuntimeException("Error authenticating user", e);
}
} else // If the principal and/or credential are missing, the context authentication
// simply fails. It should not be construed that this is an error. It happens for guest access.
{
log.info("Principal or OpaqueCredentials not initialized prior to authenticate");
}
// Ok...we are now ready to authenticate all of our subcontexts.
super.authenticate();
return;
}
use of org.apereo.portal.security.IPortalPasswordService in project uPortal by Jasig.
the class PortalPasswordServiceLocator method getPortalPasswordService.
public static IPortalPasswordService getPortalPasswordService() {
AbstractBeanLocator<IPortalPasswordService> locator = locatorInstance;
if (locator == null) {
LOG.info("Looking up bean '" + BEAN_NAME + "' in ApplicationContext due to context not yet being initialized");
final ApplicationContext applicationContext = PortalApplicationContextLocator.getApplicationContext();
applicationContext.getBean(PortalPasswordServiceLocator.class.getName());
locator = locatorInstance;
if (locator == null) {
LOG.warn("Instance of '" + BEAN_NAME + "' still null after portal application context has been initialized");
return applicationContext.getBean(BEAN_NAME, IPortalPasswordService.class);
}
}
return locator.getInstance();
}
Aggregations