org.asunder.content
Class SSCHKContentManager

java.lang.Object
  extended by org.asunder.content.AsunderContentManager
      extended by org.asunder.content.SSCHKContentManager

public class SSCHKContentManager
extends AsunderContentManager

Author:
simms2k

Constructor Summary
SSCHKContentManager(SSCHKContent content)
          Creates a new instance of SSCHKContentManager
 
Method Summary
 void computeDataDigest()
           
 void computeKbrIdBytes()
          Computes and sets the kbr id for the content
 void computeSignature(java.security.PrivateKey priKey)
          Computes the content's signature using the supplied private key (which must match the public key of course) as sign(prikey,concat(hash,path)) Assumes the dataDigest is correct, so be warned This can be processor intensive, so be sure to run in a thread
static SSCHKContent generateSSCHKContent(byte[] data, java.security.PublicKey pubKey, java.security.PrivateKey priKey, java.lang.String path)
           
static SSCHKContentKey generateSSCHKContentKey(byte[] dataDigest, java.security.PublicKey pubKey, java.lang.String path)
          Don't really know how fast this will run, so no recommendation on running in separate thread
protected  byte[] getComputedDataDigest()
           
protected  byte[] getComputedKbrIdBytes()
          Computes the kbrId bytes as digest(concat(pubkey,hash,path))
 DHTContentKey getContentKey()
           
 byte[] getDataDigest()
           
 java.lang.String getPath()
           
 java.security.PublicKey getPublicKey()
           
 byte[] getSignature()
           
 boolean verifyContent()
           
 boolean verifyDataDigest()
           
 boolean verifyKbrIdBytes()
          Verifies the the kbr ID is properly computed from the public key, data digest, and (optional) path
 boolean verifySignature()
          Verifies the contents signature.
 
Methods inherited from class org.asunder.content.AsunderContentManager
getManager
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SSCHKContentManager

public SSCHKContentManager(SSCHKContent content)
Creates a new instance of SSCHKContentManager

Method Detail

getDataDigest

public byte[] getDataDigest()

getPath

public java.lang.String getPath()

getPublicKey

public java.security.PublicKey getPublicKey()

getSignature

public byte[] getSignature()

getContentKey

public DHTContentKey getContentKey()

getComputedDataDigest

protected byte[] getComputedDataDigest()
                                throws java.io.IOException,
                                       java.security.NoSuchAlgorithmException
Throws:
java.io.IOException
java.security.NoSuchAlgorithmException

computeDataDigest

public void computeDataDigest()
                       throws java.io.IOException,
                              java.security.NoSuchAlgorithmException
Throws:
java.io.IOException
java.security.NoSuchAlgorithmException

verifyDataDigest

public boolean verifyDataDigest()
                         throws java.io.IOException,
                                java.security.NoSuchAlgorithmException
Throws:
java.io.IOException
java.security.NoSuchAlgorithmException

verifySignature

public boolean verifySignature()
                        throws java.security.NoSuchAlgorithmException,
                               java.io.IOException,
                               java.security.SignatureException,
                               java.security.InvalidKeyException,
                               DHTContentHashException
Verifies the contents signature. as sign(prikey,concat(hash,path)) Be aware that this method assumes the dataDigest is correct This can be processor intensive, so be sure to run in a thread

Throws:
java.security.NoSuchAlgorithmException
java.io.IOException
java.security.SignatureException
java.security.InvalidKeyException
DHTContentHashException

computeSignature

public void computeSignature(java.security.PrivateKey priKey)
                      throws java.security.NoSuchAlgorithmException,
                             java.security.InvalidKeyException,
                             java.io.IOException,
                             java.security.SignatureException
Computes the content's signature using the supplied private key (which must match the public key of course) as sign(prikey,concat(hash,path)) Assumes the dataDigest is correct, so be warned This can be processor intensive, so be sure to run in a thread

Parameters:
priKey - the publisher's private key
Throws:
java.security.NoSuchAlgorithmException
java.security.InvalidKeyException
java.io.IOException
java.security.SignatureException

getComputedKbrIdBytes

protected byte[] getComputedKbrIdBytes()
                                throws DHTContentHashException,
                                       java.io.IOException,
                                       java.security.NoSuchAlgorithmException,
                                       java.security.SignatureException,
                                       java.security.InvalidKeyException

Computes the kbrId bytes as digest(concat(pubkey,hash,path))

Computes the data digest too if this is not set (but assumes it is correct if it is)

Returns:
the computed id bytes
Throws:
DHTContentHashException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException

computeKbrIdBytes

public void computeKbrIdBytes()
                       throws DHTContentHashException,
                              java.io.IOException,
                              java.security.NoSuchAlgorithmException,
                              java.security.SignatureException,
                              java.security.InvalidKeyException

Computes and sets the kbr id for the content

Notice that this does not involve the signature, so it may be computed without access to the private key

Throws:
DHTContentHashException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException

verifyKbrIdBytes

public boolean verifyKbrIdBytes()
                         throws DHTContentHashException,
                                java.io.IOException,
                                java.security.NoSuchAlgorithmException,
                                java.security.SignatureException,
                                java.security.InvalidKeyException

Verifies the the kbr ID is properly computed from the public key, data digest, and (optional) path

Notice that no assumptions are made as to the validity of the data digest

Returns:
whether the verification succeeds
Throws:
DHTContentHashException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException

verifyContent

public boolean verifyContent()
                      throws DHTContentHashException,
                             DHTContentSignatureException,
                             java.io.IOException,
                             java.security.NoSuchAlgorithmException,
                             java.security.SignatureException,
                             java.security.InvalidKeyException
Specified by:
verifyContent in class AsunderContentManager
Throws:
DHTContentHashException
DHTContentSignatureException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException

generateSSCHKContent

public static SSCHKContent generateSSCHKContent(byte[] data,
                                                java.security.PublicKey pubKey,
                                                java.security.PrivateKey priKey,
                                                java.lang.String path)
                                         throws DHTContentHashException,
                                                DHTContentSignatureException,
                                                java.io.IOException,
                                                java.security.NoSuchAlgorithmException,
                                                java.security.SignatureException,
                                                java.security.InvalidKeyException
Throws:
DHTContentHashException
DHTContentSignatureException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException

generateSSCHKContentKey

public static SSCHKContentKey generateSSCHKContentKey(byte[] dataDigest,
                                                      java.security.PublicKey pubKey,
                                                      java.lang.String path)
                                               throws DHTContentHashException,
                                                      java.io.IOException,
                                                      java.security.NoSuchAlgorithmException,
                                                      java.security.SignatureException,
                                                      java.security.InvalidKeyException

Don't really know how fast this will run, so no recommendation on running in separate thread

Returns:
a content key that can be used to search for content in the Asunder DHT
Throws:
DHTContentHashException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException