mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-28 15:24:43 +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
|
@ -140,22 +140,27 @@ public class Extension implements java.security.cert.Extension {
|
|||
return ext;
|
||||
}
|
||||
|
||||
public void encode(OutputStream out) throws IOException {
|
||||
/**
|
||||
* Implementing {@link java.security.cert.Extension#encode(OutputStream)}.
|
||||
* This implementation is made final to make sure all {@code encode()}
|
||||
* methods in child classes are actually implementations of
|
||||
* {@link #encode(DerOutputStream)} below.
|
||||
*
|
||||
* @param out the output stream
|
||||
* @throws IOException
|
||||
*/
|
||||
@Override
|
||||
public final void encode(OutputStream out) throws IOException {
|
||||
if (out == null) {
|
||||
throw new NullPointerException();
|
||||
}
|
||||
|
||||
DerOutputStream dos1 = new DerOutputStream();
|
||||
DerOutputStream dos2 = new DerOutputStream();
|
||||
|
||||
dos1.putOID(extensionId);
|
||||
if (critical) {
|
||||
dos1.putBoolean(true);
|
||||
if (out instanceof DerOutputStream dos) {
|
||||
encode(dos);
|
||||
} else {
|
||||
DerOutputStream dos = new DerOutputStream();
|
||||
encode(dos);
|
||||
out.write(dos.toByteArray());
|
||||
}
|
||||
dos1.putOctetString(extensionValue);
|
||||
|
||||
dos2.write(DerValue.tag_Sequence, dos1);
|
||||
out.write(dos2.toByteArray());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue