Oracle Service RegistryのAccount(アカウント)デモは、Oracle Service RegistryのApplication Programming Interface(API)の機能およびこのAPIの使用方法のデモンストレーションを行うために使用します。
新規アカウントの登録(または既存のアカウントの更新)、アカウントの有効化、取得、検索および削除の方法を学習します。
Oracle Service RegistryのSecurityのAccount(アカウント)デモ・セットには、Oracle Service RegistryのクライアントAPIの学習を支援する次のデモが含まれています。
SaveAccount Save_accountオブジェクトをビルドして入力し、UDDIレジストリのAccountスタブを取得し、save_accountコールを実行する方法のデモンストレーションです。
DeleteAccount Delete_accountオブジェクトをビルドして入力し、UDDIレジストリのAccountスタブを取得し、delete_accountコールを実行する方法のデモンストレーションです。
Oracle Service Registryがすでにインストールされ、環境変数REGISTRY_HOMEにレジストリのインストール場所が設定されていることを想定しています。
Oracle Service Registryのデモを実行するには、レジストリが実行中である必要があります。
デモを構成する必要があります。構成システムには、グローバルとローカルの2つのレベルがあります。グローバル・レベルで定義されたプロパティは、ローカル・レベルで上書きできます。グローバル・プロパティは、次のファイルにあります。
Windows: | %REGISTRY_HOME%¥demos¥env.properties |
UNIX: | $REGISTRY_HOME/demos/env.properties |
Oracle Service Registryのインストール中に設定された値はそのまま使用でき、値の変更はすべてのデモに影響を与えます。単一のデモについて(つまりローカル・レベルで)プロパティの値を再定義する必要がある場合は、env.propertiesを編集してください。このファイルは、ファイルrun.sh(run.bat)と同じディレクトリにあります。Accountデモのローカル・レベルのプロパティは、次のファイルからロードされます。
Windows: | %REGISTRY_HOME%¥demos¥security¥account¥env.properties |
UNIX: | $REGISTRY_HOME/demos/security/account/env.properties |
この項では、すべてのデモで使用されるプログラミング・パターンを、SaveAccountデモを例にして説明します。このデモのソース・コードは次のファイルにあります。
Windows: | %REGISTRY_HOME%¥demos¥security¥account¥src¥demo¥uddi¥account¥SaveAccount.java |
UNIX: | $REGISTRY_HOME/demos/security/account/src/demo/uddi/account/SaveAccount.java |
mainメソッドは、2つの部分に分けられます。最初の部分では、ユーザーがデモを構成します。デモを実行するユーザーの資格証明が読み取られます。パブリック登録をサポートするレジストリに新規ユーザーを保存する場合は、認証をスキップするようにデモを変更できます。次に、ログイン名、パスワード、名前、電子メール・アドレスなど、保存する新規ユーザー(または更新するユーザー)に関する情報が読み取られます。
2つ目の部分では、デモが実行されます。Securityスタブが検索され、ユーザーが認証されます。次にSave_userAccountオブジェクトが作成され、SOAPを経由してsave_userAccount操作としてUDDIレジストリに送信されます。返されたUserAccountオブジェクトはコンソールに出力され、authInfoが廃棄されます。
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);
メソッドcreateSaveUserAccountを使用して、save_userAccount操作を表すオブジェクトが作成されます。 authInfoは2つの状況で必要になります。パブリック登録を許可しないようにOracle Service Registryが構成されている場合、またはアカウントがすでに存在する場合です。
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; }
ヘルパー・メソッドgetAccountStub()によって、URL_ACCOUNTプロパティで指定されたURLでリスニングするWebサービスのUDDI Accountスタブが返ります。
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:8888/registry/uddi/account"); System.out.print("Using Account at url " + url + " .."); AccountApi account = AccountStub.getInstance(url); System.out.println(" done"); return account; }
Oracle Service RegistryのAPIコールsave_userAccountが、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; }
この項では、Oracle Service RegistryのAccount(アカウント)デモをビルドして実行する方法を示します。
デモが適切に構成され、Oracle Service Registryが実行中であることを確認してください。
次のディレクトリに移動します。
Windows: | %REGISTRY_HOME%¥demos¥security¥account |
UNIX: | $REGISTRY_HOME/demos/security/account |
次のコマンドを使用して、デモをビルドします。
Windows: | run.bat make |
UNIX: | ./run.sh make |
![]() | 注意 |
---|---|
Windowsプラットフォームでデモをコンパイルすると、次のテキストが表示されることがあります。 A subdirectory or file ..\..\common\.\build\classes already exists. これは予想される現象であり、問題を示すものではありません。 |
利用可能なすべてのコマンドのリストを表示するには、次のコマンドを実行します。
Windows: | run.bat help |
UNIX: | ./run.sh help |
選択したデモを実行するには、runコマンドのパラメータにデモの名前を指定して実行します。たとえば、SaveAccountデモを実行するには、次のように起動します。
Windows: | run.bat SaveAccount |
UNIX: | ./run.sh SaveAccount |
このデモの出力は次のようになります。
Running SaveAccount demo... 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/registry/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/registry/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
デモを再ビルドするには、run.bat clean(./run.sh clean)を実行してclassesディレクトリを削除し、run.bat make(./run.sh make)を実行してデモ・クラスを再ビルドします。