[ 
https://issues.apache.org/jira/browse/DIRSERVER-2250?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16612144#comment-16612144
 ] 

Emmanuel Lecharny edited comment on DIRSERVER-2250 at 9/12/18 1:48 PM:
-----------------------------------------------------------------------

The character unicode seems to be {{E81B}}, can you confirm that using '\uE81B' 
in the java code works, like in :
{code:java}
new Value(new AttributeType("1.3.6.1.4.1.1466.115.121.1.15"), "\uE81B" );
{code}

Otherwise, your test is not going to work anyway... The defined 
{{AttributeType}} lacks a {{LdapSyntax}} and the associated {{SyntaxChecker}} 
that would make it valid. It should be something like :

{code:java}
        MutableAttributeType attributeType = new MutableAttributeType( 
"1.2.3.4" );
        attributeType.setSyntax( new LdapSyntax( 
"1.3.6.1.4.1.1466.115.121.1.15" ) );
        attributeType.getSyntax().setSyntaxChecker( 
DirectoryStringSyntaxChecker.INSTANCE );
        
        new Value( attributeType, "\uE81B" ); // instead of         new Value( 
attributeType, "" );
{code}

This code works, *but*... If you use a {{schemaManager}} instance to 
instanciate a value for the {{SN}} attributeType, as in your LDIF file :

{code:java}
public class SchemaAwareAttributeTest
{
    private AttributeType atCN = null;
    private AttributeType atDC;
    private AttributeType atSN;
...
    private static SchemaManager schemaManager;
...
    @BeforeClass
    public static void startup() throws Exception
    {
        schemaManager = new DefaultSchemaManager();
    }


    /**
     * Initialize the schemaManager
     */
    @Before
    public void setup() throws Exception
    {
        atCN = schemaManager.getAttributeType( "cn" );
        atDC = schemaManager.lookupAttributeTypeRegistry( "dc" );
        atC = schemaManager.lookupAttributeTypeRegistry( "c" );
        atSN = schemaManager.lookupAttributeTypeRegistry( "sn" );
        atPwd = schemaManager.lookupAttributeTypeRegistry( "userpassword" );
        atEMail = schemaManager.lookupAttributeTypeRegistry( "email" );
        atName = schemaManager.lookupAttributeTypeRegistry( "name" );
    }
...
    @Test
    public void testSnWithChineseChar() throws LdapException, IOException, 
ClassNotFoundException
    {
        Value snValue = new Value( atSN, "\uE81B" );
    }
{code}

then you will get an error. And this is expected...

When we process a String, we go through what is called the {{String 
Preparation}}, aka {{stringprep}} as defined in [RFC 
4518|https://tools.ietf.org/html/rfc4518]. This processing involves 6 steps, 
described in par. 2:
{noformat}
      1) Transcode
      2) Map
      3) Normalize
      4) Prohibit
      5) Check bidi
      6) Insignificant Character Handling
{noformat}

The forth step, {{prohibit}}, says that :

{norformat}
Private Use code points are prohibited.  These characters are listed in Table 
C.3 of [RFC3454].
{noformat}

Table C3 is :

{noformat}
C.3 Private use

   ----- Start Table C.3 -----
   E000-F8FF; [PRIVATE USE, PLANE 0]
   F0000-FFFFD; [PRIVATE USE, PLANE 15]
   100000-10FFFD; [PRIVATE USE, PLANE 16]
   ----- End Table C.3 -----
{noformat}

As you can see, {{E81B}} belongs to this table thus the rejection.

Now, the implementation might be overdoing here...


was (Author: elecharny):
The character unicode seems to be {{E81B}}, can you confirm that using '\uE81B' 
in the java code works, like in :
{code:java}
new Value(new AttributeType("1.3.6.1.4.1.1466.115.121.1.15"), "\uE81B" );
{code}

Otherwise, your test is not going to work anyway... The defined 
{{AttributeType}} lacks a {{LdapSyntax}} and the associated {{SyntaxChecker}} 
that would make it valid. It should be something like :

{code:java}
        MutableAttributeType attributeType = new MutableAttributeType( 
"1.2.3.4" );
        attributeType.setSyntax( new LdapSyntax( 
"1.3.6.1.4.1.1466.115.121.1.15" ) );
        attributeType.getSyntax().setSyntaxChecker( 
DirectoryStringSyntaxChecker.INSTANCE );
        
        new Value( attributeType, "\uE81B" ); // instead of         new Value( 
attributeType, "" );
{code}

This code works, *but*... If you use a {{schemaManager}} instance to 
instanciate a value for the {{SN}} attributeType, as in your LDIF file :

{code:java}
public class SchemaAwareAttributeTest
{
    private AttributeType atCN = null;
    private AttributeType atDC;
    private AttributeType atSN;
...
    private static SchemaManager schemaManager;
...
    @BeforeClass
    public static void startup() throws Exception
    {
        schemaManager = new DefaultSchemaManager();
    }


    /**
     * Initialize the schemaManager
     */
    @Before
    public void setup() throws Exception
    {
        atCN = schemaManager.getAttributeType( "cn" );
        atDC = schemaManager.lookupAttributeTypeRegistry( "dc" );
        atC = schemaManager.lookupAttributeTypeRegistry( "c" );
        atSN = schemaManager.lookupAttributeTypeRegistry( "sn" );
        atPwd = schemaManager.lookupAttributeTypeRegistry( "userpassword" );
        atEMail = schemaManager.lookupAttributeTypeRegistry( "email" );
        atName = schemaManager.lookupAttributeTypeRegistry( "name" );
    }
...
    @Test
    public void testSnWithChineseChar() throws LdapException, IOException, 
ClassNotFoundException
    {
        Value snValue = new Value( atSN, "\uE81B" );
    }
{code}

then you will get an error. And this is expected...

When we process a String, we go through what is called the {{String 
Preparation}}, aka {{stringprep}} as defined in [RFC 
4518|https://tools.ietf.org/html/rfc4518]. This processing involves 6 steps, 
described in par. 2:
{norformat}
      1) Transcode
      2) Map
      3) Normalize
      4) Prohibit
      5) Check bidi
      6) Insignificant Character Handling
{noformat}

The forth step, {{prohibit}}, says that :

{norformat}
Private Use code points are prohibited.  These characters are listed in Table 
C.3 of [RFC3454].
{noformat}

Table C3 is :

{noformat}
C.3 Private use

   ----- Start Table C.3 -----
   E000-F8FF; [PRIVATE USE, PLANE 0]
   F0000-FFFFD; [PRIVATE USE, PLANE 15]
   100000-10FFFD; [PRIVATE USE, PLANE 16]
   ----- End Table C.3 -----
{noformat}

As you can see, {{E81B}} belongs to this table thus the rejection.

Now, the implementation might be overdoing here...

> ERR_13724_INVALID_VALUE Invalid value for some Chinese characters
> -----------------------------------------------------------------
>
>                 Key: DIRSERVER-2250
>                 URL: https://issues.apache.org/jira/browse/DIRSERVER-2250
>             Project: Directory ApacheDS
>          Issue Type: Bug
>    Affects Versions: 2.0.0.AM25
>            Reporter: li
>            Priority: Major
>         Attachments: error-test.ldif
>
>
> example:  chinese character   (UTF-8 value \ue81b can't be used as the 
> Directory String value. But it is OK for version 2.0.0.M24
> The error message is following
> Error while executing LDIF
>  - [LDAP: error code 80 - OTHER: failed for MessageType : MODIFY_REQUES
>  java.lang.Exception: [LDAP: error code 80 - OTHER: failed for MessageType : 
> MODIFY_REQUEST
> Message ID : 25474
>  Modify Request
>  Object : 'ou=000030,cn=orgs,dc=citics,dc=com'
>  Modification[0]
>  Operation : replace
>  Modification
> description: 
> *{color:#FF0000}{color}*org.apache.directory.api.ldap.model.message.ModifyRequestImpl@c7661fbb:
>  ERR_13247_INVALID_VALUE_CANT_NORMALIZE Invalid upValue, it cant be 
> normalized:
> java.lang.IllegalArgumentException: ERR_13247_INVALID_VALUE_CANT_NORMALIZE 
> Invalid upValue, it cant be normalized
>  at org.apache.directory.api.ldap.model.entry.Value.<init>(Value.java:275)
>  at 
> org.apache.directory.api.ldap.model.entry.DefaultAttribute.<init>(DefaultAttribute.java:423)
>  at 
> org.apache.directory.server.core.api.entry.ServerEntryUtils.toServerModification(ServerEntryUtils.java:464)
>  at 
> org.apache.directory.server.core.api.entry.ServerEntryUtils.toServerModification(ServerEntryUtils.java:510)
>  at 
> org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext.<init>(ModifyOperationContext.java:115)
>  at 
> org.apache.directory.server.core.shared.DefaultCoreSession.modify(DefaultCoreSession.java:1028)
>  at 
> org.apache.directory.server.core.shared.DefaultCoreSession.modify(DefaultCoreSession.java:1018)
>  at 
> org.apache.directory.server.ldap.handlers.request.ModifyRequestHandler.handle(ModifyRequestHandler.java:56)
>  at 
> org.apache.directory.server.ldap.handlers.request.ModifyRequestHandler.handle(ModifyRequestHandler.java:39)
>  at 
> org.apache.directory.server.ldap.handlers.LdapRequestHandler.handleMessage(LdapRequestHandler.java:207)
>  at 
> org.apache.directory.server.ldap.handlers.LdapRequestHandler.handleMessage(LdapRequestHandler.java:56)
>  at 
> org.apache.mina.handler.demux.DemuxingIoHandler.messageReceived(DemuxingIoHandler.java:243)
>  at 
> org.apache.directory.server.ldap.LdapProtocolHandler.messageReceived(LdapProtocolHandler.java:223)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:1019)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1141)
>  at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:87)
>  at org.apache.mina.core.session.IoEvent.run(IoEvent.java:88)
>  at 
> org.apache.mina.filter.executor.UnorderedThreadPoolExecutor$Worker.runTask(UnorderedThreadPoolExecutor.java:541)
>  at 
> org.apache.mina.filter.executor.UnorderedThreadPoolExecutor$Worker.run(UnorderedThreadPoolExecutor.java:493)
>  at java.lang.Thread.run(Thread.java:748)
> ]
>  at 
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.checkResponse(DirectoryApiConnectionWrapper.java:1374)
>  at 
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.access$9(DirectoryApiConnectionWrapper.java:1342)
>  at 
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper$4.run(DirectoryApiConnectionWrapper.java:736)
>  at 
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.runAndMonitor(DirectoryApiConnectionWrapper.java:1269)
>  at 
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.checkConnectionAndRunAndMonitor(DirectoryApiConnectionWrapper.java:1205)
>  at 
> org.apache.directory.studio.connection.core.io.api.DirectoryApiConnectionWrapper.modifyEntry(DirectoryApiConnectionWrapper.java:758)
>  at 
> org.apache.directory.studio.ldapbrowser.core.jobs.ImportLdifRunnable.importLdifRecord(ImportLdifRunnable.java:515)
>  at 
> org.apache.directory.studio.ldapbrowser.core.jobs.ImportLdifRunnable.importLdif(ImportLdifRunnable.java:272)
>  at 
> org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable.executeLdif(ExecuteLdifRunnable.java:157)
>  at 
> org.apache.directory.studio.ldapbrowser.core.jobs.ExecuteLdifRunnable.run(ExecuteLdifRunnable.java:123)
>  at 
> org.apache.directory.studio.ldapbrowser.core.jobs.UpdateEntryRunnable.run(UpdateEntryRunnable.java:59)
>  at 
> org.apache.directory.studio.connection.ui.RunnableContextRunner$1.run(RunnableContextRunner.java:116)
>  at 
> org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
> [LDAP: error code 80 - OTHER: failed for MessageType : MODIFY_REQUEST
> Message ID : 25474
>  Modify Request
>  Object : 'ou=000030,cn=orgs,dc=citics,dc=com'
>  Modification[0]
>  Operation : replace
>  Modification
> description: 
> 稽核审计部org.apache.directory.api.ldap.model.message.ModifyRequestImpl@c7661fbb: 
> ERR_13247_INVALID_VALUE_CANT_NORMALIZE Invalid upValue, it cant be normalized:
> java.lang.IllegalArgumentException: ERR_13247_INVALID_VALUE_CANT_NORMALIZE 
> Invalid upValue, it cant be normalized
>  at org.apache.directory.api.ldap.model.entry.Value.<init>(Value.java:275)
>  at 
> org.apache.directory.api.ldap.model.entry.DefaultAttribute.<init>(DefaultAttribute.java:423)
>  at 
> org.apache.directory.server.core.api.entry.ServerEntryUtils.toServerModification(ServerEntryUtils.java:464)
>  at 
> org.apache.directory.server.core.api.entry.ServerEntryUtils.toServerModification(ServerEntryUtils.java:510)
>  at 
> org.apache.directory.server.core.api.interceptor.context.ModifyOperationContext.<init>(ModifyOperationContext.java:115)
>  at 
> org.apache.directory.server.core.shared.DefaultCoreSession.modify(DefaultCoreSession.java:1028)
>  at 
> org.apache.directory.server.core.shared.DefaultCoreSession.modify(DefaultCoreSession.java:1018)
>  at 
> org.apache.directory.server.ldap.handlers.request.ModifyRequestHandler.handle(ModifyRequestHandler.java:56)
>  at 
> org.apache.directory.server.ldap.handlers.request.ModifyRequestHandler.handle(ModifyRequestHandler.java:39)
>  at 
> org.apache.directory.server.ldap.handlers.LdapRequestHandler.handleMessage(LdapRequestHandler.java:207)
>  at 
> org.apache.directory.server.ldap.handlers.LdapRequestHandler.handleMessage(LdapRequestHandler.java:56)
>  at 
> org.apache.mina.handler.demux.DemuxingIoHandler.messageReceived(DemuxingIoHandler.java:243)
>  at 
> org.apache.directory.server.ldap.LdapProtocolHandler.messageReceived(LdapProtocolHandler.java:223)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$TailFilter.messageReceived(DefaultIoFilterChain.java:1019)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.callNextMessageReceived(DefaultIoFilterChain.java:650)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain.access$1300(DefaultIoFilterChain.java:49)
>  at 
> org.apache.mina.core.filterchain.DefaultIoFilterChain$EntryImpl$1.messageReceived(DefaultIoFilterChain.java:1141)
>  at org.apache.mina.core.filterchain.IoFilterEvent.fire(IoFilterEvent.java:87)
>  at org.apache.mina.core.session.IoEvent.run(IoEvent.java:88)
>  at 
> org.apache.mina.filter.executor.UnorderedThreadPoolExecutor$Worker.runTask(UnorderedThreadPoolExecutor.java:541)
>  at 
> org.apache.mina.filter.executor.UnorderedThreadPoolExecutor$Worker.run(UnorderedThreadPoolExecutor.java:493)
>  at java.lang.Thread.run(Thread.java:748)
> ]



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to