/** * @tests java.security.KeyRep.Type#values() */ @TestTargetNew( level = TestLevel.COMPLETE, notes = "", method = "values", args = {} ) public void testValues() { KeyRep.Type[] types = new KeyRep.Type[] { KeyRep.Type.SECRET, KeyRep.Type.PUBLIC, KeyRep.Type.PRIVATE }; try { assertTrue(Arrays.equals(types, KeyRep.Type.values())); } catch (Exception e) { fail("Unexpected exception " + e.getMessage()); } }
@TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", method = "readResolve", args = {} ) public final void testReadResolve04() throws ObjectStreamException { if (keyFactoryAlgorithm.isEmpty()) { System.err.println(getName() + ": skipped - no KeyFactory algorithms available"); return; } else { } for (Iterator<String> i = keyFactoryAlgorithm.iterator(); i.hasNext();) { KeyRepChild kr = new KeyRepChild(KeyRep.Type.PUBLIC, i.next(), "X.509", new byte[] { 1, 2, 3 }); try { kr.readResolve(); fail("NotSerializableException has not been thrown (no format)"); } catch (NotSerializableException ok) { } } }
@TestTargetNew( level = TestLevel.PARTIAL_COMPLETE, notes = "", method = "readResolve", args = {} ) public final void testReadResolve05() throws ObjectStreamException { if (keyFactoryAlgorithm.isEmpty()) { System.err.println(getName() + ": skipped - no KeyFactory algorithms available"); return; } else { } for (Iterator<String> i = keyFactoryAlgorithm.iterator(); i.hasNext();) { KeyRepChild kr = new KeyRepChild(KeyRep.Type.PRIVATE, i.next(), "PKCS#8", new byte[] { 1, 2, 3 }); try { kr.readResolve(); fail("NotSerializableException has not been thrown (no format)"); } catch (NotSerializableException ok) { } } }
public void bad8a() throws Exception { new DESKeySpec(null); // should not be reported byte[] key = {1, 2, 3, 4, 5, 6, 7, 8}; DESKeySpec spec = new DESKeySpec(key); KeySpec spec2 = new DESedeKeySpec(key); KerberosKey kerberosKey = new KerberosKey(null, key, 0, 0); System.out.println(spec.getKey()[0] + kerberosKey.getKeyType()); new SecretKeySpec(key, "alg"); new SecretKeySpec(key, 0, 0, "alg"); new X509EncodedKeySpec(key); new PKCS8EncodedKeySpec(key); new KeyRep(null, "alg", "format", key); new KerberosTicket(null, null, null, key, 0, null, null, null, null, null, null); new DSAPublicKeyImpl(key); }
protected Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PRIVATE, getAlgorithm(), getFormat(), getEncoded()); }
protected Object writeReplace() throws java.io.ObjectStreamException { return new KeyRep(KeyRep.Type.PUBLIC, getAlgorithm(), getFormat(), getEncoded()); }
public KeyRepChild(KeyRep.Type type, String algorithm, String format, byte[] encoded) { super(type, algorithm, format, encoded); }