org.apache.directory.api.ldap.model.schema.AttributeTypeOptions Java Examples
The following examples show how to use
org.apache.directory.api.ldap.model.schema.AttributeTypeOptions.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SearchParams.java From directory-ldap-api with Apache License 2.0 | 6 votes |
/** * Normalize the ReturningAttributes. It reads all the String from the returningAttributesString, * and grab the associated AttributeType from the schema to store it into the returningAttributes * Set. * * @param schemaManager The schema manager */ public void normalize( SchemaManager schemaManager ) { for ( String returnAttribute : returningAttributesStr ) { try { String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute ); AttributeType attributeType = schemaManager.lookupAttributeTypeRegistry( id ); AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options ); returningAttributes.add( attrOptions ); } catch ( LdapException ne ) { if ( LOG.isWarnEnabled() ) { LOG.warn( I18n.msg( I18n.MSG_13500_ATTRIBUTE_NOT_IN_SCHEMA, returnAttribute ) ); } // Unknown attributes should be silently ignored, as RFC 2251 states } } }
Example #2
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Tells if an attribute is present in the list of attribute to return * * @param attributeType The attributeType we are looking for * @return true if the attribute is present */ public boolean contains( SchemaManager schemaManager, AttributeType attributeType ) { if ( isNoAttributes() ) { return false; } if ( ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS ) && allUserAttributes ) { return true; } if ( ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS ) && allOperationalAttributes ) { return true; } // Loop on the returningAttribute, as we have two conditions to check if ( returningAttributes == null ) { return false; } for ( AttributeTypeOptions attributeTypeOptions : returningAttributes ) { if ( attributeTypeOptions.getAttributeType().equals( attributeType ) || attributeTypeOptions.getAttributeType().isAncestorOf( attributeType ) ) { return true; } } return false; }
Example #3
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | 5 votes |
/** * Tells if an attribute is present in the list of attribute to return * * @param attributeType The attributeType we are looking for * @return true if the attribute is present */ public boolean contains( SchemaManager schemaManager, AttributeType attributeType ) { if ( isNoAttributes() ) { return false; } if ( ( attributeType.getUsage() == UsageEnum.USER_APPLICATIONS ) && allUserAttributes ) { return true; } if ( ( attributeType.getUsage() != UsageEnum.USER_APPLICATIONS ) && allOperationalAttributes ) { return true; } // Loop on the returningAttribute, as we have two conditions to check if ( returningAttributes == null ) { return false; } for ( AttributeTypeOptions attributeTypeOptions : returningAttributes ) { if ( attributeTypeOptions.getAttributeType().equals( attributeType ) || attributeTypeOptions.getAttributeType().isAncestorOf( attributeType ) ) { return true; } } return false; }
Example #4
Source File: SearchParams.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * @return the returningAttributes */ public Set<AttributeTypeOptions> getReturningAttributes() { return returningAttributes; }
Example #5
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
protected void setReturningAttributes( String... attributeIds ) { this.originalAttributeNames = attributeIds; if ( ( attributeIds != null ) && ( attributeIds.length != 0 ) && ( attributeIds[0] != null ) ) { // We have something in the list // first, ignore all the unkown AT and convert the strings to // AttributeTypeOptions returningAttributes = new HashSet<AttributeTypeOptions>(); Set<String> attributesString = new HashSet<String>(); Set<AttributeTypeOptions> collectedAttributes = collectAttributeTypes( attributeIds ); // If we have valid, '*' or '+' attributes, we can get rid of the NoAttributes flag if ( ( collectedAttributes.size() > 0 ) || allUserAttributes || allOperationalAttributes ) { noAttributes = false; } // Now, loop on the list of attributes, and remove all the USER attributes if // we have the '*' attribute, and remove all the OPERATIONAL attributes if we // have the '+' attribute if ( collectedAttributes.size() > 0 ) { for ( AttributeTypeOptions attributeTypeOption : collectedAttributes ) { if ( attributeTypeOption.getAttributeType().isUser() && !allUserAttributes ) { // We can add the AttributeType in the list of returningAttributeTypes returningAttributes.add( attributeTypeOption ); attributesString.add( attributeTypeOption.getAttributeType().getOid() ); } if ( attributeTypeOption.getAttributeType().isOperational() && !allOperationalAttributes ) { // We can add the AttributeType in the list of returningAttributeTypes returningAttributes.add( attributeTypeOption ); attributesString.add( attributeTypeOption.getAttributeType().getOid() ); } } } if ( attributesString.size() > 0 ) { // We have some valid attributes, lt's convert it to String returningAttributesString = attributesString.toArray( ArrayUtils.EMPTY_STRING_ARRAY ); } else { // No valid attributes remaining, that means they were all invalid returningAttributesString = ArrayUtils.EMPTY_STRING_ARRAY; } } else { // Nothing in the list : default to '*' allUserAttributes = true; returningAttributesString = ArrayUtils.EMPTY_STRING_ARRAY; } }
Example #6
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
private Set<AttributeTypeOptions> collectAttributeTypes( String... attributesIds ) { Set<AttributeTypeOptions> collectedAttributes = new HashSet<AttributeTypeOptions>(); if ( ( attributesIds != null ) && ( attributesIds.length != 0 ) ) { for ( String returnAttribute : attributesIds ) { if ( returnAttribute == null ) { continue; } if ( returnAttribute.equals( SchemaConstants.NO_ATTRIBUTE ) ) { noAttributes = true; continue; } if ( returnAttribute.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) ) { allOperationalAttributes = true; continue; } if ( returnAttribute.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) ) { allUserAttributes = true; continue; } try { String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute ); AttributeType attributeType = session.getDirectoryService() .getSchemaManager().lookupAttributeTypeRegistry( id ); AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options ); collectedAttributes.add( attrOptions ); } catch ( LdapNoSuchAttributeException nsae ) { LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored", returnAttribute ); // Unknown attributes should be silently ignored, as RFC 2251 states } catch ( LdapException le ) { LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored", returnAttribute ); // Unknown attributes should be silently ignored, as RFC 2251 states } } } return collectedAttributes; }
Example #7
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
public void setReturningAttributes( String... attributeIds ) { this.originalAttributeNames = attributeIds; if ( ( attributeIds != null ) && ( attributeIds.length != 0 ) && ( attributeIds[0] != null ) ) { // We have something in the list // first, ignore all the unkown AT and convert the strings to // AttributeTypeOptions returningAttributes = new HashSet<AttributeTypeOptions>(); Set<String> attributesString = new HashSet<String>(); Set<AttributeTypeOptions> collectedAttributes = collectAttributeTypes( attributeIds ); // If we have valid, '*' or '+' attributes, we can get rid of the NoAttributes flag if ( ( collectedAttributes.size() > 0 ) || allUserAttributes || allOperationalAttributes ) { noAttributes = false; } // Now, loop on the list of attributes, and remove all the USER attributes if // we have the '*' attribute, and remove all the OPERATIONAL attributes if we // have the '+' attribute if ( collectedAttributes.size() > 0 ) { for ( AttributeTypeOptions attributeTypeOption : collectedAttributes ) { if ( attributeTypeOption.getAttributeType().isUser() && !allUserAttributes ) { // We can add the AttributeType in the list of returningAttributeTypes returningAttributes.add( attributeTypeOption ); attributesString.add( attributeTypeOption.getAttributeType().getOid() ); } if ( attributeTypeOption.getAttributeType().isOperational() && !allOperationalAttributes ) { // We can add the AttributeType in the list of returningAttributeTypes returningAttributes.add( attributeTypeOption ); attributesString.add( attributeTypeOption.getAttributeType().getOid() ); } } } if ( attributesString.size() > 0 ) { // We have some valid attributes, lt's convert it to String returningAttributesString = attributesString.toArray( ArrayUtils.EMPTY_STRING_ARRAY ); } else { // No valid attributes remaining, that means they were all invalid returningAttributesString = ArrayUtils.EMPTY_STRING_ARRAY; } } else { // Nothing in the list : default to '*' allUserAttributes = true; returningAttributesString = ArrayUtils.EMPTY_STRING_ARRAY; } }
Example #8
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | 4 votes |
private Set<AttributeTypeOptions> collectAttributeTypes( String... attributesIds ) { Set<AttributeTypeOptions> collectedAttributes = new HashSet<AttributeTypeOptions>(); if ( ( attributesIds != null ) && ( attributesIds.length != 0 ) ) { for ( String returnAttribute : attributesIds ) { if ( returnAttribute == null ) { continue; } if ( returnAttribute.equals( SchemaConstants.NO_ATTRIBUTE ) ) { noAttributes = true; continue; } if ( returnAttribute.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) ) { allOperationalAttributes = true; continue; } if ( returnAttribute.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) ) { allUserAttributes = true; continue; } try { String id = SchemaUtils.stripOptions( returnAttribute ); Set<String> options = SchemaUtils.getOptions( returnAttribute ); AttributeType attributeType = session.getDirectoryService() .getSchemaManager().lookupAttributeTypeRegistry( id ); AttributeTypeOptions attrOptions = new AttributeTypeOptions( attributeType, options ); collectedAttributes.add( attrOptions ); } catch ( LdapNoSuchAttributeException nsae ) { LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored", returnAttribute ); // Unknown attributes should be silently ignored, as RFC 2251 states } catch ( LdapException le ) { LOG.warn( "Requested attribute {} does not exist in the schema, it will be ignored", returnAttribute ); // Unknown attributes should be silently ignored, as RFC 2251 states } } } return collectedAttributes; }
Example #9
Source File: RangedAttributeInterceptor.java From keycloak with Apache License 2.0 | 4 votes |
@Override public EntryFilteringCursor search(SearchOperationContext sc) throws LdapException { Set<AttributeTypeOptions> attrs = sc.getReturningAttributes(); Integer lmin = null, lmax = max; if (attrs != null) { for (AttributeTypeOptions attr : attrs) { if (attr.getAttributeType().getName().equalsIgnoreCase(name)) { if (attr.getOptions() != null) { for (String option : attr.getOptions()) { if (option.startsWith("range=")) { String[] ranges = option.substring(6).split("-"); if (ranges.length == 2) { try { lmin = Integer.parseInt(ranges[0]); if (lmin < 0) { lmin = 0; } if ("*".equals(ranges[1])) { lmax = lmin + max; } else { lmax = Integer.parseInt(ranges[1]); if (lmax < lmin) { lmax = lmin; } else if (lmax > lmin + max) { lmax = lmin + max; } } } catch (NumberFormatException e) { lmin = null; lmax = max; } } } } } break; } } } return new RangedEntryFilteringCursor(super.next(sc), name, lmin, lmax); }
Example #10
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | votes |
/** * Add an attribute ID to the current list, creating the list if necessary * * @param attrId the Id to add * public void addAttrsId( String attrId ) { if ( noAttributes == null ) { if ( attrId.equals( SchemaConstants.NO_ATTRIBUTE ) ) { noAttributes = true; if ( attrsId != null ) { attrsId.clear(); } return; } if ( attrId.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) ) { allUserAttributes = true; return; } if ( attrId.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) ) { allOperationalAttributes = true; return; } if ( attrsId == null ) { attrsId = new ArrayList<String>(); } attrsId.add( attrId ); } } /** * @return the returningAttributes as a Set of AttributeTypeOptions */ public Set<AttributeTypeOptions> getReturningAttributes() { return returningAttributes; }
Example #11
Source File: FilteringOperationContext.java From MyVirtualDirectory with Apache License 2.0 | votes |
/** * Add an attribute ID to the current list, creating the list if necessary * * @param attrId the Id to add * public void addAttrsId( String attrId ) { if ( noAttributes == null ) { if ( attrId.equals( SchemaConstants.NO_ATTRIBUTE ) ) { noAttributes = true; if ( attrsId != null ) { attrsId.clear(); } return; } if ( attrId.equals( SchemaConstants.ALL_USER_ATTRIBUTES ) ) { allUserAttributes = true; return; } if ( attrId.equals( SchemaConstants.ALL_OPERATIONAL_ATTRIBUTES ) ) { allOperationalAttributes = true; return; } if ( attrsId == null ) { attrsId = new ArrayList<String>(); } attrsId.add( attrId ); } } /** * @return the returningAttributes as a Set of AttributeTypeOptions */ public Set<AttributeTypeOptions> getReturningAttributes() { return returningAttributes; }