org.seasar.util.crypto
クラス CipherPoolUtil

java.lang.Object
  上位を拡張 org.seasar.util.crypto.CipherPoolUtil

public abstract class CipherPoolUtil
extends Object

Cipherを扱うユーティリティです。

Cipher のインスタンスをプールします。基本的な使い方は次のようになります。

暗号化や複合化の情報を保持するCipherContextのインスタンスを定数として定義します。 CipherContext の標準的な実装クラスとして CipherContextImplが用意されています (利用可能なアルゴリズムはCipher のJavadoc等を参照してください)。

 public static final CipherContext BLOWFISH_CONTEXT =
     new CipherContextImpl("Blowfish", "hogefuga");
 

Cipherは初期化にコストがかかるので、CipherPoolUtilCipherContext のインスタンスをプールします。 あらかじめインスタンスをプールしておくにはcreate(CipherContext, int) メソッドを使います。

 CipherPoolUtil.create(BLOWFISH_CONTEXT, 5);
 

文字列を暗号化するにはencryptoText(CipherContext, String, String)を使います。

 String encryptoText =
     CipherPoolUtil.encryptoText(BLOWFISH_CONTEXT, "パスワード", "UTF-8");
 

文字列を復号化するにはdecryptoText(CipherContext, String, String)を使います。

 String decryptoText1 =
     CipherPoolUtil
         .decryptoText(BLOWFISH_CONTEXT, encryptoText1, "UTF-8");
 

作成者:
shinsuke

フィールドの概要
protected static ConcurrentMap<String,Queue<Cipher>> decryptoQueueMap
          decrypto用のCipherプール
protected static ConcurrentMap<String,Queue<Cipher>> encryptoQueueMap
          encrypto用のCipherプール
 
コンストラクタの概要
CipherPoolUtil()
           
 
メソッドの概要
static void create(CipherContext context, int size)
          CipherContextCipherインスタンスを事前にプールします。
static byte[] decrypto(CipherContext context, byte[] data)
          CipherContextCipherでバイト配列を復号化します。
static String decryptoText(CipherContext context, String text, String charsetName)
          CipherContextCipherで文字列を暗号化します。
static byte[] encrypto(CipherContext context, byte[] data)
          CipherContextCipherでバイト配列を暗号化します。
static String encryptoText(CipherContext context, String text, String charsetName)
          CipherContextCipherで文字列を暗号化します。
 
クラス java.lang.Object から継承されたメソッド
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

フィールドの詳細

encryptoQueueMap

protected static final ConcurrentMap<String,Queue<Cipher>> encryptoQueueMap
encrypto用のCipherプール


decryptoQueueMap

protected static final ConcurrentMap<String,Queue<Cipher>> decryptoQueueMap
decrypto用のCipherプール

コンストラクタの詳細

CipherPoolUtil

public CipherPoolUtil()
メソッドの詳細

create

public static void create(CipherContext context,
                          int size)
CipherContextCipherインスタンスを事前にプールします。

パラメータ:
context - 生成するCipherContext
size - 生成するCipherインスタンス数

encrypto

public static byte[] encrypto(CipherContext context,
                              byte[] data)
CipherContextCipherでバイト配列を暗号化します。

パラメータ:
context - 利用するCipherContext
data - 暗号化するバイト配列
戻り値:
暗号化されたバイト配列

encryptoText

public static String encryptoText(CipherContext context,
                                  String text,
                                  String charsetName)
CipherContextCipherで文字列を暗号化します。

パラメータ:
context - 利用するCipherContext
text - 暗号化する文字列
charsetName - エンコーディング名
戻り値:
暗号化された文字列

decrypto

public static byte[] decrypto(CipherContext context,
                              byte[] data)
CipherContextCipherでバイト配列を復号化します。

パラメータ:
context - 利用するCipherContext
data - 復号化するバイト配列
戻り値:
復号化されたバイト配列

decryptoText

public static String decryptoText(CipherContext context,
                                  String text,
                                  String charsetName)
CipherContextCipherで文字列を暗号化します。

パラメータ:
context - 利用するCipherContext
text - 復号化する文字列
charsetName - エンコーディング名
戻り値:
復号化された文字列


Copyright © 2010-2012 The Seasar Foundation. All Rights Reserved.