5.10.7 パスワード認証時の暗号拡張の実装
統合ユーザ管理フレームワークで標準提供されている,パスワードの暗号の形式(SHA-2,SHA-1,MD5および平文)以外でも,パスワード認証ができます。この暗号拡張の機能を利用するには,あらかじめ実装クラスを作成する必要があります。
ここでは,暗号拡張できるログインモジュールと,暗号拡張で使用するクラスの実装方法について説明します。暗号拡張の概要については,「5.3.9 パスワード認証時の暗号拡張」を参照してください。
(1) 暗号拡張を利用できるログインモジュール
WebPasswordLoginModuleまたはWebPasswordJDBCLoginModuleを使用する場合に,暗号拡張を利用できます。
(2) 暗号拡張で使用するクラスの実装方法
暗号拡張を実装する場合,com.cosminexus.admin.auth.security.PasswordCryptographyクラスを継承して処理を実装します。作成したクラスは,次に示すディレクトリの下にクラスファイルで格納します。
-
Windowsの場合:
<Application Serverのインストールディレクトリ>\manager\modules
-
UNIXの場合:
/opt/Cosminexus/manager/modules
なお,格納先ディレクトリは,統合ユーザ管理フレームワークのコンフィグレーションファイル(ua.conf)の,com.cosminexus.admin.auth.custom.modulesオプションで変更できます。
SHA-1形式でbyte型の配列で比較する場合の実装例を次に示します。
package my;
import com.cosminexus.admin.auth.security.PasswordCryptography;
import java.security.*;
public class CustomCryptography implements PasswordCryptography
{
public byte[] encrypt (byte[] plain) {
byte[] encryptedPassword = null;
try{
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(plain);
encryptedPassword = md.digest();
} catch (NoSuchAlgorithmException e) {
encryptedPassword = plain;
}
return encryptedPassword;
}
}