Java Application and SDKを調べてください
ソリューションのこのセクションでは、次の操作を行います。
-
Java Webアプリケーションの動作とコードを調べる
-
Java WebアプリケーションがOracle Identity Cloud Serviceに開始する、成功したログイン試行と失敗したログイン試行に関連する診断データを確認します。
Java Applicationの動作を確認してください
Java Webアプリケーションの動作は、認可コード権限タイプで定義された3レッグ認証フローに従います。
ブラウザのDeveloperモードを有効にして、アプリケーションと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.oraclecloud.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.oraclecloud.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.oraclecloud.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.oraclecloud.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コンソールにサインインします。
- コンソールで、ナビゲーション・ドロワーを展開し、「設定」、「診断」の順にクリックします。
- 診断タイプとして「アクティビティ表示」を選択し、「保存」をクリックします。
- Oracle Identity Cloud Serviceからサインアウトします。
Oracle Identity Cloud Serviceは、次の15分の診断データを取得します。
-
「Java Applicationの実行」トピックの手順を完了して、Java Webアプリケーションの「ログイン」ページを表示します。
-
赤いOracleアイコンをクリックします。
-
サインインに失敗した場合は、Oracle Identity Cloud Service「サインイン」ページで正しくないユーザー名またはパスワードを入力します。
-
正常にサインインするには、正しいユーザー名とパスワードを入力します。
-
Java Webアプリケーションを使用して、Oracle Identity Cloud Serviceからサインアウトします。
-
Oracle Identity Cloud Serviceコンソールに再度サインインします。
-
コンソールで、ナビゲーション・ドロワーを展開して「レポート」をクリックし、「診断データ」をクリックします。
-
時間範囲の「15-Minute」、ログ・タイプのアクティビティ・ビュー、レポート形式の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
最新のログがファイルの先頭に表示されます。