diff options
author | Kenny Root <kroot@google.com> | 2014-02-12 12:32:56 -0800 |
---|---|---|
committer | Kenny Root <kroot@android.com> | 2014-02-12 21:03:14 +0000 |
commit | b81ec2b01e6cd5e613146cadd6b9628cbd26f31b (patch) | |
tree | e20b7c26f78d6ed0ed50acdfb903e225783abe81 /luni | |
parent | b6d9c26ff5501a9aff7c94bdf0317d7818fe9147 (diff) | |
download | libcore-b81ec2b01e6cd5e613146cadd6b9628cbd26f31b.zip libcore-b81ec2b01e6cd5e613146cadd6b9628cbd26f31b.tar.gz libcore-b81ec2b01e6cd5e613146cadd6b9628cbd26f31b.tar.bz2 |
Late binding: support children of Signature
The way Signature is a class of SignatureSpi allows you to register a
provider that returns a direct child of Signature. Support that by
checking if it's a subclass before trying to wrap it in SignatureImpl.
Bug: 12971079
Change-Id: I76b03f0962fe1b6ae95f205588c17d54b4bf504c
Diffstat (limited to 'luni')
-rw-r--r-- | luni/src/main/java/java/security/Signature.java | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/luni/src/main/java/java/security/Signature.java b/luni/src/main/java/java/security/Signature.java index e70898b..24f5298 100644 --- a/luni/src/main/java/java/security/Signature.java +++ b/luni/src/main/java/java/security/Signature.java @@ -25,6 +25,7 @@ import java.util.ArrayList; import java.util.Iterator; import java.util.Set; import org.apache.harmony.security.fortress.Engine; +import org.apache.harmony.security.fortress.Engine.SpiAndProvider; /** * {@code Signature} is an engine class which is capable of creating and @@ -171,7 +172,8 @@ public abstract class Signature extends SignatureSpi { throw new NoSuchAlgorithmException("Unknown algorithm: " + algorithm); } - if (tryAlgorithm(null, provider, algorithm) == null) { + SpiAndProvider spiAndProvider = tryAlgorithm(null, provider, algorithm); + if (spiAndProvider == null) { if (provider == null) { throw new NoSuchAlgorithmException("No provider found for " + algorithm); } else { @@ -179,6 +181,9 @@ public abstract class Signature extends SignatureSpi { + " does not provide " + algorithm); } } + if (spiAndProvider.spi instanceof Signature) { + return (Signature) spiAndProvider.spi; + } return new SignatureImpl(algorithm, provider); } |