protected Serializable fieldValueForWrite(Object value, Column column) { ColumnSpec spec = column.getType().spec; if (value instanceof String) { if (spec == ColumnSpec.LONG || spec == ColumnSpec.AUTOINC) { // allow storing string into integer/long key return Long.valueOf((String) value); } if (column.getKey().equals(getPasswordField())) { // hash password if not already hashed String password = (String) value; if (!PasswordHelper.isHashed(password)) { password = PasswordHelper.hashPassword(password, passwordHashAlgorithm); } return password; } } else if (value instanceof Number) { if (spec == ColumnSpec.LONG || spec == ColumnSpec.AUTOINC) { // canonicalize to Long if (value instanceof Integer) { return Long.valueOf(((Integer) value).longValue()); } } else if (spec == ColumnSpec.STRING) { // allow storing number in string field return value.toString(); } } return (Serializable) value; }
@Override public boolean authenticate(String username, String password) { String storedPassword = getPassword(username); return PasswordHelper.verifyPassword(password, storedPassword); }
Serializable value = prop.getValue(); if (fieldName.equals(passwordFieldName)) { value = PasswordHelper.hashPassword((String) value, passwordHashAlgorithm);
attr.add(PasswordHelper.hashPassword((String) value, passwordHashAlgorithm)); attrs.put(attr); } else {
if (password != null && !PasswordHelper.isHashed(password)) { password = PasswordHelper.hashPassword(password, passwordHashAlgorithm); bson.append(getPrefixedPasswordField(), password);
attr = new BasicAttribute(backendFieldId); String password = (String) fieldMap.get(fieldId); password = PasswordHelper.hashPassword(password, passwordHashAlgorithm); attr.add(password); attrs.put(attr);
@Override public boolean authenticate(String username, String password) { Document user = getCollection().find(MongoDBSerializationHelper.fieldMapToBson(getPrefixedIdField(), username)) .first(); if (user == null) { return false; } String storedPassword = user.getString(getPrefixedPasswordField()); if (isMultiTenant()) { // check that the entry is from the current tenant, or no tenant at all if(!checkEntryTenantId(user.getString(TENANT_ID_FIELD))) { storedPassword = null; } } return PasswordHelper.verifyPassword(password, storedPassword); }