token = securityService.login(realmName, username, password); if (token != null) { securityService.associate(token); getSecurityService().disassociate();
public Principal getCallerPrincipal(SecurityService securityService) { return securityService.getCallerPrincipal(); }
@Override public void logout() throws ServletException { final SecurityService component = SystemInstance.get().getComponent(SecurityService.class); try { final Object disassociate = component.disassociate(); if (disassociate != null) { component.logout(disassociate); } } catch (final LoginException e) { throw new SecurityException(e); } }
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); } }
token = securityService.login(realmName, username, password); if (token != null) { securityService.associate(token); if (token != null) { final SecurityService securityService = getSecurityService(); final Object disassociate = securityService.disassociate(); if (disassociate != null) { securityService.logout(disassociate);
final Object loginObj = securityService.login(securityRealmName, userName, password == null ? "" : new String(password)); securityService.associate(loginObj); callerPrincipal = securityService.getCallerPrincipal(); passwordValidationCallback.setResult(true); } catch (final LoginException e) {
if (callContext == null && localClientIdentity != null) { SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); securityService.associate(localClientIdentity); if (callContext == null && localClientIdentity != null) { SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); securityService.disassociate();
if (associate) { securityService.associate(securityState); threadState = null; } else { threadState = securityService.currentState(); securityService.setState(securityState); securityService.setState(threadState); } else { securityService.disassociate();
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); } } }
final boolean authorized = type == InterfaceType.TIMEOUT || getSecurityService().isCallerAuthorized(callMethod, type); if (runAs != null) { try { securityService.associate(runAs); } catch (final LoginException e) {
if (runAs != null) { try { securityService.associate(runAs); } catch (final LoginException e) {
public boolean isCallerInRole(SecurityService securityService, String roleName) { return securityService.isCallerInRole(roleName); }
SECURITY_SERVICE.associate(securityServiceState); } catch (final LoginException e) { throw new IllegalStateException(e); threadState = SECURITY_SERVICE.currentState(); SECURITY_SERVICE.setState(securityServiceState);
SECURITY_SERVICE.setState(currentContext.securityServiceState); } else { SECURITY_SERVICE.disassociate();
private void checkAuthorization(final Method callMethod, final InterfaceType interfaceType) throws ApplicationException { final boolean authorized = securityService.isCallerAuthorized(callMethod, interfaceType); if (!authorized) { throw new ApplicationException(new EJBAccessException("Unauthorized Access by Principal Denied")); } }
private void logout() { try { SecurityService securityService = SystemInstance.get().getComponent(SecurityService.class); if (clientIdentity != null) { logger.info("Logging out"); securityService.logout(clientIdentity); ClientSecurity.setIdentity(null); } } catch (LoginException e) { throw new RuntimeException("User could not be logged out.", e); } }
@Override public void processResponse(final Response response, final ObjectOutputStream out, final ProtocolMetaData metaData) throws Exception { if (EJBResponse.class.isInstance(response)) { final EJBResponse res = (EJBResponse) response; try { res.setMetaData(metaData); res.writeExternal(out); } catch (final Throwable t) { if (logger.isDebugEnabled()) { logger.debug("Failed to write EjbResponse", t); } else if (logger.isInfoEnabled()) { logger.info("Failed to write EjbResponse - Debug for stacktrace: " + t); } } finally { try { SystemInstance.get().getComponent(SecurityService.class).disassociate(); } catch (final Throwable t) { logger.warning("Failed to disassociate security", t); } final CallContext call = CallContext.getCallContext(); if (null != call) { call.reset(); } EJBHomeProxyHandle.resolver.set(null); EJBObjectProxyHandle.resolver.set(null); } } else { logger.error("EjbRequestHandler cannot process an instance of: " + response.getClass().getName()); } }
final Object clientIdentity = req.getClientIdentity(); if (clientIdentity != null) {//noinspection unchecked securityService.associate(clientIdentity); securityService.disassociate(); 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); try { securityService.logout(securityToken); } catch (final LoginException e) {