use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class PresenceServerExtension method encode.
@Override
public void encode(OutputStream out) throws CertificateException, IOException {
DerOutputStream dos = new DerOutputStream();
super.encode(dos);
out.write(dos.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class PKCS10 method encodeAndSign.
/**
* Create the signed certificate request. This will later be
* retrieved in either string or binary format.
*
* @param requester identifies the signer (by X.500 name)
* and provides the private key used to sign.
* @exception IOException on errors.
* @exception CertificateException on certificate handling errors.
* @exception SignatureException on signature handling errors.
*/
public void encodeAndSign(X500Signer requester) throws CertificateException, IOException, SignatureException {
DerOutputStream out, scratch;
byte[] certificateRequestInfo;
byte[] sig;
if (certificateRequest != null)
throw new SignatureException("request is already signed");
subject = requester.getSigner();
/*
* Encode cert request info, wrap in a sequence for signing
*/
scratch = new DerOutputStream();
// version zero
scratch.putInteger(new BigInt(0));
// X.500 name
subject.encode(scratch);
// public key
subjectPublicKeyInfo.encode(scratch);
attributeSet.encode(scratch);
out = new DerOutputStream();
// wrap it!
out.write(DerValue.tag_Sequence, scratch);
certificateRequestInfo = out.toByteArray();
scratch = out;
/*
* Sign it ...
*/
requester.update(certificateRequestInfo, 0, certificateRequestInfo.length);
sig = requester.sign();
/*
* Build guts of SIGNED macro
*/
// sig algorithm
requester.getAlgorithmId().encode(scratch);
// sig
scratch.putBitString(sig);
/*
* Wrap those guts in a sequence
*/
out = new DerOutputStream();
out.write(DerValue.tag_Sequence, scratch);
certificateRequest = out.toByteArray();
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class CertificateScopeEntry method encode.
public void encode(DerOutputStream out) throws IOException {
DerOutputStream tmp = new DerOutputStream();
mGn.encode(tmp);
if (mPort != null) {
tmp.putInteger(mPort);
}
out.write(DerValue.tag_Sequence, tmp);
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class ExtendedKeyUsageExtension method encodeExtValue.
private void encodeExtValue() throws IOException {
DerOutputStream out = new DerOutputStream();
DerOutputStream temp = new DerOutputStream();
if (!oidSet.isEmpty()) {
Enumeration<ObjectIdentifier> oidList = oidSet.elements();
try {
while (oidList.hasMoreElements()) {
temp.putOID(oidList.nextElement());
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
try {
out.write(DerValue.tag_Sequence, temp);
} catch (IOException ex) {
} finally {
out.close();
}
extensionValue = out.toByteArray();
}
use of org.mozilla.jss.netscape.security.util.DerOutputStream in project jss by dogtagpki.
the class ExtendedKeyUsageExtension method encode.
@Override
public void encode(OutputStream out) throws CertificateException, IOException {
if (mCached == null) {
DerOutputStream temp = new DerOutputStream();
encode(temp);
}
out.write(mCached);
}
Aggregations