The BEA AquaLogic Service Registry Permission Demos are used to demonstrate the BEA AquaLogic Service Registry application programming interface's capabilities and to demonstrate how to use this API.
You will learn how to set and search permissions.
The BEA AquaLogic Service Registry security permission demo set contains the following demos to assist you in learning the BEA AquaLogic Service Registry client API:
SetPermission Demonstrates how to construct and fill the Set_permission object, get a Permission stub for the UDDI registry, and perform the set_permission call.
WhoHasPermission Demonstrates how to construct and fill the Who_hasPermission object, get a Permission stub for the UDDI registry, and perform the who_hasPermission call.
GetPermission Demonstrates how to construct and fill the Get_permission object, get a Permission stub for the UDDI registry, and perform the get_permission call.
We expect that you have already installed the BEA AquaLogic Service Registry and set the REGISTRY_HOME environment variable to the registry's installation location.
To run the BEA AquaLogic Service Registry's demos, your BEA AquaLogic Service Registry must be running. To start the registry, execute the serverstart script:
Windows: | %REGISTRY_HOME%\bin\serverstart.bat |
UNIX: | $REGISTRY_HOME/bin/serverstart.sh |
It is necessary to configure the demos. The configuration system has two levels: global and local. The properties defined at the global level may be overwritten at the local level. The global properties are located in the file:
Windows: | %REGISTRY_HOME%\demos\env.properties |
UNIX: | $REGISTRY_HOME/demos/env.properties |
The values set during the installation of the BEA AquaLogic Service Registry work out of the box, and their modification affects all demos. If you need to redefine a property's value for a single demo (that is,, at the local level), edit env.properties. This file is located in the same directory as the file run.sh (run.bat). Local level properties for the Permission demos are loaded from the file:
Windows: | %REGISTRY_HOME%\demos\security\permission\env.properties |
UNIX: | $REGISTRY_HOME/demos/security/permission/env.properties |
This section describes the programming pattern used in all demos using the SetPermission demo as an example. You can find this demo's source code in the file:
Windows: | %REGISTRY_HOME%\demos\security\permission\src\demo\uddi\permission\SetPermission.java |
UNIX: | $REGISTRY_HOME/demos/security/permission/src/demo/uddi/permission/SetPermission.java |
The main method is divided into two parts. The first part serves to configure the demo by the user. It reads the credentials of the user who will run the demo and is allowed to set permissions. Then it reads permission type, name, and action.
The second part contains the execution of the demo. It looks up the security stub and authenticates the user. It then creates a Set_permission object and sends it over SOAP to the UDDI registry as a set_permission operation. If the user has explicitly declared permissions that are not present in this operation, these will be removed.
String user = UserInput.readString("Enter login","admin"); String password = UserInput.readString("Enter password","changeit"); String principal = UserInput.readString("Enter principal type", PrincipalType.user.getValue()); String login = UserInput.readString("Enter login/group name", DemoProperties.getProperty(USER_JOHN_NAME)); String type = UserInput.readString("Enter permission type", "org.systinet.uddi.security.permission.ApiManagerPermission"); String name = UserInput.readString("Enter permission name", "org.systinet.uddi.client.taxonomy.v3.TaxonomyApi"); String action = UserInput.readString("Enter action", "download_taxonomy"); System.out.println(); UDDI_Security_PortType security = getSecurityStub(); String authInfo = getAuthInfo(user, password, security); Set_permission set = createSetPermission(login, principal, name, type, action, authInfo); setPermission(set); discardAuthInfo(authInfo, security);
The method createSetPermission creates an object representing the set_permission operation.
public static Set_permission createSetPermission(String login, String principal, String name, String type, String action, String authInfo) throws InvalidParameterException { System.out.println(principal+", login/name = " + login); System.out.println("type = " + type); System.out.println("name = " + name); System.out.println("action = " + action); PermissionDescriptors permissionDescriptors = new PermissionDescriptors(); permissionDescriptors.setPrincipal(new Principal(login, PrincipalType.getPrincipalType(principal))); PermissionDescriptor descriptor = new PermissionDescriptor(); descriptor.setName(name); descriptor.setType(type); descriptor.addAction(action); permissionDescriptors.addPermissionDescriptor(descriptor); Set_permission set = new Set_permission(); set.setPermissionDescriptors(permissionDescriptors); set.setAuthInfo(authInfo); return set; }
The helper method, getPermissionStub(), returns the UDDI Permission stub of the Web service listening at the URL specified by the URL_PERMISSION property.
public static PermissionApi getPermissionStub() throws SOAPException { // you can specify your own URL in property - uddi.demos.url.permission String url = DemoProperties.getProperty(URL_PERMISSION, "http://localhost:8080/uddi/permission"); System.out.print("Using Permission API at url " + url + " .."); PermissionApi permission = PermissionStub.getInstance(url); System.out.println(" done"); return permission; }
The BEA AquaLogic Service Registry API call set_permission is performed in the method setPermission.
public static void setPermission(Set_permission set) throws SOAPException, PermissionException { PermissionApi permissionApi = getPermissionStub(); System.out.print("Save in progress ..."); permissionApi.set_permission(set); System.out.println(" done"); }
This section shows how to build and run the BEA AquaLogic Service Registry Permission demos.
Be sure that the demos are properly configured and the BEA AquaLogic Service Registry is up and running.
Change your working directory to
Windows: | %REGISTRY_HOME%\demos\security\permission |
UNIX: | $REGISTRY_HOME/demos/security/permission |
Build demos using:
Windows: | run.bat make |
UNIX: | ./run.sh make |
Note | |
---|---|
When compiling demos on Windows platforms, you may see the following text: A subdirectory or file ..\..\common\.\build\classes already exists. This is expected and does not indicate a problem. |
To get list of all available commands, run
Windows: | run.bat help |
UNIX: | ./run.sh help |
The selected demo can be executed via the run command using the name of the demo as a parameter. For example, to run the SetPermission demo, invoke
Windows: | run.bat SetPermission |
UNIX: | ./run.sh SetPermission |
The output of this demo will resemble the following:
Running SetPermission demo... ************************************************************************** *** BEA AquaLogic Service Registry Demo: SetPermission *** ************************************************************************** Setting permission where Enter login [admin]: Enter password [changeit]: Enter principal type [user]: Enter login/group name [demo_john]: Enter permission type [org.systinet.uddi.security.permission.ApiManagerPermission]: Enter permission name [org.systinet.uddi.client.taxonomy.v3.TaxonomyApi]: Enter action [download_taxonomy]: Using Security at url https://mycomp.com:8443/uddi/security .. done Logging in .. done user, login/name = demo_john type = org.systinet.uddi.security.permission.ApiManagerPermission name = org.systinet.uddi.client.taxonomy.v3.TaxonomyApi action = download_taxonomy Using Permission API at url https://mycomp.com:8443/uddi/permission .. done Save in progress ... done Logging out .. done
To rebuild demos, execute run.bat clean (./run.sh clean) to delete the classes directory and run.bat make (./run.sh make) to rebuild the demo classes.