User Manager Java API Quick Start (SOAP) user-manager-java-api-quick-start-soap
Java API Quick Start(SOAP) is available for the User Manager API.
Quick Start (SOAP mode): Adding users using the Java API
Quick Start (SOAP mode): Deleting users using the Java API
Quick Start (SOAP mode): Creating Groups using the Java API
Quick Start (SOAP mode): Managing users and groups using the Java API
Quick Start (SOAP mode): Managing roles and permissions using the Java API
Quick Start (SOAP mode): Programmatically synchronizing users using the Java API
Quick Start (SOAP mode): Programmatically managing the Preferences Nodes using the Java API
AEM Forms operations can be performed using the AEM Forms strongly typed API and the connection mode should be set to SOAP.
Quick Start (SOAP mode): Adding users using the Java API quick-start-soap-mode-adding-users-using-the-java-api
The following code example adds a user named Wendy Blue to AEM Forms. (See Adding Users.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βimport com.adobe.idp.um.api.infomodel.impl.*;
βimport com.adobe.idp.um.api.infomodel.*;
βpublic class AddUser {
β public static void main(String[] args) {
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β //Create a ServiceClientFactory object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an DirectoryManagerServiceClient object
β DirectoryManagerServiceClient dmClient = new DirectoryManagerServiceClient(myFactory);
β //Create a User object and populate its attributes
β UserImpl u = new UserImpl();
β u.setDomainName("DefaultDom");
β u.setUserid("wblue");
β u.setCanonicalName("wblue");
β u.setPrincipalType("USER");
β u.setGivenName("Wendy");
β u.setFamilyName("Blue");
β u.setLocale(Locale.CANADA);
β u.setTimezone(TimeZone.getDefault());
β u.setDisabled(false);
β //Add the User to the system using the DirectoryManagerServiceClient
β dmClient.createLocalUser(u,"password");
β //Ensure that the user was added
β //Create a PrincipalSearchFilter to find the user by ID
β PrincipalSearchFilter psf = new PrincipalSearchFilter();
β psf.setUserId("wblue");
β List<User> principalList = dmClient.findPrincipals(psf);
β Iterator<User> pit = principalList.iterator();
β if(pit.hasNext()){
β User theUser = pit.next();
β System.out.println("User ID: " + theUser.getUserid());
β System.out.println("User name: " + theUser.getGivenName() +" "+ theUser.getFamilyName());
β System.out.println("User Domain: " + theUser.getDomainName());
β System.out.println("is user disabled?: " + theUser.isDisabled());
β }
β }catch (Exception e) {
β e.printStackTrace();
β }
β;
β }
β}
Quick Start (SOAP mode): Deleting users using the Java API quick-start-soap-mode-deleting-users-using-the-java-api
The following code example deletes a user named Wendy Blue from AEM Forms. (See Deleting Users.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.idp.um.api.infomodel.PrincipalSearchFilter;
βimport com.adobe.idp.um.api.infomodel.User;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βpublic class DeleteUser {
β public static void main(String[] args) {
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, ServiceClientFactoryProperties.DSC_JBOSS_SERVER_TYPE);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β // Create a ServiceClientFactory object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β // Create a DirectoryManagerServiceClient object
β DirectoryManagerServiceClient dm = new DirectoryManagerServiceClient(myFactory);
β //Find the target user by the user ID value
β PrincipalSearchFilter psf = new PrincipalSearchFilter();
β psf.setUserId("wblue");
β List<User> principalList = dm.findPrincipals(psf);
β Iterator<User> pit = principalList.iterator();
β //Delete the user
β while(pit.hasNext()){
β User targetUser = pit.next();
β dm.deleteLocalUser(targetUser.getOid());
β }
β } catch (Exception e) {
β e.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Managing users and groups using the Java API quick-start-soap-mode-managing-users-and-groups-using-the-java-api
The following code example finds a local user and the local group to which the user belongs. (See Managing Users and Groups.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM FOrms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.um.api.infomodel.*;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class ManageUsersAndGroupsTest
β{
β public static void main(String[] args) {
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β //Create a ServiceClientFactory object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β // Create an DirectoryManagerServiceClient object
β DirectoryManagerServiceClient dirClient = new DirectoryManagerServiceClient(myFactory);
β // Find a local user
β PrincipalSearchFilter psf = new PrincipalSearchFilter();
β psf.setUserId("wblue");
β List principalList = dirClient.findPrincipals(psf);
β Iterator pit = principalList.iterator();
β String oid = "";
β User testUser = null;
β if (pit.hasNext())
β {
β // Obtain the principalβs object identifier
β testUser = (User)(pit.next());
β }
β // Find the local group
β Set groupMemberships = testUser.getGroupMemberships();
β Iterator git = groupMemberships.iterator();
β Group localGroup = null;
β if (git.hasNext())
β {
β // Obtain the group to which the user belongs
β localGroup = (Group)(git.next());
β }
β // Determine the domain and the group to which the local user belongs
β String verifyCanonicalName = testUser.getCanonicalName();
β Domain verifyDomain = dirClient.findDomain(testUser.getDomainName());
β String verifyDomainName = verifyDomain.getDomainName();
β Group verifyGroup = dirClient.getDomainAsGroup(verifyDomainName);
β String verifyGroupName = verifyGroup.getCanonicalName();
β // Print the uniquely identifying information about the user
β System.out.println("User name: " + verifyCanonicalName);
β System.out.println("Group name: " + verifyGroupName);
β System.out.println("Domain names should match: " + verifyDomainName + ", "+ testUser.getDomainName());
β }
β catch (Exception e)
β {
β System.out.println("Error occurred: " + e.getMessage());
β }
β }
β}
Quick Start (SOAP mode): Managing roles and permissions using the Java API quick-start-soap-mode-managing-roles-and-permissions-using-the-java-api
The following code example assigns the Services User role to a principal, prints the roles the principal has, and subsequently removes the role from the principal. Two services are invoked for this quick start: the DirectoryManager service and the AuthorizationManager service.(See Managing Roles and Permissions.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.um.api.infomodel.*;
βimport com.adobe.livecycle.usermanager.client.AuthorizationManagerServiceClient;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βpublic class ManageRolesAndPermissionsTest
β{
β public static void main(String[] args) {
β try{
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β //Create a ServiceClientFactory object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β // Create an AuthorizationManagerServiceClient object
β AuthorizationManagerServiceClient amClient = new AuthorizationManagerServiceClient(myFactory);
β // Retrieve a principal
β DirectoryManagerServiceClient dirClient = new DirectoryManagerServiceClient(myFactory);
β PrincipalSearchFilter psf = new PrincipalSearchFilter();
β psf.setUserId("wblue");
β List principalList = dirClient.findPrincipals(psf);
β Iterator pit = principalList.iterator();
β String oid = "";
β if (pit.hasNext())
β {
β // Obtain the principalβs object identifier
β oid = ((User)pit.next()).getOid();
β String[] principalOids = new String[1];
β principalOids[0] = oid;
β //Obtain the roles to be assigned
β RoleSearchFilter rsf = new RoleSearchFilter();
β rsf.setRoleName("Services User");
β List roleList = amClient.findRoles(rsf);
β Iterator rit = roleList.iterator();
β String roleId1 = "";
β if (rit.hasNext())
β {
β // Obtain the role identifier
β roleId1 = ((Role)rit.next()).getId();
β // Assign the role to the principal
β amClient.assignRole(roleId1, principalOids);
β }
β else
β {
β System.out.println("Role not found");
β }
β // Determine which roles the principal has
β Set roleSet = amClient.findRolesForPrincipal(oid);
β // Print the roles the principal has
β Iterator it = roleSet.iterator();
β Role r = null;
β System.out.println("Roles:");
β while (it.hasNext())
β {
β r = ((Role)it.next());
β System.out.println(r.getName());
β }
β // Remove a role from the principal
β //amClient.unassignRole(roleId1, principalOids);
β }
β else
β {
β System.out.println("Principal not found");
β }
β }catch (Exception e) {
β e.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Programmatically synchronizing users using the Java API quick-start-soap-mode-programmatically-synchronizing-users-using-the-java-api
The following Java code example synchronizes users by using the User Management APIs. (See Programmatically Synchronizing Users.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β * 19. adobe-usermanager-util-client.jar
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βimport com.adobe.idp.um.api.DirectoryManager;
βimport com.adobe.idp.um.api.infomodel.DirectorySyncInfo;
βimport com.adobe.idp.um.dsc.util.client.UserManagerUtilServiceClient;
βpublic class SynchDomain {
β public static void main(String[] args) {
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β //Create a UserManagerUtilServiceClient object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β UserManagerUtilServiceClient umutil = new UserManagerUtilServiceClient(myFactory);
β //Specify the set of enterprise domains to synchronize
β Set<String> domainNames = new HashSet<String>();
β domainNames.add("adobe3");
β //Perform the synchronization operation on the set of enterprise domains specified above
β umutil.scheduleSynchronization(domainNames);
β //In case the synchronization needs to be performed on all the registered enterprise domains use this method umutil.scheduleSynchronization();
β DirectoryManager dm = new DirectoryManagerServiceClient(myFactory);
β Map<String, DirectorySyncInfo> synchStatus = dm.getDirectorySyncStatus(domainNames);
β String domainName = "adobe3";
β DirectorySyncInfo di = synchStatus.get(domainName);
β if(di.getSyncStatus() == DirectorySyncInfo.SYNCSTATUS_COMPLETED){
β System.out.println("Directory synch for domain "+domainName+" is complete");
β }
β }catch (Exception e) {
β e.printStackTrace();
β }
β }
β}
Quick Start (SOAP mode): Adding users using the Java API quick_start_soap_mode_adding_users_using_the_java_api-1
The following code example adds a user named Wendy Blue to AEM Forms. (See Adding Users.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.*;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βimport com.adobe.idp.um.api.infomodel.impl.*;
βimport com.adobe.idp.um.api.infomodel.*;
βpublic class AddUser {
β public static void main(String[] args) {
β try {
β //Set connection properties required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β //Create a ServiceClientFactory object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an DirectoryManagerServiceClient object
β DirectoryManagerServiceClient dmClient = new DirectoryManagerServiceClient(myFactory);
β //Create a User object and populate its attributes
β UserImpl u = new UserImpl();
β u.setDomainName("DefaultDom");
β u.setUserid("wblue");
β u.setCanonicalName("wblue");
β u.setPrincipalType("USER");
β u.setGivenName("Wendy");
β u.setFamilyName("Blue");
β u.setLocale(Locale.CANADA);
β u.setTimezone(TimeZone.getDefault());
β u.setDisabled(false);
β //Add the User to the system using the DirectoryManagerServiceClient
β dmClient.createLocalUser(u,"password");
β //Ensure that the user was added
β //Create a PrincipalSearchFilter to find the user by ID
β PrincipalSearchFilter psf = new PrincipalSearchFilter();
β psf.setUserId("wblue");
β List<User> principalList = dmClient.findPrincipals(psf);
β Iterator<User> pit = principalList.iterator();
β if(pit.hasNext()){
β User theUser = pit.next();
β System.out.println("User ID: " + theUser.getUserid());
β System.out.println("User name: " + theUser.getGivenName() +" "+ theUser.getFamilyName());
β System.out.println("User Domain: " + theUser.getDomainName());
β System.out.println("is user disabled?: " + theUser.isDisabled());
β }
β }catch (Exception e) {
β e.printStackTrace();
β }
β;
β }
β}
Quick Start (SOAP mode): Creating Groups using the Java API quick-start-soap-mode-creating-groups-using-the-java-api
The following code example creates a group named ΓΫΆΉΚΣΖ΅Group to AEM Forms. (See Creating Groups.)
β/*
β * This Java Quick Start uses the SOAP mode and contains the following JAR files
β * in the class path:
β * 1. adobe-livecycle-client.jar
β * 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β *
β * The JBoss files must be kept in the jboss\client folder. You can copy the client folder to
β * your local development environment and then include the 3 JBoss JAR files in your class path
β *
β * These JAR files are in the following path:
β * <install directory>/sdk/client-libs/common
β *
β *
β * <install directory>/jboss/bin/client
β *
β * If you want to invoke a remote Forms Server instance and there is a
β * firewall between the client application and the server, then it is
β * recommended that you use the SOAP mode. When using the SOAP mode,
β * you have to include additional JAR files in the following
β * path
β * <install directory>/sdk/client-libs/thirdparty
β *
β * For information about the SOAP
β * mode and the additional JAR files that need to be included,
β * see "Setting connection properties" in Programming
β * with AEM Forms
β *
β * For complete details about the location of the AEM Forms JAR files,
β * see "Including AEM Forms Java library files" in Programming
β * with AEM Forms
β */
βimport java.util.List;
βimport java.util.Properties;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
βimport com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
βimport com.adobe.idp.um.api.infomodel.Group;
βimport com.adobe.idp.um.api.infomodel.Principal;
βimport com.adobe.idp.um.api.infomodel.PrincipalSearchFilter;
βimport com.adobe.idp.um.api.infomodel.PrincipalReference;
βimport com.adobe.idp.um.api.infomodel.impl.GroupImpl;
βimport com.adobe.livecycle.usermanager.client.DirectoryManagerServiceClient;
βpublic class AddGroup {
β public static void main(String[] args) {
β try {
β //Set connection properties that are required to invoke AEM Forms
β Properties connectionProps = new Properties();
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
β connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
β //Create a ServiceClientFactory object
β ServiceClientFactory myFactory = ServiceClientFactory.createInstance(connectionProps);
β //Create an DirectoryManagerServiceClient object
β DirectoryManagerServiceClient dmClient = new DirectoryManagerServiceClient(myFactory);
β //Specify the group and domain name
β String groupName = "ΓΫΆΉΚΣΖ΅Group";
β String domainName = "TestDomain";
β //Check whether the group exists
β String groupOid = checkGroupExist(groupName, domainName,dmClient);
β //The group exists
β if(groupOid != null){
β System.out.println("The group exists");
β return;
β }
β //The group does not exist
β String groupCanonicalName = groupName;
β GroupImpl group = new GroupImpl();
β group.setCanonicalName(groupCanonicalName);
β group.setDomainName(domainName);
β group.setGroupType(Group.GROUPTYPE_PRINCIPALS);
β group.setLocal(true);
β group.setPrincipalType(Principal.PRINCIPALTYPE_GROUP);
β groupOid = dmClient.createLocalGroup(group);
β System.out.println("Sample group created with name "+groupName);
β }catch (Exception e) {
β e.printStackTrace();
β }
β }
β /**
β * Search for a group in the specified domain
β */
β private static String checkGroupExist(String groupName, String domainName, DirectoryManagerServiceClient directoryManager){
β try {
β PrincipalSearchFilter psf = new PrincipalSearchFilter();
β psf.setCommonName(groupName);
β psf.setSpecificDomainName(domainName);
β //By default the filter causes like search unless you are using the absolute version
β //Setting this ensures that search is exact
β psf.setMatchExactCriteria(true);
β //By default search returns obsolete groups also. Set this to ensure that
β //only active groups are returned
β psf.setRetrieveOnlyActive();
β //PrincipalReference are lightweight group objects and searching for them is better performance.
β //If you do not require any other group attribute then use this
β //mode of search
β List<PrincipalReference> result = directoryManager.findPrincipalReferences(psf);
β if(result.isEmpty()){
β System.out.println("Sample group with name "+groupName +" does not exist");
β return null;
β }else{
β String oid = result.get(0).getOid();
β System.out.println("Sample group with name "+groupName +" already exists");
β return oid;
β }
β }catch (Exception e) {
β e.printStackTrace();
β }
β return "";
β }
β}
Quick Start (SOAP mode) Managing Preferences Nodes quick-start-soap-mode-managing-preferences-nodes
The following Java code models managing of Preferences Nodes by using the User Management APIs. ( See Programmatically Managing the Preferences Nodes)
/*
* This Java Quick Start uses the SOAP mode and contains the following JAR files
* in the class path:
* 1. adobe-livecycle-client.jar
* 2. adobe-usermanager-client.jar
* 3. activation.jar (required for SOAP mode)
* 4. axis.jar (required for SOAP mode)
* 5. commons-codec-1.3.jar (required for SOAP mode)
* 6. commons-collections-3.2.jar (required for SOAP mode)
* 7. commons-discovery.jar (required for SOAP mode)
* 8. commons-logging.jar (required for SOAP mode)
* 9. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
* 10. jaxen-1.1-beta-9.jar (required for SOAP mode)
* 11. jaxrpc.jar (required for SOAP mode)
* 12. log4j.jar (required for SOAP mode)
* 13. mail.jar (required for SOAP mode)
* 14. saaj.jar (required for SOAP mode)
* 15. wsdl4j.jar (required for SOAP mode)
* 16. xalan.jar (required for SOAP mode)
* 17. xbean.jar (required for SOAP mode)
* 18. xercesImpl.jar (required for SOAP mode)
β*
* These JAR files are in the following path:
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/sdk/client-libs/common
*
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/sdk/client-libs/jboss
*
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/jboss/bin/client
*
* If you want to invoke a remote AEM Forms instance and there is a
* firewall between the client application and AEM Forms, then it is
* recommended that you use the SOAP mode. When using the SOAP mode,
* you have to include additional JAR files in the following
* path
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/sdk/client-libs/thirdparty
*
* For information about the SOAP
* mode and the additional JAR files that need to be included,
* see "Setting connection properties" in Programming
* with AEM Forms
*
* For complete details about the location of the AEM Forms JAR files,
* see "Including AEM Forms library files" in Programming
* with AEM Forms
*/
import java.util.*;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.idp.um.api.UMException;
import com.adobe.livecycle.usermanager.client.PreferenceManagerServiceClient;
public class ManagePreferences {
public static void main(String[] args) {
//Set connection properties required to invoke AEM Forms
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
//Create a PreferenceManagerServiceClient object
ServiceClientFactory factory = ServiceClientFactory.createInstance(connectionProps);
PreferenceManagerServiceClient pmutil = new PreferenceManagerServiceClient(factory);
//get the preference map for a particular node
String path = "/ΓΫΆΉΚΣΖ΅/LiveCycle/Config/UM/CommonNameOrder";
Map<String, String> map;
try {
map = pmutil.getPreferences(path);
for(String str:map.keySet()) {
//assert on the key as "ReverseOrder"
//assert on the value[map.get(str)] as "false"
}
} catch (UMException e) {
e.printStackTrace();
}
// set preferences by editing a particular key/value pair of a Node.
String path = "/ΓΫΆΉΚΣΖ΅/LiveCycle/Config/UM/CommonNameOrder";
Map<String, String> map = new HashMap<String, String>();
map.put("ReverseOrder", "true");
try {
pmutil.setPreferences(path, map);
Map<String, String> map1 = pmutil.getPreferences(path);
for(String str:map1.keySet()) {
//assert on the key as "ReverseOrder"
//assert on the value[map.get(str)] as "true"
}
} catch (UMException e) {
e.printStackTrace();
}
}
}
Quick Start (SOAP mode): Programmatically managing the Preferences Nodes using the Java API quick-start-soap-mode-programmatically-managing-the-preferences-nodes-using-the-java-api
The following Java code models managing of Preferences Nodes by using the User Management APIs ( See Programmatically Managing the Preferences Nodes)
/*
* This Java Quick Start uses the SOAP mode and contains the following JAR files
* in the class path:
* 1. adobe-livecycle-client.jar
* 2. adobe-usermanager-client.jar
*
* These JAR files are in the following path:
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/sdk/client-libs/common
*
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/sdk/client-libs/jboss
*
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/jboss/bin/client
*
* If you want to invoke a remote AEM Forms instance and there is a
* firewall between the client application and AEM FOrms, then it is
* recommended that you use the SOAP mode. When using the SOAP mode,
* you have to include additional JAR files in the following
* path
* <install directory>/ΓΫΆΉΚΣΖ΅/ΓΫΆΉΚΣΖ΅_Experience_Manager_forms/sdk/client-libs/thirdparty
*
* For information about the SOAP
* mode and the additional JAR files that need to be included,
* see "Setting connection properties" in Programming
* with AEM Forms
*
* For complete details about the location of the AEM Forms JAR files,
* see "Including AEM FOrms library files" in Programming
* with AEM FOrms
*/
import java.util.*;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.idp.um.api.UMException;
import com.adobe.livecycle.usermanager.client.PreferenceManagerServiceClient;
public class ManagePreferences {
public static void main(String[] args) {
//Set connection properties required to invoke AEM Forms
Properties connectionProps = new Properties();
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "https://'[server]:[port]'");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL,ServiceClientFactoryProperties.DSC_SOAP_PROTOCOL);
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, "administrator");
connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, "password");
//Create a PreferenceManagerServiceClient object
ServiceClientFactory factory = ServiceClientFactory.createInstance(connectionProps);
PreferenceManagerServiceClient pmutil = new PreferenceManagerServiceClient(factory);
//get the preference map for a particular node
String path = "/ΓΫΆΉΚΣΖ΅/LiveCycle/Config/UM/CommonNameOrder";
Map<String, String> map;
try {
map = pmutil.getPreferences(path);
for(String str:map.keySet()) {
//assert on the key as "ReverseOrder"
//assert on the value[map.get(str)] as "false"
}
} catch (UMException e) {
e.printStackTrace();
}
// set preferences by editing a particular key/value pair of a Node.
String path = "/ΓΫΆΉΚΣΖ΅/LiveCycle/Config/UM/CommonNameOrder";
Map<String, String> map = new HashMap<String, String>();
map.put("ReverseOrder", "true");
try {
pmutil.setPreferences(path, map);
Map<String, String> map1 = pmutil.getPreferences(path);
for(String str:map1.keySet()) {
//assert on the key as "ReverseOrder"
//assert on the value[map.get(str)] as "true"
}
} catch (UMException e) {
e.printStackTrace();
}
}
}