Refine search
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler(); Constraint constraint = new Constraint(); constraint.setName("auth"); mapping.setPathSpec( "/*" ); mapping.setConstraint( constraint ); securityHandler.setConstraintMappings(Collections.singletonList(mapping)); securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setLoginService(loginService);
String password = credentials.substring(i+1); UserIdentity user = login (username, password, request); if (user!=null) return new UserAuthentication(getAuthMethod(),user);
public static void addBasicAuthHandler(Server server, Handler handler) { addAuthHandler(server, Constraint.__BASIC_AUTH, new BasicAuthenticator(), handler); }
@Override public UserIdentity login(String username, Object password, ServletRequest request) { UserIdentity user = super.login(username,password,request); if (user!=null) { HttpSession session = ((HttpServletRequest)request).getSession(true); Authentication cached=new SessionAuthentication(getAuthMethod(),user,password); session.setAttribute(SessionAuthentication.__J_AUTHENTICATED, cached); } return user; }
@Override public Authenticator getAuthenticator(Server server, ServletContext context, AuthConfiguration configuration, IdentityService identityService, LoginService loginService) { String auth=configuration.getAuthMethod(); Authenticator authenticator=null; if (auth==null || Constraint.__BASIC_AUTH.equalsIgnoreCase(auth)) authenticator=new BasicAuthenticator(); else if (Constraint.__DIGEST_AUTH.equalsIgnoreCase(auth)) authenticator=new DigestAuthenticator(); else if (Constraint.__FORM_AUTH.equalsIgnoreCase(auth)) authenticator=new FormAuthenticator(); else if ( Constraint.__SPNEGO_AUTH.equalsIgnoreCase(auth) ) authenticator = new SpnegoAuthenticator(); else if ( Constraint.__NEGOTIATE_AUTH.equalsIgnoreCase(auth) ) // see Bug #377076 authenticator = new SpnegoAuthenticator(Constraint.__NEGOTIATE_AUTH); if (Constraint.__CERT_AUTH.equalsIgnoreCase(auth)||Constraint.__CERT_AUTH2.equalsIgnoreCase(auth)) authenticator=new ClientCertAuthenticator(); return authenticator; }
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler(); mapping.setConstraint(constraint); securityHandler.addConstraintMapping(mapping); securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setLoginService(loginService);
@Override protected Authenticator getHandlerAuthenticator() { return new BasicAuthenticator(); }
String password = credentials.substring(i+1); UserIdentity user = login (username, password, request); if (user!=null) return new UserAuthentication(getAuthMethod(),user);
cm.setPathSpec("/*"); ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); csh.setAuthenticator(new BasicAuthenticator()); csh.setRealmName("myrealm"); csh.addConstraintMapping(healthcheckConstraintMapping); csh.addConstraintMapping(cm);
@Override protected Authenticator getHandlerAuthenticator() { return new BasicAuthenticator(); }
String password = credentials.substring(i+1); UserIdentity user = login (username, password, request); if (user!=null) return new UserAuthentication(getAuthMethod(),user);
ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler(); mapping.setConstraint(constraint); securityHandler.addConstraintMapping(mapping); securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setLoginService(loginService);
@Override public Authenticator getAuthenticator() { return new BasicAuthenticator(); }
String password = credentials.substring(i+1); UserIdentity user = login (username, password, request); if (user!=null) return new UserAuthentication(getAuthMethod(),user);
private SecurityHandler getSecurityHandler(String pUser, String pPassword, String pRole) { HashLoginService loginService = getLoginService(pUser, pPassword, pRole); server.addBean(loginService); ConstraintSecurityHandler securityHandler = new ConstraintSecurityHandler(); securityHandler.setConstraintMappings(getConstraintMappings(pRole)); securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.addBean(loginService); return securityHandler; }
environment.jersey().register(new BasicAuthProvider<Subject>(new BasicAuthenticator(), "MyAuth"));
String password = credentials.substring(i+1); UserIdentity user = login (username, password, request); if (user!=null) return new UserAuthentication(getAuthMethod(),user);
@Override public void customize(Server server) { LOG.debug("Customizing server to allow requests for {}", USER_AUTHORIZED); HashLoginService login = new HashLoginService(); login.putUser(USER_AUTHORIZED, Credential.getCredential(USER_PW), new String[] {"users"}); login.setName("users"); Constraint constraint = new Constraint(); constraint.setName(Constraint.__BASIC_AUTH); constraint.setRoles(new String[]{"users"}); constraint.setAuthenticate(true); ConstraintMapping cm = new ConstraintMapping(); cm.setConstraint(constraint); cm.setPathSpec("/*"); ConstraintSecurityHandler security = new ConstraintSecurityHandler(); security.setAuthenticator(new BasicAuthenticator()); security.setRealmName("users"); security.addConstraintMapping(cm); security.setLoginService(login); // chain the PQS handler to security security.setHandler(server.getHandlers()[0]); server.setHandler(security); } }
private BasicAuthenticator() { // TODO Auto-generated constructor stub } public static BasicAuthenticator THIS = new BasicAuthenticator(); public static Authenticator getAutheticator(){ return THIS; } final static String USERNAME = ""; final static String PASSWORD = ""; @Override public PasswordAuthentication getPasswordAuthentication() { return new PasswordAuthentication(USERNAME, PASSWORD.toCharArray()); }
String password = credentials.substring(i+1); UserIdentity user = login (username, password, request); if (user!=null) return new UserAuthentication(getAuthMethod(),user);