What information can I get from the user through Java EE?

0

I need to implement SSO (Single Sign-On) on a company client that I work with, the scenario is basically the following: They have a web system, done in java, that has a normal login, however they do not want a screen and that this check is done against an Active Directory that they have. So I'd like to know what information I can use about the user. I've been suggested frameworks like Waffle, Kerberos and SPNEGO, but I found that they are too complicated to implement. I would like this integration to be as simple as possible.

Thank you in advance.

    
asked by anonymous 30.01.2017 / 13:11

1 answer

0

They need to pass the user and password to be validated, an example to help you would be that block of code that I implemented:

public static boolean authenticateJndi(String username, String password) throws Exception{
        try{    
        Properties props = new Properties();
        props.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
        props.put(Context.PROVIDER_URL, "ldap://192.168.1.5:389");
        props.put(Context.SECURITY_AUTHENTICATION, "simple");
        props.put(Context.SECURITY_PRINCIPAL, "login");
        props.put(Context.SECURITY_CREDENTIALS, "senha");
        DirContext context = new InitialDirContext(props);
        System.out.println("Autenticado");
        context.close();
        return true;
        } catch(NamingException e){
            throw new NamingException("Houve um problema na autenticação");

        }
    }
    
30.01.2017 / 13:17