Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.

How to get name of a PolicyEntry principal?

Avatar

Level 2

I am using the Java API (EJB Mode) to create Policies and Policy-Entries. I am able to do this without any problems. However when I retrieve a created Policy and its Policies-Entries I cannot obtain anything meaningful about the Principal associated with the Policy-Entry. Most of the fields of the Principal are null, with the exception of the canonical-name. However, the canonical-name returned does not correspond to that of the Principal when the Policy Entry was created. Also the domain for the returned Principal is not the same as when the Policy-Entry was created and it does exist in the system.

When I look at the Policy and the Policy-Entry using the “LiveCycle Administration Console” it shows-up what I would expect, with the Principals associated listed.

So my question is how do I get name and other information about the Principals associated with a Policy-Entry.

2 Replies

Avatar

Level 2

Here is a short program that reproduces this problem:

package lctest;

import com.adobe.edc.sdk.SDKException;
import java.util.*;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactory;
import com.adobe.idp.dsc.clientsdk.ServiceClientFactoryProperties;
import com.adobe.idp.um.api.infomodel.Principal;
import com.adobe.livecycle.rightsmanagement.client.*;
import com.adobe.livecycle.rightsmanagement.client.infomodel.*;
import java.util.logging.Level;
import java.util.logging.Logger;

public class ListPolicies
{
    public static void main(String[] args)
    {
        try
        {
            //String domain    = "docmgt";
            String username = "administrator";
            String password = "password";
            String policySet= "docMgnt";

            //Set connection properties required to invoke LiveCycle ES2
            Properties connectionProps = new Properties();
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_DEFAULT_EJB_ENDPOINT, "jnp://ift-6:1099");
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_TRANSPORT_PROTOCOL, ServiceClientFactoryProperties.DSC_EJB_PROTOCOL);
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_SERVER_TYPE, "JBoss");
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_USERNAME, username);
            connectionProps.setProperty(ServiceClientFactoryProperties.DSC_CREDENTIAL_PASSWORD, password);

            // Create the service client factory
            ServiceClientFactory scFactory = ServiceClientFactory.createInstance(connectionProps);

            //Create a RightsManagementClient object
            RightsManagementClient rightsClient = new RightsManagementClient(scFactory);

            PolicySearchFilter pf = new PolicySearchFilter();

            pf.setPolicySetName(policySet);
            pf.setType(Policy.ORGANIZATIONAL_POLICY);

            PolicyManager policyManager = rightsClient.getPolicyManager();
            Policy[] policies = policyManager.getPolicies(pf,100);

            for (Policy lcPolicy : policies)
            {
                System.out.println("Policy Name: "+lcPolicy.getName());
                System.out.println("Policy LeasePeriod: "+lcPolicy.getOfflineLeasePeriod());

                List<PolicyEntry> pEntries = lcPolicy.getPolicyEntries();

                System.out.println("Policy Entries ---");

                for (PolicyEntry pEntry : pEntries)
                {
                    Principal pr = pEntry.getPrincipal();

                    System.out.println("\tPrincipal Type: "+pr.getPrincipalType());
                    System.out.println("\tPrincipal CommonName: "+pr.getCommonName());
                    System.out.println("\tPrincipal Description: "+pr.getDescription());
                    System.out.println("\tPrincipal Oid: "+pr.getOid());
                    System.out.println("\tPrincipal DomainName: "+pr.getDomainName());
                    System.out.println("\tPrincipal CanonicalName: "+pr.getCanonicalName());
                    System.out.println("\t=======================");
                }

                System.out.println("--------------------------------------------");
            }
        }
        catch (SDKException ex)
        {
            Logger.getLogger(ListPolicies.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}

The output from this program is as follows:

Policy Name: View and Print
Policy LeasePeriod: 1
Policy Entries ---
        Principal Type: USER
        Principal CommonName: null
        Principal Description: null
        Principal Oid: null
        Principal DomainName: OID
        Principal CanonicalName: B59C774B-BC6A-9C02-0636-053ABB637B4B
        =======================
        Principal Type: USER
        Principal CommonName: null
        Principal Description: null
        Principal Oid: null
        Principal DomainName: OID
        Principal CanonicalName: BC701FAD-6DC3-EB57-79D9-8FF11E9166D5
        =======================
        Principal Type: GROUP
        Principal CommonName: null
        Principal Description: null
        Principal Oid: null
        Principal DomainName: OID
        Principal CanonicalName: 9B1A96DF-CE7D-D813-FCBB-C7C920735FB1
        =======================
--------------------------------------------

Avatar

Level 2

The problem here is that the value returned by the getCanonicalName method of the Principal in the PolicyEntry is the Oid. Therefore to get all the values of the Principal one needs to use the findPrincipal method of the DirectoryManagerServiceClient class.

The documentation should be updated to make this clear.

I still do not understand why the Principal returned from the PolicyEntry has most of its fields unpopulated. There should be not need to do a findPrincipal. In addition why is the value for the Oid returned by the getCanonicalName method, instead of the getOid method.