Skip to content

Commit

Permalink
8296612: CertAttrSet is useless
Browse files Browse the repository at this point in the history
Reviewed-by: mullan
  • Loading branch information
wangweij committed Nov 10, 2022
1 parent 6b456f7 commit 27527b4
Show file tree
Hide file tree
Showing 52 changed files with 80 additions and 203 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected byte[] engineGetEncoded() throws IOException {
" impl not found");
}
tmp2 = new DerOutputStream();
mdAlgId.derEncode(tmp2);
mdAlgId.encode(tmp2);
tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0),
tmp2);

Expand Down
4 changes: 2 additions & 2 deletions src/java.base/share/classes/sun/security/pkcs/PKCS7.java
Original file line number Diff line number Diff line change
Expand Up @@ -782,9 +782,9 @@ public static byte[] generateNewSignedData(
// CMSAlgorithmProtection (RFC6211)
DerOutputStream derAp = new DerOutputStream();
DerOutputStream derAlgs = new DerOutputStream();
digAlgID.derEncode(derAlgs);
digAlgID.encode(derAlgs);
DerOutputStream derSigAlg = new DerOutputStream();
sigAlgID.derEncode(derSigAlg);
sigAlgID.encode(derSigAlg);
derAlgs.writeImplicit((byte)0xA1, derSigAlg);
derAp.write(DerValue.tag_Sequence, derAlgs);
authAttrs = new PKCS9Attributes(new PKCS9Attribute[]{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ public PKCS9Attribute(DerValue derVal) throws IOException {
* should be encoded as <code>T61String</code>s.
*/
@Override
public void derEncode(DerOutputStream out) throws IOException {
public void encode(DerOutputStream out) throws IOException {
DerOutputStream temp = new DerOutputStream();
temp.putOID(oid);
switch (index) {
Expand Down
8 changes: 2 additions & 6 deletions src/java.base/share/classes/sun/security/pkcs/SignerInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,6 @@ private void checkCMSAlgorithmProtection() throws IOException {
}
}

public void encode(DerOutputStream out) throws IOException {

derEncode(out);
}

/**
* DER encode this object onto an output stream.
* Implements the {@code DerEncoder} interface.
Expand All @@ -222,7 +217,8 @@ public void encode(DerOutputStream out) throws IOException {
*
* @exception IOException on encoding error.
*/
public void derEncode(DerOutputStream out) throws IOException {
@Override
public void encode(DerOutputStream out) throws IOException {
DerOutputStream seq = new DerOutputStream();
seq.putInteger(version);
DerOutputStream issuerAndSerialNumber = new DerOutputStream();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,10 @@ public PKCS10Attribute(PKCS9Attribute attr) {
*
* @exception IOException on encoding errors.
*/
public void derEncode(DerOutputStream out) throws IOException {
@Override
public void encode(DerOutputStream out) throws IOException {
PKCS9Attribute attr = new PKCS9Attribute(attributeId, attributeValue);
attr.derEncode(out);
attr.encode(out);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,24 +87,15 @@ public PKCS10Attributes(DerInputStream in) throws IOException {
}
}

/**
* Encode the attributes in DER form to the stream.
*
* @param out the OutputStream to marshal the contents to.
* @exception IOException on encoding errors.
*/
public void encode(DerOutputStream out) throws IOException {
derEncode(out);
}

/**
* Encode the attributes in DER form to the stream.
* Implements the {@code DerEncoder} interface.
*
* @param out the OutputStream to marshal the contents to.
* @exception IOException on encoding errors.
*/
public void derEncode(DerOutputStream out) throws IOException {
@Override
public void encode(DerOutputStream out) throws IOException {
// first copy the elements into an array
Collection<PKCS10Attribute> allAttrs = map.values();
PKCS10Attribute[] attribs =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public static byte[] getEncoded(PSSParameterSpec spec) throws IOException {
}
if (!mdAlgId.getOID().equals(AlgorithmId.SHA_oid)) {
tmp2 = new DerOutputStream();
mdAlgId.derEncode(tmp2);
mdAlgId.encode(tmp2);
tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0),
tmp2);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public interface DerEncoder {
*
* @param out the stream on which the DER encoding is written.
*/
void derEncode(DerOutputStream out)
void encode(DerOutputStream out)
throws IOException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ private DerOutputStream putOrderedSet(byte tag, DerEncoder[] set,

for (int i = 0; i < set.length; i++) {
streams[i] = new DerOutputStream();
set[i].derEncode(streams[i]);
set[i].encode(streams[i]);
}

// order the element encodings
Expand Down Expand Up @@ -582,7 +582,8 @@ public void putLength(int len) throws IOException {
*
* @exception IOException on output error.
*/
public void derEncode(DerOutputStream out) throws IOException {
@Override
public void encode(DerOutputStream out) throws IOException {
out.write(toByteArray());
}

Expand All @@ -592,7 +593,7 @@ public void derEncode(DerOutputStream out) throws IOException {
* @throws IOException on output error
*/
public DerOutputStream write(DerEncoder encoder) throws IOException {
encoder.derEncode(this);
encoder.encode(this);
return this;
}

Expand Down
10 changes: 2 additions & 8 deletions src/java.base/share/classes/sun/security/x509/AVA.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,13 +616,6 @@ public int hashCode() {
return toRFC2253CanonicalString().hashCode();
}

/*
* AVAs are encoded as a SEQUENCE of two elements.
*/
public void encode(DerOutputStream out) throws IOException {
derEncode(out);
}

/**
* DER encode this object onto an output stream.
* Implements the <code>DerEncoder</code> interface.
Expand All @@ -632,7 +625,8 @@ public void encode(DerOutputStream out) throws IOException {
*
* @exception IOException on encoding error.
*/
public void derEncode(DerOutputStream out) throws IOException {
@Override
public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();

tmp.putOID(oid);
Expand Down
11 changes: 2 additions & 9 deletions src/java.base/share/classes/sun/security/x509/AlgorithmId.java
Original file line number Diff line number Diff line change
Expand Up @@ -147,13 +147,6 @@ protected void decodeParams() throws IOException {
algParams.init(encodedParams.clone());
}

/**
* Marshal a DER-encoded "AlgorithmID" sequence on the DER stream.
*/
public final void encode(DerOutputStream out) throws IOException {
derEncode(out);
}

/**
* DER encode this object onto an output stream.
* Implements the <code>DerEncoder</code> interface.
Expand All @@ -164,7 +157,7 @@ public final void encode(DerOutputStream out) throws IOException {
* @exception IOException on encoding error.
*/
@Override
public void derEncode (DerOutputStream out) throws IOException {
public void encode (DerOutputStream out) throws IOException {
DerOutputStream bytes = new DerOutputStream();

bytes.putOID(algid);
Expand Down Expand Up @@ -242,7 +235,7 @@ public void derEncode (DerOutputStream out) throws IOException {
*/
public final byte[] encode() throws IOException {
DerOutputStream out = new DerOutputStream();
derEncode(out);
encode(out);
return out.toByteArray();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,9 @@
* </pre>
*
* @see Extension
* @see CertAttrSet
*/

public class AuthorityInfoAccessExtension extends Extension
implements CertAttrSet {
public class AuthorityInfoAccessExtension extends Extension {

public static final String NAME = "AuthorityInfoAccess";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,8 @@
* @author Amit Kapoor
* @author Hemma Prafullchandra
* @see Extension
* @see CertAttrSet
*/
public class AuthorityKeyIdentifierExtension extends Extension
implements CertAttrSet {
public class AuthorityKeyIdentifierExtension extends Extension {

public static final String NAME = "AuthorityKeyIdentifier";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,9 @@
* </pre>
* @author Amit Kapoor
* @author Hemma Prafullchandra
* @see CertAttrSet
* @see Extension
*/
public class BasicConstraintsExtension extends Extension
implements CertAttrSet {
public class BasicConstraintsExtension extends Extension {

public static final String NAME = "BasicConstraints";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,8 @@
* @since 1.4.2
* @see DistributionPoint
* @see Extension
* @see CertAttrSet
*/
public class CRLDistributionPointsExtension extends Extension
implements CertAttrSet {
public class CRLDistributionPointsExtension extends Extension {

public static final String NAME = "CRLDistributionPoints";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,8 @@
*
* @author Hemma Prafullchandra
* @see Extension
* @see CertAttrSet
*/
public class CRLNumberExtension extends Extension
implements CertAttrSet {
public class CRLNumberExtension extends Extension {

public static final String NAME = "CRLNumber";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,8 @@
* @author Hemma Prafullchandra
* @see java.security.cert.CRLReason
* @see Extension
* @see CertAttrSet
*/
public class CRLReasonCodeExtension extends Extension
implements CertAttrSet {
public class CRLReasonCodeExtension extends Extension {

public static final String NAME = "CRLReasonCode";

Expand Down
44 changes: 0 additions & 44 deletions src/java.base/share/classes/sun/security/x509/CertAttrSet.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
* @author Amit Kapoor
* @author Hemma Prafullchandra
*/
public class CertificateAlgorithmId implements CertAttrSet {
public class CertificateAlgorithmId implements DerEncoder {
private AlgorithmId algId;

public static final String NAME = "algorithmID";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
*
* @author Amit Kapoor
* @author Hemma Prafullchandra
* @see CertAttrSet
* @see DerEncoder
*/
public class CertificateExtensions implements CertAttrSet {
public class CertificateExtensions implements DerEncoder {

public static final String NAME = "extensions";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,8 @@
* @author Sean Mullan
* @since 1.5
* @see Extension
* @see CertAttrSet
*/
public class CertificateIssuerExtension extends Extension
implements CertAttrSet {
public class CertificateIssuerExtension extends Extension {

public static final String NAME = "CertificateIssuer";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@
* @author Anne Anderson
* @since 1.4
* @see Extension
* @see CertAttrSet
*/
public class CertificatePoliciesExtension extends Extension
implements CertAttrSet {
public class CertificatePoliciesExtension extends Extension {

public static final String NAME = "CertificatePolicies";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
*
* @author Amit Kapoor
* @author Hemma Prafullchandra
* @see CertAttrSet
* @see DerEncoder
*/
public class CertificateSerialNumber implements CertAttrSet {
public class CertificateSerialNumber implements DerEncoder {

public static final String NAME = "serialNumber";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
*
* @author Amit Kapoor
* @author Hemma Prafullchandra
* @see CertAttrSet
* @see DerEncoder
*/
public class CertificateSubjectName implements CertAttrSet {
public class CertificateSubjectName implements DerEncoder {

public static final String NAME = "subject";

Expand Down

1 comment on commit 27527b4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.