Understanding Differences Between JNI ASDK and Access SDK

2-42 Developers Guide for Oracle Access Manager and Oracle Security Token Service application must work with different Oracle Access Manager systems or different configurations. Each AccessClient class instance can log its messages to different log files by passing in an appropriate logger name while constructing the Access Client instances. You must pass AccessClient.CompatibilityMode.OAM_10G in compatibility mode when initializing AccessClient objects. If you use the createInstance method, you must use the AccessClient class instance obtained using this method when instantiating the AuthenticationScheme, ResourceRequest, or UserSession classes. While the application is shutting down, it should invoke the AccessClient class shutdown method to perform uninitialization as shown in the following examples: ■ For Oracle Access Manager 10g JNI ASDK Public static void main String args[] { try { ObConfig.Initialize ; Configuration is read from the location pointed by OBACCESS_INSTALL_DIR environment variable OR ObConfig.Initialize configLocation; Configuration is read from the location provided ……….. }catch ObAccessException e{ } ObConfig.shutdown; }main ends here ■ For Oracle Access Manager 11g Access SDK import java.io.; import java.util.; import oracle.security.am.asdk.; Import classes from OAM11g Access ASDK ………….. Public static void main String args[] { try { ac = AccessClient.createDefaultInstance “”, AccessClient.CompatibilityMode.OAM_10G; Refer to Oracle Access Manager Access SDK Java API Reference OR AccessClient.createInstance“”,AccessClient.CompatibilityMode.OAM_10G; Refer to Oracle Access Manager Access SDK Java API Reference ……….. }catch AccessException e{ } ac.shutdown; }main ends here

2.9.3.2.2 Performing Access Operations

As shown in Table 2–6 , there is a one-to-one mapping between the classes that are used to perform access operations. The classes in oracle.security.am.asdk are AuthenticationScheme, ResourceRequest, and UserSession. Introduction to the Access SDK and API 2-43 Depending how the AccessClient class is instantiated, use the corresponding constructor of these classes. Similar to Oracle Access Manager 10g JNI ASDK, any error that occurs during initialization or while performing access operations, is reported as an exception. AccessException is the exception class used in Oracle Access Manager 11g Access SDK as seen in the following examples: ■ For Oracle Access Manager 10g JNI ASDK Public static void main String args[] { try { ObConfig.Initialize ; Configuration is read from the location pointed by OBACCESS_INSTALL_DIR environment variable ObResourceRequest rrq = new ObResourceRequestms_protocol, ms_resource,ms_ method; if rrq.isProtected { System.out.printlnResource is protected.; ObAuthenticationScheme authnScheme = new ObAuthenticationSchemerrq; if authnScheme.isForm { System.out.printlnForm Authentication Scheme.; Hashtable creds = new Hashtable; creds.putuserid, ms_login; creds.putpassword, ms_passwd; ObUserSession session = new ObUserSessionrrq, creds; if session.getStatus == ObUserSession.LOGGEDIN { if session.isAuthorizedrrq { System.out.printlnUser is logged in and authorized for the request at level + session.getLevel; } else { System.out.printlnUser is logged in but NOT authorized; } } else { System.out.printlnUser is NOT logged in; } } else { System.out.printlnnon-Form Authentication Scheme.; } } else { System.out.printlnResource is NOT protected.; } }catch ObAccessException oe { System.out.printlnAccess Exception: + oe.getMessage; } ObConfig.shutdown; }main ends here ■ For Oracle Access Manager 11g Access SDK import java.io.; import java.util.; import oracle.security.am.asdk.; Import classes from OAM11g Access ASDK Public static void main String args[] { AccessClient ac; try { ac = AccessClient.createDefaultInstance“”, AccessClient.CompatibilityMode.OAM_10G; ResourceRequest rrq = new ResourceRequestms_protocol,ms_resource, ms_