use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificateIssuerUniqueIdentity method encode.
/**
* Encode the identity 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();
id.encode(tmp, DerValue.createTag(DerValue.TAG_CONTEXT, false, (byte) 1));
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class HoldInstructionExtension method encodeThis.
// Encode this extension value
private void encodeThis() throws IOException {
if (holdInstructionCodeOID == null)
throw new IOException("Unintialized hold instruction extension");
try (DerOutputStream os = new DerOutputStream()) {
os.putOID(holdInstructionCodeOID);
this.extensionValue = os.toByteArray();
}
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class GeneralNames method encode.
/**
* Write the extension to the DerOutputStream.
*
* @param out the DerOutputStream to write the extension to.
* @exception GeneralNamesException on encoding error.
* @exception IOException on error.
*/
public void encode(DerOutputStream out) throws IOException, GeneralNamesException {
if (size() == 0) {
return;
}
Enumeration<GeneralNameInterface> names = elements();
DerOutputStream temp = new DerOutputStream();
while (names.hasMoreElements()) {
Object obj = names.nextElement();
if (!(obj instanceof GeneralNameInterface)) {
throw new GeneralNamesException("Element in GeneralNames " + "not of type GeneralName.");
}
GeneralNameInterface intf = (GeneralNameInterface) obj;
if (obj instanceof GeneralName) {
intf.encode(temp);
} else {
DerOutputStream gname = new DerOutputStream();
intf.encode(gname);
int nameType = intf.getType();
// constructed form
if (nameType == GeneralNameInterface.NAME_ANY || nameType == GeneralNameInterface.NAME_X400 || nameType == GeneralNameInterface.NAME_EDI) {
temp.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) nameType), gname);
} else if (nameType == GeneralNameInterface.NAME_DIRECTORY) {
// EXPLICIT tag because directoryName is a CHOICE
temp.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) nameType), gname);
} else
// primitive form
temp.writeImplicit(DerValue.createTag(DerValue.TAG_CONTEXT, false, (byte) nameType), gname);
}
}
out.write(DerValue.tag_Sequence, temp);
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class KeyUsageExtension method encode.
/**
* Write the extension to the DerOutputStream.
*
* @param out the DerOutputStream to write the extension to.
* @exception IOException on encoding errors.
*/
@Override
public void encode(OutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
if (this.extensionValue == null) {
this.extensionId = PKIXExtensions.KeyUsage_Id;
this.critical = true;
encodeThis();
}
super.encode(tmp);
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class NameConstraintsExtension 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 (this.extensionValue == null) {
this.extensionId = PKIXExtensions.NameConstraints_Id;
encodeThis();
}
super.encode(tmp);
out.write(tmp.toByteArray());
}
Aggregations