Account  Locate

The BEA AquaLogic Service Registry Account 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 register new accounts (or update existing accounts), enable, get, find, and delete accounts.

The BEA AquaLogic Service Registry security account demo set contains the following demos to assist you in learning the BEA AquaLogic Service Registry client API:

SaveAccount Demonstrates how to construct and fill the Save_account object, get an Account stub for the UDDI registry, and perform the save_account call.

DeleteAccount Demonstrates how to construct and fill the Delete_account object, get an Account stub for the UDDI registry, and perform the delete_account call.

Prerequisites and Preparatory Steps: Code  Locate

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 Account demo are loaded from the file:

Windows: %REGISTRY_HOME%\demos\security\account\env.properties
UNIX: $REGISTRY_HOME/demos/security/account/env.properties

Table 12. Properties Used in Demos

NameDefault ValueDescription
uddi.demos.url.accounthttp://localhost:8080/uddi/accountthe account Web service port URL
uddi.demos.url.securityhttp://localhost:8080/uddi/securitythe security Web service port URL

Presentation and Functional Presentation  Locate

This section describes the programming pattern used in all demos using the SaveAccount demo as an example. You can find this demo's source code in the file:

Windows: %REGISTRY_HOME%\demos\security\account\src\demo\uddi\account\SaveAccount.java
UNIX: $REGISTRY_HOME/demos/security/account/src/demo/uddi/account/SaveAccount.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. If you wish to save new user on a registry that supports public registration, then the demo may be modified to skip authentication. It then reads information about the new user to be saved (or about the user to be updated) including login name, password, name, and email address.

The second part contains the execution of the demo. It looks up the security stub and authenticates the user. It then creates a Save_userAccount object and sends it over SOAP to the UDDI registry as a save_userAccount operation. The returned UserAccount object is printed to the console and the authInfo is discarded.

String admin = UserInput.readString("Enter admin login","admin");
String admin_password = UserInput.readString("Enter admin password","changeit");
String login = UserInput.readString("Enter new user's login","demo_eric");
String password = UserInput.readString("Enter password","demo_eric");
String name = UserInput.readString("Enter full name","Eric Demo");
String email = UserInput.readString("Enter email","demo_eric@localhost");
System.out.println();

UDDI_Security_PortType security = getSecurityStub();
String authInfo = getAuthInfo(admin, admin_password, security);
Save_userAccount save = createSaveUserAccount(login, password, name, email, authInfo);
UserAccount userAccount = saveUserAccount(save);
printUserAccount(userAccount);
discardAuthInfo(authInfo, security);

The method createSaveUserAccount is used to create an object representing the save_userAccount operation. The authInfo is required under two circumstances: if the BEA AquaLogic Service Registry is configured not to allow public registration or if the account already exists.

public static Save_userAccount createSaveUserAccount(String login, String password,
  String name, String email, String authInfo) throws InvalidParameterException {
    System.out.println("login = " + login);
    System.out.println("password = " + password);
    System.out.println("name = " + name);
    System.out.println("email = " + email);

    UserAccount account = new UserAccount();
    account.setLoginName(login);
    account.setPassword(password);
    account.setFullName(name);
    account.setEmail(email);
    account.setLanguageCode("EN");

    Save_userAccount save = new Save_userAccount(account, authInfo);
    return save;
}

The helper method, getAccountStub(), returns the UDDI Account stub of the web service listening at the URL specified by the URL_ACCOUNT property.

public static AccountApi getAccountStub() throws SOAPException {
    // you can specify your own URL in property - uddi.demos.url.account
    String url = DemoProperties.getProperty(URL_ACCOUNT, "http://localhost:8080/uddi/account");
    System.out.print("Using Account at url " + url + " ..");
    AccountApi account = AccountStub.getInstance(url);
    System.out.println(" done");
    return account;
}

The BEA AquaLogic Service Registry API call save_userAccount is performed in the method saveUserAccount.

public static UserAccount saveUserAccount(Save_userAccount save) throws SOAPException, AccountException {
    AccountApi accountApi = getAccountStub();
    System.out.print("Save in progress ...");
    UserAccount userAccount = accountApi.save_userAccount(save);
    System.out.println(" done");
    return userAccount;
}

Building and Running Demos  Locate

This section shows how to build and run the BEA AquaLogic Service Registry Account demos.

  1. Be sure that the demos are properly configured and the BEA AquaLogic Service Registry is up and running.

  2. Change your working directory to

    Windows: %REGISTRY_HOME%\demos\security\account
    UNIX: $REGISTRY_HOME/demos/security/account

  3. Build demos using:

    Windows: run.bat make
    UNIX: ./run.sh make

    [Note]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.

  4. To get list of all available commands, run

    Windows: run.bat help
    UNIX: ./run.sh help

  5. The selected demo can be executed via the run command using the name of the demo as a parameter. For example, to run the SaveAccount demo, invoke

    Windows: run.bat SaveAccount
    UNIX: ./run.sh SaveAccount

    The output of this demo will resemble the following:

    Running SaveAccount demo...
    **************************************************************************
    ***    Systinet Registry Demo - SaveAccount   ***
    **************************************************************************
    
    Saving user account where
    Enter admin login [admin]:
    Enter admin password [changeit]:
    Enter new user's login [demo_eric]:
    Enter password [demo_eric]:
    Enter full name [Eric Demo]:
    Enter email [demo_eric@localhost]:
    
    Using Security at url https://mycomp.com:8443/uddi/security .. done
    Logging in .. done
    login = demo_eric
    password = demo_eric
    name = Eric Demo
    email = demo_eric@localhost
    Using Account at url https://mycomp.com:8443/uddi/account .. done
    Save in progress ... done
    
    User account
    <userAccount xmlns="http://systinet.com/uddi/account/5.0">
    <loginName>demo_eric</loginName>
    <password>GD70gCeNfkwBph1m2bgGxQ==</password>
    <email>demo_eric@localhost</email>
    <fullName>Eric Demo</fullName>
    <languageCode>EN</languageCode>
    <expiration>1970-01-01T02:00:00.000+02:00</expiration>
    <external>false</external>
    <blocked>false</blocked>
    <businessesLimit>1</businessesLimit>
    <servicesLimit>4</servicesLimit>
    <bindingsLimit>2</bindingsLimit>
    <tModelsLimit>100</tModelsLimit>
    <assertionsLimit>10</assertionsLimit>
    <subscriptionsLimit>0</subscriptionsLimit>
    <lastLoginTime>2004-05-18T16:20:09.084+02:00</lastLoginTime>
    </userAccount>
    
    ********************************************************
    Logging out .. done
    
  6. 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.