GetInstance.java revision 5359
/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 4856968 7054918
* @library ../testlibrary
* @summary make sure getInstance() works correctly, including failover
* and delayed provider selection for Signatures
* @author Andreas Sterbenz
*/
public class GetInstance {
throw new Exception("Wrong provider");
}
}
try {
} finally {
}
}
s.newInstance(null);
s.newInstance(params);
try {
s.newInstance(0);
throw new Exception("call should not succeed");
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
if (cause instanceof InvalidParameterException == false) {
throw new Exception("incorrect exception");
}
}
}
public static class FooProvider extends Provider {
FooProvider() {
super("foo", 1.0d, "none");
// throws InvalidKeyException, skipped in delayed provider selection
}
}
public static class BarProvider extends Provider {
BarProvider() {
super("bar", 1.0d, "none");
// all entries invalid for failover
// not an SPI, skipped in delayed provider selection
}
}
public static class BazProvider extends Provider {
BazProvider() {
super("baz", 1.0d, "none");
}
}
public static class FooDigest extends MessageDigestSpi {
public byte[] engineDigest() { return new byte[0]; }
public void engineReset() {}
public void engineUpdate(byte input) {}
}
public static class FooStore extends CertStoreSpi {
public FooStore(CertStoreParameters params) throws InvalidAlgorithmParameterException { super(params); }
}
public static class BaseSignatureSpi extends SignatureSpi {
}
}
protected void engineUpdate(byte b) throws SignatureException { }
protected byte[] engineSign() throws SignatureException {
return new byte[0];
}
return false;
}
}
return null;
}
}
public static class BaseSignature extends Signature {
BaseSignature(String s) {
super(s);
}
//
}
protected void engineUpdate(byte b) throws SignatureException { }
protected byte[] engineSign() throws SignatureException {
return new byte[0];
}
return false;
}
}
return null;
}
}
public byte[] getEncoded() { return null; }
}
public static class FooSignatureSpi extends BaseSignatureSpi {
public FooSignatureSpi() {
super();
}
}
public static class BazSignatureSpi extends BaseSignatureSpi {
public BazSignatureSpi() {
super();
}
throw new InvalidKeyException("verify not supported");
}
}
public static class BazSignature extends BaseSignature {
public BazSignature() {
super("baz");
}
}
}