Modifying user attributes
Ensure that you fetch the user before you modify the user attributes.
// Fetch the user
String userId = “testuser”;
RgyUser rgyUser = null;
try {
rgyUser = rgyRegistry.getUser(“Default”, userId);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}
// Ensure the user was found
if (rgyUser == null) {
System.out.println(“Group does not exist”);
System.exit(1);
}
// Set the password-valid
try {
rgyUser.attributeReplace(RgyAttributes.SEC_PWD_VALID_NAME,
RgyAttributes.BOOL_TRUE_VALUE);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}
// Unset the max-login-failures policy
try {
rgyUser.attributeDelete(RgyAttributes. MAX_LOGIN_FAILURES_NAME);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}
// Set the min-password-length policy to 7
try {
rgyUser.attributeReplace(RgyAttributes.MIN_PASSWORD_LENGTH_NAME, “7”);
}
catch (RgyException e) {
e.printStackTrace();
System.exit(1);
}