JavaアプリケーションおよびSDKの確認
解決策のこのセクションでは、次の操作を行います。
-
Java Webアプリケーションの動作とコードの確認
-
Java WebアプリケーションがOracle Identity Cloud Serviceに対して開始する、成功したログイン試行および失敗したログイン試行に関連する診断データを確認します。
Javaアプリケーションの動作の確認
Java Webアプリケーションの動作は、認可コード付与タイプによって定義された3-legged認証フローに従います。
アプリケーションとOracle Identity Cloud Serviceの両方が実行するすべてのリクエスト、レスポンスおよびリダイレクトを検証できるように、ブラウザの開発者モードを有効にします。次の例では、Google Chromeを使用します。
ブラウザの開発者ログには、次のイベントフローが表示されます。
-
/auth/oracle
リソースをリクエストすると、WebブラウザはJava Webアプリケーションからリダイレクト・レスポンスを受信します。Request URL: http://localhost:8080/auth Request Method: GET Status Code: 302 Found Response Headers Location: https://idcs-abcd1234.identity.domain.com/oauth2/v1/authorize?client_id=123456789abcdefghij&redirect_uri= http%3A%2F%2Flocalhost%3A8080%2Fcallback&response_type=code&scope=urn:opc:idm:t.user.me+openid&state=1234
-
Oracle Identity Cloud Serviceは、認可コード・リクエストを受信し、「サインイン」ページを表示します。
Request URL: https://idcs-abcd1234.identity.domain.com/oauth2/v1/authorize?client_id=123456789abcdefghij&redirect_uri= http%3A%2F%2Flocalhost%3A8080%2Fcallback&response_type=code&scope=urn:opc:idm:t.user.me+openid&state=1234 Request Method: GET Status Code: 303 See Other Response Headers Location: https://idcs-abcd1234.identity.domain.com/ui/v1/signin Set-cookie: ORA_OCIS_REQ_1=[value has been omitted for readability]
-
Oracle Identity Cloud Serviceにサインインすると、WebブラウザがJava WebアプリケーションのコールバックURLにリダイレクトされます。
Request URL: http://localhost:8080/callback?code=[value has been omitted for readability]&state=1234 Request Method: GET Status Code: 200 OK Response Hearders Set-Cookie: JSESSIONID=[value has been omitted for readability]
この例では、コールバックURLによって、Webブラウザがホーム・ページにリダイレクトされ、ユーザー・アクセス・トークンおよびIDトークンがセッション属性として設定されます。
SDKログの確認
次のステップに従って、Oracle Identity Cloud ServiceのJava SDKログオンをオンにし、開発中に見つかった問題を調べます。
ConnectionOptions.java
クラス・ファイルを開き、getOptions()
メソッドを編集します。Constants.LOG_LEVEL
値をDEBUG
に設定します。
アプリケーションを再構築し、再度実行します。
次のようなログの詳細が表示されます。
Fine: Got token manager
Fine: using config endpoint: https://idcs-abcd1234.identity.domain.com:443/.well-known/idcs-configuration
...
Fine: Got response content: [value has been omitted for readability]
...
Fine: getAuthorizationCodeUrl returning with url: [value has been omitted for readability]
...
Fine: authorizationCode with code: [value has been omitted for readability]
...
Fine: Obtaining access token from: [value has been omitted for readability]
...
Fine: returning access token
...
Fine: Token signature verification result: true
診断データのチェック
Java WebアプリケーションがOracle Identity Cloud Serviceに対して開始するログイン試行の成功と失敗の両方が、Oracle Identity Cloud Service診断ログ・ファイルに登録されます。
- Oracle Identity Cloud Serviceコンソールにサインインします。
- コンソールで、ナビゲーション・ドロワーを開き、「設定」、「診断」の順にクリックします。
- 診断タイプとして「アクティビティ・ビュー」を選択し、「保存」をクリックします。
- Sign out of Oracle Identity Cloud Service.
Oracle Identity Cloud Serviceは、次の15分間の診断データを取得します。
-
Java Webアプリケーションの「ログイン」ページを表示するには、「Javaアプリケーションの実行」トピックのステップを実行します。
-
赤い「Oracle」アイコンをクリックします。
-
サインインを正常に試行するには、Oracle Identity Cloud Serviceの「サインイン」ページに不正なユーザー名またはパスワードを入力します。
-
正常にサインインするには、正しいユーザー名とパスワードを入力します。
-
Java Webアプリケーションを使用して、Oracle Identity Cloud Serviceからサインアウトします。
-
Oracle Identity Cloud Serviceコンソールに再度サインインします。
-
コンソールで、ナビゲーション・ドロワーを展開し、「レポート」、「診断データ」の順にクリックします。
-
時間範囲に「15分」、ログ・タイプに「アクティビティ・ビュー」、レポート形式に「CSV」を選択し、「レポートのダウンロード」をクリックします。
診断ログ・ファイルには、Oracle Identity Cloud Serviceにサインインするユーザーに関する次のような情報が含まれます。
Message: ID Token will be signed with User Tenant:idcs-abcd1234 Resource Tenant:idcs-abcd1234, clientId=123456789abcdefghij
Component: OAuth
Timestamp: [Date]
Actor ID: your.email@example.com
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"request":{"tenant":"idcs-abcd1234","grant types":"authorization_code","scopes":["urn:opc:idm:t.user.me"]},"user":{"id":"111111","name":"your.email@example.com","tenant":"idcs-abcd1234","auth-type":"PASSWORD"},"client":{"id":"123456789abcdefghij","name":"Sample App","tenant":"idcs-abcd1234","auth-type":"PASSWORD"},"environment":{"isCSR":"false","onBehalfOfUser":"false"},"response":{"result":"ALLOWED","scopes":["urn:opc:idm:t.user.me"],"custom-claims":{"clientAppRoles":["Authenticated Client","Me"],"userAppRoles":["Authenticated","Global Viewer","Identity Domain Administrator"],"user_isAdmin":"true"}}}
Component: Authorization/getAllowedScopes
Timestamp: [Date]
Actor ID: your.email@example.com
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"Message":"SSO SignOn Policy evaluation result for user : 11111 is : effect:ALLOW,authenticationFactor:IDP,allowUserToSkip2FAEnrolment:false,2FAFrequency:SESSION,reAuthenticate:false,trustedDevice2FAFrequency:
Component:
Timestamp:
Actor ID:
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluatePolicy] Evaluating Default Sign-On Policy
Component: PolicyEngine
Timestamp: [Date]
Actor ID: uiSignin
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluateRule] Evaluating MFA rule
Component: PolicyEngine
Timestamp: [Date]
Actor ID: uiSignin
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluatePolicy] Evaluating Default Authentication Target App Policy
Component: PolicyEngine
Timestamp: [Date]
Actor ID: idcssso
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"password":"********","authFactor":"USERNAME_PASSWORD","device":"{\"currentTime\":\"[date]",\"screenWidth\":1920,\"screenHeight\":1080,\"screenColorDepth\":24,\"screenPixelDepth\":24,\"windowPixelRatio\":1,\"language\":\"en\",\"userAgent\":\"Mozilla\/5.0 (Windows NT 10.0
Component:
Timestamp:
Actor ID:
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: {"Message":"No session found so need to collect credentials","Redirecting to Login URL: ":https://idcs-abcd1234.identity.oraclecloud.com/ui/v1/signin}
Component: SSO
Timestamp: [Date]
Actor ID: Unauthenticated
---------------------------------------------------------------
...
---------------------------------------------------------------
Message: [PolicyEngineUtil.evaluatePolicy] Evaluating Default Identity Provider Policy
Component: PolicyEngine
Timestamp: [Date]
Actor ID: Unauthenticated
---------------------------------------------------------------
Message: Authorization Request, received parameters: scope[urn:opc:idm:t.user.me openid] response_type[code] state[1234] redirect_uri[http://localhost:8080/callback] client_id[123456789abcdefghij]
Component: OAuth
Timestamp: [Date]
Actor ID: Unauthenticated
最新のログがファイルの先頭に表示されます。