org.asunder.content
Class SSKKContentManager

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

public class SSKKContentManager
extends AsunderContentManager

Author:
simms2k

Constructor Summary
SSKKContentManager(SSKKContent content)
          Creates a new instance of SSKKContentManager
 
Method Summary
 void computeDataDigest()
           
 void computeKbrIdBytes()
           Computes the kbr id bytes
 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,version)) Assumes the dataDigest is correct, so be warned This can be processor intensive, so be sure to run in a thread
static SSKKContent generateSSKKContent(byte[] data, java.security.PublicKey pubKey, java.security.PrivateKey priKey, java.lang.String path, long version)
           Generates subspace-signed keyword-key content which may be inserted into the Asunder DHT
static SSKKContentKey generateSSKKContentKey(java.security.PublicKey pubKey, java.lang.String path)
          Generates a content key that may be used to search for content on the Asunder DHT
protected  byte[] getComputedKbrIdBytes()
          Computes the kbrId bytes as digest(concat(pubkey,path))
 DHTContentKey getContentKey()
           
 byte[] getDataDigest()
           
 java.lang.String getPath()
           
 java.security.PublicKey getPublicKey()
           
 byte[] getSignature()
           
 long getVersion()
           
 boolean verifyContent()
           
 boolean verifyDataDigest()
           
 boolean verifyKbrIdBytes()
           
 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

SSKKContentManager

public SSKKContentManager(SSKKContent content)
Creates a new instance of SSKKContentManager

Method Detail

getDataDigest

public byte[] getDataDigest()

getPath

public java.lang.String getPath()

getPublicKey

public java.security.PublicKey getPublicKey()

getSignature

public byte[] getSignature()

getVersion

public long getVersion()

getContentKey

public DHTContentKey getContentKey()

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
Verifies the contents signature. as sign(prikey,concat(datadigest,path,version)) 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

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,version)) 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,path))

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 the kbr id bytes

If the data digest is not set, computes this too. Otherwise, assumes it is correct

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
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

generateSSKKContent

public static SSKKContent generateSSKKContent(byte[] data,
                                              java.security.PublicKey pubKey,
                                              java.security.PrivateKey priKey,
                                              java.lang.String path,
                                              long version)
                                       throws DHTContentHashException,
                                              DHTContentSignatureException,
                                              java.io.IOException,
                                              java.security.NoSuchAlgorithmException,
                                              java.security.SignatureException,
                                              java.security.InvalidKeyException

Generates subspace-signed keyword-key content which may be inserted into the Asunder DHT

Returns:
the content
Throws:
DHTContentHashException
DHTContentSignatureException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException

generateSSKKContentKey

public static SSKKContentKey generateSSKKContentKey(java.security.PublicKey pubKey,
                                                    java.lang.String path)
                                             throws DHTContentHashException,
                                                    java.io.IOException,
                                                    java.security.NoSuchAlgorithmException,
                                                    java.security.SignatureException,
                                                    java.security.InvalidKeyException

Generates a content key that may be used to search for content on the Asunder DHT

Returns:
the content key
Throws:
DHTContentHashException
java.io.IOException
java.security.NoSuchAlgorithmException
java.security.SignatureException
java.security.InvalidKeyException