[OPENIDM-9143] Backport OPENIDM-7669: When defining an array type in configuration, the type specified for the items is ignored Created: 01/Sep/17  Updated: 13/Feb/18  Resolved: 13/Feb/18

Status: Closed
Project: OpenIDM
Component/s: Module - Provisioner framework
Affects Version/s: OpenIDM 5.0.0
Fix Version/s: OpenIDM 5.0.0.1

Type: Bug Priority: Minor
Reporter: Chris Drake Assignee: Chris Drake
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Backport
is a backport of OPENIDM-7669 When defining an array type in config... Closed
Target Version/s:
Verified Version/s:

 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


 Comments   
Comment by Chris Drake [ 01/Sep/17 ]

commit 20e36e2a355754e94cd19ab6ff6d921a103c063b

Comment by Jakub Janoska [ 09/Nov/17 ]

Verified onĀ OpenIDM version "5.0.1-SNAPSHOT" (revision: 3508864) jenkins-OpenIDM - 5.0.x - postcommit-137 origin/sustaining/5.0.x.

Type for the items is correct now. Log from described example:

Nov 09, 2017 10:02:07 AM org.slf4j.Logger$info$0 call
INFO: Source: [e1NTSEE1MTJ9UjR2aCtlemVaVUUxeTNrQytuRUFXenordm5QdHhsM2ppMEdMR1VBcVJnQUIyanVPOXJOa05XdVpJOC8xSSt0TXN0T25wZU9oc1lMNmVCRkp4NDM1T1FTbytZVW8wclZn] Class: class java.util.ArrayList
Nov 09, 2017 10:02:07 AM org.slf4j.Logger$info$0 call
INFO: Value: e1NTSEE1MTJ9UjR2aCtlemVaVUUxeTNrQytuRUFXenordm5QdHhsM2ppMEdMR1VBcVJnQUIyanVPOXJOa05XdVpJOC8xSSt0TXN0T25wZU9oc1lMNmVCRkp4NDM1T1FTbytZVW8wclZn Class: class java.lang.String
Comment by Mark Offutt [ 13/Feb/18 ]

Reopening to adjust Fix Version field

Generated at Wed Feb 20 21:25:41 GMT 2019 using Jira 7.13.0#713000-sha1:fbf406879436de2f3fb1cfa09c7fa556fb79615a.