private void cleanup() { authSucceeded = false; username = null; password = null; principal = null; pam.dispose(); } }
@Override public String getName() { return userName.getUserName(); }
@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()); } }
UnixUser user = null; try { user = new PAM("pam service").authenticate("username","password"); // authentication success } catch (PAMException ex){ // authentication failed }
private void check(int ret, String msg) throws PAMException { this.ret = ret; if(ret!=0) { if(pht!=null) throw new PAMException(msg+" : "+libpam.pam_strerror(pht,ret)); else throw new PAMException(msg); } }
public static Passwd loadPasswd(String userName) throws PAMException { Passwd pwd = libc.getpwnam(userName); if (pwd == null) { throw new PAMException("No user information is available"); } return pwd; }
@Override public boolean checkUnixUser(String userName) throws NativeAccessException { return UnixUser.exists(userName); }
private void createPam(String service) throws LoginException { try { _pam = new PAM(service); } catch (PAMException ex) { LoginException le = new LoginException("Error initializing PAM"); le.initCause(ex); throw le; } }
private void cleanup() { _authSucceeded = false; _username = null; _password = null; _principal = null; _pam.dispose(); } }
@Override public String getName() { return userName.getUserName(); }
private void createPam(String service) throws LoginException { try { pam = new PAM(service); } catch (PAMException ex) { LoginException le = new LoginException("Error initializing PAM"); le.initCause(ex); throw le; } }
@Override protected void finalize() throws Throwable { super.finalize(); dispose(); }
private void cleanup() { _authSucceeded = false; _username = null; Arrays.fill(_passwordchar, ' '); _principal = null; _pam.dispose(); } }
@Override protected void finalize() throws Throwable { super.finalize(); dispose(); }