简体   繁体   中英

Authenticating Mac local users in Java

I have used jcifs 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM