2013年12月17日火曜日

Oracle Entitlements Server with Java SM

1.  Create New Application (go to Authorization management > Application > click new Application)
2.   Create New Security Module (go to System Configuration > Security Module > click New)
3.  Create New Resource Type (go to Newly Created Application > Resource Types > Click new)
4.  Create New Resource (go to Newly Created Application > Default Policy Domain > Resources Catalog > Resources > Create New)
5.  Create New Permit Authorization Policy (go to Newly Created Application > Default Policy Domain > Application Policies > Create New)
6.  Create New Deny Authorization Policy (go to Newly Created Application > Default Policy Domain > Application Policies > Create New)
7.  Edit the following file
$OES_CLIENT_HOME/oessm/SMConfigTool/smconfig.java.controlled.prp
8.  Run the config.sh
9.  This will create a directory in $OES_CLIENT_HOME/oes_sm_instances/< SM_NAME_AS _IN_PRP_FILE >
10.   Create a sample application to validate the authorization request. Code  Snippet is as follows-
11.   Run the program to check that it is authorizing the user initiating the resource request.

Sample source:
******************************************************************
public class HelloWBworld2 {

    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
         WLSUserImpl p = new WLSUserImpl("weblogic_wc");
          System.out.println("HelloWBworld :: principal :: "+p);
          Subject user = new Subject();
          System.out.println("HelloWBworld :: Subject :: "+user);
//           user.getPrincipals().add(p);
          System.out.println("HelloWBworld :: Subject after add :: "+user);
          // Resource being accessed AppName/ResourceType/ResouceName
          String resourceString = "HelloWBWorld/MyWBResourceType/MyWBResource";
          System.out.println("HelloWBworld :: resourceString :: " +resourceString);
          // Action initiated by the user
          String action = "write";
          System.out.println("HelloWBworld :: action :: "+action);
          // Environmental/Context attributes
          while (true)
          {
              System.out.println("HelloWBworld :: while start ");
              try {
                 // get Authorization response from OES
                 PrepareResponse response = PepRequestFactoryImpl.getPepRequestFactory()
                             .newPepRequest(
                                     user,
                                    action,
                                    resourceString,
                                    null).decide();
                System.out.println( "Request: {" + user + " " + action + " " + resourceString +  "} \nResult: " + response.allowed());
              } catch (PepException e) {
                 System.out.println( "***** Caught exception:  " + e.getMessage());
                 e.printStackTrace();
                 System.exit(1);
              }
        }
    }
}****************************************************************
http://docs.oracle.com/cd/E37115_01/dev.1112/e27154/handle_auth_calls.htm

0 件のコメント :

コメントを投稿