Refine search
public Object mapFromAttributes(Attributes attributes) throws NamingException { Attribute roleAttr = attributes.get(groupRoleAttributeName); NamingEnumeration<?> ne = roleAttr.getAll(); // assert ne.hasMore(); Object group = ne.next(); String role = group.toString(); return new SimpleGrantedAuthority(rolePrefix + role.toUpperCase()); } };
private String extractString( Attribute attr ) throws Exception { StringBuilder attrStr = new StringBuilder(); for ( NamingEnumeration<?> eattr = attr.getAll(); eattr.hasMore(); ) { if ( attrStr.length() > 0 ) { attrStr.append( data.multi_valuedFieldSeparator ); } attrStr.append( eattr.next().toString() ); } return attrStr.toString(); }
public Object encodeAttributeValue(Attribute attribute) { List<Object> values = new ArrayList<Object>(); try { NamingEnumeration<?> enumeration = attribute.getAll(); while(enumeration.hasMore()) { values.add(enumeration.nextElement()); } } catch (NamingException ne) { System.err.println(ne); ne.printStackTrace(); } return values; }
private List<String> addAttributeValues(String attrId, Attributes attrs, List<String> values) throws NamingException { if (attrId == null || attrs == null) { return values; } if (values == null) { values = new ArrayList<String>(); } Attribute attr = attrs.get(attrId); if (attr == null) { return values; } NamingEnumeration<?> e = attr.getAll(); while (e.hasMore()) { String value = (String)e.next(); values.add(value); } return values; }
Attributes attrs = ctx.getAttributes(lookup, new String[] {"PTR"}); for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements();) { Attribute attr = (Attribute) ae.next(); for (Enumeration vals = attr.getAll(); vals.hasMoreElements();) { Object elem = vals.nextElement(); if ("PTR".equals(attr.getID()) && elem != null) {
public Object mapFromAttributes(Attributes attributes) throws NamingException { Attribute roleAttr = attributes.get(groupRoleAttributeName); NamingEnumeration<?> ne = roleAttr.getAll(); // assert ne.hasMore(); Object group = ne.next(); String role = group.toString(); return new SimpleGrantedAuthority(rolePrefix + role.toUpperCase()); } };
protected Set<String> addAttributeValues(String attrId, Attributes attrs, Set<String> values) throws NamingException { if (attrId == null || attrs == null) { return values; } if (values == null) { values = new HashSet<String>(); } Attribute attr = attrs.get(attrId); if (attr == null) { return values; } NamingEnumeration<?> e = attr.getAll(); while (e.hasMore()) { String value = (String)e.next(); values.add(value); } return values; }
while (answer.hasMoreElements()) { Attributes attributes = ((SearchResult) answer.next()).getAttributes(); String groupName = (String) attributes.get(manager.getGroupNameField()).get(); String description = ""; NamingEnumeration ne = memberField.getAll(); while (ne.hasMore()) { ne.next(); elements = elements + 1;
public Object mapFromAttributes(Attributes attributes) throws NamingException { Attribute roleAttr = attributes.get(groupRoleAttributeName); NamingEnumeration<?> ne = roleAttr.getAll(); // assert ne.hasMore(); Object group = ne.next(); String role = group.toString(); return new GrantedAuthorityImpl(rolePrefix + role.toUpperCase()); } };
/** * Look into A-record at a specific DNS address. * * @return resolved IP addresses or null if no A-record was present */ @Nullable public static List<String> resolveARecord(String rootDomainName) { if (isLocalOrIp(rootDomainName)) { return null; } try { Attributes attrs = getDirContext().getAttributes(rootDomainName, new String[]{A_RECORD_TYPE, CNAME_RECORD_TYPE}); Attribute aRecord = attrs.get(A_RECORD_TYPE); Attribute cRecord = attrs.get(CNAME_RECORD_TYPE); if (aRecord != null && cRecord == null) { List<String> result = new ArrayList<>(); NamingEnumeration<String> entries = (NamingEnumeration<String>) aRecord.getAll(); while (entries.hasMore()) { result.add(entries.next()); } return result; } } catch (Exception e) { logger.warn("Cannot load A-record for eureka server address {}", rootDomainName, e); return null; } return null; }
private static void printAttrs(Attributes attrs) throws NamingException { NamingEnumeration<? extends Attribute> attrsEnum = attrs.getAll(); while (attrsEnum.hasMore()) { Attribute currentAttr = attrsEnum.next(); outstream.print(String.format("%1$s:", currentAttr.getID())); NamingEnumeration<?> valuesEnum = currentAttr.getAll(); while (valuesEnum.hasMoreElements()) { outstream.print(String.format("%1$s ", valuesEnum.nextElement().toString())); } outstream.println(); } }
private String lookupPtrRecord(String reversedDomain) throws Exception { Attributes attrs = ctx.getAttributes(reversedDomain, new String[] {"PTR"}); for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements(); ) { Attribute attr = (Attribute) ae.next(); for (Enumeration<?> vals = attr.getAll(); vals.hasMoreElements(); ) return vals.nextElement().toString(); } return null; }
/** * Helper method used to retrieve all attribute values from a particular context attribute. * * @param attr the LDAP attribute. * @return the values of the attribute. * @throws javax.naming.NamingException if there is an LDAP error while reading the values. */ public static Collection<String> getAllAttributeValues(Attribute attr) throws NamingException { Set<String> values = new HashSet<String>(); NamingEnumeration ne = null; try { ne = attr.getAll(); while (ne.hasMore()) { String value = (String) ne.next(); values.add(value); } } finally { closeEnumeration(ne); } return values; }
private static void printAttrs(Attributes attrs) throws NamingException { NamingEnumeration<? extends Attribute> attrsEnum = attrs.getAll(); while (attrsEnum.hasMore()) { Attribute currentAttr = attrsEnum.next(); outstream.print(String.format("%1$s:", currentAttr.getID())); NamingEnumeration<?> valuesEnum = currentAttr.getAll(); while (valuesEnum.hasMoreElements()) { outstream.print(String.format("%1$s ", valuesEnum.nextElement().toString())); } outstream.println(); } }
private String lookupPtrRecord(String reversedDomain) throws Exception { Attributes attrs = ctx.getAttributes(reversedDomain, new String[]{"PTR"}); for (NamingEnumeration ae = attrs.getAll(); ae.hasMoreElements(); ) { Attribute attr = (Attribute) ae.next(); for (Enumeration<?> vals = attr.getAll(); vals.hasMoreElements(); ) return vals.nextElement().toString(); } return null; }
@Override public boolean process(SearchResult record) throws NamingException { result.add(record.getNameInNamespace()); NamingEnumeration<? extends Attribute> allAttributes = record.getAttributes().getAll(); while(allAttributes.hasMore()) { Attribute attribute = allAttributes.next(); addAllAttributeValuesToResult(attribute.getAll()); } return true; }