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