if (logger.isDebugEnabled()) {
logger.debug("username from client : " + username);
}
User user = userList.getUser ( username );
if ( user == null ) {
if (logger.isDebugEnabled()) {
logger.debug("user returned from userList is null");
}
return false; // user doesn't exist.
}
if ( ! user.authenticate( msgContext.getPassword() ) )
{
if (logger.isDebugEnabled()) {
logger.debug("authenticate failed");
}
return false; // password doesn't match.
}
if (logger.isDebugEnabled()) {
logger.debug("authenticate passed (" + username + ")");
}
for ( Role role : user.getRoles() )
{
if (logger.isDebugEnabled()) {
logger.debug("user [" + user.getName() + "] role ["+ role.getName() +"]");
}
for ( String roleAllowed : rolesAllowed )
{
if ( role.getName().equals( roleAllowed ) )
{
if (logger.isDebugEnabled()) {
logger.debug( "auth : " + user.getName()+ " is in role [" + roleAllowed + "]");
}
msgContext.setProperty(SecurityModel.BEEHIVE_AUTHUSER, user);
return true;
}
}