Authenticating Mac local users in Java
I have used jci开发者_运维技巧fs to authenticate Windows users (local as well as domain)
How do i authenticate Mac local users using Java code ?
Another option is libpam4j
Here is a simple example with libpam4j:
UnixUser user = null;
try {
user = new PAM("pam service").authenticate("username","password");
// authentication success
} catch (PAMException ex){
// authentication failed
}
The library is also available via maven:
<dependency>
<groupId>org.kohsuke</groupId>
<artifactId>libpam4j</artifactId>
<version>1.6</version>
</dependency>
I'm using JPAM. It does use some native code (which is provided), but it's simple to set up and ties straight into PAM, so it'll work on almost any *nix, including Mac OS X.
精彩评论