Linux PAM module in Java

I have my own authentication mechanism written in Java. I was wondering what would be the best way to implement the Linux PAM module without rewriting the code in C?

I know this list of available PAM modules , but none of them are Java related.

There is also JPam , but it does the opposite: it allows you to get information about the user / group that will be used in the Java application, while I need to use the existing Java code to authenticate users in Linux (for example, via SSH).

Any suggestions are welcome.

+3
source share
5 answers

:

  • Java-, GCJ
  • C, JVM Java-.

.

+2

, pam_exec?

script PAM.

. PAM - :

auth sufficient pam_exec.so expose_authtok /usr/local/bin/myscript-example

script, vars, Java, .

, script , auth .

script, :

#!/bin/sh
read password
echo "User: $PAM_USER"
echo "Ruser: $PAM_RUSER"
echo "Rhost: $PAM_RHOST"
echo "Service: $PAM_SERVICE"
echo "TTY: $PAM_TTY"
echo "Password : $password"
exit $?
+2

C PAM , JNI JVM.

JVM , "exe", JAR. , JNI, JVM ; , JNI C Java.

, JVM C-, . C PAM , .

, , JNI Java . , "C" (, char *) Java JVM. Java PAM.

!

+1

Java C-, PAM. JNI (Java Native Interface). JNI C Java, . GNU CNI, . , Wikipedia JNI

0

http://jaas-pam.sourceforge.net/

It performs user authentication and works with the Tomcat jaas realm, but does not return any group / role information, so there is no role-based web authentication.

0
source

Source: https://habr.com/ru/post/1752353/


All Articles