Crypto Service暗号サービスThe Crypto Service allows an application to request various encryption algorithms provided by the normal Java crypto providers and 3rd party providers such as Cryptix. 暗号サービスは、アプリケーションが、ノーマルのJava暗号化プロバイダ、およびCryptixのようなサードパーティープロバイダによって提供される様々な暗号化アルゴリズムをリクエストすることを可能にします。 Configuration設定# ------------------------------------------------------------------- # # S E R V I C E S # # ------------------------------------------------------------------- # Classes for Turbine Services should be defined here. # Format: services.[name].classname=[implementing class] # # To specify properties of a service use the following syntax: # service.[name].[property]=[value] # Turbineのサービスのためのクラス群はここに定義します。 # フォーマット: services.[name].classname=[implementing class] # # サービスのプロパティを設定するには、以下の書式を使用します: # service.[name].[property]=[value] services.CryptoService.classname=org.apache.fulcrum.crypto.TurbineCryptoService . . . # ------------------------------------------------------------------- # # C R Y P T O S E R V I C E # # ------------------------------------------------------------------- # # Uncomment the following line if you want to use UnixCrypt and have # compiled the Fulcrum jar in the presence of the cryptix32.jar. # #services.CryptoService.algorithm.unix = org.apache.fulcrum.crypto.provider.UnixCrypt # # UnixCryptを使用したい場合、以下の行をアンコメントし、 # cryptix32.jarがある状態でFulcrumのjarをコンパイルしてください。 # #services.CryptoService.algorithm.unix = org.apache.fulcrum.crypto.provider.UnixCrypt # # This is a simple, cleartext "encryption" provider. # # # これはシンプルなクリアテキスト暗号化プロバイダです。 # services.CryptoService.algorithm.cleartext = org.apache.fulcrum.crypto.provider.ClearCrypt # # This is the default crypto provider. It implements the normal Java MessageDigest ciphers # You need not to have this, it is the default if no algorithms are given. The default # provider gives you all the Java MessageDigest Ciphers # # # これはデフォルト暗号プロバイダです。 # なにも持ち込む必要の無い、標準のJavaのMessageDigest Cipherを実装し、 # 他のアルゴリズムが与えられない場合のデフォルトとなります。 # デフォルトプロバイダはJavaのMessageDigest Cipherの全てを提供します。 # services.CryptoService.algorithm.default = org.apache.fulcrum.crypto.provider.JavaCrypt Usage使用方法If you want to encrypt a clear text with a MessageDigest Cipher, you can do it like this: クリアテキストをMessageDigest Cipherで暗号化したければ、このように行うことができます:
import org.apache.fulcrum.crypto.CryptoAlgorithm;
import org.apache.fulcrum.crypto.TurbineCrypto;
public class CryptoExample
{
public String doMD5Encryption(String input)
{
CryptoAlgorithm ca = TurbineCrypto.getService().getCryptoAlgorithm("default");
ca.setCipher("MD5");
return ca.encrypt(input);
}
}
Default ProviderデフォルトプロバイダIn the source code and the example above, there is talk about a "default" provider which is used if no encryption algorithm is specifically requested. The reason for this comes from the first user of the crypto service, the Security Service. It gives you the ability to select an encryption algorithm like MD5 or SHA1 which is in turn used with the normal java crypto providers. As we just wanted to "add" new algorithms and still be able to use the old java.security names like MD5 and SHA1, we decided to add a "catchall" algorithm to the crypto service. ソースコードおよび上記の例において、暗号化アルゴリズムが特にリクエストされない場合、使用される"default"プロバイダについて説明します。 これは、暗号サービスの最初のユーザ、セキュリティサービスから来るものです。 これは、ノーマルのjava暗号化プロバイダを使用し、MD5やSHA1といった暗号化アルゴリズムのどれかを選択することを可能にします。 私たちは新しいアルゴリズムをただ"add"するだけであり、さらに、古いjava.securityパッケージが名付けたMD5とSHA1のようなもの使っているものが使用できるようにするとともに、暗号のサービスに「各種の」アルゴリズムを加えることを決定しました。 If you don't set the default provider explicitly, the org.apache.fulcrum.crypto.provider.JavaCrypt class is used. If you don't set the Cipher of this class explicitly, then SHA is used. デフォルトプロバイダを明示的にセットしない場合、org.apache.fulcrum.crypto.provider.JavaCryptクラスが使用されます。 あなたがこのクラスのCipherを明示的にセットしなければ、SHAが使用されます。 Included ProvidersIncluded ProvidersThe following algorithm providers are included in the Cryptoservice: 以下のアルゴリズムプロバイダは、暗号サービスに含まれています:
|