カスタム暗号化
ステップ 1. Maven プロジェクトを作成して API 依存関係を取得する
Maven プロジェクトを作成して API 依存関係を取得するには、次の手順に従います。
<install-directory>/confluence/WEB-INF/lib
ディレクトリに移動します。次のコマンドを使用して、
atlassian-secrets-api.jar
ファイルをローカルの Maven リポジトリにインストールします。mvn install:install-file \ -Dfile=./atlassian-secrets-api-<version>.jar \ -DgroupId=com.atlassian.secrets \ -DartifactId=atlassian-secrets-api \ -Dversion=<version> \ -Dpackaging=jar \ -DgeneratePom=true
次のコマンドを使用して、
atlassian-secrets-store.jar
ファイルをローカルの Maven リポジトリにインストールします。mvn install:install-file \ -Dfile=./atlassian-secrets-store-<version>.jar \ -DgroupId=com.atlassian.secrets \ -DartifactId=atlassian-secrets-store \ -Dversion=<version> \ -Dpackaging=jar \ -DgeneratePom=true
次の pom を使用して Maven プロジェクトを作成します。
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId><your_group_ID></groupId> <artifactId><your_artifact_ID></artifactId> <version><your_version></version> <properties> <maven.compiler.source>1.8</maven.compiler.source> <maven.compiler.target>1.8</maven.compiler.target> </properties> <build> <resources> <resource> <directory>src/main/resources/libs</directory> <excludes> <exclude>*</exclude> </excludes> <filtering>false</filtering> </resource> </resources> </build> <dependencies> <dependency> <groupId>com.atlassian.secrets</groupId> <artifactId>atlassian-secrets-api</artifactId> <version><api_version></version> <scope>provided</scope> </dependency> <dependency> <groupId>com.atlassian.secrets</groupId> <artifactId>atlassian-secrets-store</artifactId> <version><api_version></version> <scope>provided</scope> </dependency> </dependencies> </project>
ステップ 2. SecretStore インターフェイスを実装する
SecretStore
インターフェイスには、要件に応じて実装する必要がある 2 つのメソッド store
と get
が含まれています。get
メソッドは Confluence の起動中に呼び出されるため、長期実行タスクが起動時間に影響を与える可能性があります。暗号化ツールでのみ使用されるため、store
メソッドが Confluence から呼び出されることはありません。
Confluence 8.6 以降では、Cipher
インターフェイスは廃止されたものと見なしてください。代わりに、新しいインターフェイスの SecretStore
とそのメソッド store
および get
を使用してください。これらのメソッドは、対応する Cipher
インターフェイスのメソッド encrypt
および decrypt
に優先します。
Cipher
インターフェイスとそのメソッドは引き続き使用できますが、将来的には廃止されるため、新しい暗号化機能を設定するときには使用しないでください。
例として Base64SecretStore
と AlgorithmSecretStore
を使用できます。
ステップ 3. 実装をテストする
The encryption tool described in Base64 encoding and AES encryption uses the same code as Confluence to decrypt the password. You can use it to test your implementation.
CLI と jar が同じフォルダーにあるとします。
java -cp "./*" com.atlassian.secrets.cli.db.DbCipherTool -c your.package.here.ClassName
ステップ 4. ライブラリを利用可能にする
Confluence がライブラリにアクセスできる必要があります。リフレクションによってクラスはインスタンス化されます。
ライブラリを <install-directory>/confluence/WEB-INF/lib
ディレクトリに置きます。