I went here:
https://github.com/matthiasblaesing/libpam4jand used svn co according to the green button "clone or download" button:
https://github.com/matthiasblaesing/libpam4j.gitThe "pamTest" code employing these jars is actually part of Apache UIMA DUCC downloadable from here:
http://uima.apache.org/downloads.cgi#Latest%20Official%20ReleasesPamTest
package org.apache.uima.ducc.ws.authentication;
public class PamTest {
public static void main(String[] args) {
PamAuthenticate instance = new PamAuthenticate();
instance.launch(args, true);
}
}
PamAuthenticate
package org.apache.uima.ducc.ws.authentication;
import org.jvnet.libpam.PAM;
import org.jvnet.libpam.UnixUser;
public class PamAuthenticate {
private enum Result { success, failure };
private void info(Result result, String text) {
System.out.println(
result.name()+" "+text);
}
/*
* See UserAuthentciate.
*/
protected void launch(String[] args, boolean verbose) {
try {
if(args == null) {
info(Result.failure, "args==null");
}
else if(args.length != 2) {
info(Result.failure, "args.length!=2");
}
else if(args[0] == null) {
info(Result.failure, "args[0]==null");
}
else if(args[1] == null) {
info(Result.failure, "args[1]==null");
}
else {
String userid = args[0];
String password = args[1];
UnixUser u = new PAM("sshd").authenticate(userid, password);
info(Result.success, "groups = "+u.getGroups().toString());
}
}