net.adamcin.httpsig.api
Interface Key

All Known Subinterfaces:
UserKey

public interface Key

Interface representing an object which can sign content and/or verify signatures


Method Summary
 boolean canSign()
           
 boolean canVerify()
           
 Set<Algorithm> getAlgorithms()
           
 String getId()
           
 byte[] sign(Algorithm algorithm, byte[] contentBytes)
          Signs the challengeHash using the specified signature Algorithm
 boolean verify(Algorithm algorithm, byte[] contentBytes, byte[] signatureBytes)
          Verifies the signatureBytes against the challengeHash using an underlying public key
 

Method Detail

getId

String getId()
Returns:
the Key's self-identification. This may end up not being unique within a keychain.

getAlgorithms

Set<Algorithm> getAlgorithms()
Returns:
the Set of Signature Algorithms supported by this key.

canVerify

boolean canVerify()
Returns:
true if this Key can be used for verification

verify

boolean verify(Algorithm algorithm,
               byte[] contentBytes,
               byte[] signatureBytes)
Verifies the signatureBytes against the challengeHash using an underlying public key

Parameters:
algorithm - the selected Signature Algorithm
contentBytes - the result of RequestContent.getContent(java.util.List, java.nio.charset.Charset)
signatureBytes - the result of Authorization.getSignatureBytes()
Returns:
true if signature is valid

canSign

boolean canSign()
Returns:
true if this Key can be used for signing

sign

byte[] sign(Algorithm algorithm,
            byte[] contentBytes)
Signs the challengeHash using the specified signature Algorithm

Parameters:
algorithm - the selected Signature Algorithm
contentBytes - the result of RequestContent.getContent(java.util.List, java.nio.charset.Charset)
Returns:
byte array containing the challengeHash signature or null if a signature could not be generated.


Copyright © 2013-2014. All Rights Reserved.