Example usage for org.apache.shiro.realm.ldap JndiLdapContextFactory setContextFactoryClassName

List of usage examples for org.apache.shiro.realm.ldap JndiLdapContextFactory setContextFactoryClassName

Introduction

In this page you can find the example usage for org.apache.shiro.realm.ldap JndiLdapContextFactory setContextFactoryClassName.

Prototype

public void setContextFactoryClassName(String contextFactoryClassName) 

Source Link

Document

The name of the ContextFactory class to use.

Usage

From source file:io.vertx.ext.auth.impl.realms.LDAPAuthRealm.java

License:Open Source License

@Override
public void init(JsonObject config) {
    this.config = config;
    JndiLdapRealm ldapRealm = new JndiLdapRealm();
    JndiLdapContextFactory factory = new JndiLdapContextFactory();
    String userDNTemplate = config.getString(LDAP_USER_DN_TEMPLATE_FIELD);
    if (userDNTemplate != null) {
        ldapRealm.setUserDnTemplate(userDNTemplate);
    }/*  w w  w  . j  a  va  2  s. c  o m*/
    String url = config.getString(LDAP_URL);
    if (url != null) {
        factory.setUrl(url);
    }
    String authenticationMechanism = config.getString(LDAP_AUTHENTICATION_MECHANISM);
    if (authenticationMechanism != null) {
        factory.setAuthenticationMechanism(authenticationMechanism);
    }
    String contextFactoryClassName = config.getString(LDAP_CONTEXT_FACTORY_CLASS_NAME);
    if (contextFactoryClassName != null) {
        factory.setContextFactoryClassName(contextFactoryClassName);
    }
    boolean poolingEnabled = config.getBoolean(LDAP_POOLING_ENABLED, false);
    factory.setPoolingEnabled(poolingEnabled);
    String referral = config.getString(LDAP_REFERRAL);
    if (referral != null) {
        factory.setReferral(referral);
    }
    String systemUsername = config.getString(LDAP_SYSTEM_USERNAME);
    if (systemUsername != null) {
        factory.setSystemUsername(systemUsername);
    }
    String systemPassword = config.getString(LDAP_SYSTEM_PASSWORD);
    if (systemPassword != null) {
        factory.setSystemPassword(systemPassword);
    }
    ldapRealm.setContextFactory(factory);
    ldapRealm.init();
    this.securityManager = new DefaultSecurityManager(ldapRealm);
    this.realm = ldapRealm;
}

From source file:io.vertx.ext.auth.shiro.impl.LDAPAuthProvider.java

License:Open Source License

public static Realm createRealm(JsonObject config) {
    JndiLdapRealm ldapRealm = new JndiLdapRealm();
    JndiLdapContextFactory factory = new JndiLdapContextFactory();
    String userDNTemplate = config.getString(LDAP_USER_DN_TEMPLATE_FIELD);
    if (userDNTemplate != null) {
        ldapRealm.setUserDnTemplate(userDNTemplate);
    }//w  w w .  j  a v a 2  s .  c om
    String url = config.getString(LDAP_URL);
    if (url != null) {
        factory.setUrl(url);
    }
    String authenticationMechanism = config.getString(LDAP_AUTHENTICATION_MECHANISM);
    if (authenticationMechanism != null) {
        factory.setAuthenticationMechanism(authenticationMechanism);
    }
    String contextFactoryClassName = config.getString(LDAP_CONTEXT_FACTORY_CLASS_NAME);
    if (contextFactoryClassName != null) {
        factory.setContextFactoryClassName(contextFactoryClassName);
    }
    boolean poolingEnabled = config.getBoolean(LDAP_POOLING_ENABLED, false);
    factory.setPoolingEnabled(poolingEnabled);
    String referral = config.getString(LDAP_REFERRAL);
    if (referral != null) {
        factory.setReferral(referral);
    }
    String systemUsername = config.getString(LDAP_SYSTEM_USERNAME);
    if (systemUsername != null) {
        factory.setSystemUsername(systemUsername);
    }
    String systemPassword = config.getString(LDAP_SYSTEM_PASSWORD);
    if (systemPassword != null) {
        factory.setSystemPassword(systemPassword);
    }
    ldapRealm.setContextFactory(factory);
    ldapRealm.init();
    return ldapRealm;
}

From source file:io.vertx.ext.auth.shiro.impl.LDAPAuthRealm.java

License:Open Source License

public LDAPAuthRealm(JsonObject config) {
    JndiLdapRealm ldapRealm = new JndiLdapRealm();
    JndiLdapContextFactory factory = new JndiLdapContextFactory();
    String userDNTemplate = config.getString(LDAP_USER_DN_TEMPLATE_FIELD);
    if (userDNTemplate != null) {
        ldapRealm.setUserDnTemplate(userDNTemplate);
    }/*from   w  ww.j a  v  a 2 s .c o  m*/
    String url = config.getString(LDAP_URL);
    if (url != null) {
        factory.setUrl(url);
    }
    String authenticationMechanism = config.getString(LDAP_AUTHENTICATION_MECHANISM);
    if (authenticationMechanism != null) {
        factory.setAuthenticationMechanism(authenticationMechanism);
    }
    String contextFactoryClassName = config.getString(LDAP_CONTEXT_FACTORY_CLASS_NAME);
    if (contextFactoryClassName != null) {
        factory.setContextFactoryClassName(contextFactoryClassName);
    }
    boolean poolingEnabled = config.getBoolean(LDAP_POOLING_ENABLED, false);
    factory.setPoolingEnabled(poolingEnabled);
    String referral = config.getString(LDAP_REFERRAL);
    if (referral != null) {
        factory.setReferral(referral);
    }
    String systemUsername = config.getString(LDAP_SYSTEM_USERNAME);
    if (systemUsername != null) {
        factory.setSystemUsername(systemUsername);
    }
    String systemPassword = config.getString(LDAP_SYSTEM_PASSWORD);
    if (systemPassword != null) {
        factory.setSystemPassword(systemPassword);
    }
    ldapRealm.setContextFactory(factory);
    ldapRealm.init();
    this.securityManager = new DefaultSecurityManager(ldapRealm);
    this.realm = ldapRealm;
}