import java.util.HashMap;
import java.util.Map;
import java.util.Random;
+import java.util.SortedSet;
import java.util.concurrent.Executor;
import javax.jcr.Node;
public UserDetails mapUserFromContext(final DirContextOperations ctx,
final String username, GrantedAuthority[] authorities) {
+ if (ctx == null)
+ throw new ArgeoException("No LDAP information found for user "
+ + username);
+
final StringBuffer userHomePathT = new StringBuffer("");
Runnable action = new Runnable() {
public void run() {
}
// password
- byte[] arr = (byte[]) ctx
- .getAttributeSortedStringSet(passwordAttribute).first();
+ SortedSet<?> passwordAttributes = ctx
+ .getAttributeSortedStringSet(passwordAttribute);
+ String password;
+ if (passwordAttributes == null || passwordAttributes.size() == 0) {
+ throw new ArgeoException("No password found for user " + username);
+ } else {
+ byte[] arr = (byte[]) passwordAttributes.first();
+ password = new String(arr);
+ // erase password
+ Arrays.fill(arr, (byte) 0);
+ }
JcrUserDetails userDetails = new JcrUserDetails(
- userHomePathT.toString(), username, new String(arr), true,
- true, true, true, authorities);
- // erase password
- Arrays.fill(arr, (byte) 0);
+ userHomePathT.toString(), username, password, true, true, true,
+ true, authorities);
return userDetails;
}
if (ldapAttribute.equals("description")) {
String value = userProfile.getProperty(jcrProperty).getString();
- if(value.trim().equals(""))
+ if (value.trim().equals(""))
return;
}