Example usage for java.security SignedObject getObject

List of usage examples for java.security SignedObject getObject

Introduction

In this page you can find the example usage for java.security SignedObject getObject.

Prototype

public Object getObject() throws IOException, ClassNotFoundException 

Source Link

Document

Retrieves the encapsulated object.

Usage

From source file:Main.java

public static void main(String[] argv) throws Exception {
    KeyPairGenerator keyGen = KeyPairGenerator.getInstance("DSA");
    keyGen.initialize(1024);//from w w w  . j ava 2s.  co  m
    KeyPair keypair = keyGen.genKeyPair();
    PrivateKey privateKey = keypair.getPrivate();
    PublicKey publicKey = keypair.getPublic();

    Serializable o = new MyClass();
    Signature sig = Signature.getInstance(privateKey.getAlgorithm());
    SignedObject so = new SignedObject(o, privateKey, sig);

    sig = Signature.getInstance(publicKey.getAlgorithm());
    boolean b = so.verify(publicKey, sig);
    o = (MyClass) so.getObject();
}