Tech Tip – How to get a list of all objects of a given type using CA SSO Java sdk

iamtechtips

How to get list of all object of a given type using CA SSO Java sdk

 

INSTRUCTIONS:

To get a list of all objects of a given type, you can use following method from interface com.netegrity.sdk.policyapi.SmPolicyAPi

SmApiResult getGlobalObjectNames(java.lang.String propName,
                                 java.util.Vector objectNames)
                                 throws SmApiException
Gets a list of global objects.
Parameters:
propName – Property name of the global object.
objectNames – This Vector will be populated with the retrieved list of global objects.
Returns:
The result of the request.
Throws:
SmApiException

As you can see above, this method can be invoked only on Global objects. These are the type of objects which is not a child of any other object. For e.g. Realm is a child Domain object and Rule is a child of Realm object, so Realm and Rule are not a global object. However, Domain itself is a global object as it is not a child of any other object.

Following table list all the global class types and their corresponding property names which is to be used in the getGlobalObjectNames API call.

Class

Property Name

com.netegrity.sdk.policyapi.SmAgentConfig

AgentConfigs

com.netegrity.sdk.policyapi.SmAgentGroup

AgentGroups

com.netegrity.sdk.policyapi.SmAgent

Agents

com.netegrity.sdk.policyapi.SmAgentType

AgentTypes

com.netegrity.sdk.policyapi.SmAdmin

Admins

com.netegrity.sdk.policyapi.SmAuthAzMap

AuthAzMaps

com.netegrity.sdk.policyapi.SmCertMap

CertMaps

com.netegrity.sdk.policyapi.SmDomain

Domains

com.netegrity.sdk.policyapi.SmHostConfig

HostConfigs

com.netegrity.sdk.policyapi.SmKeyManagement

KeyManagement

com.netegrity.sdk.policyapi.SmPasswordPolicy

PasswordPolicies

com.netegrity.sdk.policyapi.SmScheme

Schemes

com.netegrity.sdk.policyapi.SmSelfReg

SelfRegs

com.netegrity.sdk.policyapi.SmSharedSecretPolicy

SharedSecretPolicy

com.netegrity.sdk.policyapi.SmTrustedHost

TrustedHosts

com.netegrity.sdk.policyapi.SmUserDirectory

UserDirectories

Sample code :  Get all Agents 


SmApiResult result = new SmApiResult();
SmPolicyApi policyapi = new SmPolicyApiImpl(mySession);
Vector vector = new Vector(15);

//Get List of all Agents
result = policyapi.getGlobalObjectNames("Agents", vector);
System.out.println("Result is success? " + result);
System.out.println("Vector is" + vector.size();

Iterator i = vector.iterator();
while (i.hasNext()) {
System.out.println(i.next());
}

RELATED BLOGS :

Tech Tip – How to automatically redirect user to login page after idletimeout

 

Leave a Reply