use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificateExtensions method encode.
/**
* Encode the extensions in DER form to the stream.
*
* @param out the DerOutputStream to marshal the contents to.
* @exception CertificateException on encoding errors.
* @exception IOException on errors.
*/
@Override
public void encode(OutputStream out) throws CertificateException, IOException {
try (DerOutputStream tmp = new DerOutputStream()) {
DerOutputStream extOut = new DerOutputStream();
for (int i = 0; i < size(); i++) {
Object thisOne = elementAt(i);
if (thisOne instanceof CertAttrSet)
((CertAttrSet) thisOne).encode(extOut);
else if (thisOne instanceof Extension)
((Extension) thisOne).encode(extOut);
else
throw new CertificateException("Invalid extension object");
}
DerOutputStream seq = new DerOutputStream();
seq.write(DerValue.tag_Sequence, extOut);
tmp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 3), seq);
out.write(tmp.toByteArray());
}
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificateIssuerName method encode.
/**
* Encode the name in DER form to the stream.
*
* @param out the DerOutputStream to marshal the contents to.
* @exception IOException on errors.
*/
@Override
public void encode(OutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
dnName.encode(tmp);
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificatePoliciesExtension method encode.
/**
* Write the extension to the OutputStream.
*
* @param out the OutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@Override
public void encode(OutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
if (extensionValue == null) {
extensionId = PKIXExtensions.CertificatePolicies_Id;
critical = false;
encodeThis();
}
super.encode(tmp);
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class IssuerAlternativeNameExtension method encodeThis.
// Encode this extension
private void encodeThis() throws IOException {
DerOutputStream os = new DerOutputStream();
try {
names.encode(os);
} catch (GeneralNamesException e) {
throw new IOException(e);
}
this.extensionValue = os.toByteArray();
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class InvalidityDateExtension method encodeThis.
// Encode this extension value
private void encodeThis() throws IOException {
if (invalidityDate == null)
throw new IOException("Unintialized invalidity date extension");
try (DerOutputStream os = new DerOutputStream()) {
os.putGeneralizedTime(this.invalidityDate);
this.extensionValue = os.toByteArray();
}
}
Aggregations