improve scm-pam-plugin

This commit is contained in:
Sebastian Sdorra
2011-01-01 22:02:37 +01:00
parent 6d1a123eae
commit 2baf53d697
3 changed files with 154 additions and 4 deletions

View File

@@ -131,12 +131,14 @@ public class PAMAuthenticationHandler implements AuthenticationHandler
{
try
{
UnixUser user = pam.authenticate(username, password);
UnixUser unixUser = pam.authenticate(username, password);
if (user != null)
if (unixUser != null)
{
result = new AuthenticationResult(new User(username, username,
null));
User user = new User(username, username, null);
user.setAdmin(isAdmin(unixUser));
result = new AuthenticationResult(user);
}
}
catch (PAMException ex)
@@ -227,6 +229,40 @@ public class PAMAuthenticationHandler implements AuthenticationHandler
this.config = config;
}
//~--- get methods ----------------------------------------------------------
/**
* Method description
*
*
* @param unixUser
*
* @return
*/
private boolean isAdmin(UnixUser unixUser)
{
boolean admin = false;
if (config.getAdminUserSet().contains(unixUser.getUserName()))
{
admin = true;
}
else
{
for (String group : unixUser.getGroups())
{
if (config.getAdminGroupSet().contains(group))
{
admin = true;
break;
}
}
}
return admin;
}
//~--- fields ---------------------------------------------------------------
/** Field description */