All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evasion.sam.jaas.JNDIClient Maven / Gradle / Ivy

There is a newer version: 2.0.0.2
Show newest version
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.sam.jaas;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author sebastien
 */
public class JNDIClient {

    /**
     * LOGGER.
     */
    private static final Logger LOGGER = Logger.getLogger(EvasionEJBLoginModule.class.getName());

    private Context ctx;

    public JNDIClient(String providerUrl) {
        Map properties = new HashMap(2);
        properties.put(Context.PROVIDER_URL, providerUrl); // "iiop://127.0.0.1:3700"
        try {
            ctx = new InitialContext(new Hashtable(properties));
        } catch (NamingException ex) {
            LOGGER.log(Level.SEVERE, "JNDI Exception ", ex);
        }
    }

    public Object lookup(String name) {
        try {
            return ctx.lookup(name);
        } catch (NamingException ex) {
            LOGGER.log(Level.SEVERE, "JNDI lookup Exception ", ex);
        }
        return null;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy