8296072: CertAttrSet::encode and DerEncoder::derEncode should write into DerOutputStream
Reviewed-by: xuelei, mullan
This commit is contained in:
parent
37107fc157
commit
0d0bd7bd40
src/java.base/share/classes/sun/security
pkcs
pkcs10
util
x509
AVA.javaAlgorithmId.javaAuthorityInfoAccessExtension.javaAuthorityKeyIdentifierExtension.javaBasicConstraintsExtension.javaCRLDistributionPointsExtension.javaCRLExtensions.javaCRLNumberExtension.javaCRLReasonCodeExtension.javaCertAttrSet.javaCertificateAlgorithmId.javaCertificateExtensions.javaCertificateIssuerExtension.javaCertificateIssuerName.javaCertificatePoliciesExtension.javaCertificateSerialNumber.javaCertificateSubjectName.javaCertificateValidity.javaCertificateVersion.javaCertificateX509Key.javaDeltaCRLIndicatorExtension.javaExtendedKeyUsageExtension.javaExtension.javaFreshestCRLExtension.javaInhibitAnyPolicyExtension.javaInvalidityDateExtension.javaIssuerAlternativeNameExtension.javaIssuingDistributionPointExtension.javaKeyUsageExtension.javaNameConstraintsExtension.javaNetscapeCertTypeExtension.javaPolicyConstraintsExtension.javaPolicyMappingsExtension.javaPrivateKeyUsageExtension.javaSubjectAlternativeNameExtension.javaSubjectInfoAccessExtension.javaSubjectKeyIdentifierExtension.javaX509CRLImpl.javaX509CertImpl.javaX509CertInfo.java
test/jdk/sun/security
pkcs
tools/keytool
util/asn1StringTypes
@ -26,7 +26,6 @@
|
||||
package sun.security.pkcs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Date;
|
||||
|
||||
@ -525,7 +524,7 @@ public class PKCS9Attribute implements DerEncoder {
|
||||
* should be encoded as <code>T61String</code>s.
|
||||
*/
|
||||
@Override
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
DerOutputStream temp = new DerOutputStream();
|
||||
temp.putOID(oid);
|
||||
switch (index) {
|
||||
@ -643,11 +642,7 @@ public class PKCS9Attribute implements DerEncoder {
|
||||
default: // can't happen
|
||||
}
|
||||
|
||||
DerOutputStream derOut = new DerOutputStream();
|
||||
derOut.write(DerValue.tag_Sequence, temp.toByteArray());
|
||||
|
||||
out.write(derOut.toByteArray());
|
||||
|
||||
out.write(DerValue.tag_Sequence, temp.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.pkcs;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.security.*;
|
||||
import java.security.cert.*;
|
||||
@ -223,7 +222,7 @@ public class SignerInfo implements DerEncoder {
|
||||
*
|
||||
* @exception IOException on encoding error.
|
||||
*/
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
DerOutputStream seq = new DerOutputStream();
|
||||
seq.putInteger(version);
|
||||
DerOutputStream issuerAndSerialNumber = new DerOutputStream();
|
||||
@ -245,10 +244,7 @@ public class SignerInfo implements DerEncoder {
|
||||
if (unauthenticatedAttributes != null)
|
||||
unauthenticatedAttributes.encode((byte)0xA1, seq);
|
||||
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
tmp.write(DerValue.tag_Sequence, seq);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
out.write(DerValue.tag_Sequence, seq);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -25,7 +25,6 @@
|
||||
|
||||
package sun.security.pkcs10;
|
||||
|
||||
import java.io.OutputStream;
|
||||
import java.io.IOException;
|
||||
|
||||
import sun.security.pkcs.PKCS9Attribute;
|
||||
@ -108,7 +107,7 @@ public class PKCS10Attribute implements DerEncoder {
|
||||
*
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
PKCS9Attribute attr = new PKCS9Attribute(attributeId, attributeValue);
|
||||
attr.derEncode(out);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.pkcs10;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
@ -94,7 +93,7 @@ public class PKCS10Attributes implements DerEncoder {
|
||||
* @param out the OutputStream to marshal the contents to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
derEncode(out);
|
||||
}
|
||||
|
||||
@ -105,17 +104,14 @@ public class PKCS10Attributes implements DerEncoder {
|
||||
* @param out the OutputStream to marshal the contents to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
// first copy the elements into an array
|
||||
Collection<PKCS10Attribute> allAttrs = map.values();
|
||||
PKCS10Attribute[] attribs =
|
||||
allAttrs.toArray(new PKCS10Attribute[map.size()]);
|
||||
|
||||
DerOutputStream attrOut = new DerOutputStream();
|
||||
attrOut.putOrderedSetOf(DerValue.createTag(DerValue.TAG_CONTEXT,
|
||||
true, (byte)0),
|
||||
attribs);
|
||||
out.write(attrOut.toByteArray());
|
||||
out.putOrderedSetOf(
|
||||
DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0), attribs);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 1922, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Interface to an object that knows how to write its own DER
|
||||
@ -41,7 +40,7 @@ public interface DerEncoder {
|
||||
*
|
||||
* @param out the stream on which the DER encoding is written.
|
||||
*/
|
||||
void derEncode(OutputStream out)
|
||||
void derEncode(DerOutputStream out)
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
|
@ -27,7 +27,6 @@ package sun.security.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
@ -583,7 +582,7 @@ extends ByteArrayOutputStream implements DerEncoder {
|
||||
*
|
||||
* @exception IOException on output error.
|
||||
*/
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
out.write(toByteArray());
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@ package sun.security.x509;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.text.Normalizer;
|
||||
import java.util.*;
|
||||
@ -633,14 +632,12 @@ public class AVA implements DerEncoder {
|
||||
*
|
||||
* @exception IOException on encoding error.
|
||||
*/
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
DerOutputStream tmp2 = new DerOutputStream();
|
||||
|
||||
tmp.putOID(oid);
|
||||
value.encode(tmp);
|
||||
tmp2.write(DerValue.tag_Sequence, tmp);
|
||||
out.write(tmp2.toByteArray());
|
||||
out.write(DerValue.tag_Sequence, tmp);
|
||||
}
|
||||
|
||||
private String toKeyword(int format, Map<String, String> oidMap) {
|
||||
|
@ -164,9 +164,8 @@ public class AlgorithmId implements Serializable, DerEncoder {
|
||||
* @exception IOException on encoding error.
|
||||
*/
|
||||
@Override
|
||||
public void derEncode (OutputStream out) throws IOException {
|
||||
public void derEncode (DerOutputStream out) throws IOException {
|
||||
DerOutputStream bytes = new DerOutputStream();
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
|
||||
bytes.putOID(algid);
|
||||
|
||||
@ -234,8 +233,7 @@ public class AlgorithmId implements Serializable, DerEncoder {
|
||||
} else {
|
||||
bytes.write(encodedParams);
|
||||
}
|
||||
tmp.write(DerValue.tag_Sequence, bytes);
|
||||
out.write(tmp.toByteArray());
|
||||
out.write(DerValue.tag_Sequence, bytes);
|
||||
}
|
||||
|
||||
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -149,15 +148,14 @@ public class AuthorityInfoAccessExtension extends Extension
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.AuthInfoAccess_Id;
|
||||
this.critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2009, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -215,18 +214,17 @@ implements CertAttrSet<String> {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on error.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
extensionId = PKIXExtensions.AuthorityKey_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -190,16 +189,14 @@ implements CertAttrSet<String> {
|
||||
*
|
||||
* @param out the DerOutputStream to encode the extension to.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.BasicConstraints_Id;
|
||||
critical = ca;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
@ -199,7 +198,8 @@ public class CRLDistributionPointsExtension extends Extension
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
encode(out, PKIXExtensions.CRLDistributionPoints_Id, false);
|
||||
}
|
||||
|
||||
@ -207,17 +207,15 @@ public class CRLDistributionPointsExtension extends Extension
|
||||
* Write the extension to the DerOutputStream.
|
||||
* (Also called by the subclass)
|
||||
*/
|
||||
protected void encode(OutputStream out, ObjectIdentifier extensionId,
|
||||
boolean isCritical) throws IOException {
|
||||
protected void encode(DerOutputStream out, ObjectIdentifier extensionId,
|
||||
boolean isCritical) throws IOException {
|
||||
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = extensionId;
|
||||
this.critical = isCritical;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,6 @@ import java.io.OutputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.cert.CRLException;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
@ -145,16 +144,8 @@ public class CRLExtensions {
|
||||
throws CRLException {
|
||||
try {
|
||||
DerOutputStream extOut = new DerOutputStream();
|
||||
Collection<Extension> allExts = map.values();
|
||||
Object[] objs = allExts.toArray();
|
||||
|
||||
for (int i = 0; i < objs.length; i++) {
|
||||
if (objs[i] instanceof CertAttrSet)
|
||||
((CertAttrSet)objs[i]).encode(extOut);
|
||||
else if (objs[i] instanceof Extension)
|
||||
((Extension)objs[i]).encode(extOut);
|
||||
else
|
||||
throw new CRLException("Illegal extension object");
|
||||
for (Extension ext : map.values()) {
|
||||
ext.encode(extOut);
|
||||
}
|
||||
|
||||
DerOutputStream seq = new DerOutputStream();
|
||||
@ -168,7 +159,7 @@ public class CRLExtensions {
|
||||
tmp = seq;
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
} catch (IOException | CertificateException e) {
|
||||
} catch (IOException e) {
|
||||
throw new CRLException("Encoding error: " + e.toString());
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@ -198,7 +197,8 @@ implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
encode(out, PKIXExtensions.CRLNumber_Id, true);
|
||||
}
|
||||
|
||||
@ -206,18 +206,15 @@ implements CertAttrSet<String> {
|
||||
* Write the extension to the DerOutputStream.
|
||||
* (Also called by the subclass)
|
||||
*/
|
||||
protected void encode(OutputStream out, ObjectIdentifier extensionId,
|
||||
boolean isCritical) throws IOException {
|
||||
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
protected void encode(DerOutputStream out, ObjectIdentifier extensionId,
|
||||
boolean isCritical) throws IOException {
|
||||
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = extensionId;
|
||||
this.critical = isCritical;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.cert.CRLReason;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@ -158,16 +157,14 @@ public class CRLReasonCodeExtension extends Extension
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.ReasonCode_Id;
|
||||
this.critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
|
||||
package sun.security.x509;
|
||||
|
||||
import sun.security.util.DerOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@ -58,12 +59,12 @@ public interface CertAttrSet<T> {
|
||||
* Encodes the attribute to the output stream in a format
|
||||
* that can be parsed by the <code>decode</code> method.
|
||||
*
|
||||
* @param out the OutputStream to encode the attribute to.
|
||||
* @param out the DerOutputStream to encode the attribute to.
|
||||
*
|
||||
* @exception CertificateException on encoding or validity errors.
|
||||
* @exception IOException on other errors.
|
||||
*/
|
||||
void encode(OutputStream out)
|
||||
void encode(DerOutputStream out)
|
||||
throws CertificateException, IOException;
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@ package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -105,11 +104,9 @@ public class CertificateAlgorithmId implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
algId.encode(tmp);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
algId.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.security.cert.CertificateException;
|
||||
@ -148,8 +147,9 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
|
||||
* @exception CertificateException on encoding errors.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out)
|
||||
throws CertificateException, IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out)
|
||||
throws CertificateException, IOException {
|
||||
encode(out, false);
|
||||
}
|
||||
|
||||
@ -161,33 +161,21 @@ public class CertificateExtensions implements CertAttrSet<Extension> {
|
||||
* @exception CertificateException on encoding errors.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out, boolean isCertReq)
|
||||
public void encode(DerOutputStream out, boolean isCertReq)
|
||||
throws CertificateException, IOException {
|
||||
DerOutputStream extOut = new DerOutputStream();
|
||||
Collection<Extension> allExts = map.values();
|
||||
Object[] objs = allExts.toArray();
|
||||
|
||||
for (int i = 0; i < objs.length; i++) {
|
||||
if (objs[i] instanceof CertAttrSet)
|
||||
((CertAttrSet)objs[i]).encode(extOut);
|
||||
else if (objs[i] instanceof Extension)
|
||||
((Extension)objs[i]).encode(extOut);
|
||||
else
|
||||
throw new CertificateException("Illegal extension object");
|
||||
for (Extension ext : map.values()) {
|
||||
ext.encode(extOut);
|
||||
}
|
||||
|
||||
DerOutputStream seq = new DerOutputStream();
|
||||
seq.write(DerValue.tag_Sequence, extOut);
|
||||
|
||||
DerOutputStream tmp;
|
||||
if (!isCertReq) { // certificate
|
||||
tmp = new DerOutputStream();
|
||||
tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)3),
|
||||
DerOutputStream seq = new DerOutputStream();
|
||||
seq.write(DerValue.tag_Sequence, extOut);
|
||||
out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)3),
|
||||
seq);
|
||||
} else
|
||||
tmp = seq; // pkcs#10 certificateRequest
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
} else {
|
||||
out.write(DerValue.tag_Sequence, extOut);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2003, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.DerValue;
|
||||
@ -176,18 +175,17 @@ public class CertificateIssuerExtension extends Extension
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to
|
||||
* @param out the DerOutputStream to write the extension to
|
||||
* @exception IOException on encoding errors
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.CertificateIssuer_Id;
|
||||
critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@ package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
@ -107,11 +106,9 @@ public class CertificateIssuerName implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
dnName.encode(tmp);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
dnName.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
|
||||
import sun.security.util.DerValue;
|
||||
@ -177,15 +176,14 @@ implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.CertificatePolicies_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2019, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@ package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Random;
|
||||
@ -117,11 +116,9 @@ public class CertificateSerialNumber implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
serial.encode(tmp);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
serial.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@ package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.security.auth.x500.X500Principal;
|
||||
@ -107,11 +106,9 @@ public class CertificateSubjectName implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
dnName.encode(tmp);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
dnName.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,7 +25,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.cert.*;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
@ -144,10 +143,11 @@ public class CertificateValidity implements CertAttrSet<String> {
|
||||
/**
|
||||
* Encode the CertificateValidity period in DER form to the stream.
|
||||
*
|
||||
* @param out the OutputStream to marshal the contents to.
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
|
||||
// in cases where default constructor is used check for
|
||||
// null values
|
||||
@ -167,10 +167,7 @@ public class CertificateValidity implements CertAttrSet<String> {
|
||||
} else {
|
||||
pair.putGeneralizedTime(notAfter);
|
||||
}
|
||||
DerOutputStream seq = new DerOutputStream();
|
||||
seq.write(DerValue.tag_Sequence, pair);
|
||||
|
||||
out.write(seq.toByteArray());
|
||||
out.write(DerValue.tag_Sequence, pair);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,7 +27,6 @@ package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -155,10 +154,11 @@ public class CertificateVersion implements CertAttrSet<String> {
|
||||
/**
|
||||
* Encode the CertificateVersion period in DER form to the stream.
|
||||
*
|
||||
* @param out the OutputStream to marshal the contents to.
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
// Nothing for default
|
||||
if (version == V1) {
|
||||
return;
|
||||
@ -166,11 +166,8 @@ public class CertificateVersion implements CertAttrSet<String> {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
tmp.putInteger(version);
|
||||
|
||||
DerOutputStream seq = new DerOutputStream();
|
||||
seq.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0),
|
||||
out.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0),
|
||||
tmp);
|
||||
|
||||
out.write(seq.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -28,7 +28,6 @@ package sun.security.x509;
|
||||
import java.security.PublicKey;
|
||||
import java.io.InputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -97,14 +96,12 @@ public class CertificateX509Key implements CertAttrSet<String> {
|
||||
/**
|
||||
* Encode the key in DER form to the stream.
|
||||
*
|
||||
* @param out the OutputStream to marshal the contents to.
|
||||
* @param out the DerOutputStream to marshal the contents to.
|
||||
* @exception IOException on errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
tmp.write(key.getEncoded());
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
out.write(key.getEncoded());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -25,8 +25,9 @@
|
||||
|
||||
package sun.security.x509;
|
||||
|
||||
import sun.security.util.DerOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.math.BigInteger;
|
||||
|
||||
/**
|
||||
@ -106,7 +107,8 @@ public class DeltaCRLIndicatorExtension extends CRLNumberExtension {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
super.encode(out, PKIXExtensions.DeltaCRLIndicator_Id, true);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
@ -198,15 +197,14 @@ implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.ExtendedKeyUsage_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -140,22 +140,27 @@ public class Extension implements java.security.cert.Extension {
|
||||
return ext;
|
||||
}
|
||||
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
/**
|
||||
* Implementing {@link java.security.cert.Extension#encode(OutputStream)}.
|
||||
* This implementation is made final to make sure all {@code encode()}
|
||||
* methods in child classes are actually implementations of
|
||||
* {@link #encode(DerOutputStream)} below.
|
||||
*
|
||||
* @param out the output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public final void encode(OutputStream out) throws IOException {
|
||||
if (out == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
DerOutputStream dos1 = new DerOutputStream();
|
||||
DerOutputStream dos2 = new DerOutputStream();
|
||||
|
||||
dos1.putOID(extensionId);
|
||||
if (critical) {
|
||||
dos1.putBoolean(true);
|
||||
if (out instanceof DerOutputStream dos) {
|
||||
encode(dos);
|
||||
} else {
|
||||
DerOutputStream dos = new DerOutputStream();
|
||||
encode(dos);
|
||||
out.write(dos.toByteArray());
|
||||
}
|
||||
dos1.putOctetString(extensionValue);
|
||||
|
||||
dos2.write(DerValue.tag_Sequence, dos1);
|
||||
out.write(dos2.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,8 +25,9 @@
|
||||
|
||||
package sun.security.x509;
|
||||
|
||||
import sun.security.util.DerOutputStream;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -89,7 +90,8 @@ public class FreshestCRLExtension extends CRLDistributionPointsExtension {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
super.encode(out, PKIXExtensions.FreshestCRL_Id, false);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -159,16 +158,14 @@ implements CertAttrSet<String> {
|
||||
*
|
||||
* @param out the DerOutputStream to encode the extension to.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.InhibitAnyPolicy_Id;
|
||||
critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2007, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2007, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Date;
|
||||
import java.util.Enumeration;
|
||||
|
||||
@ -177,16 +176,14 @@ public class InvalidityDateExtension extends Extension
|
||||
* @param out the DerOutputStream to write the extension to
|
||||
* @exception IOException on encoding errors
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.InvalidityDate_Id;
|
||||
this.critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -159,18 +158,17 @@ extends Extension implements CertAttrSet<String> {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding error.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.IssuerAlternativeName_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2005, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@ -234,15 +233,14 @@ public class IssuingDistributionPointExtension extends Extension
|
||||
* @param out the output stream.
|
||||
* @exception IOException on encoding error.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.IssuingDistributionPoint_Id;
|
||||
this.critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -318,16 +317,14 @@ implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.KeyUsage_Id;
|
||||
this.critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.*;
|
||||
@ -233,18 +232,17 @@ implements CertAttrSet<String>, Cloneable {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.NameConstraints_Id;
|
||||
this.critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -264,16 +263,14 @@ implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = NetscapeCertType_Id;
|
||||
this.critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -201,15 +200,14 @@ implements CertAttrSet<String> {
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.PolicyConstraints_Id;
|
||||
critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.*;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -145,18 +144,17 @@ implements CertAttrSet<String> {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.PolicyMappings_Id;
|
||||
critical = true;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.security.cert.CertificateException;
|
||||
import java.security.cert.CertificateParsingException;
|
||||
import java.security.cert.CertificateExpiredException;
|
||||
@ -237,18 +236,17 @@ implements CertAttrSet<String> {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.PrivateKeyUsage_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -161,18 +160,17 @@ implements CertAttrSet<String> {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.SubjectAlternativeName_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.*;
|
||||
@ -154,15 +153,14 @@ public class SubjectInfoAccessExtension extends Extension
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (this.extensionValue == null) {
|
||||
this.extensionId = PKIXExtensions.SubjectInfoAccess_Id;
|
||||
this.critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import sun.security.util.*;
|
||||
@ -122,18 +121,17 @@ implements CertAttrSet<String> {
|
||||
/**
|
||||
* Write the extension to the OutputStream.
|
||||
*
|
||||
* @param out the OutputStream to write the extension to.
|
||||
* @param out the DerOutputStream to write the extension to.
|
||||
* @exception IOException on encoding errors.
|
||||
*/
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
@Override
|
||||
public void encode(DerOutputStream out) throws IOException {
|
||||
if (extensionValue == null) {
|
||||
extensionId = PKIXExtensions.SubjectKey_Id;
|
||||
critical = false;
|
||||
encodeThis();
|
||||
}
|
||||
super.encode(tmp);
|
||||
out.write(tmp.toByteArray());
|
||||
super.encode(out);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1257,7 +1257,7 @@ public class X509CRLImpl extends X509CRL implements DerEncoder {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
if (signedCRL == null)
|
||||
throw new IOException("Null CRL to encode");
|
||||
out.write(signedCRL.clone());
|
||||
|
@ -330,7 +330,7 @@ public class X509CertImpl extends X509Certificate implements DerEncoder {
|
||||
*
|
||||
* @exception IOException on encoding error.
|
||||
*/
|
||||
public void derEncode(OutputStream out) throws IOException {
|
||||
public void derEncode(DerOutputStream out) throws IOException {
|
||||
if (signedCert == null)
|
||||
throw new IOException("Null certificate to encode");
|
||||
out.write(signedCert.clone());
|
||||
|
@ -26,7 +26,6 @@
|
||||
package sun.security.x509;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import java.security.cert.*;
|
||||
import java.util.*;
|
||||
@ -179,14 +178,15 @@ public class X509CertInfo implements CertAttrSet<String> {
|
||||
* @exception CertificateException on encoding errors.
|
||||
* @exception IOException on other errors.
|
||||
*/
|
||||
public void encode(OutputStream out)
|
||||
throws CertificateException, IOException {
|
||||
@Override
|
||||
public void encode(DerOutputStream out)
|
||||
throws CertificateException, IOException {
|
||||
if (rawCertInfo == null) {
|
||||
DerOutputStream tmp = new DerOutputStream();
|
||||
emit(tmp);
|
||||
rawCertInfo = tmp.toByteArray();
|
||||
emit(out);
|
||||
rawCertInfo = out.toByteArray();
|
||||
} else {
|
||||
out.write(rawCertInfo.clone());
|
||||
}
|
||||
out.write(rawCertInfo.clone());
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -31,7 +31,6 @@
|
||||
* java.base/sun.security.x509
|
||||
* @run main SignerOrder
|
||||
*/
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.KeyPair;
|
||||
@ -115,7 +114,7 @@ public class SignerOrder {
|
||||
}
|
||||
|
||||
static void printSignerInfos(SignerInfo signerInfo) throws IOException {
|
||||
ByteArrayOutputStream strm = new ByteArrayOutputStream();
|
||||
DerOutputStream strm = new DerOutputStream();
|
||||
signerInfo.derEncode(strm);
|
||||
System.out.println("SignerInfo, length: "
|
||||
+ strm.toByteArray().length);
|
||||
@ -125,7 +124,7 @@ public class SignerOrder {
|
||||
}
|
||||
|
||||
static void printSignerInfos(SignerInfo[] signerInfos) throws IOException {
|
||||
ByteArrayOutputStream strm = new ByteArrayOutputStream();
|
||||
DerOutputStream strm = new DerOutputStream();
|
||||
for (int i = 0; i < signerInfos.length; i++) {
|
||||
signerInfos[i].derEncode(strm);
|
||||
System.out.println("SignerInfo[" + i + "], length: "
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2013, 2020, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2013, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -30,10 +30,10 @@
|
||||
* java.base/sun.security.util
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
|
||||
import sun.security.pkcs.PKCS9Attribute;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.util.ObjectIdentifier;
|
||||
import jdk.test.lib.hexdump.HexPrinter;
|
||||
@ -57,10 +57,10 @@ public class UnknownAttribute {
|
||||
if (p2.isKnown()) {
|
||||
throw new Exception();
|
||||
}
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
p2.derEncode(bout);
|
||||
HexPrinter.simple().dest(System.err).format(bout.toByteArray());
|
||||
if (!Arrays.equals(data, bout.toByteArray())) {
|
||||
DerOutputStream dout = new DerOutputStream();
|
||||
p2.derEncode(dout);
|
||||
HexPrinter.simple().dest(System.err).format(dout.toByteArray());
|
||||
if (!Arrays.equals(data, dout.toByteArray())) {
|
||||
throw new Exception();
|
||||
}
|
||||
// Unknown attr from value
|
||||
@ -75,9 +75,9 @@ public class UnknownAttribute {
|
||||
if (p3.isKnown()) {
|
||||
throw new Exception();
|
||||
}
|
||||
bout = new ByteArrayOutputStream();
|
||||
p3.derEncode(bout);
|
||||
if (!Arrays.equals(data, bout.toByteArray())) {
|
||||
dout = new DerOutputStream();
|
||||
p3.derEncode(dout);
|
||||
if (!Arrays.equals(data, dout.toByteArray())) {
|
||||
throw new Exception();
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2019, 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2019, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
import sun.security.tools.keytool.Main;
|
||||
import sun.security.util.DerOutputStream;
|
||||
import sun.security.util.DerValue;
|
||||
import sun.security.x509.BasicConstraintsExtension;
|
||||
import sun.security.x509.CertificateExtensions;
|
||||
@ -41,7 +42,6 @@ import sun.security.x509.Extension;
|
||||
import sun.security.x509.KeyIdentifier;
|
||||
import sun.security.x509.KeyUsageExtension;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@ -203,9 +203,9 @@ public class ExtOptionCamelCase {
|
||||
// ATTENTION: the extensions created above might contain raw
|
||||
// extensions (not of a subtype) and we need to store and reload
|
||||
// it to resolve them to subtypes.
|
||||
ByteArrayOutputStream bout = new ByteArrayOutputStream();
|
||||
exts.encode(bout);
|
||||
exts = new CertificateExtensions(new DerValue(bout.toByteArray()).data);
|
||||
DerOutputStream dout = new DerOutputStream();
|
||||
exts.encode(dout);
|
||||
exts = new CertificateExtensions(new DerValue(dout.toByteArray()).data);
|
||||
|
||||
if (clazz == null) {
|
||||
throw new Exception("Should fail");
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1999, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -63,7 +63,7 @@ public class StringTypes {
|
||||
derOut.putT61String(s);
|
||||
derOut.putBMPString(s);
|
||||
|
||||
derOut.derEncode(fout);
|
||||
fout.write(derOut.toByteArray());
|
||||
fout.close();
|
||||
|
||||
FileInputStream fis = new FileInputStream(fileName);
|
||||
|
Loading…
x
Reference in New Issue
Block a user