@Override public Collection<GrantedAuthority> getGrantedAuthorities(DirContextOperations user, String username) { if (MEMBER_OF.equals(getGroupSearchBase())) { String[] memberOfs = user.getStringAttributes(MEMBER_OF); if (memberOfs==null || memberOfs.length==0) { return EMPTY_LIST; } else { return Arrays.stream(memberOfs).map(s -> new LdapAuthority(s,s)).collect(Collectors.toList()); } } else { return super.getGrantedAuthorities(user, username); } }
/** * Creates the user authority list from the values of the {@code memberOf} attribute * obtained from the user's Active Directory entry. */ @Override protected Collection<? extends GrantedAuthority> loadUserAuthorities( DirContextOperations userData, String username, String password) { String[] groups = userData.getStringAttributes("memberOf"); if (groups == null) { logger.debug("No values for 'memberOf' attribute."); return AuthorityUtils.NO_AUTHORITIES; } if (logger.isDebugEnabled()) { logger.debug("'memberOf' attribute values: " + Arrays.asList(groups)); } ArrayList<GrantedAuthority> authorities = new ArrayList<>( groups.length); for (String group : groups) { authorities.add(new SimpleGrantedAuthority(new DistinguishedName(group) .removeLast().getValue())); } return authorities; }
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); } }
String[] rolesForAttribute = ctx.getStringAttributes(this.roleAttributes[i]);
/** * Creates the user authority list from the values of the {@code memberOf} attribute * obtained from the user's Active Directory entry. */ @Override protected Collection<? extends GrantedAuthority> loadUserAuthorities( DirContextOperations userData, String username, String password) { String[] groups = userData.getStringAttributes("memberOf"); if (groups == null) { logger.debug("No values for 'memberOf' attribute."); return AuthorityUtils.NO_AUTHORITIES; } if (logger.isDebugEnabled()) { logger.debug("'memberOf' attribute values: " + Arrays.asList(groups)); } ArrayList<GrantedAuthority> authorities = new ArrayList<>( groups.length); for (String group : groups) { authorities.add(new SimpleGrantedAuthority(new DistinguishedName(group) .removeLast().getValue())); } return authorities; }
String[] groups = ctx.getStringAttributes(groupAttribute); if (groups != null && groups.length > 0) { return Arrays.stream(groups)
public LdapUser mapFromContext(DirContextOperations ctx) throws NamingException, UnsupportedMemberAffiliationException { Optional.ofNullable(ctx.getStringAttribute(identifierAttribute)).orElseThrow(() -> new InvalidSecurityConfigurationException( "Can not get a username using '" + identifierAttribute + "' attribute to identify the user.")); String username = ctx.getStringAttribute(identifierAttribute); Optional<String> firstName = Optional.ofNullable(ctx.getStringAttribute(firstNameAttribute)); Optional<String> lastName = Optional.ofNullable(ctx.getStringAttribute(lastNameAttribute)); Optional<String> email = Optional.ofNullable(ctx.getStringAttribute(mailAddressAttribute)); if (StringUtils.hasText(memberOfFilter)) { String[] memberOf = ctx.getStringAttributes(MEMBER_OF_ATTRIBUTE); if (!Arrays.asList(memberOf).contains(memberOfFilter)) { throw new UnsupportedMemberAffiliationException("User '" + username + "' is not a member of '" + memberOfFilter + "'"); } return new LdapUser(username, firstName, lastName, email, memberOf); } return new LdapUser(username, firstName, lastName, email); } }
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); } }
String[] rolesForAttribute = ctx.getStringAttributes(roleAttributes[i]);
String[] rolesForAttribute = ctx.getStringAttributes(this.roleAttributes[i]);