|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecteneter.messaging.dataprocessing.serializing.RsaSerializer
public class RsaSerializer
Serializer using RSA. The serialization:
String aDataToSerialize = "Hello";
KeyPairGenerator aKeyPairGenerator = KeyPairGenerator.getInstance("RSA");
aKeyPairGenerator.initialize(1024);
KeyPair aKeyPair = aKeyPairGenerator.generateKeyPair();
RSAPrivateKey aPrivateKey = (RSAPrivateKey)aKeyPair.getPrivate();
RSAPublicKey aPublicKey = (RSAPublicKey)aKeyPair.getPublic();
RsaSerializer aSerializer = new RsaSerializer(aPublicKey, aPrivateKey);
Object aSerializedData = aSerializer.serialize(aDataToSerialize, String.class);
String aDeserializedData = aSerializer.deserialize(aSerializedData, String.class);
Constructor Summary | |
---|---|
RsaSerializer(java.security.interfaces.RSAPublicKey publicKey,
java.security.interfaces.RSAPrivateKey privateKey)
Constructs the RSA serializer with default paraneters. |
|
RsaSerializer(java.security.interfaces.RSAPublicKey publicKey,
java.security.interfaces.RSAPrivateKey privateKey,
int aesBitSize,
ISerializer underlyingSerializer)
Constructs the RSA serializer with custom parameters. |
Method Summary | ||
---|---|---|
|
deserialize(java.lang.Object serializedData,
java.lang.Class<T> clazz)
Deserializes data. |
|
java.lang.String |
getCipherTransformationSpecification()
Gets name of used cipher transformation name. |
|
|
serialize(T dataToSerialize,
java.lang.Class<T> clazz)
Serializes data. |
|
RsaSerializer |
setCipherTransformationSpecification(java.lang.String cipherTransformationName)
Sets name of the cipher transformation. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RsaSerializer(java.security.interfaces.RSAPublicKey publicKey, java.security.interfaces.RSAPrivateKey privateKey)
publicKey
- public key used for serialization. It can be null if the serializer will be used only for deserialization.privateKey
- private key used for deserialization. It can be null if the serializer will be used only for serialization.public RsaSerializer(java.security.interfaces.RSAPublicKey publicKey, java.security.interfaces.RSAPrivateKey privateKey, int aesBitSize, ISerializer underlyingSerializer)
publicKey
- publicKey public key used for serialization. It can be null if the serializer will be used only for deserialization.privateKey
- private key used for deserialization. It can be null if the serializer will be used only for serialization.aesBitSize
- size of the random key generated for the AES encryption, 128, 256, ... Default value is 128.underlyingSerializer
- underlying serializer used to serialize/deserialize data e.g. XmlStringSerializerMethod Detail |
---|
public RsaSerializer setCipherTransformationSpecification(java.lang.String cipherTransformationName)
cipherTransformationName
- sets the transformation name in format algorithmName/algorithmMode/algorithmPadding
The default value which is compatible with .NET is RSA/ECB/PKCS1Padding.
public java.lang.String getCipherTransformationSpecification()
public <T> java.lang.Object serialize(T dataToSerialize, java.lang.Class<T> clazz) throws java.lang.Exception
serialize
in interface ISerializer
dataToSerialize
- Data to be serialized.clazz
- represents the serialized type.
java.lang.Exception
- If the serialization fails.public <T> T deserialize(java.lang.Object serializedData, java.lang.Class<T> clazz) throws java.lang.Exception
deserialize
in interface ISerializer
serializedData
- Data to be deserialized.
java.lang.Exception
- If the deserialization fails.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |