final Entry e = it.next(); ldapEntry.setDn(e.getDn().getName()); ldapEntry.setBindPrincipal(e.getDn().getName()); for (Attribute attribute : e.getAttributes()) { if (activeDirectory && "userPrincipalName".equalsIgnoreCase(attribute.getId())) { ldapEntry.setBindPrincipal(attribute.getString()); if (attribute.isHumanReadable()) { ldapEntry.put(attribute.getId(), Joiner.on(", ").join(attribute.iterator())); if ("memberOf".equalsIgnoreCase(attribute.getId()) || "isMemberOf".equalsIgnoreCase(attribute.getId())) { for (Value<?> group : attribute) { groupDns.add(group.getString());
sb.append( " Entry : '" ).append( name.toString() ).append( "'\n" ); sb.append( " Attribute description : '" ).append( attrId ).append( "'\n" ); sb.append( " Attribute value : '" ); if ( attrVal.isHumanReadable() ) sb.append( attrVal.getValue() ); byte[] binVal = attrVal.getBytes(); sb.append( Strings.utf8ToString( binVal ) ).append( '/' ).append( Strings.dumpBytes( binVal ) ) .append( "'\n" );
for (Entry e : groupSearch) { if (LOG.isTraceEnabled()) { LOG.trace("Group Entry: {}", e.toString(" ")); if (! e.containsAttribute(groupIdAttribute)) { LOG.warn("Unknown group id attribute {}, skipping group entry {}", groupIdAttribute, e); continue; final String groupId = e.get(groupIdAttribute).getString(); if (ldapEntry == null) { LOG.trace("DN {} == {} member?", dn, member.getString()); if (dn != null && dn.equalsIgnoreCase(normalizedDn(member.getString()))) { groups.add(groupId); } else { if (!isNullOrEmpty(uid) && uid.equalsIgnoreCase(member.getString())) { LOG.trace("UID {} == {} member?", uid, member.getString()); groups.add(groupId);
/** * Anonymize an attribute using pure random values (either chars of bytes, depending on the Attribute type) */ @Override public Attribute anonymize( Map<Value, Value> valueMap, Set<Value> valueSet, Attribute attribute ) { Attribute result = new DefaultAttribute( attribute.getAttributeType() ); for ( Value value : attribute ) { byte[] bytesValue = value.getBytes(); byte[] newValue = computeNewValue( bytesValue ); try { result.add( newValue ); Value anonValue = new Value( attribute.getAttributeType(), newValue ); valueMap.put( ( Value ) value, anonValue ); valueSet.add( anonValue ); } catch ( LdapInvalidAttributeValueException e ) { throw new RuntimeException( I18n.err( I18n.ERR_13436_ERROR_ANONYMIZING_VALUE, value ) ); } } return result; }
public void move( MoveOperationContext moveContext, Entry entry, boolean cascade ) throws LdapException { Attribute oc = entry.get( objectClassAT ); for ( Value value : oc ) { String oid = schemaManager.getObjectClassRegistry().getOidByName( value.getValue() ); if ( objectClass2synchronizerMap.containsKey( oid ) ) { RegistrySynchronizer synchronizer = objectClass2synchronizerMap.get( oid ); synchronizer.move( moveContext.getDn(), moveContext.getNewSuperior(), entry, cascade ); return; } } if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) ) { schemaSynchronizer.move( moveContext.getDn(), moveContext.getNewSuperior(), entry, cascade ); return; } throw new LdapUnwillingToPerformException( ResultCodeEnum.UNWILLING_TO_PERFORM ); }
Attribute oc = entry.get( objectClassAT ); String oid = schemaManager.getObjectClassRegistry().getOidByName( value.getValue() ); if ( oc.contains( MetaSchemaConstants.META_SCHEMA_OC ) ) if ( oc.contains( SchemaConstants.ORGANIZATIONAL_UNIT_OC ) ) if ( deleteContext.getDn().size() != 3 ) String ouValue = deleteContext.getDn().getRdn().getValue(); ouValue = Strings.toLowerCaseAscii( Strings.trim( ouValue ) );
Dn dn = new Dn(accountDN); EntryCursor cursor = connection.search(dn, accountDN, SearchScope.ONELEVEL, (String[])null); if (cursor.next()) { for (Attribute attr : entry.getAttributes()) { String id = attr.getId(); List<String> values; if (account.containsKey(id)) { values = new ArrayList<String>(); values.add(attr.get().getValue().toString()); account.put(id, values);
public Object[] getElements( Object inputElement ) { List<AttributeValueObject> elements = new ArrayList<AttributeValueObject>(); Entry entry = ( Entry ) inputElement; Iterator<Attribute> attributes = entry.iterator(); while ( attributes.hasNext() ) { Attribute attribute = attributes.next(); Iterator<Value<?>> values = attribute.iterator(); while ( values.hasNext() ) { Value<?> value = values.next(); elements.add( new AttributeValueObject( attribute.getId(), value.getString() ) ); } } return elements.toArray(); }
/** * Get keys. * @throws IOException e * @return keys */ public List<EncryptionKey> getKeys() throws IOException { Iterator<Value> iterator1 = entry.get(KerberosAttribute.KRB5_KEY_AT).iterator(); List<EncryptionKey> keys = new ArrayList<>(); while (iterator1.hasNext()) { byte[] encryKey = iterator1.next().getBytes(); EncryptionKey key = new EncryptionKey(); key.decode(encryKey); key.setKvno(1); // TODO: kvno should be correctly stored and retrieved keys.add(key); } return keys; }
dnBytes = Strings.getBytesUtf8( getName().getName() ); compareRequestLength = 1 + TLV.getNbBytes( dnBytes.length ) + dnBytes.length; attrIdBytes = Strings.getBytesUtf8( getAttributeId() ); avaLength = 1 + TLV.getNbBytes( attrIdBytes.length ) + attrIdBytes.length; attrValBytes = getAssertionValue().getBytes(); avaLength += 1 + TLV.getNbBytes( attrValBytes.length ) + attrValBytes.length;
/** * @see Object#toString() */ public String toString() { return "CompareContext for Dn '" + getDn().getName() + "'" + ( ( oid != null ) ? ", oid : <" + oid + ">" : "" ) + ( ( value != null ) ? ", value :'" + ( ( value.isHumanReadable() ) ? value.getValue() : ( ( !value.isHumanReadable() ) ? Strings.dumpBytes( value.getBytes() ) : "unknown value type" ) ) + "'" : "" ); } }
/** * {@inheritDoc} */ @Override public boolean compare( Dn dn, String attributeName, Value value ) throws LdapException { CompareRequest compareRequest = new CompareRequestImpl(); compareRequest.setName( dn ); compareRequest.setAttributeId( attributeName ); if ( value.isHumanReadable() ) { compareRequest.setAssertionValue( value.getValue() ); } else { compareRequest.setAssertionValue( value.getBytes() ); } CompareResponse compareResponse = compare( compareRequest ); return processResponse( compareResponse ); }
private void applyAttributes(Map<String, Object> props, Entry entry) throws LdapInvalidAttributeValueException { for (Attribute attr: entry.getAttributes()) { if (attr.isHumanReadable()) { final Object propValue; // for multivalue properties, store as collection if (attr.size() > 1) { List<String> values = new ArrayList(); for (Value<?> value : attr) { values.add(value.getString()); } propValue = values; } else { propValue = attr.getString(); } props.put(attr.getId(), propValue); } } }
private LscDatasets convertEntry(Entry entry, boolean onlyFirstValue) { if(entry == null) return null; LscDatasets converted = new LscDatasets(); Iterator<Attribute> entryAttributes = entry.iterator(); while(entryAttributes.hasNext()) { Attribute attr = entryAttributes.next(); if(attr != null && attr.size() > 0) { Iterator<Value<?>> values = attr.iterator(); if(!onlyFirstValue) { Set<Object> datasetsValues = new HashSet<Object>(); while(values.hasNext()) { Value<?> value = values.next(); if (value.isHumanReadable()) { datasetsValues.add(value.getString()); } else { datasetsValues.add(value.getBytes()); } } converted.getDatasets().put(attr.getId(), datasetsValues); } else { Value<?> value = values.next(); converted.getDatasets().put(attr.getId(), value.isHumanReadable() ? value.getString() : value.getBytes()); } } } return converted; }
/** * @return representation of value, escaped for use in a filter if required */ public String getEscapedValue() { if ( value.isHumanReadable() ) { return escapeFilterValue( value.getValue() ); } else { return escapeFilterValue( value.getAttributeType(), value.getBytes() ); } }
/** * Displays security warning messages if any possible secutiry issue is found. * @throws Exception if there are failures parsing and accessing internal structures */ protected void showSecurityWarnings() throws Exception { // Warn if the default password is not changed. boolean needToChangeAdminPassword = false; Dn adminDn = getDnFactory().create( ServerDNConstants.ADMIN_SYSTEM_DN ); Entry adminEntry = partitionNexus.lookup( new LookupOperationContext( adminSession, adminDn ) ); Value<?> userPassword = adminEntry.get( SchemaConstants.USER_PASSWORD_AT ).get(); needToChangeAdminPassword = Arrays.equals( PartitionNexus.ADMIN_PASSWORD_BYTES, userPassword.getBytes() ); if ( needToChangeAdminPassword ) { LOG.warn( "You didn't change the admin password of directory service " + "instance '" + instanceId + "'. " + "Please update the admin password as soon as possible " + "to prevent a possible security breach." ); } }
/** * Method wraps ldap client to return multi-occurring attribute values by name within a given entry and returns * as a list of strings. * * @param entry contains the target ldap entry. * @param attributeName name of ldap attribute to retrieve. * @return List of type string containing attribute values. */ protected List<String> getAttributes( Entry entry, String attributeName ) { List<String> attrValues = new ArrayList<>(); if ( entry != null ) { Attribute attr = entry.get( attributeName ); if ( attr != null ) { for ( Value<?> value : attr ) { attrValues.add( value.getString() ); } } else { return null; } } return attrValues; }
/** * Method wraps ldap client to return multi-occurring attribute values by name within a given entry and returns * as a set of strings. * * @param entry contains the target ldap entry. * @param attributeName name of ldap attribute to retrieve. * @return List of type string containing attribute values. */ protected Set<String> getAttributeSet( Entry entry, String attributeName ) { // create Set with case insensitive comparator: Set<String> attrValues = new TreeSet<>( String.CASE_INSENSITIVE_ORDER ); if ( entry != null && entry.containsAttribute( attributeName ) ) { for ( Value<?> value : entry.get( attributeName ) ) { attrValues.add( value.getString() ); } } return attrValues; }