if (Thread.currentThread().getContextClassLoader().getResource(appContextLocation) == null) { if (super.log.isInfoEnabled()) { super.log.info("cannot locate " + appContextLocation);
if ((singletonId == null) || "".equals(singletonId)) { if (Thread.currentThread().getContextClassLoader().getResource(appContextLocation) == null) { if (super.log.isInfoEnabled()) { super.log.info("cannot locate " + appContextLocation); }  throw new IllegalArgumentException("Cannot locate " + appContextLocation);
    public void initialize(Subject subject, CallbackHandler callbackHandler,        Map sharedState, Map options) {        super.initialize(subject, callbackHandler, sharedState, options);        if (super.log.isInfoEnabled()) {            super.log.info("initializing jboss login module");        }        this.key = (String) options.get("key");        if ((key == null) || "".equals(key)) {            throw new IllegalArgumentException("key must be defined");        }        String singletonId = (String) options.get("singletonId");        String appContextLocation = (String) options.get("appContextLocation");        if ((((singletonId == null) || "".equals(singletonId))            && (appContextLocation == null)) || "".equals(appContextLocation)) {            throw new IllegalArgumentException(                "appContextLocation must be defined");        }        String beanName = (String) options.get("authenticationManager");        if (Thread.currentThread().getContextClassLoader().getResource(appContextLocation) == null) {            if (super.log.isInfoEnabled()) {                super.log.info("cannot locate " + appContextLocation);            }            throw new IllegalArgumentException("Cannot locate "                + appContextLocation);        }        ClassPathXmlApplicationContext ctx = null;        if ((singletonId == null) || "".equals(singletonId)) {            try {                ctx = new ClassPathXmlApplicationContext(appContextLocation);            } catch (Exception e) {                if (super.log.isInfoEnabled()) {                    super.log.info("error loading spring context "                        + appContextLocation + " " + e);                }                throw new IllegalArgumentException(                    "error loading spring context " + appContextLocation + " "                    + e);            }        } else {            if (super.log.isInfoEnabled()) {                super.log.debug("retrieving singleton instance " + singletonId);            }            BeanFactoryLocator bfl = SingletonBeanFactoryLocator.getInstance();            BeanFactoryReference bf = bfl.useBeanFactory(singletonId);            ctx = (ClassPathXmlApplicationContext) bf.getFactory();            if (ctx == null) {                if (super.log.isInfoEnabled()) {                    super.log.info("singleton " + beanName + " does not exists");                }                throw new IllegalArgumentException("singleton " + singletonId                    + " does not exists");            }        }        if ((beanName == null) || "".equals(beanName)) {            Map beans = null;            try {                beans = ctx.getBeansOfType(AuthenticationManager.class, true,                        true);            } catch (Exception e) {                if (super.log.isInfoEnabled()) {                    super.log.info("exception in getBeansOfType " + e);                }                throw new IllegalStateException(                    "spring error in get beans by class");            }            if (beans.size() == 0) {                throw new IllegalArgumentException(                    "Bean context must contain at least one bean of type AuthenticationManager");            }            beanName = (String) beans.keySet().iterator().next();        }        authenticationManager = (AuthenticationManager) ctx.getBean(beanName);        if (super.log.isInfoEnabled()) {            super.log.info("Successfully started JbossSpringLoginModule");        }    }