Refine search
getInitParameter(name)==null) setInitParameter(name,context.getInitParameter(name)); setLoginService(findLoginService()); if (_loginService!=null) unmanage(_loginService); setIdentityService(_loginService.getIdentityService()); setIdentityService(findIdentityService()); setIdentityService(new DefaultIdentityService()); manage(_identityService); unmanage(_identityService); Authenticator.Factory authenticatorFactory = getAuthenticatorFactory(); if (_authenticator==null && authenticatorFactory!=null && _identityService!=null) setAuthenticator(authenticatorFactory.getAuthenticator(getServer(),ContextHandler.getCurrentContext(),this, _identityService, _loginService)); else if (_realmName!=null) LOG.warn("No Authenticator for "+this); throw new IllegalStateException("No Authenticator");
context.getSecurityHandler().setAuthMethod(method.toString(false, true)); context.getMetaData().setOrigin("auth-method", descriptor); break; context.getSecurityHandler().setAuthMethod(method.toString(false, true)); context.getMetaData().setOrigin("auth-method", descriptor); if (!context.getSecurityHandler().getAuthMethod().equals(method.toString(false, true))) throw new IllegalStateException("Conflicting auth-method value in "+descriptor.getResource()); break; context.getSecurityHandler().setRealmName(nameStr); context.getMetaData().setOrigin("realm-name", descriptor); break; context.getSecurityHandler().setRealmName(nameStr); context.getMetaData().setOrigin("realm-name", descriptor); if (!context.getSecurityHandler().getRealmName().equals(nameStr)) throw new IllegalStateException("Conflicting realm-name value in "+descriptor.getResource()); break; if (Constraint.__FORM_AUTH.equalsIgnoreCase(context.getSecurityHandler().getAuthMethod())) context.getSecurityHandler().setInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE,loginPageName); context.getMetaData().setOrigin("form-login-page",descriptor); break; context.getSecurityHandler().setInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE,loginPageName);
@Override public void logout() { SecurityHandler security=SecurityHandler.getCurrentSecurityHandler(); if (security!=null) security.logout(this); } }
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); SecurityHandler security=SecurityHandler.getCurrentSecurityHandler(); if (security==null) { if (LOG.isDebugEnabled()) LOG.debug("!SecurityHandler"); return; } LoginService login_service=security.getLoginService(); if (login_service==null) { if (LOG.isDebugEnabled()) LOG.debug("!LoginService"); return; } _userIdentity=login_service.login(_name,_credentials, null); LOG.debug("Deserialized and relogged in {}",this); }
public void logout(Authentication.User user) { LOG.debug("logout {}",user); LoginService login_service=getLoginService(); if (login_service!=null) { login_service.logout(user.getUserIdentity()); } IdentityService identity_service=getIdentityService(); if (identity_service!=null) { // TODO recover previous from threadlocal (or similar) Object previous=null; identity_service.disassociate(previous); } }
final Handler handler=getHandler(); if (checkSecurity(baseRequest)) authenticator.prepareRequest(baseRequest); RoleInfo roleInfo = prepareConstraintInfo(pathInContext, baseRequest); if (!checkUserDataPermissions(pathInContext, baseRequest, base_response, roleInfo)) isAuthMandatory(baseRequest, base_response, roleInfo); LOG.warn("No authenticator for: "+roleInfo); if (!baseRequest.isHandled()) boolean authorized=checkWebResourcePermissions(pathInContext, baseRequest, base_response, roleInfo, userAuth.getUserIdentity()); if (!authorized)
if (name.startsWith("org.eclipse.jetty.security.") && getInitParameter(name)==null) setInitParameter(name,context.getInitParameter(name)); _loginService=findLoginService(); if (_loginService!=null) _loginServiceShared=true; _identityService=_loginService.getIdentityService(); _identityService=findIdentityService(); if (_loginService.getIdentityService()==null) _loginService.setIdentityService(_identityService); else if (_loginService.getIdentityService()!=_identityService) throw new IllegalStateException("LoginService has different IdentityService to "+this); _authenticator=_authenticatorFactory.getAuthenticator(getServer(),ContextHandler.getCurrentContext(),this, _identityService, _loginService); if (_authenticator!=null) _authMethod=_authenticator.getAuthMethod(); LOG.warn("No ServerAuthentication for "+this); throw new IllegalStateException("No ServerAuthentication");
protected LoginService findLoginService() throws Exception { Collection<LoginService> list = getServer().getBeans(LoginService.class); LoginService service = null; String realm=getRealmName(); if (realm!=null) { for (LoginService s : list) if (s.getName()!=null && s.getName().equals(realm)) { service=s; break; } } else if (list.size()==1) service = list.iterator().next(); return service; }
/** * @param securityHandler The {@link SecurityHandler} to set on this context. */ public void setSecurityHandler(SecurityHandler securityHandler) { if (isStarted()) throw new IllegalStateException("STARTED"); Handler next=null; if (_securityHandler!=null) { next=_securityHandler.getHandler(); _securityHandler.setHandler(null); replaceHandler(_securityHandler,securityHandler); } _securityHandler = securityHandler; if (next!=null && _securityHandler.getHandler()==null) _securityHandler.setHandler(next); relinkHandlers(); }
private static Handler getSecuredHandler(final Handler handler, final String login, final String password) { final SecurityHandler securityHandler = new DummySecurityHandler(login); securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setIdentityService(new DefaultIdentityService()); securityHandler.setLoginService(new DummyLoginService(login, password)); securityHandler.setHandler(handler); return securityHandler; }
protected WebAppContext createContext() { final WebAppContext ctx = new WebAppContext(); ctx.setContextPath("/"); ctx.setWar(appBase); if(!Strings.isNullOrEmpty(webInfLocation)) { ctx.setDescriptor(webInfLocation); } // configure security to avoid err println "Null identity service, trying login service:" // but I've found no way to get rid of LoginService=xxx log on system err :( HashLoginService loginService = new HashLoginService(); loginService.setIdentityService(new DefaultIdentityService()); ctx.getSecurityHandler().setLoginService(loginService); ctx.getSecurityHandler().setIdentityService(loginService.getIdentityService()); ctx.addLifeCycleListener(new AbstractLifeCycle.AbstractLifeCycleListener() { @Override public void lifeCycleStarting(LifeCycle event) { ctx.getServletContext().setInitParameter("restx.baseServerUri", baseUrl()); ctx.getServletContext().setInitParameter("restx.serverId", getServerId()); } }); return ctx; }
/** * @param securityHandler The {@link SecurityHandler} to set on this context. */ public void setSecurityHandler(SecurityHandler securityHandler) { if (isStarted()) throw new IllegalStateException("STARTED"); if (_securityHandler!=null) _securityHandler.setHandler(null); _securityHandler = securityHandler; relinkHandlers(); }
@Override protected void doStop() throws Exception { super.doStop(); _constraintMap.clear(); }
/** * @see org.eclipse.jetty.security.SecurityHandler#doStart() */ @Override protected void doStart() throws Exception { _constraintMap.clear(); if (_constraintMappings!=null) { for (ConstraintMapping mapping : _constraintMappings) { processConstraintMapping(mapping); } } //Servlet Spec 3.1 pg 147 sec 13.8.4.2 log paths for which there are uncovered http methods checkPathsWithUncoveredHttpMethods(); super.doStart(); }
public void configureWebApplication() throws Exception { // Jetty tries to do this in WebAppContext.resolveWebApp but it failed to delete the directory. File t = webApp.getTempDirectory(); if (t==null) t = new File(getProject().getBuild().getDirectory(),"tmp"); File extractedWebAppDir= new File(t, "webapp"); if (isExtractedWebAppDirStale(extractedWebAppDir, webAppFile)) { FileUtils.deleteDirectory(extractedWebAppDir); } super.configureWebApplication(); getWebAppConfig().setWar(webAppFile.getCanonicalPath()); for (Artifact a : (Set<Artifact>) project.getArtifacts()) { if (a.getGroupId().equals("org.jenkins-ci.main") && a.getArtifactId().equals("jenkins-core")) { File coreBasedir = pluginWorkspaceMap.read(a.getId()); if (coreBasedir != null) { String extraCP = new File(coreBasedir, "src/main/resources").toURI() + "," + new File(coreBasedir, "target/classes").toURI(); getLog().info("Will load directly from " + extraCP); getWebAppConfig().setExtraClasspath(extraCP); } } } // cf. https://wiki.jenkins-ci.org/display/JENKINS/Jetty HashLoginService hashLoginService = (new HashLoginService("Jenkins Realm")); hashLoginService.setConfig(System.getProperty("jetty.home", "work") + "/etc/realm.properties"); getWebAppConfig().getSecurityHandler().setLoginService(hashLoginService); }
case Constraint.__FORM_AUTH: authenticator = new FormAuthenticator(); securityHandler.setInitParameter(FormAuthenticator.__FORM_LOGIN_PAGE, formLoginPage); securityHandler.setInitParameter(FormAuthenticator.__FORM_ERROR_PAGE, formErrorPage); break; case Constraint.__BASIC_AUTH: securityHandler.setAuthenticator(authenticator); securityHandler.setRealmName(realmName);
@Override public void sessionDestroyed(HttpSessionEvent se) { final HttpSession session = se.getSession(); if (session == null) { return; } final Object authCreds = session .getAttribute(SessionAuthentication.__J_AUTHENTICATED); if (authCreds != null) { final SessionAuthentication sessionAuth = (SessionAuthentication) authCreds; securityHandler.logout(sessionAuth); session.removeAttribute(SessionAuthentication.__J_AUTHENTICATED); } } });
private void readObject(ObjectInputStream stream) throws IOException, ClassNotFoundException { stream.defaultReadObject(); SecurityHandler security=SecurityHandler.getCurrentSecurityHandler(); if (security==null) throw new IllegalStateException("!SecurityHandler"); LoginService login_service=security.getLoginService(); if (login_service==null) throw new IllegalStateException("!LoginService"); _userIdentity=login_service.login(_name,_credentials); LOG.debug("Deserialized and relogged in {}",this); }
public void logout(Authentication.User user) { LOG.debug("logout {}",user); LoginService login_service=getLoginService(); if (login_service!=null) { login_service.logout(user.getUserIdentity()); } IdentityService identity_service=getIdentityService(); if (identity_service!=null) { // TODO recover previous from threadlocal (or similar) Object previous=null; identity_service.disassociate(previous); } }
final Handler handler=getHandler(); if (checkSecurity(baseRequest)) Object constraintInfo = prepareConstraintInfo(pathInContext, baseRequest); if (!checkUserDataPermissions(pathInContext, baseRequest, base_response, constraintInfo)) isAuthMandatory(baseRequest, base_response, constraintInfo); LOG.warn("No authenticator for: "+constraintInfo); if (!baseRequest.isHandled()) boolean authorized=checkWebResourcePermissions(pathInContext, baseRequest, base_response, constraintInfo, userAuth.getUserIdentity()); if (!authorized)