private String getPassword(DirContextOperations user) { Object passwordAttrValue = user.getObjectAttribute(this.passwordAttributeName); if (passwordAttrValue == null) { return null; } if (passwordAttrValue instanceof byte[]) { return new String((byte[]) passwordAttrValue); } return String.valueOf(passwordAttrValue); }
.getObjectAttribute("ldapContext"); if (ldapContext != null) { ldapAuth.setContext(ldapContext);
@Override public UserDetails mapUserFromContext(DirContextOperations ctx, String username, Collection<? extends GrantedAuthority> authorities) { String email = (String) ctx.getObjectAttribute("mail"); String firstName = (String) ctx.getObjectAttribute("givenName"); String lastName = (String) ctx.getObjectAttribute("sn"); BroadleafExternalAuthenticationUserDetails details = new BroadleafExternalAuthenticationUserDetails(username, "", authorities); details.setEmail(email); details.setFirstName(firstName); details.setLastName(lastName); details.setSite(determineSite(ctx, username, authorities)); return provisioningService.provisionAdminUser(details); }
String email = (String)ctx.getObjectAttribute("mail"); UserDetails userDetails = null; if (useEmailAddressAsUsername) { broadleafUser.setFirstName((String)ctx.getObjectAttribute("givenName")); broadleafUser.setLastName((String)ctx.getObjectAttribute("sn")); broadleafUser.setEmail(email);
essence.setDn(dn); Object passwordValue = ctx.getObjectAttribute(this.passwordAttributeName); .getObjectAttribute(PasswordPolicyControl.OID);
public Essence(DirContextOperations ctx) { super(ctx); setCn(ctx.getStringAttributes("cn")); setGivenName(ctx.getStringAttribute("givenName")); setSn(ctx.getStringAttribute("sn")); setDescription(ctx.getStringAttribute("description")); setTelephoneNumber(ctx.getStringAttribute("telephoneNumber")); Object passo = ctx.getObjectAttribute("userPassword"); if (passo != null) { String password = LdapUtils.convertPasswordToString(passo); setPassword(password); } }
private String getPassword(DirContextOperations user) { Object passwordAttrValue = user.getObjectAttribute(this.passwordAttributeName); if (passwordAttrValue == null) { return null; } if (passwordAttrValue instanceof byte[]) { return new String((byte[]) passwordAttrValue); } return String.valueOf(passwordAttrValue); }
@Override public String doMapFromContext(final DirContextOperations context) { // Get the password return new String( ObjectUtils.defaultIfNull((byte[]) context.getObjectAttribute(PASSWORD_ATTRIBUTE), new byte[0]), StandardCharsets.UTF_8); } }).stream().findFirst().orElse(null);
@Override public void executeWithContext( DirContext ctx, LdapEntryIdentification ldapEntryIdentification) { DirContextOperations obj = (DirContextOperations) LDAPUtils.getLdapTemplateInContext(ctx, template) .lookup(user); String name = obj.getObjectAttribute(userNameAttribute).toString(); Matcher m = userNamePattern.matcher(name); if (m.matches()) { name = m.group(1); } userName.set(name); } });
/** * Since the InitialLdapContext that's stored as a property of an LdapAuthenticationToken is transient (because it * isn't Serializable), we need some way to recreate the InitialLdapContext if it's null (e.g., if the * LdapAuthenticationToken has been serialized and deserialized). This is that mechanism. * * @param authenticator the LdapAuthenticator instance from your application's context * @param auth the LdapAuthenticationToken in which to recreate the InitialLdapContext * @return The reconstructed InitialLdapContext */ static public InitialLdapContext recreateLdapContext(LdapAuthenticator authenticator, LdapAuthenticationToken auth) { DirContextOperations authAdapter = authenticator.authenticate(auth); InitialLdapContext context = (InitialLdapContext) authAdapter.getObjectAttribute("ldapContext"); auth.setContext(context); return context; }
public Authentication authenticate(Authentication auth) { // Authenticate, using the passed-in credentials. DirContextOperations authAdapter = authenticator.authenticate(auth); // Creating an LdapAuthenticationToken (rather than using the existing Authentication // object) allows us to add the already-created LDAP context for our application to use later. // Needs a dummy role in order to initially authenticate, empty "" isn't allowed LdapAuthenticationToken ldapAuth = new LdapAuthenticationToken(auth, DUMMY_ROLE); // Get the user from the Ikasan internal data store & add their authorities to the token User user = this.userService.loadUserByUsername(auth.getPrincipal().toString()); ldapAuth.addAuthorities(user.getAuthorities()); InitialLdapContext ldapContext = (InitialLdapContext) authAdapter.getObjectAttribute("ldapContext"); if (ldapContext != null) { ldapAuth.setContext(ldapContext); } return ldapAuth; }
@Override public UserOrg doMapFromContext(final DirContextOperations context) { final UserOrg user = new UserOrg(); user.setDn(context.getDn().toString()); user.setLastName(context.getStringAttribute(SN_ATTRIBUTE)); user.setFirstName(context.getStringAttribute(GIVEN_NAME_ATTRIBUTE)); user.setSecured(context.getObjectAttribute(PASSWORD_ATTRIBUTE) != null); user.setId(Normalizer.normalize(context.getStringAttribute(uidAttribute))); // Special and also optional attributes Optional.ofNullable(departmentAttribute).ifPresent(a -> user.setDepartment(context.getStringAttribute(a))); Optional.ofNullable(localIdAttribute).ifPresent(a -> user.setLocalId(context.getStringAttribute(a))); Optional.ofNullable(lockedAttribute).ifPresent(a -> fillLockedData(user, context.getStringAttribute(a))); // Save the normalized CN of the company user.setCompany(toCompany(user.getDn())); if (context.attributeExists(PWD_ACCOUNT_LOCKED_ATTRIBUTE)) { user.setLockedBy(PPOLICY_NAME); user.setLocked(parseLdapDate(context.getStringAttribute(PWD_ACCOUNT_LOCKED_ATTRIBUTE))); } // Save the mails user.setMails( new ArrayList<>(CollectionUtils.emptyIfNull(context.getAttributeSortedStringSet(MAIL_ATTRIBUTE)))); return user; }
essence.setDn(dn); Object passwordValue = ctx.getObjectAttribute(this.passwordAttributeName); .getObjectAttribute(PasswordPolicyControl.OID);
essence.setDn(dn); Object passwordValue = ctx.getObjectAttribute(passwordAttributeName); PasswordPolicyResponseControl ppolicy = (PasswordPolicyResponseControl) ctx.getObjectAttribute(PasswordPolicyControl.OID);
public Essence(DirContextOperations ctx) { super(ctx); setCn(ctx.getStringAttributes("cn")); setSn(ctx.getStringAttribute("sn")); setDescription(ctx.getStringAttribute("description")); setTelephoneNumber(ctx.getStringAttribute("telephoneNumber")); Object passo = ctx.getObjectAttribute("userPassword"); if(passo != null) { String password = LdapUtils.convertPasswordToString(passo); setPassword(password); } }
public Essence(DirContextOperations ctx) { super(ctx); setCn(ctx.getStringAttributes("cn")); setGivenName(ctx.getStringAttribute("givenName")); setSn(ctx.getStringAttribute("sn")); setDescription(ctx.getStringAttribute("description")); setTelephoneNumber(ctx.getStringAttribute("telephoneNumber")); Object passo = ctx.getObjectAttribute("userPassword"); if (passo != null) { String password = LdapUtils.convertPasswordToString(passo); setPassword(password); } }