public Context getInitialContext(Hashtable env) throws javax.naming.NamingException { if (!org.apache.openejb.OpenEJB.isInitialized()) { initializeOpenEJB(env); } String user = (String) env.get(Context.SECURITY_PRINCIPAL); String pass = (String) env.get(Context.SECURITY_CREDENTIALS); String realmName = (String) env.get("openejb.authentication.realmName"); if (user != null && pass != null){ try { SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); Object identity = null; if (realmName == null) { identity = securityService.login(user, pass); } else { identity = securityService.login(realmName, user, pass); } securityService.associate(identity); } catch (LoginException e) { throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e); } } ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); Context context = containerSystem.getJNDIContext(); context = (Context) context.lookup("openejb/local"); return context; }
@SuppressWarnings("unchecked") @Override public Context getInitialContext(final Hashtable env) throws javax.naming.NamingException { if (!OpenEJB.isInitialized()) { initializeOpenEJB(env); } final String user = (String) env.get(Context.SECURITY_PRINCIPAL); final String pass = (String) env.get(Context.SECURITY_CREDENTIALS); final String realmName = (String) env.get("openejb.authentication.realmName"); if (user != null && pass != null) { try { final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); final Object identity; if (realmName == null) { identity = securityService.login(user, pass); } else { identity = securityService.login(realmName, user, pass); } securityService.associate(identity); } catch (final LoginException e) { throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e); } } final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); Context context = containerSystem.getJNDIContext(); context = (Context) context.lookup("openejb/local"); return context; }
@SuppressWarnings("unchecked") @Override public Context getInitialContext(final Hashtable env) throws javax.naming.NamingException { if (!OpenEJB.isInitialized()) { initializeOpenEJB(env); } final String user = (String) env.get(Context.SECURITY_PRINCIPAL); final String pass = (String) env.get(Context.SECURITY_CREDENTIALS); final String realmName = (String) env.get("openejb.authentication.realmName"); if (user != null && pass != null) { try { final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); final Object identity; if (realmName == null) { identity = securityService.login(user, pass); } else { identity = securityService.login(realmName, user, pass); } securityService.associate(identity); } catch (final LoginException e) { throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e); } } final ContainerSystem containerSystem = SystemInstance.get().getComponent(ContainerSystem.class); Context context = containerSystem.getJNDIContext(); context = (Context) context.lookup("openejb/local"); return context; }