Merge remote-tracking branch 'open/master' into os-merge-2018-06-18-17_42

This commit is contained in:
Florian Friemel
2018-06-18 17:51:41 +01:00
34 changed files with 653 additions and 211 deletions

View File

@ -42,6 +42,8 @@ import java.util.jar.JarInputStream
@CordaSerializable
interface Attachment : NamedByHash {
fun open(): InputStream
@JvmDefault
fun openAsJAR(): JarInputStream {
val stream = open()
try {
@ -55,6 +57,7 @@ interface Attachment : NamedByHash {
* Finds the named file case insensitively and copies it to the output stream.
* @throws FileNotFoundException if the given path doesn't exist in the attachment.
*/
@JvmDefault
fun extractFile(path: String, outputTo: OutputStream) = openAsJAR().use { it.extractFile(path, outputTo) }
/**

View File

@ -43,6 +43,7 @@ interface TransactionWithSignatures : NamedByHash {
* @throws SignatureException if any signatures are invalid or unrecognised.
* @throws SignaturesMissingException if any signatures should have been present but were not.
*/
@JvmDefault
@Throws(SignatureException::class)
fun verifyRequiredSignatures() = verifySignaturesExcept(emptySet())
@ -58,6 +59,7 @@ interface TransactionWithSignatures : NamedByHash {
* @throws SignatureException if any signatures are invalid or unrecognised.
* @throws SignaturesMissingException if any signatures should have been present but were not.
*/
@JvmDefault
@Throws(SignatureException::class)
fun verifySignaturesExcept(vararg allowedToBeMissing: PublicKey) {
verifySignaturesExcept(Arrays.asList(*allowedToBeMissing))
@ -75,6 +77,7 @@ interface TransactionWithSignatures : NamedByHash {
* @throws SignatureException if any signatures are invalid or unrecognised.
* @throws SignaturesMissingException if any signatures should have been present but were not.
*/
@JvmDefault
@Throws(SignatureException::class)
fun verifySignaturesExcept(allowedToBeMissing: Collection<PublicKey>) {
val needed = getMissingSigners() - allowedToBeMissing
@ -92,6 +95,7 @@ interface TransactionWithSignatures : NamedByHash {
* @throws InvalidKeyException if the key on a signature is invalid.
* @throws SignatureException if a signature fails to verify.
*/
@JvmDefault
@Throws(InvalidKeyException::class, SignatureException::class)
fun checkSignaturesAreValid() {
for (sig in sigs) {
@ -110,6 +114,7 @@ interface TransactionWithSignatures : NamedByHash {
/**
* Return the [PublicKey]s for which we still need signatures.
*/
@JvmDefault
fun getMissingSigners(): Set<PublicKey> {
val sigKeys = sigs.map { it.by }.toSet()
// TODO Problem is that we can get single PublicKey wrapped as CompositeKey in allowedToBeMissing/mustSign