Java Code Examples for javax.naming.directory.InitialDirContext#getEnvironment()

The following examples show how to use javax.naming.directory.InitialDirContext#getEnvironment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LDAPCertStore.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "throw");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 2
Source File: LDAPCertStore.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "throw");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 3
Source File: LDAPCertStore.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 4
Source File: LDAPCertStore.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "throw");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 5
Source File: LDAPCertStore.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "throw");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 6
Source File: LDAPCertStore.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 7
Source File: LDAPCertStore.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 8
Source File: LDAPCertStore.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 9
Source File: LDAPCertStore.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 10
Source File: LDAPCertStore.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "throw");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 11
Source File: LDAPCertStore.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}
 
Example 12
Source File: LDAPCertStore.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Create InitialDirContext.
 *
 * @param server Server DNS name hosting LDAP service
 * @param port   Port at which server listens for requests
 * @throws InvalidAlgorithmParameterException if creation fails
 */
private void createInitialDirContext(String server, int port)
        throws InvalidAlgorithmParameterException {
    String url = "ldap://" + server + ":" + port;
    Hashtable<String,Object> env = new Hashtable<>();
    env.put(Context.INITIAL_CONTEXT_FACTORY,
            "com.sun.jndi.ldap.LdapCtxFactory");
    env.put(Context.PROVIDER_URL, url);

    // If property is set to true, disable application resource file lookup.
    boolean disableAppResourceFiles = AccessController.doPrivileged(
        new GetBooleanAction(PROP_DISABLE_APP_RESOURCE_FILES));
    if (disableAppResourceFiles) {
        if (debug != null) {
            debug.println("LDAPCertStore disabling app resource files");
        }
        env.put("com.sun.naming.disable.app.resource.files", "true");
    }

    try {
        ctx = new InitialDirContext(env);
        /*
         * By default, follow referrals unless application has
         * overridden property in an application resource file.
         */
        Hashtable<?,?> currentEnv = ctx.getEnvironment();
        if (currentEnv.get(Context.REFERRAL) == null) {
            ctx.addToEnvironment(Context.REFERRAL, "follow");
        }
    } catch (NamingException e) {
        if (debug != null) {
            debug.println("LDAPCertStore.engineInit about to throw "
                + "InvalidAlgorithmParameterException");
            e.printStackTrace();
        }
        Exception ee = new InvalidAlgorithmParameterException
            ("unable to create InitialDirContext using supplied parameters");
        ee.initCause(e);
        throw (InvalidAlgorithmParameterException)ee;
    }
}