Uploaded image for project: 'OpenIDM'
  1. OpenIDM
  2. OPENIDM-9143

Backport OPENIDM-7669: When defining an array type in configuration, the type specified for the items is ignored

    Details

      Description

      When defining an array type in configuration, the type specified for the items is ignored rather than being coerced to the defined type. To replicate this, use Sample2b and modify userPassword to:

      Provisioner File
                      "userPassword" : { 
      			"type" : "array", 
      			"items" : { 
      				"type" : "string",
      				"nativeType" : "JAVA_TYPE_BYTE_ARRAY" 
      			}, 
      			"nativeName" : "userPassword", 
      			"nativeType" : "JAVA_TYPE_BYTE_ARRAY" 
      		},
      

      And add a transformation script to the userPassword during sync to log it out (for testing):

      sync.json
                      {
                        "source" : "userPassword",
                        "target" : "userPassword",
                        "transform" : {
                          "type" : "groovy",
                          "file" : "script/testScript.groovy"
                        }
                      },
      
      testScript.groovy
      import org.slf4j.*;
      def logger = LoggerFactory.getLogger('logger');
      logger.info('Source: {} Class: {}', source, source.getClass());
      def value = (source instanceof List ? source.first() : source);
      logger.info('Value: {} Class: {}', value, value.getClass());
      source;
      
      testScript.js
      logger.info('Source: {} Class: {}', source, typeof source);
      value = source[0];
      logger.info('Value: {} Class: {}', value, typeof value);
      source;
      

      When querying the user object via REST on the system end-point, you'll see the userPassword value(s) as base64 encoded strings, as you would expect:

      {
        "_id": "uid=jdoe,ou=People,dc=example,dc=com",
        "dn": "uid=jdoe,ou=People,dc=example,dc=com",
        "description": "Created for OpenIDM",
        "employeeType": null,
        "disabled": null,
        "sn": "Doe",
        "mail": "jdoe@example.com",
        "givenName": "John",
        "userPassword": [
          "e1NTSEF9Y09rVy9hbTVzeFBYa0hnQkJnMllxL0NEdVZ2OVdPYzB3c0o5T0E9PQ==",
          "e1NTSEF9Q0VyWXUyRHZPZmxBLzc3cktrdndaejBzV1k1Yk1jKzZYOUZFN3c9PQ=="
        ],
        "telephoneNumber": "1-415-599-1100",
        "uid": "jdoe",
        "ldapGroups": [
          "cn=openidm,ou=Groups,dc=example,dc=com"
        ],
        "cn": "John Doe"
      }
      

      However, when running the synchronisation, the log file output will show a Java Byte Array as the source value(s):

          Feb 17, 2017 12:42:01 PM org.slf4j.Logger$info call
          INFO: Source: [[B@3b6738a1, [B@75b6f07e] Class: class java.util.ArrayList
          Feb 17, 2017 12:42:01 PM org.slf4j.Logger$info call
          INFO: Value: [123, 83, 83, 72, 65, 125, 99, 79, 107, 87, 47, 97, 109, 53, 115, 120, 80, 88, 107, 72, 103, 66, 66, 103, 50, 89, 113, 47, 67, 68, 117, 86, 118, 57, 87, 79, 99, 48, 119, 115, 74, 57, 79, 65, 61, 61] Class: class [B
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                cgdrake Chris Drake
                Reporter:
                cgdrake Chris Drake
              • Votes:
                0 Vote for this issue
                Watchers:
                3 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: