mirror of
https://github.com/scm-manager/scm-manager.git
synced 2026-03-06 12:20:56 +01:00
remove duplicated admin group and user configuration
This commit is contained in:
@@ -137,7 +137,6 @@ public class PAMAuthenticationHandler implements AuthenticationHandler
|
||||
{
|
||||
User user = new User(username);
|
||||
|
||||
user.setAdmin(isAdmin(unixUser));
|
||||
result = new AuthenticationResult(user, unixUser.getGroups());
|
||||
}
|
||||
}
|
||||
@@ -229,40 +228,6 @@ 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 */
|
||||
|
||||
@@ -52,28 +52,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
public class PAMConfig
|
||||
{
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAdminGroups()
|
||||
{
|
||||
return adminGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getAdminUsers()
|
||||
{
|
||||
return adminUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -87,28 +65,6 @@ public class PAMConfig
|
||||
|
||||
//~--- set methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param adminGroups
|
||||
*/
|
||||
public void setAdminGroups(String adminGroups)
|
||||
{
|
||||
this.adminGroups = adminGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param adminUsers
|
||||
*/
|
||||
public void setAdminUsers(String adminUsers)
|
||||
{
|
||||
this.adminUsers = adminUsers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
@@ -120,65 +76,8 @@ public class PAMConfig
|
||||
this.serviceName = serviceName;
|
||||
}
|
||||
|
||||
//~--- get methods ----------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Set<String> getAdminGroupSet()
|
||||
{
|
||||
return split(adminGroups);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
Set<String> getAdminUserSet()
|
||||
{
|
||||
return split(adminUsers);
|
||||
}
|
||||
|
||||
//~--- methods --------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Method description
|
||||
*
|
||||
*
|
||||
* @param rawString
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private Set<String> split(String rawString)
|
||||
{
|
||||
Set<String> tokens = new HashSet<String>();
|
||||
|
||||
for (String token : rawString.split(","))
|
||||
{
|
||||
if (token.trim().length() > 0)
|
||||
{
|
||||
tokens.add(token);
|
||||
}
|
||||
}
|
||||
|
||||
return tokens;
|
||||
}
|
||||
|
||||
//~--- fields ---------------------------------------------------------------
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "admin-groups")
|
||||
private String adminGroups = "";
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "admin-users")
|
||||
private String adminUsers = "";
|
||||
|
||||
/** Field description */
|
||||
@XmlElement(name = "service-name")
|
||||
private String serviceName = "sshd";
|
||||
|
||||
@@ -38,16 +38,6 @@ registerGeneralConfigPanel({
|
||||
fieldLabel : 'Service name',
|
||||
name : 'service-name',
|
||||
allowBlank : false
|
||||
},{
|
||||
xtype : 'textfield',
|
||||
fieldLabel : 'Admin Groups',
|
||||
name : 'admin-groups',
|
||||
allowBlank : true
|
||||
},{
|
||||
xtype : 'textfield',
|
||||
fieldLabel : 'Admin Users',
|
||||
name : 'admin-users',
|
||||
allowBlank : true
|
||||
}],
|
||||
|
||||
onSubmit: function(values){
|
||||
|
||||
Reference in New Issue
Block a user