/** * Returns the groups a user belongs to * @param username * @return Set of group names * @throws PAMException * @deprecated * Pointless and ugly convenience method. */ public Set<String> getGroupsOfUser(String username) throws PAMException { return new UnixUser(username).getGroups(); }
/** * Returns the groups a user belongs to * @param username * @return Set of group names * @throws PAMException * @deprecated * Pointless and ugly convenience method. */ public Set<String> getGroupsOfUser(String username) throws PAMException { return new UnixUser(username).getGroups(); }
/** * Returns the groups a user belongs to * @param username * @return Set of group names * @throws PAMException * @deprecated * Pointless and ugly convenience method. */ public Set<String> getGroupsOfUser(String username) throws PAMException { return new UnixUser(username).getGroups(); }
protected void authenticateUser() throws LoginException { // A Unix user must have a name not null so check here. if ((_username == null) || (_username.length() == 0)) { throw new LoginException("Invalid Username"); } UnixUser user = authenticate(_username, _password); if (user == null) { // JAAS behavior throw new LoginException("Failed Pam Login for " + _username); } if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "PAM login succeeded for: " + _username); } /* * Get the groups from the libpam4j UnixUser class that has been * returned after a successful authentication. */ String[] grpList = null; Set<String> groupSet = user.getGroups(); if (groupSet != null) { grpList = new String[groupSet.size()]; user.getGroups().toArray(grpList); } else { //Empty group list, create a zero-length group list grpList = new String[0]; } commitUserAuthentication(grpList); }
protected void authenticateUser() throws LoginException { // A Unix user must have a name not null so check here. if ((_username == null) || (_username.length() == 0)) { throw new LoginException("Invalid Username"); } UnixUser user = authenticate(_username, _password); if (user == null) { // JAAS behavior throw new LoginException("Failed Pam Login for " + _username); } if (_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "PAM login succeeded for: " + _username); } /* * Get the groups from the libpam4j UnixUser class that has been * returned after a successful authentication. */ String[] grpList = null; Set<String> groupSet = user.getGroups(); if (groupSet != null) { grpList = new String[groupSet.size()]; user.getGroups().toArray(grpList); } else { //Empty group list, create a zero-length group list grpList = new String[0]; } commitUserAuthentication(grpList); }
@Override public Set<String> pamAuthenticate(String serviceName, String userName, String password) throws NativeAccessException { if (serviceName == null) { serviceName = "sshd"; // use sshd as the default } try { UnixUser unixUser = new PAM(serviceName).authenticate(userName, password); return unixUser.getGroups(); } catch (Throwable exc) { throw new NativeAccessException("Failed to do Pam Authentication. " + exc.getLocalizedMessage()); } }
public PamPrincipal(UnixUser user) { super(); userName = user.getUserName(); gecos = user.getGecos(); homeDir = user.getDir(); shell = user.getShell(); uid = user.getUID(); gid = user.getGID(); groups = Collections.unmodifiableSet(user.getGroups()); }
public PamPrincipal(UnixUser user) { super(); _userName = user.getUserName(); _gecos = user.getGecos(); _homeDir = user.getDir(); _shell = user.getShell(); _uid = user.getUID(); _gid = user.getGID(); _groups = Collections.unmodifiableSet(user.getGroups()); }
public PamPrincipal(UnixUser user) { super(); _userName = user.getUserName(); _gecos = user.getGecos(); _homeDir = user.getDir(); _shell = user.getShell(); _uid = user.getUID(); _gid = user.getGID(); _groups = Collections.unmodifiableSet(user.getGroups()); }
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { Set<String> roles = new LinkedHashSet<>(); UnixUserPrincipal user = principals.oneByType(UnixUserPrincipal.class); if (user != null) { roles.addAll(user.getUnixUser().getGroups()); } SecurityUtils.getSubject().getSession().setAttribute(SUBJECT_USER_ROLES, roles); SecurityUtils.getSubject().getSession().setAttribute(SUBJECT_USER_GROUPS, roles); /* Coverity Scan CID 1361682 */ String userName = null; if (user != null) { userName = user.getName(); } GatewayLog.lookedUpUserRoles(roles, userName); return new SimpleAuthorizationInfo(roles); }
@Override protected AuthorizationInfo doGetAuthorizationInfo(PrincipalCollection principals) { Set<String> roles = new LinkedHashSet<>(); UnixUserPrincipal user = principals.oneByType(UnixUserPrincipal.class); if (user != null) { roles.addAll(user.getUnixUser().getGroups()); } SecurityUtils.getSubject().getSession().setAttribute(SUBJECT_USER_ROLES, roles); SecurityUtils.getSubject().getSession().setAttribute(SUBJECT_USER_GROUPS, roles); /* Coverity Scan CID 1361682 */ String userName = null; if (user != null) { userName = user.getName(); } GatewayLog.lookedUpUserRoles(roles, userName); return new SimpleAuthorizationInfo(roles); }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { String username = authentication.getPrincipal().toString(); String password = authentication.getCredentials().toString(); try { UnixUser u = new PAM(serviceName).authenticate(username, password); Set<String> grps = u.getGroups(); GrantedAuthority[] groups = new GrantedAuthority[grps.size()]; int i=0; for (String g : grps) groups[i++] = new GrantedAuthorityImpl(g); EnvVars.setHudsonUserEnvVar(username); // I never understood why Acegi insists on keeping the password... return new UsernamePasswordAuthenticationToken(username, password, groups); } catch (PAMException e) { throw new BadCredentialsException(e.getMessage(),e); } }
public Authentication authenticate(Authentication authentication) throws AuthenticationException { String username = authentication.getPrincipal().toString(); String password = authentication.getCredentials().toString(); try { UnixUser u = new PAM(serviceName).authenticate(username, password); Set<String> grps = u.getGroups(); GrantedAuthority[] groups = new GrantedAuthority[grps.size()]; int i=0; for (String g : grps) groups[i++] = new GrantedAuthorityImpl(g); EnvVars.setHudsonUserEnvVar(username); // I never understood why Acegi insists on keeping the password... return new UsernamePasswordAuthenticationToken(username, password, groups); } catch (PAMException e) { throw new BadCredentialsException(e.getMessage(),e); } }