X-Git-Url: https://git.argeo.org/?a=blobdiff_plain;f=security%2Fruntime%2Forg.argeo.security.core%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fsecurity%2Fjcr%2FJcrUserDetails.java;h=223c06de0d3dd44b4a108cc39c1b01a14fc495b3;hb=72c5c4c7e5348ad96a451ef866a1e231db976dc7;hp=05ae165e03fbcccd0d63be4679745b787742f567;hpb=4d665b0700136573b05879aa19897d8f448d8ca4;p=lgpl%2Fargeo-commons.git diff --git a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/JcrUserDetails.java b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/JcrUserDetails.java index 05ae165e0..223c06de0 100644 --- a/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/JcrUserDetails.java +++ b/security/runtime/org.argeo.security.core/src/main/java/org/argeo/security/jcr/JcrUserDetails.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import javax.jcr.Node; +import javax.jcr.Property; import javax.jcr.RepositoryException; import javax.jcr.Session; @@ -22,6 +23,9 @@ public class JcrUserDetails extends User implements ArgeoNames { private final String homePath; private final String securityWorkspace; + /** Human readable user name */ + private String displayName; + protected JcrUserDetails(String securityWorkspace, String homePath, String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, @@ -43,6 +47,15 @@ public class JcrUserDetails extends User implements ArgeoNames { userProfile.getProperty(ARGEO_CREDENTIALS_NON_EXPIRED) .getBoolean(), userProfile.getProperty( ARGEO_ACCOUNT_NON_LOCKED).getBoolean(), authorities); + // human readable name + if (userProfile.hasProperty(Property.JCR_TITLE)) { + displayName = userProfile.getProperty(Property.JCR_TITLE) + .getString(); + if (displayName.trim().equals("")) + displayName = null; + } + if (displayName == null) + displayName = userProfile.getProperty(ARGEO_USER_ID).getString(); // home is defined as the parent of the profile homePath = userProfile.getParent().getPath(); securityWorkspace = userProfile.getSession().getWorkspace().getName(); @@ -109,4 +122,15 @@ public class JcrUserDetails extends User implements ArgeoNames { public String getSecurityWorkspace() { return securityWorkspace; } + + /** The human readable name of this user */ + public String getDisplayName() { + return displayName; + } + + @Override + public String toString() { + return getDisplayName(); + } + }