Adding a user to a policy using Java API

46 views
Skip to first unread message

Camron R

unread,
Dec 22, 2009, 11:01:50 AM12/22/09
to Adobe LiveCycle Developers
I have a question that isn't answered by the API Quickstarts
http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000004.html
and I couldn't figure out by looking at the Rights Management API
calls.

I have a policy set with a policy. I have gone into the server and set
up the policy to be able to accept users from a domain. And I have
users on the server in the correct domain. Now, how can I go about
using the Java API to append this user to a policy?

Thanks very much.

Duane Nickull

unread,
Dec 22, 2009, 12:13:58 PM12/22/09
to Adobe LiveCycle Developers
By default, they will have access to the policy if they are listed as one of the group members in your directory.  They could simply then write a java POJO to invoke the remote RM services they need.  LC ES will warn if they are not authorized to use the policy.  All the RM calls are listed under “Rights Management.....Quick starts”.

For all operations to manage users, see the API docs for the “User Manager API” (quite nicely named if I may say so)

;-p

The code is as follows:

/*
 * 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 adobe-utilities.jar
 * 4. jbossall-client.jar (use a different JAR file if LiveCycle ES2 is not deployed
 * on JBoss)
 * 5. activation.jar (required for SOAP mode)
 * 6. axis.jar (required for SOAP mode)
 * 7. commons-codec-1.3.jar (required for SOAP mode)
 * 8.  commons-collections-3.1.jar  (required for SOAP mode)
 * 9. commons-discovery.jar (required for SOAP mode)
 * 10. commons-logging.jar (required for SOAP mode)
 * 11. dom3-xml-apis-2.5.0.jar (required for SOAP mode)
 * 12. jaxen-1.1-beta-9.jar (required for SOAP mode)
 * 13. jaxrpc.jar (required for SOAP mode)
 * 14. log4j.jar (required for SOAP mode)
 * 15. mail.jar (required for SOAP mode)
 * 16. saaj.jar (required for SOAP mode)
 * 17. wsdl4j.jar (required for SOAP mode)
 * 18. xalan.jar (required for SOAP mode)
 * 19. xbean.jar (required for SOAP mode)
 * 20. xercesImpl.jar (required for SOAP mode)
 *
 *  These JAR files are located in the following path:
 * <install directory>/Adobe/Adobe LiveCycle ES2/LiveCycle_ES_SDK/client-libs/common
 *
 * The adobe-utilities.jar file is located in the following path:
 * <install directory>/Adobe/Adobe LiveCycle ES2/LiveCycle_ES_SDK/client-libs/jboss
 *
 * The jbossall-client.jar file is located in the following path:
 * <install directory>/Adobe/Adobe LiveCycle ES2/jboss/client
 *
 * SOAP required JAR files are located in the following path:
 * <install directory>/Adobe/Adobe LiveCycle ES2/LiveCycle_ES_SDK/client-libs/thirdparty
 *
 * If you want to invoke a remote LiveCycle ES2 instance and there is a
 * firewall between the client application and LiveCycle ES2, then it is
 * recommended that you use the SOAP mode. When using the SOAP mode,
 * you have to include these additional JAR files
 *
 * For information about the SOAP
 * mode, see "Setting connection properties" in Programming
 * with LiveCycle ES2
 */

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 AddUserSOAP {

    public static void main(String[] args) {
        try {
            //Set connection properties required to invoke LiveCycle ES2 using SOAP mode                            
            Properties connectionProps = new Properties();
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_SOAP_ENDPOINT, "http://hiro-xp:8080");
            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();
        }
;
    }

}



Duane
--

You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
To post to this group, send email to live...@googlegroups.com.
To unsubscribe from this group, send email to livecycle+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/livecycle?hl=en.




---
Adobe LiveCycle Enterprise Architecture - http://www.adobe.com/products/livecycle/
My TV Show - http://tv.adobe.com/show/duanes-world/
My Blog – http://technoracle.blogspot.com/
My Band – http://22ndcenturyofficial.com/
Twitter – http://twitter.com/duanechaos

Camron R

unread,
Dec 22, 2009, 12:53:23 PM12/22/09
to Adobe LiveCycle Developers
Could you be more specific? Plus, I don't think this will work because
the user is not a member of any group. The user is a third-party
person who wants to view our documents. He lets us know which document
he wants to see. I have an API call that adds him to LC and then add
him to the policy that is attached to a document. Then I send a link
to the document.

I've searched all through the APIs and none of it is very intuitive. I
need something that looks like this:

mypolicy.attachUser(userName);

But it doesn't exist. I can't have the user being warned that they
cannot view the document.

> On 12/22/09 8:01 AM, "Camron R" <camron.rus...@gmail.com> wrote:
>
> I have a question that isn't answered by the API Quickstartshttp://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?co...


> and I couldn't figure out by looking at the Rights Management API
> calls.
>
> I have a policy set with a policy. I have gone into the server and set
> up the policy to be able to accept users from a domain. And I have
> users on the server in the correct domain. Now, how can I go about
> using the Java API to append this user to a policy?
>
> Thanks very much.
>
> --
>
> You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
> To post to this group, send email to live...@googlegroups.com.
> To unsubscribe from this group, send email to livecycle+...@googlegroups.com.

> For more options, visit this group athttp://groups.google.com/group/livecycle?hl=en.


>
> ---
> Adobe LiveCycle Enterprise Architecture -http://www.adobe.com/products/livecycle/
> My TV Show -http://tv.adobe.com/show/duanes-world/

> My Blog -http://technoracle.blogspot.com/
> My Band -http://22ndcenturyofficial.com/
> Twitter -http://twitter.com/duanechaos

David Liao

unread,
Dec 22, 2009, 1:25:07 PM12/22/09
to live...@googlegroups.com
Camron:

You will need to add that user via the UserManager api to the local domain, then apply policy to the document as above using Duane's code.  The policy should accept user from all principals in the domain to open the document (or define a sub group that has the same priviliege)  http://help.adobe.com/en_US/livecycle/9.0/programLC/help/index.htm?content=000004.html

Cheers,

David
David Liao
www.ensemble.com

Duane Nickull

unread,
Dec 22, 2009, 1:42:57 PM12/22/09
to Adobe LiveCycle Developers
Thanks David.  David is correct but you can also do this another way if your architecture is using a remote LDAP.  All you have to do is to create a “group” that is allowed to use the policy then by default, adding or removing users to that group will give them the privileges.

One thing that I just noticed which seems to suck is the fact that the Adobe API docs seem to have missed the whole concept of REST.  The URL’s are not linked to the specific resources with deep linking.  I am going to send a request off to someone to fix this.

Duane

> and I couldn't figure out by looking at the Rights Management API
> calls.
>
> I have a policy set with a policy. I have gone into the server and set
> up the policy to be able to accept users from a domain. And I have
> users on the server in the correct domain. Now, how can I go about
> using the Java API to append this user to a policy?
>
> Thanks very much.
>
> --
>
> You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
> To post to this group, send email to live...@googlegroups.com.
> To unsubscribe from this group, send email to livecycle+...@googlegroups.com <mailto:livecycle%2Bunsu...@googlegroups.com> .
> For more options, visit this group athttp://groups.google.com/group/livecycle?hl=en <http://groups.google.com/group/livecycle?hl=en> .

>
> ---
> Adobe LiveCycle Enterprise Architecture -http://www.adobe.com/products/livecycle/
> My TV Show -http://tv.adobe.com/show/duanes-world/
> My Blog -http://technoracle.blogspot.com/
> My Band -http://22ndcenturyofficial.com/
> Twitter -http://twitter.com/duanechaos

--

You received this message because you are subscribed to the Google Groups "Adobe LiveCycle Developers" group.
To post to this group, send email to live...@googlegroups.com.
To unsubscribe from this group, send email to livecycle+...@googlegroups.com <mailto:livecycle%2Bunsu...@googlegroups.com> .

For more options, visit this group at http://groups.google.com/group/livecycle?hl=en.





---
Reply all
Reply to author
Forward
0 new messages