Inheritance diagram for edu.virtualschool.jco.JCOSignedBytes:


Definition at line 23 of file JCOSignedBytes.java.
Public Member Functions | |
| JCOSignedBytes (byte[] object, JCOAsymmetricKey signingKey) throws JCOFault | |
| JCOSignedBytes (Serializable object, JCOAsymmetricKey signingKey) throws JCOFault | |
| final Object | verify (JCOAsymmetricKey verificationKey) throws JCOSignatureFault, JCOFault |
| byte[] | getSignature () |
| String | getAlgorithm () |
| JCOEncodedBytes | encode () throws JCOFault |
Package Functions | |
| final void | signBytes (JCOAsymmetricKey signingKey) throws JCOFault |
Package Attributes | |
| byte[] | signature |
| String | algorithm |
Static Package Attributes | |
| final int | SALT_LENGTH = 25 |
| final long | serialVersionUID = -5545654298242764588L |
|
||||||||||||
|
Construct a signed byte array.
Definition at line 36 of file JCOSignedBytes.java. References edu.virtualschool.jco.JCOSignedBytes.signBytes().
00038 {
00039 super(object);
00040 signBytes(signingKey);
00041 }
|
|
||||||||||||
|
Construct a signed serializable object
Definition at line 48 of file JCOSignedBytes.java. References edu.virtualschool.jco.JCOSignedBytes.signBytes().
00050 {
00051 super(object);
00052 signBytes(signingKey);
00053 }
|
|
|
Return a clone of the receiver's signature.
Definition at line 110 of file JCOSignedBytes.java.
00111 {
00112 byte[] sig = (byte[])this.signature.clone();
00113 return sig;
00114 }
|
|
|
Internal utility used by constructors to sign the contents of the receiver's inherited byte array.
Definition at line 60 of file JCOSignedBytes.java. Referenced by edu.virtualschool.jco.JCOSignedBytes.JCOSignedBytes().
00062 {
00063 try
00064 {
00065 SecureRandom random = new SecureRandom();
00066 PSSSigner eng = new PSSSigner(new RSAEngine(), new SHA1Digest(), SALT_LENGTH);
00067 eng.init(true, new ParametersWithRandom(signingKey.getParameters(), random));
00068 eng.update(bytes, 0, bytes.length);
00069 this.signature = eng.generateSignature();
00070 }
00071 catch (CryptoException e) { throw new JCOFault(e); }
00072 catch (DataLengthException e) { throw new JCOFault(e); }
00073 }
|
|
|
Verify the signature of the receiver.
Definition at line 81 of file JCOSignedBytes.java.
00083 {
00084 try
00085 {
00086 RSAEngine engine = new RSAEngine();
00087 SHA1Digest digest = new SHA1Digest();
00088 PSSSigner signer = new PSSSigner(engine, digest, SALT_LENGTH);
00089 signer.init(false, verificationKey.getParameters());
00090 signer.update(bytes, 0, bytes.length);
00091 boolean isValid = signer.verifySignature(this.signature);
00092
00093 if (!isValid)
00094 throw new JCOSignatureFault("Signature verification failed. The verification key is not the complement of the signing key.");
00095
00096 ByteArrayInputStream bis = new ByteArrayInputStream(this.bytes);
00097 ObjectInputStream oi = new ObjectInputStream(bis);
00098 Object obj = oi.readObject();
00099 bis.close();
00100 oi.close();
00101 return obj;
00102 }
00103 catch (IOException e) { throw new JCOFault(e); }
00104 catch (ClassNotFoundException e) { throw new JCOFault(e); }
00105 }
|