public static void addBasicAuthHandler(Server server, Handler handler) { addAuthHandler(server, Constraint.__BASIC_AUTH, new BasicAuthenticator(), handler); }
mapping.setConstraint( constraint ); securityHandler.setConstraintMappings(Collections.singletonList(mapping)); securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setLoginService(loginService);
securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setLoginService(loginService);
securityHandler.setAuthenticator(new BasicAuthenticator()); securityHandler.setLoginService(loginService);
csh.setAuthenticator(new BasicAuthenticator()); csh.setRealmName("myrealm"); csh.addConstraintMapping(healthcheckConstraintMapping);
@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; }
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; }
@Override protected Authenticator getHandlerAuthenticator() { return new BasicAuthenticator(); }
@Override protected Authenticator getHandlerAuthenticator() { return new BasicAuthenticator(); }
void configureAuthentication(Environment environment) { JdbcRealm realm = getJdbcRealm(); // However your Shiro realm is configured DefaultSecurityManager securityManager = new DefaultSecurityManager(realm); SecurityUtils.setSecurityManager(securityManager); environment.jersey().register(new BasicAuthProvider<Subject>(new BasicAuthenticator(), "Shiro")); }
@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); } }
public ServletContextHandler authBasic(ServletContextHandler ctx) { assertNotYetSetUp(); auth(ctx, new BasicAuthenticator()); return ctx; }
/** * Configure basic authentication. * * @param ctx * @param methods * @return servlet context handler */ public ServletContextHandler authBasic(ServletContextHandler ctx, String... methods) { assertNotYetSetUp(); auth(ctx, new BasicAuthenticator(), methods); return ctx; }
SecurityHandler sh = new SecurityHandler(); // the UserRealm is the collection of users, and a mechanism to determine if // provided credentials are valid sh.setUserRealm(new MyUserRealm()); // the Authenticator is a strategy for extracting authentication credentials // from the request. BasicAuthenticator uses HTTP Basic Auth sh.setAuthenticator(new BasicAuthenticator());
protected ConstraintSecurityHandler configureBasicAuthentication(Server server, AvaticaServerConfiguration config) { final String[] allowedRoles = config.getAllowedRoles(); final String realm = config.getHashLoginServiceRealm(); final String loginServiceProperties = config.getHashLoginServiceProperties(); HashLoginService loginService = new HashLoginService(realm, loginServiceProperties); server.addBean(loginService); return configureCommonAuthentication(Constraint.__BASIC_AUTH, allowedRoles, new BasicAuthenticator(), null, loginService); }
protected ConstraintSecurityHandler configureBasicAuthentication(Server server, AvaticaServerConfiguration config) { final String[] allowedRoles = config.getAllowedRoles(); final String realm = config.getHashLoginServiceRealm(); final String loginServiceProperties = config.getHashLoginServiceProperties(); HashLoginService loginService = new HashLoginService(realm, loginServiceProperties); server.addBean(loginService); return configureCommonAuthentication(Constraint.__BASIC_AUTH, allowedRoles, new BasicAuthenticator(), null, loginService); }
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; }
public static ConstraintSecurityHandler createSecurityHandler() { Constraint constraint = new Constraint("BASIC", "customer"); constraint.setAuthenticate(true); ConstraintMapping mapping = new ConstraintMapping(); mapping.setConstraint(constraint); mapping.setPathSpec("/*"); ConstraintSecurityHandler handler = new ConstraintSecurityHandler(); handler.addConstraintMapping(mapping); handler.setAuthenticator(new BasicAuthenticator()); handler.setLoginService(new HashLoginService("RiderAutoParts", "etc/rest-users.properties")); return handler; }
public static ConstraintSecurityHandler createSecurityHandler() { Constraint constraint = new Constraint("BASIC", "customer"); constraint.setAuthenticate(true); ConstraintMapping mapping = new ConstraintMapping(); mapping.setConstraint(constraint); mapping.setPathSpec("/*"); ConstraintSecurityHandler handler = new ConstraintSecurityHandler(); handler.addConstraintMapping(mapping); handler.setAuthenticator(new BasicAuthenticator()); handler.setLoginService(new HashLoginService("RiderAutoParts", "src/main/resources/users.properties")); return handler; }
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; }