@Override public synchronized UserIdentity putUser( String userName, Credential credential, String[] roles ) { List<String> newRoles = new ArrayList<String>(); newRoles.add( "default" ); Collections.addAll( newRoles, roles ); return super.putUser( userName, credential, newRoles.toArray( new String[newRoles.size()] ) ); } };
String webDir = EventHubHandler.class.getClassLoader().getResource("frontend").toExternalForm(); HashLoginService loginService = new HashLoginService(); loginService.putUser(properties.getProperty("eventhubhandler.username"), new Password(properties.getProperty("eventhubhandler.password")), new String[]{"user"});
if ( !Utils.isEmpty( slaveServer.getPassword() ) ) { hashLoginService = new HashLoginService( "Kettle" ); hashLoginService.putUser( slaveServer.getUsername(), new Password( slaveServer.getPassword() ), new String[] { "default" } ); } else {
private HashLoginService getLoginService(String pUser, String pPassword, String pRole) { Credential credential = Credential.getCredential(pPassword); HashLoginService loginService = new HashLoginService("jolokia Realm"); loginService.putUser(pUser, credential, new String[] {pRole}); return loginService; }
securityHandler.addConstraintMapping(constraintMapping); HashLoginService loginService = new HashLoginService(); loginService.putUser("username", new Password("password"), new String[] {"user"}); securityHandler.setLoginService(loginService);
public void addUser( final String user, final String password ) { loginService.putUser( user, new Password( password ), new String[] { "allowed" } ); }
public void addUser( final String user, final String password ) { loginService.putUser( user, new Password( password ), new String[] { "allowed" } ); }
@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 void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
public void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
public void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
public void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
@Override public void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
public void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
public void update(String userName, Credential credential, String[] roleArray) { if (LOG.isDebugEnabled()) LOG.debug("update: " + userName + " Roles: " + roleArray.length); putUser(userName,credential,roleArray); }
private HashLoginService getLoginService(String pUser, String pPassword, String pRole) { Credential credential = Credential.getCredential(pPassword); HashLoginService loginService = new HashLoginService("jolokia Realm"); loginService.putUser(pUser, credential, new String[] {pRole}); return loginService; }
public void addUser(String userName, Credential credential, String[] roles) { ((HashLoginService)context.getSecurityHandler().getLoginService()).putUser(userName, credential, roles); }
@Override public void addRealm(Realm realm) { HashLoginService loginService = new HashLoginService(); loginService.setName(realm.getName()); Collection<UserRole> users = realm.getUsers().values(); for (UserRole user : users) { String[] roles = user.getRoles().toArray(new String[0]); Password password = new Password(user.getPassword()); loginService.putUser(user.getUser(), password, roles); } server.addBean(loginService); }
@Override protected SecurityHandler createSecurityHandler() { HashLoginService l = new HashLoginService(); for (User user : Users.getUsers()) { String[] roles = user.getRolesAsArray(); if (user.getId().startsWith("admin")) roles = new String[] { "apiuser", "apiadmin"}; l.putUser(user.getId(), Credential.getCredential(user.getPassword()), roles); } l.setName("apimanrealm"); ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); csh.setAuthenticator(new BasicAuthenticator()); csh.setRealmName("apimanrealm"); csh.setLoginService(l); return csh; }
/** * Creates a basic auth security handler. */ protected SecurityHandler createSecurityHandler() throws Exception { HashLoginService l = new HashLoginService(); for (User user : Users.getUsers()) { l.putUser(user.getId(), Credential.getCredential(user.getPassword()), user.getRolesAsArray()); } l.setName("apimanrealm"); ConstraintSecurityHandler csh = new ConstraintSecurityHandler(); csh.setAuthenticator(new BasicAuthenticator()); csh.setRealmName("apimanrealm"); csh.setLoginService(l); return csh; }