--- /dev/null
+package org.argeo.security.jcr;
+
+import org.springframework.security.GrantedAuthority;
+import org.springframework.security.userdetails.User;
+
+public class JcrUserDetails extends User {
+ private static final long serialVersionUID = -3594542993773402380L;
+ private final String homePath;
+
+ public JcrUserDetails(String homePath, String username, String password,
+ boolean enabled, boolean accountNonExpired,
+ boolean credentialsNonExpired, boolean accountNonLocked,
+ GrantedAuthority[] authorities) throws IllegalArgumentException {
+ super(username, password, enabled, accountNonExpired,
+ credentialsNonExpired, accountNonLocked, authorities);
+ this.homePath = homePath;
+ }
+
+ public String getHomePath() {
+ return homePath;
+ }
+
+}
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.argeo.commons.security</groupId>
<version>0.2.3-SNAPSHOT</version>
</dependency>
+ <!-- JCR -->
+ <dependency>
+ <groupId>org.argeo.dep.osgi</groupId>
+ <artifactId>org.argeo.dep.osgi.jcr</artifactId>
+ </dependency>
+
<!-- Spring -->
<dependency>
<groupId>org.argeo.dep.osgi</groupId>
--- /dev/null
+package org.argeo.security.ldap.jcr;
+
+import javax.jcr.Session;
+
+import org.springframework.ldap.core.DirContextAdapter;
+import org.springframework.ldap.core.DirContextOperations;
+import org.springframework.security.GrantedAuthority;
+import org.springframework.security.userdetails.UserDetails;
+import org.springframework.security.userdetails.ldap.UserDetailsContextMapper;
+
+public class JcrUserDetailsContextMapper implements UserDetailsContextMapper {
+ private Session session;
+
+ public UserDetails mapUserFromContext(DirContextOperations ctx,
+ String username, GrantedAuthority[] authority) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void mapUserToContext(UserDetails user, DirContextAdapter ctx) {
+ // TODO Auto-generated method stub
+
+ }
+
+}
return name.replace(':', '_');
}
+ /** Cleanly disposes a {@link Binary} even if it is null. */
public static void closeQuietly(Binary binary) {
if (binary == null)
return;
binary.dispose();
}
+
+ /**
+ * Creates depth from a string (typically a username) by adding levels based
+ * on its first characters: "aBcD",2 => a/aB
+ */
+ public static String firstCharsToPath(String str, Integer nbrOfChars) {
+ if (str.length() < nbrOfChars)
+ throw new ArgeoException("String " + str
+ + " length must be greater or equal than " + nbrOfChars);
+ StringBuffer path = new StringBuffer("");
+ StringBuffer curr = new StringBuffer("");
+ for (int i = 0; i < nbrOfChars; i++) {
+ curr.append(str.charAt(i));
+ path.append(curr);
+ if (i < nbrOfChars - 1)
+ path.append('/');
+ }
+ return path.toString();
+ }
}