Authenticating Mac local users in Java

726 views Asked by At

I have used jcifs to authenticate Windows users (local as well as domain)

How do i authenticate Mac local users using Java code ?

2

There are 2 answers

0
Scott On

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.

0
sdorra On

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>