import static org.junit.Assert.*; import org.junit.Before; import org.junit.Test; public class SecurityServiceTest { private SecurityService securityService; @Before public void setUp() { securityService = new SecurityService(); //Mock any database access you need here, like DAOs. //example: securityService.setUserDAO(myMockUserDAO); } @Test public void loginWithNull_False() { assertFalse(securityService.login(null, "123")); } }
@Override public void login(final String s, final String s1) throws ServletException { final SecurityService component = SystemInstance.get().getComponent(SecurityService.class); try { final Object uuid = component.login(s, s1); component.associate(uuid); } catch (final LoginException e) { throw new ServletException(e); } }
@Override public void login(final String s, final String s1) throws ServletException { final SecurityService component = SystemInstance.get().getComponent(SecurityService.class); try { final Object uuid = component.login(s, s1); component.associate(uuid); } catch (final LoginException e) { throw new ServletException(e); } }
private void login() throws AuthenticationException { String user = (String) properties.get(Context.SECURITY_PRINCIPAL); String pass = (String) properties.get(Context.SECURITY_CREDENTIALS); String realmName = (String) properties.get("openejb.authentication.realmName"); if (user != null && pass != null){ try { logger.info("Logging in"); SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); if (realmName == null) { clientIdentity = securityService.login(user, pass); } else { clientIdentity = securityService.login(realmName, user, pass); } ClientSecurity.setIdentity(clientIdentity); } catch (LoginException e) { throw (AuthenticationException) new AuthenticationException("User could not be authenticated: "+user).initCause(e); } } }
private void login() throws AuthenticationException { final String user = (String) properties.get(Context.SECURITY_PRINCIPAL); final String pass = (String) properties.get(Context.SECURITY_CREDENTIALS); final String realmName = (String) properties.get("openejb.authentication.realmName"); if (user != null && pass != null) { try { if (logger.isDebugEnabled()) { logger.debug("Logging in: " + user); } final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); if (realmName == null) { clientIdentity = securityService.login(user, pass); } else { clientIdentity = securityService.login(realmName, user, pass); } ClientSecurity.setIdentity(clientIdentity); } catch (final LoginException e) { throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e); } } }
private void login() throws AuthenticationException { final String user = (String) properties.get(Context.SECURITY_PRINCIPAL); final String pass = (String) properties.get(Context.SECURITY_CREDENTIALS); final String realmName = (String) properties.get("openejb.authentication.realmName"); if (user != null && pass != null) { try { if (logger.isDebugEnabled()) { logger.debug("Logging in: " + user); } final SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); if (realmName == null) { clientIdentity = securityService.login(user, pass); } else { clientIdentity = securityService.login(realmName, user, pass); } ClientSecurity.setIdentity(clientIdentity); } catch (final LoginException e) { throw (AuthenticationException) new AuthenticationException("User could not be authenticated: " + user).initCause(e); } } }
token = securityService.login(realmName, username, password); if (token != null) { securityService.associate(token);
token = securityService.login(realmName, username, password); if (token != null) { securityService.associate(token);
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; }
token = securityService.login(realmName, username, password); if (token != null) { securityService.associate(token);
securityService.disassociate(); token = securityService.login(user, password); if (AbstractSecurityService.class.isInstance(securityService) && AbstractSecurityService.class.cast(securityService).currentState() == null) { securityService.associate(token);
securityService.disassociate(); token = securityService.login(user, password); if (AbstractSecurityService.class.isInstance(securityService) && AbstractSecurityService.class.cast(securityService).currentState() == null) { securityService.associate(token);
final Object loginObj = securityService.login(securityRealmName, userName, password == null ? "" : new String(password)); securityService.associate(loginObj); callerPrincipal = securityService.getCallerPrincipal();
final Object loginObj = securityService.login(securityRealmName, userName, password == null ? "" : new String(password)); securityService.associate(loginObj); callerPrincipal = securityService.getCallerPrincipal();
token = logoutIdentity; } else { token = securityService.login(securityRealm, username, password, timeout);
if (authentication != null) { try { securityToken = securityService.login(authentication.getRealm(), authentication.getUser(), new String(authentication.getPassword())); } catch (final Throwable t) { res.setResponse(req.getVersion(), ResponseCodes.AUTH_DENIED, t);