Merge "Late binding: support children of Signature"
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.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 @@
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 @@
+ " does not provide " + algorithm);
}
}
+ if (spiAndProvider.spi instanceof Signature) {
+ return (Signature) spiAndProvider.spi;
+ }
return new SignatureImpl(algorithm, provider);
}