use of org.mozilla.jss.netscape.security.util.BigInt in project jss by dogtagpki.
the class PresenceServerExtension method encodeThis.
public void encodeThis() throws IOException {
try (DerOutputStream out = new DerOutputStream()) {
DerOutputStream temp = new DerOutputStream();
temp.putInteger(new BigInt(mVersion));
temp.putOctetString(mStreetAddress.getBytes());
temp.putOctetString(mTelephoneNumber.getBytes());
temp.putOctetString(mRFC822Name.getBytes());
temp.putOctetString(mID.getBytes());
temp.putOctetString(mHostName.getBytes());
temp.putInteger(new BigInt(mPortNumber));
temp.putInteger(new BigInt(mMaxUsers));
temp.putInteger(new BigInt(mServiceLevel));
out.write(DerValue.tag_Sequence, temp);
this.extensionValue = out.toByteArray();
}
}
use of org.mozilla.jss.netscape.security.util.BigInt 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.BigInt in project jss by dogtagpki.
the class CertificateVersion method encode.
/**
* Encode the CertificateVersion period in DER form to the stream.
*
* @param out the OutputStream to marshal the contents to.
* @exception IOException on errors.
*/
@Override
public void encode(OutputStream out) throws IOException {
// Nothing for default
if (version == V1) {
return;
}
try (DerOutputStream tmp = new DerOutputStream();
DerOutputStream seq = new DerOutputStream()) {
tmp.putInteger(new BigInt(version));
seq.write(DerValue.createTag(DerValue.TAG_CONTEXT, true, (byte) 0), tmp);
out.write(seq.toByteArray());
}
}
use of org.mozilla.jss.netscape.security.util.BigInt in project jss by dogtagpki.
the class BasicConstraintsExtension method encodeThis.
// Encode this extension value
private void encodeThis() throws IOException {
try (DerOutputStream out = new DerOutputStream()) {
DerOutputStream tmp = new DerOutputStream();
if (ca) {
tmp.putBoolean(ca);
}
if (pathLen >= 0) {
tmp.putInteger(new BigInt(pathLen));
}
out.write(DerValue.tag_Sequence, tmp);
this.extensionValue = out.toByteArray();
}
}
use of org.mozilla.jss.netscape.security.util.BigInt in project jss by dogtagpki.
the class PKCS7 method getCertificate.
/**
* Returns the X.509 certificate listed in this PKCS7 block
* which has a matching serial number and Issuer name, or
* null if one is not found.
*
* @param serial the serial number of the certificate to retrieve.
* @param name the Distinguished Name of the Issuer.
*/
public X509Certificate getCertificate(BigInt serial, X500Name name) {
for (int i = 0; i < certificates.length; i++) {
X509Certificate cert = certificates[i];
X500Name thisName = (X500Name) cert.getIssuerDN();
BigInteger tmpSerial = cert.getSerialNumber();
BigInt thisSerial = new BigInt(tmpSerial);
if (serial.equals(thisSerial) && name.equals(thisName)) {
return cert;
}
}
return null;
}
Aggregations