接続の確立
JDBC データソースの作成
Java アプリケーションから接続するJDBC データソースを作成できます。CData JDBC Driver for Confluence に基づくJDBC データソースの作成は、3つの基本ステップで構成されます。
- ドライバーのJAR ファイルをクラスパスに追加します。JAR ファイルはインストールディレクトリの[lib]サブフォルダ内にあります。.lic ファイルはJAR ファイルと同じフォルダ内に配置される必要があることに注意してください。
- ドライバークラスを入力します。次に例を示します。
cdata.jdbc.confluence.ConfluenceDriver
- JDBC URL を入力します。次に例を示します。
jdbc:confluence:User=admin;APIToken=myApiToken;Url=https://yoursitename.atlassian.net;Timezone=America/New_York; or jdbc:cdata:confluence:User=admin;APIToken=myApiToken;Url=https://yoursitename.atlassian.net;Timezone=America/New_York;
上記の2つ目の形式は、同じURL 形式を使用しているドライバー間でアプリケーションに競合がある場合は、CData ドライバーを使用していることを確認するために常に使用できます。URL は "jdbc:confluence:" または"jdbc:cdata:confluence:" のいずれかから始まり、任意の接続プロパティの名前と値のペアをセミコロン区切りで入力します。
Connecting to Confluence
You can establish a connection to any Confluence Cloud account or Confluence Server instance. To connect set the URL connection property. For example, https://yoursitename.atlassian.net.
Authenticating to Confluence
Confluence supports the following authentication methods: Basic Authentication, standard OAuth2.0 Authentication and SSO.
Basic Authentication
Confluence Cloud Account
Aquire a Token
An API token is necessary for account authentication. To generate one, login to your Atlassian account and select API tokens > Create API token. The generated token is displayed.
Authenticate Using the Token
To authenticate to a Cloud account, provide the following (Note: Password has been deprecated for connecting to a Cloud Account and is now used only to connect to a Server Instance.):
- AuthScheme: Set this to Basic.
- User: The user to be used to authenticate with the Confluence server.
- APIToken: The API Token associated with the currently authenticated user.
- Url: The URL associated with your Jira endpoint. For example, https://yoursitename.atlassian.net.
Confluence Server Instance
To authenticate to a Server instance, specify the following:
- AuthScheme: Set this to Basic.
- User: The user which to be used to authenticate with the Confluence instance.
- Password: The password which is used to authenticate with the Confluence server.
- Url: The URL associated with your Jira endpoint. For example, https://yoursitename.atlassian.net.
OAuth
In all cases, you must set AuthScheme to OAuth and Scope to to the value obtained from your application settings. In all the flows described below, it is assumed that you have done so. Note: OAuth 1.0 is deprecated in Confluence Cloud and should only be used by hosted Confluence users.Desktop Applications
This section describes desktop authentication using the credentials for your custom OAuth app. See カスタムOAuth アプリの作成 for more information.Get an OAuth Access Token
After setting the following, you are ready to connect:
- OAuthClientId: Set to the client Id in your app settings.
- OAuthClientSecret: Set to the client secret in your app settings.
- CallbackURL: Set to the Redirect URL in your app settings.
- OAuthVersion: Set to 2.0.
- Url: The URL to your Confluence endpoint; for example, https://yoursitename.atlassian.net.
- InitiateOAuth: Set to GETANDREFRESH. You can use InitiateOAuth to avoid repeating the OAuth exchange and manually setting the OAuthAccessToken.
- Extracts the access token from the callback URL and authenticates requests.
- Obtains a new access token when the old one expires.
- Saves OAuth values in OAuthSettingsLocation. These values persist across connections.
Web Applications
When connecting via a web application, you need to register a custom OAuth app with Confluence. See カスタムOAuth アプリの作成 for more information. You can then use the 本製品 to get and manage the OAuth token values.Get an OAuth Access Token
Set the following connection properties to obtain the OAuthAccessToken:
- OAuthClientId: Set to the client Id in your app settings.
- OAuthClientSecret: Set to the client secret in your app settings.
- OAuthVersion: Set to 2.0.
- Url: The URL to your Confluence endpoint; for example, https://yoursitename.atlassian.net.
Then call stored procedures to complete the OAuth exchange:
- Call the GetOAuthAuthorizationURL stored procedure. Set the AuthMode input to WEB and set the CallbackURL input to the Redirect URI you specified in your app settings. If necessary, set the Permissions parameter to request custom permissions. The stored procedure returns the URL to the OAuth endpoint.
- Open the URL, log in, and authorize the application. You are redirected back to the callback URL.
- Call the GetOAuthAccessToken stored procedure. Set the AuthMode input to WEB. Set the Verifier input to the "code" parameter in the query string of the callback URL. If necessary, set the Permissions parameter to request custom permissions.
To connect to data, set the OAuthAccessToken connection property to the access token returned by the stored procedure. When the access token expires after ExpiresIn seconds, call the GetOAuthAccessToken stored procedure again to obtain a new access token.
Headless Machines
To configure the driver to use OAuth with a user account on a headless machine, you need to authenticate on another device that has an internet browser.- Choose one of two options:
- Option 1: Obtain the OAuthVerifier value as described in "Obtain and Exchange a Verifier Code" below.
- Option 2: Install the 本製品 on a machine with a browser and transfer the OAuth authentication values after you authenticate through the usual browser-based flow, as described in "Transfer OAuth Settings" below.
- Then configure the 本製品 to automatically refresh the access token on the headless machine.
Option 1: Obtain and Exchange a Verifier Code
To obtain a verifier code, you must authenticate at the OAuth authorization URL.
Follow the steps below to authenticate from the machine with an internet browser and obtain the OAuthVerifier connection property.
- Create the Authorization URL by setting the following properties:
- InitiateOAuth: Set to OFF.
- OAuthClientId: Set to the client Id assigned when you registered your application.
- OAuthClientSecret: Set to the client secret assigned when you registered your application.
- OAuthVersion: Set to 2.0.
- Call the GetOAuthAuthorizationURL stored procedure with the CallbackURL input parameter set to the exact Redirect URI you specified in your app details under APIS AND FEATURES > OAuth 2.0 (3LO).
- Open the returned URL in a browser. Log in and grant permissions to the 本製品. You are then redirected to the callback URL, which contains the verifier code.
- Save the value of the verifier code. You need to set this in the OAuthVerifier connection property.
Next, you need to exchange the OAuth verifier code for OAuth refresh and access tokens. Set the following properties:
On the headless machine, set the following connection properties to obtain the OAuth authentication values.
- InitiateOAuth: Set this to REFRESH.
- OAuthVerifier: Set this to the verifier code.
- OAuthClientId: (custom applications only) Set this to the client Id in your custom OAuth application settings.
- OAuthClientSecret: (custom applications only) Set this to the client secret in the custom OAuth application settings.
- OAuthSettingsLocation: Set this to persist the encrypted OAuth authentication values to the specified location.
- InitiateOAuth: Set to REFRESH.
After the OAuth settings file is generated, you need to re-set the following properties to connect:
- InitiateOAuth: Set this to REFRESH.
- OAuthClientId: Set this to the client Id assigned when you registered your application.
- OAuthClientSecret: Set this to the client secret assigned when you registered your application.
- OAuthSettingsLocation: Set this to the location containing the encrypted OAuth authentication values. Make sure this location gives read and write permissions to the 本製品 to enable the automatic refreshing of the access token.
- OAuthVersion: Set to 2.0.
- Url: The URL to your Confluence endpoint; for example, https://yoursitename.atlassian.net.
Option 2: Transfer OAuth Settings
Prior to connecting on a headless machine, you need to install and create a connection with the driver on a device that supports an internet browser. Set the connection properties as described in "Desktop Applications" above.
After completing the instructions in "Desktop Applications", the resulting authentication values are encrypted and written to the location specified by OAuthSettingsLocation. The default filename is OAuthSettings.txt.
After you have successfully tested the connection, copy the OAuth settings file to your headless machine.
On the headless machine, set the following connection properties to connect to data:
- InitiateOAuth: Set this to REFRESH.
- OAuthClientId: Set this to the client Id assigned when you registered your application.
- OAuthClientSecret: Set this to the client secret assigned when you registered your application.
- OAuthSettingsLocation: Set this to the location of your OAuth settings file. Make sure this location gives read and write permissions to the 本製品 to enable the automatic refreshing of the access token.
- CallbackURL: Set to the Callback URL in your app details under APIS AND FEATURES > OAuth 2.0 (3LO).
- InitiateOAuth: Set to REFRESH.
- OAuthSettingsLocation: Set to the location of your OAuth settings file. Make sure this location gives read and write permissions to the 本製品 to enable the automatic refreshing of the access token.
- OAuthVersion: Set to 2.0.
- Url: The URL to your Confluence endpoint; for example, https://yoursitename.atlassian.net.
Crowd
AuthScheme をCrowd に設定し、次の接続プロパティを設定します。
- User:Crowd ユーザーアカウント。
- Password:Crowd アカウントに関連付けられたパスワード。
- SSOLoginURL:Crowd アカウントに関連付けられたログインURL。IDP URL は、自身のアプリケーション->[SSO]->[SSO information]->[Identity provider single sign-on URL]にあります。
- SSOAppName:SSO を有効にするアプリケーション名。
- SSOAppPassword:SSO を有効にするアプリケーションのパスワード。
- SSOExchangeUrl:The URL used used to exchange the SAML token for Confluence cookies. This URL may have the following formats:
- https://<authority of Confluence instance>/plugins/servlet/samlconsumer
- https://<authority of Confluence instance>/plugins/servlet/samlsso
接続文字列の例:
AuthScheme=Crowd;Url=https://yoursitename.atlassian.net;SSOLoginURL='https://<authority>/crowd/console/secure/saml/sso.action';User=crowdUserName;Password=crowdPassword;SSOExchangeUrl=https://<authority of Confluence instance>/plugins/servlet/samlconsumer;SSOAppName=CrowdAppName;SSOAppPassword=CrowdAppPassword;
Okta
Okta に接続するには、AuthScheme をOkta に設定し、次のプロパティを設定します。
- User:Okta ユーザー。
- Password:Okta ユーザーのパスワード。
- SSOLoginURL:SSO プロバイダーのログインURL。
- SSOExchangeUrl: The URL used used to exchange the SAML token for Confluence cookies. This URL may have the following formats:
- https://<authority of Confluence instance>/plugins/servlet/samlconsumer
- https://<authority of Confluence instance>/plugins/servlet/samlsso
Okta クライアントリクエストコンテキストをオーバーライドする信頼されたアプリケーションまたはプロキシを使用する場合、またはMFA を設定している場合は、Okta を使用して認証するためにSSOProperties を組み合わせて使用する必要があります。必要に応じて、以下のいずれかを設定します。
- APIToken:Okta クライアントリクエストコンテキストをオーバーライドする、信頼されたアプリケーションまたはプロキシ経由でユーザーを認証する場合、これを顧客がOkta 組織で作成したAPI Token に設定します。
- MFAType:MFA フローを設定した場合、次の対応するタイプのいずれかに設定します:OktaVerify、Email、またはSMS。
- MFAPassCode:MFA フローを設定した場合は、有効なパスコードに設定します。
これを空欄または無効な値に設定した場合、本製品 はユーザーのデバイスまたはE メールにワンタイムパスワードチャレンジを発行します。パスコードを受信後、取得したワンタイムパスワードをMFAPassCode 接続プロパティに設定する接続を再度開きます。 - MFARememberDevice:デフォルトはTrue です。Okta は、MFA が必要な場合にデバイスを記憶させることをサポートします。設定された認証ポリシーに従ってデバイスの記憶が許可されている場合、本製品 はMFA 認証の有効期間を延長するデバイストークンを送信します。MFA を記憶させない場合は、この 変数をFalse に設定してください。
接続文字列の例:
AuthScheme=Okta;Url=https://yoursitename.atlassian.net;SSOLoginURL='https://example.okta.com/home/appType/0bg4ivz6cJRZgCz5d6/46';User=oktaUserName;Password=oktaPassword;SSOExchangeUrl=https://<authority of Confluence instance>/plugins/servlet/samlconsumer;