Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update idmconsole/src/main/java/org/jboss/seam/security/examples/idmcons... #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class UserAction implements Serializable {
private static final long serialVersionUID = 5820385095080724087L;

private static final String ATTRIBUTE_NAME_USER_ENABLED = "USER_ENABLED";

public static final String ATTRIBUTE_NAME_FIRST_NAME = "FIRST_NAME";
public static final String ATTRIBUTE_NAME_LAST_NAME = "LAST_NAME";



private String firstname;
private String lastname;
Expand Down Expand Up @@ -77,6 +82,11 @@ public void editUser(String username) throws IdentityException, FeatureNotSuppor

Attribute enabledAttr = identitySession.getAttributesManager().getAttribute(username,
ATTRIBUTE_NAME_USER_ENABLED);

Attribute firstNameAttr = identitySession.getAttributesManager().getAttribute(username, ATTRIBUTE_NAME_FIRST_NAME);

Attribute lastNameAttr = identitySession.getAttributesManager().getAttribute(username, ATTRIBUTE_NAME_LAST_NAME);


if (enabledAttr != null) {
Object value = enabledAttr.getValue();
Expand All @@ -94,6 +104,41 @@ public void editUser(String username) throws IdentityException, FeatureNotSuppor
}


if (firstNameAttr != null) {
Object value = firstNameAttr.getValue();
if (value != null) {
if (String.class.isAssignableFrom(value.getClass())) {
firstname = (String) firstNameAttr.getValue();
} else {
firstname = String.valueOf((String) value);
}
} else {
firstname = "";
}
} else {
firstname = "";
}

if (lastNameAttr != null) {
Object value = lastNameAttr.getValue();
if (value != null) {
if (String.class.isAssignableFrom(value.getClass())) {
lastname = (String) lastNameAttr.getValue();
} else {
lastname = String.valueOf((String) value);
}
} else {
lastname = "";
}
} else {
lastname = "";
}

newUserFlag = false;

}


newUserFlag = false;
}

Expand Down Expand Up @@ -140,6 +185,11 @@ private String saveNewUser() throws IdentityException, FeatureNotSupportedExcept
User user = identitySession.getPersistenceManager().createUser(username);
identitySession.getAttributesManager().updatePassword(user, password);

identitySession.getAttributesManager().updateAttributes(user, new Attribute[] {
new SimpleAttribute(ATTRIBUTE_NAME_FIRST_NAME, firstname),
new SimpleAttribute(ATTRIBUTE_NAME_LAST_NAME, lastname)
});

for (Role role : roles) {
identitySession.getRoleManager().createRole(role.getRoleType(), user, role.getGroup());
}
Expand Down