External authentication in ejabberd using Java


Venkas

I am working on a task to implement external authentication in ejabberd using Java.

I've searched the internet for examples and found examples in PHP, Perl, Python, but nothing in Java.

I know the configuration that needs to be done in the 'ejabberd.cfg' file.

Any code samples in Java would be very helpful.

Vinod

try this:

public static void main(String[] args) {
    try {

        outerloop: while (true) {
            byte[] lB = new byte[2];

            int startPos = 0;

            while (startPos < lB.length) {

                int ret = System.in.read(lB, startPos,
                        (lB.length - startPos));

                if (ret < 0) {

                    break outerloop;
                }
                startPos += ret;
            }

            int streamLen = System.in.available();

            byte[] rd = new byte[streamLen];

            startPos = 0;

            while (startPos < streamLen) {

                int ret = System.in.read(rd, startPos,
                        (streamLen - startPos));
                if (ret < 0) {

                    break outerloop;
                }
                startPos += ret;
            }

            String inputArgs = new String(rd, "ASCII");

            String[] arguments = inputArgs.split(":");

            String userName = arguments[1];
            String password = arguments[3];
            //
            // Here do the authentication
            //

            boolean resultOfAuthentication = // Result of Authentication;

            byte[] res = new byte[4];
            res[0] = 0;
            res[1] = 2;
            res[2] = 0;

            if (resultOfAuthentication) {
                res[3] = 1;
            } else {
                res[3] = 0;
            }
            System.out.write(res, 0, res.length);
            System.out.flush();
        }
    } catch (Exception e) {
        System.out.println("ERROR");

    }

}

Related


ejabberd external authentication php sqlserver

Kasaf I have an ejabberd 15.03 server in a centOS virtual machine and I need to implement an external authentication method with php against SQL Server. The official documentation shows a php/mysql example php/mysql external authentication Is there a way to ch

External authentication module for ejabberd on Windows

David Comer How to get ejabberd to run external authentication scripts on Windows? So far I have modified the file C:\ Program Files \ ejabberd-15.06 \ lib \ ejabberd-15.06 \ priv \ cfg \ ejabberd.yml Comment out the existing auth_method directive and add the

ejabberd external authentication php sqlserver

Kasaf I have an ejabberd 15.03 server in a centOS virtual machine and I need to implement an external authentication method with php against SQL Server. The official documentation shows a php/mysql example php/mysql external authentication Is there a way to ch

ejabberd external authentication php sqlserver

Kasaf I have an ejabberd 15.03 server in a centOS virtual machine and I need to implement an external authentication method with php against SQL Server. The official documentation shows a php/mysql example php/mysql external authentication Is there a way to ch

External authentication module for ejabberd on Windows

David Comer How to get ejabberd to run external authentication scripts on Windows? So far I have modified the file C:\ Program Files \ ejabberd-15.06 \ lib \ ejabberd-15.06 \ priv \ cfg \ ejabberd.yml Comment out the existing auth_method directive and add the

ejabberd external authentication php sqlserver

Kasaf I have an ejabberd 15.03 server in a centOS virtual machine and I need to implement an external authentication method with php against SQL Server. The official documentation shows a php/mysql example php/mysql external authentication Is there a way to ch

External authentication module for ejabberd on Windows

David Comer How to get ejabberd to run external authentication scripts on Windows? So far I have modified the file C:\ Program Files \ ejabberd-15.06 \ lib \ ejabberd-15.06 \ priv \ cfg \ ejabberd.yml Comment out the existing auth_method directive and add the

External authentication using fingerprint reader

Jeremy Smith I understand that the Android/iOS biometric subsystem is not intended to be used to expose "fingerprint ID" outside of proprietary internal APIs for unlocking devices etc. But can the sensor itself be used to collect fingerprint data to send to a

External authentication using fingerprint reader

Jeremy Smith I understand that the Android/iOS biometric subsystem is not designed to be used to expose "fingerprint ID" outside of proprietary internal APIs for unlocking devices etc. But can the sensor itself be used to collect fingerprint data to send to a

JWT authentication in ejabberd

AD95 I have followed this documentation ejabberd authentication to configure the ejabberd service to use jwt tokens to authenticate users . In the ejabberd.yml file, I have configured the authentication mechanism as follows `auth_method: [jwt, sql] jwt_key: /

How to create authentication using external text file

Jamie Patterson As part of a larger program, I need to check someone's username and password against an external txt file. Do I need to use dictionaries in my text files? username = input("What is your username?") password = input("Password?") #To do: check u

Problems with external authentication data retrieval using owin

Daniel T. Can someone provide an example how to retrieve the profile picture url from facebook? Somehow I can't. I can retrieve first name, last name, email, gender, and it should allow retrieval of profile pictures, but it doesn't. There is no such thing as a

Kerberos authentication with Java on external network times out

Janetti I followed this article to create a java program for testing kerberos authentication : https://docs.oracle.com/javase/jndi/tutorial/ldap/security/gssapi.html The only thing I changed was the config file. The program works fine when I point the Windows

Kerberos authentication with Java on external network times out

Janetti I followed this article to create a java program for testing kerberos authentication : https://docs.oracle.com/javase/jndi/tutorial/ldap/security/gssapi.html The only thing I changed was the config file. The program works fine when I point the Windows

MVC 5 external authentication using authentication mode = form

Felipe Miosso I am following this tutorial to create a simple MVC 5 application with external authentication. It works fine, however, if I change to authentication mode="None", authentication mode="Forms"it stops working. I am invalid in: await HttpContext.Get

Pre-authentication steps in ejabberd

Shubham 1164 I'm working on a whatsapp-like project and using ejabberd as a backend server for Android/IOS clients. I want to do something like step 1 for whatsapp. The client sends the mobile number to the server. 2. The server sends an OTP to the client and

Using external libraries in Java

Maxim Kumpan Here is the error I keep getting when running: [java] Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException Note that this is a runtime error, not a compile time error. Both tasks in my build.xml have the same set of

Using external libraries in Java

Maxim Kumpan Here is the error I keep getting when running: [java] Exception in thread "main" java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException Note that this is a runtime error, not a compile time error. Both tasks in my build.xml have the same set of

Using NTLM authentication in a Java application

demon I want to use Windows NTLM authentication in my Java application to transparently authenticate intranet users. If using a browser (single sign-on), the user will not notice any authentication. I found some libraries with NTLM support, but don't know whic