8296072: CertAttrSet::encode and DerEncoder::derEncode should write into DerOutputStream

Reviewed-by: xuelei, mullan
This commit is contained in:
Weijun Wang 2022-11-01 12:49:11 +00:00
parent 37107fc157
commit 0d0bd7bd40
50 changed files with 209 additions and 314 deletions

View file

@ -26,7 +26,6 @@
package sun.security.pkcs10;
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
import java.util.Collections;
import java.util.Enumeration;
@ -94,7 +93,7 @@ public class PKCS10Attributes implements DerEncoder {
* @param out the OutputStream to marshal the contents to.
* @exception IOException on encoding errors.
*/
public void encode(OutputStream out) throws IOException {
public void encode(DerOutputStream out) throws IOException {
derEncode(out);
}
@ -105,17 +104,14 @@ public class PKCS10Attributes implements DerEncoder {
* @param out the OutputStream to marshal the contents to.
* @exception IOException on encoding errors.
*/
public void derEncode(OutputStream out) throws IOException {
public void derEncode(DerOutputStream out) throws IOException {
// first copy the elements into an array
Collection<PKCS10Attribute> allAttrs = map.values();
PKCS10Attribute[] attribs =
allAttrs.toArray(new PKCS10Attribute[map.size()]);
DerOutputStream attrOut = new DerOutputStream();
attrOut.putOrderedSetOf(DerValue.createTag(DerValue.TAG_CONTEXT,
true, (byte)0),
attribs);
out.write(attrOut.toByteArray());
out.putOrderedSetOf(
DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte)0), attribs);
}
/**