/** * Sets the attribute. * * @param attribute the new attribute * @throws LdapException if the attribute is not binary. */ public void setAttribute( Attribute attribute ) throws LdapException { if ( attribute.isHumanReadable() ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.CONSTRAINT_VIOLATION, I18n.err( I18n.ERR_16007_BINARY_REQUIRED ) ); } this.attribute = attribute; }
/** * Sets the attribute. * * @param attribute the new attribute * @throws LdapException if the attribute is not binary. */ public void setAttribute( Attribute attribute ) throws LdapException { if ( attribute.isHumanReadable() ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.CONSTRAINT_VIOLATION, I18n.err( I18n.ERR_16007_BINARY_REQUIRED ) ); } this.attribute = attribute; }
/** * Sets the attribute. * * @param attribute the new attribute * @throws LdapException if the attribute is not binary. */ public void setAttribute( Attribute attribute ) throws LdapException { if ( attribute.isHumanReadable() ) { throw new LdapInvalidAttributeValueException( ResultCodeEnum.CONSTRAINT_VIOLATION, I18n.err( I18n.ERR_16007_BINARY_REQUIRED ) ); } this.attribute = attribute; }
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13724_INVALID_VALUE, value ) ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_13724_INVALID_VALUE, value ), pe );
/** * {@inheritDoc} */ @Override public byte[] getBytes() throws LdapInvalidAttributeValueException { Value value = get(); if ( !isHumanReadable() && ( value != null ) ) { return value.getBytes(); } String message = I18n.err( I18n.ERR_13214_VALUE_EXPECT_BYTES ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); }
/** * {@inheritDoc} */ @Override public byte[] getBytes() throws LdapInvalidAttributeValueException { Value value = get(); if ( !isHumanReadable() && ( value != null ) ) { return value.getBytes(); } String message = I18n.err( I18n.ERR_13214_VALUE_EXPECT_BYTES ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); }
throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg );
/** * {@inheritDoc} */ @Override public String getString() throws LdapInvalidAttributeValueException { Value value = get(); if ( isHumanReadable() && ( value != null ) ) { return value.getValue(); } String message = I18n.err( I18n.ERR_13215_VALUE_EXPECT_STRING ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); }
/** * {@inheritDoc} */ @Override public byte[] getBytes() throws LdapInvalidAttributeValueException { Value value = get(); if ( !isHumanReadable() && ( value != null ) ) { return value.getBytes(); } String message = I18n.err( I18n.ERR_13214_VALUE_EXPECT_BYTES ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); }
/** * {@inheritDoc} */ @Override public String getString() throws LdapInvalidAttributeValueException { Value value = get(); if ( isHumanReadable() && ( value != null ) ) { return value.getValue(); } String message = I18n.err( I18n.ERR_13215_VALUE_EXPECT_STRING ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); }
/** * {@inheritDoc} */ @Override public String getString() throws LdapInvalidAttributeValueException { Value value = get(); if ( isHumanReadable() && ( value != null ) ) { return value.getValue(); } String message = I18n.err( I18n.ERR_13215_VALUE_EXPECT_STRING ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); }
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. * * @param syntaxChecker the SyntaxChecker to use to validate the value * @return <code>true</code> if the value is valid * @exception LdapInvalidAttributeValueException if the value cannot be validated */ public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapInvalidAttributeValueException { if ( syntaxChecker == null ) { String message = I18n.err( I18n.ERR_13219_NULL_SYNTAX_CHECKER, toString() ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); } // No attributeType, or it's in relaxed mode if ( isHR ) { // We need to prepare the String in this case return syntaxChecker.isValidSyntax( getValue() ); } else { return syntaxChecker.isValidSyntax( bytes ); } }
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. * * @param syntaxChecker the SyntaxChecker to use to validate the value * @return <code>true</code> if the value is valid * @exception LdapInvalidAttributeValueException if the value cannot be validated */ public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapInvalidAttributeValueException { if ( syntaxChecker == null ) { String message = I18n.err( I18n.ERR_13219_NULL_SYNTAX_CHECKER, toString() ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); } // No attributeType, or it's in relaxed mode if ( isHR ) { // We need to prepare the String in this case return syntaxChecker.isValidSyntax( getValue() ); } else { return syntaxChecker.isValidSyntax( bytes ); } }
/** * Uses the syntaxChecker associated with the attributeType to check if the * value is valid. * * @param syntaxChecker the SyntaxChecker to use to validate the value * @return <code>true</code> if the value is valid * @exception LdapInvalidAttributeValueException if the value cannot be validated */ public final boolean isValid( SyntaxChecker syntaxChecker ) throws LdapInvalidAttributeValueException { if ( syntaxChecker == null ) { String message = I18n.err( I18n.ERR_13219_NULL_SYNTAX_CHECKER, toString() ); LOG.error( message ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, message ); } // No attributeType, or it's in relaxed mode if ( isHR ) { // We need to prepare the String in this case return syntaxChecker.isValidSyntax( getValue() ); } else { return syntaxChecker.isValidSyntax( bytes ); } }
/** * Get the SubtreeSpecification, parse it and stores it into the subentry */ private void setSubtreeSpecification( Subentry subentry, Entry entry ) throws LdapException { String subtree = entry.get( directoryService.getAtProvider().getSubtreeSpecification() ).getString(); SubtreeSpecification ss; try { ss = ssParser.parse( subtree ); } catch ( Exception e ) { String msg = I18n.err( I18n.ERR_307, entry.getDn() ); LOG.warn( msg ); throw new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, msg ); } subentry.setSubtreeSpecification( ss ); }
public LdapComparatorDescription[] parseComparators( Attribute attr ) throws LdapInvalidAttributeValueException { if ( attr == null || attr.size() == 0 ) { return EMPTY_COMPARATORS; } LdapComparatorDescription[] comparatorDescriptions = new LdapComparatorDescription[attr.size()]; int pos = 0; for ( Value value : attr ) { try { comparatorDescriptions[pos++] = comparatorParser.parse( value.getValue() ); } catch ( ParseException e ) { LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_407, value.getValue() ) ); iave.initCause( e ); throw iave; } } return comparatorDescriptions; }
public NormalizerDescription[] parseNormalizers( Attribute attr ) throws LdapInvalidAttributeValueException { if ( attr == null || attr.size() == 0 ) { return EMPTY_NORMALIZERS; } NormalizerDescription[] normalizerDescriptions = new NormalizerDescription[attr.size()]; int pos = 0; for ( Value value : attr ) { try { normalizerDescriptions[pos++] = normalizerParser.parse( value.getValue() ); } catch ( ParseException e ) { LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_406, value.getValue() ) ); iave.initCause( e ); throw iave; } } return normalizerDescriptions; }
@NotNull private ExternalIdentity createIdentity(@NotNull Entry entry, @Nullable String id, boolean isGroup) throws LdapInvalidAttributeValueException { LdapProviderConfig.Identity cfg = isGroup ? config.getGroupConfig() : config.getUserConfig(); if (id == null) { String idAttribute = cfg.getIdAttribute(); Attribute attr = entry.get(idAttribute); if (attr == null) { throw new LdapInvalidAttributeValueException(ResultCodeEnum.CONSTRAINT_VIOLATION, "no value found for attribute '" + idAttribute + "' for entry " + entry); } id = attr.getString(); } String extId = config.getUseUidForExtId() ? id : entry.getDn().getName(); ExternalIdentityRef ref = new ExternalIdentityRef(extId, this.getName()); String path = cfg.makeDnPath() ? createDNPath(entry.getDn()) : null; LdapIdentity identity = isGroup ? new LdapGroup(this, ref, id, path, entry) : new LdapUser(this, ref, id, path, entry); Map<String, Object> props = identity.getProperties(); applyAttributes(props, entry); return identity; }
LdapInvalidAttributeValueException iave = new LdapInvalidAttributeValueException( ResultCodeEnum.INVALID_ATTRIBUTE_SYNTAX, I18n.err( I18n.ERR_421, value.getValue() ) );