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 {
/** * Creates a new Password object. * * @param password the password string * @return the new Password object */ public Password newPassword(String password) { return new Password(password); }
return new Password(passwd);
public static void main(String[] arg) { if (arg.length != 1 && arg.length != 2) { System.err.println("Usage - java " + Password.class.getName() + " [<user>] <password>"); System.err.println("If the password is ?, the user will be prompted for the password"); System.exit(1); } String p = arg[arg.length == 1 ? 0 : 1]; Password pw = new Password(p); System.err.println(pw.toString()); System.err.println(obfuscate(pw.toString())); System.err.println(Credential.MD5.digest(p)); if (arg.length == 2) System.err.println(Credential.Crypt.crypt(arg[0], pw.toString())); } }
/** * Get a credential from a String. If the credential String starts with a known Credential type (eg "CRYPT:" or "MD5:" ) then a Credential of that type is * returned. Otherwise, it tries to find a credential provider whose prefix matches with the start of the credential String. Else the credential is assumed * to be a Password. * * @param credential * String representation of the credential * @return A Credential or Password instance. */ public static Credential getCredential(String credential) { if (credential.startsWith(Crypt.__TYPE)) return new Crypt(credential); if (credential.startsWith(MD5.__TYPE)) return new MD5(credential); for (CredentialProvider cp : CREDENTIAL_PROVIDER_LOADER) { if (credential.startsWith(cp.getPrefix())) { final Credential credentialObj = cp.getCredential(credential); if (credentialObj != null) { return credentialObj; } } } return new Password(credential); }
securityHandler.addConstraintMapping(constraintMapping); HashLoginService loginService = new HashLoginService(); loginService.putUser("username", new Password("password"), new String[] {"user"}); securityHandler.setLoginService(loginService);
// inside init() method boolean pass= Password.check(userInput); Password mess= new Password(); passwordLabel.setText(mess.getDisplay(pass)); // passing the boolean to the getDisplay method ... // getDisplay method. public String getDisplay(boolean result) { return result ? "The Password meets the requirements" : "Your password does not match the requirements"; }
/** * Creates a new Password object. * * @param password the password string * @return the new Password object */ public Password newPassword(String password) { return new Password(password); }
/** Make a {@link UserStore} for a single user,password,role*/ public static UserStore addUser(UserStore userStore, String user, String password, String role) { String[] roles = role == null ? null : new String[]{role}; Credential cred = new Password(password); userStore.addUser(user, cred, roles); return userStore; }
@Override protected void doStart() throws Exception { UserPrincipal p = new UserPrincipal(username, new Password(password)); users.put(username, p); super.doStart(); }
@Override protected void loadUsers() throws IOException { putUser(username, new Password(password), new String[] { role }); } };
public void actionPerformed(ActionEvent e) { String userInput = inputBox.getText(); boolean pass= Password.check(userInput); //String message = Password.display(null); Password mess= new Password(); passwordLabel.setText( mess.getDisplay()); }
/** Make a {@link UserStore} for a single user,password,role*/ public static UserStore addUser(UserStore userStore, String user, String password, String role) { String[] roles = role == null ? null : new String[]{role}; Credential cred = new Password(password); userStore.addUser(user, cred, roles); return userStore; }
protected boolean login(Subject clientSubject, String credentials, String authMethod, MessageInfo messageInfo) throws IOException, UnsupportedCallbackException { credentials = credentials.substring(credentials.indexOf(' ')+1); credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1); int i = credentials.indexOf(':'); String userName = credentials.substring(0,i); String password = credentials.substring(i+1); return login(clientSubject, userName, new Password(password), authMethod, messageInfo); }
protected boolean login(Subject clientSubject, String credentials, String authMethod, MessageInfo messageInfo) throws IOException, UnsupportedCallbackException { credentials = credentials.substring(credentials.indexOf(' ')+1); credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1); int i = credentials.indexOf(':'); String userName = credentials.substring(0,i); String password = credentials.substring(i+1); return login(clientSubject, userName, new Password(password), authMethod, messageInfo); }
protected boolean login(Subject clientSubject, String credentials, String authMethod, MessageInfo messageInfo) throws IOException, UnsupportedCallbackException { credentials = credentials.substring(credentials.indexOf(' ')+1); credentials = B64Code.decode(credentials,StringUtil.__ISO_8859_1); int i = credentials.indexOf(':'); String userName = credentials.substring(0,i); String password = credentials.substring(i+1); return login(clientSubject, userName, new Password(password), authMethod, messageInfo); }
private static void addUserPassword(PropertyUserStore propertyUserStore, String user, String password, String[] roles) { Credential cred = new Password(password); propertyUserStore.addUser(user, cred, 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); }
/** Very simple! */ private static UserStore makeUserStore(String user, String password, String role) { Credential cred = new Password(password); PropertyUserStore propertyUserStore = new PropertyUserStore(); String[] roles = role == null ? null : new String[]{role}; propertyUserStore.addUser(user, cred, roles); try { propertyUserStore.start(); } catch (Exception ex) { throw new FusekiException("UserStore", ex); } return propertyUserStore; }