/** * {@inheritDoc} */ public void init( DirectoryService directoryService ) throws LdapException { super.init( directoryService ); krb5KeyAT = schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_KEY_AT ); krb5PrincipalNameAT = schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ); krb5KeyVersionNumberAT = schemaManager .lookupAttributeTypeRegistry( KerberosAttribute.KRB5_KEY_VERSION_NUMBER_AT ); userPasswordAT = schemaManager .lookupAttributeTypeRegistry( SchemaConstants.USER_PASSWORD_AT ); LOG_KRB.info( "KeyDerivation Interceptor initialized" ); }
/** * Creates and initializes a new instance of Schema synchronizer * * @param schemaManager The server schemaManager * @throws Exception If something went wrong */ public SchemaSynchronizer( SchemaManager schemaManager ) throws Exception { this.schemaManager = schemaManager; disabledAT = schemaManager.lookupAttributeTypeRegistry( MetaSchemaConstants.M_DISABLED_AT ); factory = new SchemaEntityFactory(); cnAT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.CN_AT ); dependenciesAT = schemaManager.lookupAttributeTypeRegistry( MetaSchemaConstants.M_DEPENDENCIES_AT ); ouSchemaDn = new Dn( schemaManager, SchemaConstants.OU_SCHEMA ); }
/** * Constructs a filter expression tree for the filter used to search the * directory. * * @param schemaManager The server schemaManager to use for attribute lookups * @param principal the principal to use for building the filter * @return the filter expression tree * @throws Exception if there are problems while looking up attributes */ private static ExprNode getFilter( SchemaManager schemaManager, String principal ) throws Exception { AttributeType type = schemaManager.lookupAttributeTypeRegistry( KerberosAttribute.KRB5_PRINCIPAL_NAME_AT ); Value value = new Value( type, principal ); return new EqualityNode<String>( type, value ); }
/** * Returns the attributeType from an Attribute ID. * * @param upId The ID we are looking for * @return The found attributeType * @throws LdapException If the lookup failed */ protected AttributeType getAttributeType( String upId ) throws LdapException { if ( Strings.isEmpty( Strings.trim( upId ) ) ) { String message = I18n.err( I18n.ERR_13204_NULL_ATTRIBUTE_ID ); LOG.error( message ); throw new IllegalArgumentException( message ); } return schemaManager.lookupAttributeTypeRegistry( upId ); }
/** * Returns the attributeType from an Attribute ID. * * @param upId The ID we are looking for * @return The found attributeType * @throws LdapException If the lookup failed */ protected AttributeType getAttributeType( String upId ) throws LdapException { if ( Strings.isEmpty( Strings.trim( upId ) ) ) { String message = I18n.err( I18n.ERR_13204_NULL_ATTRIBUTE_ID ); LOG.error( message ); throw new IllegalArgumentException( message ); } return schemaManager.lookupAttributeTypeRegistry( upId ); }
/** * Returns the attributeType from an Attribute ID. * * @param upId The ID we are looking for * @return The found attributeType * @throws LdapException If the lookup failed */ protected AttributeType getAttributeType( String upId ) throws LdapException { if ( Strings.isEmpty( Strings.trim( upId ) ) ) { String message = I18n.err( I18n.ERR_13204_NULL_ATTRIBUTE_ID ); LOG.error( message ); throw new IllegalArgumentException( message ); } return schemaManager.lookupAttributeTypeRegistry( upId ); }
/** * {@inheritDoc} */ @Override public void init( DirectoryService directoryService ) throws LdapException { // allow base initialization super.init( directoryService ); // initialize from config algorithm = LdapSecurityConstants.getAlgorithm( config.getHashAlgorithm() ); attributeTypes = new ArrayList<>(); for ( String attributeType : config.getHashAttributes() ) { attributeTypes.add( schemaManager.lookupAttributeTypeRegistry( attributeType ) ); } }
/** * {@inheritDoc} */ @Override public void registerSupportedSaslMechanisms( Set<String> supportedSaslMechanisms ) throws LdapException { Attribute supportedSaslMechanismsAt; supportedSaslMechanismsAt = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( SchemaConstants.SUPPORTED_SASL_MECHANISMS_AT ) ); for ( String saslMechanism : supportedSaslMechanisms ) { supportedSaslMechanismsAt.add( saslMechanism ); } rootDse.add( supportedSaslMechanismsAt ); }
private void createContextCsnModList() throws LdapException { Modification contextCsnMod = new DefaultModification(); contextCsnMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE ); DefaultAttribute contextCsnAt = new DefaultAttribute( schemaManager .lookupAttributeTypeRegistry( SchemaConstants.CONTEXT_CSN_AT ) ); contextCsnMod.setAttribute( contextCsnAt ); mods.add( contextCsnMod ); Modification timeStampMod = new DefaultModification(); timeStampMod.setOperation( ModificationOperation.REPLACE_ATTRIBUTE ); DefaultAttribute timeStampAt = new DefaultAttribute( schemaManager .lookupAttributeTypeRegistry( SchemaConstants.MODIFY_TIMESTAMP_AT ) ); timeStampMod.setAttribute( timeStampAt ); mods.add( timeStampMod ); }
/** * Looks up the Normalizer to use for a name component using the attributeId * for the name component. First the attribute is resolved, then its * equality matching rule is looked up. The normalizer of that matching * rule is returned. * * @param id the name or oid of the attribute in the name component to * normalize the value of * @return the Normalizer to use for normalizing the value of the attribute * @throws LdapException if there are failures resolving the Normalizer */ private Normalizer lookup( String id ) throws LdapException { AttributeType type = schemaManager.lookupAttributeTypeRegistry( id ); MatchingRule mrule = type.getEquality(); if ( mrule == null ) { return new NoOpNormalizer( id ); } return mrule.getNormalizer(); }
/** * Init the replication service * @param directoryservice The directory service */ public void init( DirectoryService directoryservice ) throws Exception { this.directoryService = directoryservice; session = directoryService.getAdminSession(); schemaManager = directoryservice.getSchemaManager(); adsReplCookieAT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ADS_REPL_COOKIE ); adsDsReplicaIdAT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ADS_DS_REPLICA_ID ); Attribute cookieAttr = new DefaultAttribute( adsReplCookieAT ); cookieMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, cookieAttr ); Attribute ridAttr = new DefaultAttribute( adsDsReplicaIdAT ); ridMod = new DefaultModification( ModificationOperation.REPLACE_ATTRIBUTE, ridAttr ); prepareSyncSearchRequest(); }
/** * Looks up the Normalizer to use for a name component using the attributeId * for the name component. First the attribute is resolved, then its * equality matching rule is looked up. The normalizer of that matching * rule is returned. * * @param id the name or oid of the attribute in the name component to * normalize the value of * @return the Normalizer to use for normalizing the value of the attribute * @throws LdapException if there are failures resolving the Normalizer */ private Normalizer lookup( String id ) throws LdapException { AttributeType type = schemaManager.lookupAttributeTypeRegistry( id ); MatchingRule mrule = type.getEquality(); if ( mrule == null ) { return new NoOpNormalizer( id ); } return mrule.getNormalizer(); }
/** * Create a new instance of the producer replication manager. * * @param directoryService The directoryService instance * @throws Exception if we add an error while creating the configuration */ public ReplConsumerManager( DirectoryService directoryService ) throws Exception { this.directoryService = directoryService; adminSession = directoryService.getAdminSession(); schemaManager = directoryService.getSchemaManager(); replConsumerDn = directoryService.getDnFactory().create( REPL_CONSUMER_DN_STR ); adsReplLastSentCsn = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.ADS_REPL_LAST_SENT_CSN ); PROVIDER_LOG.debug( "Starting the replication consumer manager" ); createConsumersBranch(); }
/** * Generate the comparators attribute from the registry */ private static Attribute generateComparators( SchemaManager schemaManager ) throws LdapException { Attribute attr = new DefaultAttribute( schemaManager.lookupAttributeTypeRegistry( SchemaConstants.COMPARATORS_AT ) ); for ( LdapComparator<?> comparator : schemaManager.getComparatorRegistry() ) { attr.add( SchemaUtils.render( comparator ) ); } return attr; }
/** * Visit a PresenceNode. If the attribute exists, the node is returned, otherwise * null is returned. * * @param node the node to visit * @return The visited node */ private ExprNode visitPresenceNode( PresenceNode node ) throws LdapException { // still need this check here in case the top level is a leaf node // with an undefined attributeType for its attribute if ( !ncn.isDefined( node.getAttribute() ) ) { return null; } node.setAttributeType( schemaManager.lookupAttributeTypeRegistry( node.getAttribute() ) ); return node; }
/** * Visit a ExtensibleNode. If the attribute exists, the node is returned, otherwise * null is returned. * * TODO implement the logic for ExtensibleNode * * @param node the node to visit * @return the visited node */ private ExprNode visitExtensibleNode( ExtensibleNode node ) throws LdapException { // still need this check here in case the top level is a leaf node // with an undefined attributeType for its attribute if ( !ncn.isDefined( node.getAttribute() ) ) { return null; } node.setAttributeType( schemaManager.lookupAttributeTypeRegistry( node.getAttribute() ) ); return node; }
/** * {@inheritDoc} */ @Override public Object normalizeByName( String name, String value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); Normalizer normalizer = lookup( name ); if ( attributeType.getSyntax().isHumanReadable() ) { return normalizer.normalize( value ); } else { String unescaped = unescape( value ); return normalizer.normalize( unescaped ); } }
/** * {@inheritDoc} */ @Override public Object normalizeByName( String name, String value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); Normalizer normalizer = lookup( name ); if ( attributeType.getSyntax().isHumanReadable() ) { return normalizer.normalize( value ); } else { String unescaped = unescape( value ); return normalizer.normalize( unescaped ); } }
/** * {@inheritDoc} */ @Override public Object normalizeByName( String name, String value ) throws LdapException { AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( name ); Normalizer normalizer = lookup( name ); if ( attributeType.getSyntax().isHumanReadable() ) { return normalizer.normalize( value ); } else { String unescaped = unescape( value ); return normalizer.normalize( unescaped ); } }
public RegistrySynchronizerAdaptor( SchemaManager schemaManager ) throws Exception { this.schemaManager = schemaManager; this.schemaSynchronizer = new SchemaSynchronizer( schemaManager ); this.objectClassAT = schemaManager.lookupAttributeTypeRegistry( SchemaConstants.OBJECT_CLASS_AT ); this.registrySynchronizers[COMPARATOR_INDEX] = new ComparatorSynchronizer( schemaManager ); this.registrySynchronizers[NORMALIZER_INDEX] = new NormalizerSynchronizer( schemaManager ); this.registrySynchronizers[SYNTAX_CHECKER_INDEX] = new SyntaxCheckerSynchronizer( schemaManager ); this.registrySynchronizers[SYNTAX_INDEX] = new SyntaxSynchronizer( schemaManager ); this.registrySynchronizers[MATCHING_RULE_INDEX] = new MatchingRuleSynchronizer( schemaManager ); this.registrySynchronizers[ATTRIBUTE_TYPE_INDEX] = new AttributeTypeSynchronizer( schemaManager ); this.registrySynchronizers[OBJECT_CLASS_INDEX] = new ObjectClassSynchronizer( schemaManager ); this.registrySynchronizers[MATCHING_RULE_USE_INDEX] = new MatchingRuleUseSynchronizer( schemaManager ); this.registrySynchronizers[DIT_STRUCTURE_RULE_INDEX] = new DitStructureRuleSynchronizer( schemaManager ); this.registrySynchronizers[DIT_CONTENT_RULE_INDEX] = new DitContentRuleSynchronizer( schemaManager ); this.registrySynchronizers[NAME_FORM_INDEX] = new NameFormSynchronizer( schemaManager ); ObjectClassRegistry ocReg = schemaManager.getObjectClassRegistry(); for ( int ii = 0; ii < META_OBJECT_CLASSES.length; ii++ ) { ObjectClass oc = ocReg.lookup( META_OBJECT_CLASSES[ii] ); objectClass2synchronizerMap.put( oc.getOid(), registrySynchronizers[ii] ); } }