From cdc4fdb1d1e280375121186f4091b82c71b174ae Mon Sep 17 00:00:00 2001 From: emmanuel lecharny Date: Wed, 21 Aug 2024 14:59:40 +0200 Subject: [PATCH] Partial fix to DIRSERVER_1728: interceptor-normalization & interceptor-operational --- .../java/org/apache/directory/server/i18n/I18n.java | 8 +++++--- .../org/apache/directory/server/i18n/errors.properties | 8 +++++--- .../server/core/normalization/ExpandingVisitor.java | 4 ++-- .../operational/OperationalAttributeInterceptor.java | 10 +++++----- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java index f34c4345db..e03d5e755b 100644 --- a/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java +++ b/i18n/src/main/java/org/apache/directory/server/i18n/I18n.java @@ -343,10 +343,15 @@ public enum I18n // No error // apacheds-interceptors-normalization errors 23000 - 23999 + ERR_23000_FAILED_TO_EXPAND_NODE("ERR_23000_FAILED_TO_EXPAND_NODE"), + // apacheds-interceptors-number errors 24000 - 24999 // No error // apacheds-interceptors-operational errors 25000 - 25999 + ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE("ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE"), + ERR_25001_CANNOT_MODIFY__MODIFIERS_NAME("ERR_25001_CANNOT_MODIFY__MODIFIERS_NAME"), + // apacheds-interceptors-ppolicy errors 26000 - 26999 // No error @@ -518,8 +523,6 @@ public enum I18n ERR_1("ERR_1"), ERR_7("ERR_7"), - ERR_30("ERR_30"), - ERR_31("ERR_31"), ERR_32("ERR_32"), ERR_36("ERR_36"), ERR_37("ERR_37"), @@ -626,7 +629,6 @@ public enum I18n ERR_249("ERR_249"), ERR_254_ADD_EXISTING_VALUE("ERR_254_ADD_EXISTING_VALUE"), ERR_259("ERR_259"), - ERR_261("ERR_261"), ERR_262("ERR_262"), ERR_269("ERR_269"), ERR_270("ERR_270"), diff --git a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties index 9c1a0e17a4..79bd05aa1f 100644 --- a/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties +++ b/i18n/src/main/resources/org/apache/directory/server/i18n/errors.properties @@ -333,10 +333,15 @@ ERR_19004_CANNOT_ALLOW_SUBSCHEMA_SUBENTRY_MOVE=Can not allow the move of the sub # --- no error --- # apacheds-interceptors-normalization errors 23000 - 23999 +ERR_23000_FAILED_TO_EXPAND_NODE=Failed to expand node + # apacheds-interceptors-number errors 24000 - 24999 # --- no error --- # apacheds-interceptors-operational errors 25000 - 25999 +ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE=The {0} operational attribute cannot be modified by a user +ERR_25001_CANNOT_MODIFY__MODIFIERS_NAME=The ModifiersName operational attribute cannot be modified by a user + # apacheds-interceptors-ppolicy errors 26000 - 26999 # --- no error --- @@ -508,8 +513,6 @@ ERR_49045_SCOPE_NODE_NOT_IN_SUBTREE_SCOPE=ScopeNode is not of subtree scope. ERR_1=Failed to identify OID for: {0} ERR_7=Cannot create a digested password for algorithm ''{0}'' -ERR_30=The {0} operational attribute cannot be modified by a user -ERR_31=The ModifiersName operational attribute cannot be modified by a user ERR_32=The ModifyTimestamp operational attribute cannot be modified by a user ERR_36=An LDAPURL should not contains a scope ERR_37=An LDAPURL should not contains filters @@ -641,7 +644,6 @@ ERR_226=[33] aliasProblem - the alias when dereferenced would not name a known o ERR_249=The global schema subentry cannot be added since it exists by default. ERR_254_ADD_EXISTING_VALUE=Trying to add existing value ''{0}'' to attribute {1} ERR_259=Attempt to search under non-existant entry\: -ERR_261=Failed to expand node ERR_262=System partition has wrong name: should be ''system'' not ''{0}''. ERR_269=userRoot() in org.apache.directory.server.prefs.ServerPreferencesFactory not implemented! ERR_270=Failed to set up node. diff --git a/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java b/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java index ad29e95fd4..8170f00831 100644 --- a/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java +++ b/interceptors/normalization/src/main/java/org/apache/directory/server/core/normalization/ExpandingVisitor.java @@ -187,8 +187,8 @@ else if ( leaf instanceof SubstringNode ) } catch ( LdapException e ) { - // log something here and throw a runtime excpetion - throw new RuntimeException( I18n.err( I18n.ERR_261 ) ); + // log something here and throw a runtime exception + throw new RuntimeException( I18n.err( I18n.ERR_23000_FAILED_TO_EXPAND_NODE ) ); } } else diff --git a/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java b/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java index aa89d08c3b..f10bcf3265 100644 --- a/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java +++ b/interceptors/operational/src/main/java/org/apache/directory/server/core/operational/OperationalAttributeInterceptor.java @@ -247,7 +247,7 @@ private boolean checkAddOperationalAttribute( boolean isAdmin, Entry entry, Attr if ( !isAdmin ) { // Wrong ! - String message = I18n.err( I18n.ERR_30, attribute ); + String message = I18n.err( I18n.ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE, attribute ); LOG.error( message ); throw new LdapNoPermissionException( message ); } @@ -383,7 +383,7 @@ public void modify( ModifyOperationContext modifyContext ) throws LdapException { if ( !isAdmin ) { - String message = I18n.err( I18n.ERR_31 ); + String message = I18n.err( I18n.ERR_25001_CANNOT_MODIFY__MODIFIERS_NAME ); LOG.error( message ); throw new LdapNoPermissionException( message ); } @@ -397,7 +397,7 @@ public void modify( ModifyOperationContext modifyContext ) throws LdapException { if ( !isAdmin ) { - String message = I18n.err( I18n.ERR_30, attributeType ); + String message = I18n.err( I18n.ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE, attributeType ); LOG.error( message ); throw new LdapNoPermissionException( message ); } @@ -411,7 +411,7 @@ public void modify( ModifyOperationContext modifyContext ) throws LdapException { if ( !isAdmin ) { - String message = I18n.err( I18n.ERR_30, attributeType ); + String message = I18n.err( I18n.ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE, attributeType ); LOG.error( message ); throw new LdapNoPermissionException( message ); } @@ -423,7 +423,7 @@ public void modify( ModifyOperationContext modifyContext ) throws LdapException if ( PWD_POLICY_STATE_ATTRIBUTE_TYPES.contains( attributeType ) && !isAdmin ) { - String message = I18n.err( I18n.ERR_30, attributeType ); + String message = I18n.err( I18n.ERR_25000_CANNOT_MODIFY_OPERATIONAL_ATTRIBUTE, attributeType ); LOG.error( message ); throw new LdapNoPermissionException( message ); }