/** * Sets the attribute value to use in the comparison. * * @param attrVal * the attribute value used in comparison. */ public void setAssertionValue( String attrVal ) { this.attrVal = new StringValue( attrVal ); }
/** * Construct an AVA. The type and value are normalized : * <li> the type is trimmed and lowercased </li> * <li> the value is trimmed </li> * <p> * Note that the upValue should <b>not</b> be null or empty, or resolved * to an empty string after having trimmed it. * * @param upType The Usrr Provided type * @param normType The normalized type * @param upValue The User Provided value * @param normValue The normalized value */ public AVA( String upType, String normType, String upValue, String normValue ) throws LdapInvalidDnException { this( upType, normType, new StringValue( upValue ), new StringValue( normValue ) ); }
/** * @see EntryAttribute#remove(String...) * * @return <code>true</code> if all the values shave been removed from this attribute */ public boolean remove( String... vals ) { if ( !isHR ) { return false; } boolean removed = true; for ( String val:vals ) { StringValue value = new StringValue( attributeType, val ); removed &= values.remove( value ); } return removed; }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapInvalidDnException { if ( value == null ) { return null; } String strValue = value.getString(); return new StringValue( strValue.trim().toUpperCase() ); }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { String str = value.getString(); if ( StringTools.isEmpty( str ) ) { return new StringValue( str ); } return new StringValue( str ); }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } String str = value.getString().trim(); if ( str.length() == 0 ) { return new StringValue( "" ); } else if ( Character.isDigit( str.charAt( 0 ) ) ) { // We do this test to avoid a lowerCasing which cost time return new StringValue( str ); } else { return new StringValue( str.toLowerCase() ); } }
/** * A constructor that constructs a RDN from a type and a value. Constructs * an Rdn from the given attribute type and value. The string attribute * values are not interpreted as RFC 2253 formatted RDN strings. That is, * the values are used literally (not parsed) and assumed to be un-escaped. * * @param upType The user provided type of the RDN * @param upValue The user provided value of the RDN * @throws LdapInvalidDnException If the RDN is invalid */ public RDN( String upType, String upValue ) throws LdapInvalidDnException { addAttributeTypeAndValue( upType, upType, new StringValue( upValue ), new StringValue( upValue ) ); upName = upType + '=' + upValue; start = 0; length = upName.length(); // create the internal normalized form normalize(); }
/** * A constructor that constructs a RDN from a type and a value. Constructs * an Rdn from the given attribute type and value. The string attribute * values are not interpreted as RFC 2253 formatted RDN strings. That is, * the values are used literally (not parsed) and assumed to be un-escaped. * * @param upType The user provided type of the RDN * @param upValue The user provided value of the RDN * @param normType The normalized provided type of the RDN * @param normValue The normalized provided value of the RDN * @throws LdapInvalidDnException If the RDN is invalid */ public RDN( String upType, String normType, String upValue, String normValue ) throws LdapInvalidDnException { addAttributeTypeAndValue( upType, normType, new StringValue( upValue ), new StringValue( normValue ) ); upName = upType + '=' + upValue; start = 0; length = upName.length(); // create the internal normalized form normalize(); }
/** * Store the value of a AVA, after having trimmed it. * * @param value The value of the AVA */ public void setValueNormalized( String value ) { String newValue = StringTools.trim( value ); if ( StringTools.isEmpty( newValue ) ) { this.normValue = new StringValue( "" ); } else { this.normValue = new StringValue( newValue ); } upName = upName.substring( 0, upName.indexOf( '=' ) + 1 ) + value; start = -1; length = upName.length(); }
public Value<?> normalize( Value<?> value ) throws LdapException { if ( !value.isBinary() ) { return new StringValue( value.getString().toLowerCase() ); } throw new IllegalStateException( I18n.err( I18n.ERR_473 ) ); }
/** * {@inheritDoc} */ public Value<?> normalize( final Value<?> value ) { if ( value == null ) { return null; } if ( !value.isBinary() ) { String str = value.getString(); for ( int i = 0; i < matchers.length; i++ ) { str = matchers[i].replaceAll( str ); } return new StringValue( str ); } return value; }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } String strValue = value.getString(); if ( strValue.length() == 0 ) { return new StringValue( "" ); } // if value is a numeric id then return it as is if ( checker.isValidSyntax( strValue ) ) { return value; } // if it is a name we need to do a lookup String oid = schemaManager.getRegistries().getOid( strValue ); if ( oid != null ) { return new StringValue( oid ); } // if all else fails throw new LdapOtherException( I18n.err( I18n.ERR_04225, value ) ); }
private void parseRdnInternal( String name, Position pos, RDN rdn ) throws LdapInvalidDnException { int rdnStart = pos.start; // SPACE* matchSpaces( name, pos ); // attributeType: ALPHA (ALPHA|DIGIT|HYPEN) | NUMERICOID String type = matchAttributeType( name, pos ); // SPACE* matchSpaces( name, pos ); // EQUALS matchEquals( name, pos ); // SPACE* matchSpaces( name, pos ); // here we only match "simple" values // stops at \ + # " -> Too Complex Exception String upValue = matchValue( name, pos ); String value = StringTools.trimRight( upValue ); // TODO: trim, normalize, etc // SPACE* matchSpaces( name, pos ); String upName = name.substring( rdnStart, pos.start ); AVA ava = new AVA( type, type, new StringValue( upValue ), new StringValue( value ), upName ); rdn.addAttributeTypeAndValue( ava ); rdn.setUpName( upName ); rdn.normalize(); }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.DIRECTORY_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.TELEPHONE_NUMBER ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidDnException( I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { DN dn = null; String dnStr = value.getString(); dn = new DN( dnStr ); dn.normalize( schemaManager.getNormalizerMapping() ); return new StringValue( dn.getNormName() ); }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.NUMERIC_STRING ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidDnException( I18n.err( I18n.ERR_04224, value ) ); } }
/** * {@inheritDoc} */ public Value<?> normalize( Value<?> value ) throws LdapException { if ( value == null ) { return null; } try { String normalized = PrepareString.normalize( value.getString(), PrepareString.StringType.CASE_IGNORE ); return new StringValue( normalized ); } catch ( IOException ioe ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_04224, value ) ); } }
/** * Convert the ServerAttribute to a ClientAttribute * * @return An instance of ClientAttribute */ public EntryAttribute toClientAttribute() { // Create the new EntryAttribute EntryAttribute clientAttribute = new DefaultClientAttribute( upId ); // Copy the values for ( Value<?> value:this ) { Value<?> clientValue = null; if ( value instanceof StringValue ) { clientValue = new StringValue( value.getString() ); } else { clientValue = new BinaryValue( value.getBytes() ); } clientAttribute.add( clientValue ); } return clientAttribute; }