5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay/*
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay *
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * Copyright (c) 2014 ForgeRock AS. All Rights Reserved
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay *
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * The contents of this file are subject to the terms
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * of the Common Development and Distribution License
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * (the License). You may not use this file except in
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * compliance with the License.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay *
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * You can obtain a copy of the License at
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * http://forgerock.org/license/CDDLv1.0.html
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * See the License for the specific language governing
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * permission and limitations under the License.
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay *
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * When distributing Covered Code, include this CDDL
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * Header Notice in each file and include the License file
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * at http://forgerock.org/license/CDDLv1.0.html
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * If applicable, add the following below the CDDL Header,
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * with the fields enclosed by brackets [] replaced by
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * your own identifying information:
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay * "Portions Copyrighted [year] [name of copyright owner]"
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay */
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport groovyx.net.http.RESTClient
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.apache.http.client.HttpClient
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.forgerock.openicf.connectors.scriptedrest.ScriptedRESTConfiguration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.forgerock.openicf.misc.scriptedcommon.OperationType
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.identityconnectors.common.logging.Log
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.identityconnectors.framework.common.objects.AttributeInfoBuilder
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport org.identityconnectors.framework.common.objects.ObjectClass
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_CREATABLE
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_READABLE
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_RETURNED_BY_DEFAULT
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayimport static org.identityconnectors.framework.common.objects.AttributeInfo.Flags.NOT_UPDATEABLE
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef operation = operation as OperationType
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef configuration = configuration as ScriptedRESTConfiguration
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef httpClient = connection as HttpClient
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef connection = customizedConnection as RESTClient
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef log = log as Log
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaylog.info("Entering " + operation + " Script");
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// Declare the __ACCOUNT__ attributes
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// _id
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef idAIB = new AttributeInfoBuilder("__NAME__", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayidAIB.setRequired(true);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayidAIB.setCreateable(true);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayidAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayidAIB.setUpdateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// userName
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef userNameAIB = new AttributeInfoBuilder("userName", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayuserNameAIB.setCreateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayuserNameAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayuserNameAIB.setUpdateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// displayName
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef displayNameAIB = new AttributeInfoBuilder("displayName", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaydisplayNameAIB.setRequired(true);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaydisplayNameAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// group displayName
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef grpDisplayNameAIB = new AttributeInfoBuilder("displayName", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaygrpDisplayNameAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaygrpDisplayNameAIB.setCreateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaygrpDisplayNameAIB.setUpdateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// familyName
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef familyNameAIB = new AttributeInfoBuilder("familyName", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayfamilyNameAIB.setRequired(true);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayfamilyNameAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// givenName
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef givenNameAIB = new AttributeInfoBuilder("givenName", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaygivenNameAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// telephoneNumber
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef telephoneNumberAIB = new AttributeInfoBuilder("telephoneNumber", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaytelephoneNumberAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// emailAddress
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef emailAddressAIB = new AttributeInfoBuilder("emailAddress", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemayemailAddressAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// members
1c6f894b8df0697f8689142b3e866c575efed9ebJason Lemaydef membersAIB = new AttributeInfoBuilder("members", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaymembersAIB.setMultiValued(true);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay// groups
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef groupsAIB = new AttributeInfoBuilder("groups", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaygroupsAIB.setMultiValued(true);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay//created
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef createdAIB = new AttributeInfoBuilder("created", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaycreatedAIB.setCreateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaycreatedAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaycreatedAIB.setUpdateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay//lastModified
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaydef lastModifiedAIB = new AttributeInfoBuilder("lastModified", String.class);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaylastModifiedAIB.setCreateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaylastModifiedAIB.setMultiValued(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason LemaylastModifiedAIB.setUpdateable(false);
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemayreturn builder.schema({
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay objectClass {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay type ObjectClass.ACCOUNT_NAME
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute idAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute userNameAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute displayNameAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute familyNameAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute givenNameAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute telephoneNumberAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute emailAddressAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute groupsAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute createdAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute lastModifiedAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute "password", String.class, EnumSet.of(NOT_RETURNED_BY_DEFAULT, NOT_UPDATEABLE, NOT_READABLE)
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay }
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay objectClass {
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay type ObjectClass.GROUP_NAME
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute idAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute grpDisplayNameAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute createdAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute lastModifiedAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay attribute membersAIB.build()
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay }
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay})
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemay
5f22ff8ce7baf0b39668468cc854eec3eb946003Jason Lemaylog.info("Schema script done");