use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class SubjectInfoAccessExtension method decodeThis.
private void decodeThis() throws IOException {
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
throw new IOException("Invalid encoding of AuthInfoAccess extension");
}
while (val.data.available() != 0) {
DerValue seq = val.data.getDerValue();
ObjectIdentifier method = seq.data.getDerValue().getOID();
GeneralName gn = new GeneralName(seq.data.getDerValue());
addAccessDescription(method, gn);
}
}
use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class GenericASN1Extension 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();
try {
if (this.extensionValue == null) {
this.extensionId = new ObjectIdentifier(OID);
this.critical = true;
encodeThis();
}
} catch (ParseException e) {
}
super.encode(tmp);
out.write(tmp.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class AuthInfoAccessExtension method decodeThis.
private void decodeThis() throws IOException {
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
throw new IOException("Invalid encoding of AuthInfoAccess extension");
}
while (val.data.available() != 0) {
DerValue seq = val.data.getDerValue();
ObjectIdentifier method = seq.data.getDerValue().getOID();
GeneralName gn = new GeneralName(seq.data.getDerValue());
addAccessDescription(method, gn);
}
}
use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class X509CRLImpl method getExtensionValue.
/**
* Gets the DER encoded OCTET string for the extension value
* (<code>extnValue</code>) identified by the passed in oid String.
* The <code>oid</code> string is
* represented by a set of positive whole number separated
* by ".", that means,<br>
* <positive whole number>.<positive whole number>.<...>
*
* @param oid the Object Identifier value for the extension.
* @return the der encoded octet string of the extension value.
*/
@Override
public byte[] getExtensionValue(String oid) {
if (extensions == null)
return null;
try (DerOutputStream out = new DerOutputStream()) {
String extAlias = OIDMap.getName(new ObjectIdentifier(oid));
Extension crlExt = null;
if (extAlias == null) {
// may be unknown
ObjectIdentifier findOID = new ObjectIdentifier(oid);
Extension ex = null;
ObjectIdentifier inCertOID;
for (Enumeration<Extension> e = extensions.getElements(); e.hasMoreElements(); ) {
ex = e.nextElement();
inCertOID = ex.getExtensionId();
if (inCertOID.equals(findOID)) {
crlExt = ex;
break;
}
}
} else
crlExt = extensions.get(extAlias);
if (crlExt == null)
return null;
byte[] extData = crlExt.getExtensionValue();
if (extData == null)
return null;
out.putOctetString(extData);
return out.toByteArray();
} catch (Exception e) {
return null;
}
}
use of org.mozilla.jss.netscape.security.util.ObjectIdentifier in project jss by dogtagpki.
the class LdapV3DNStrConverter method parseAVAKeyword.
/**
* Converts a AVA keyword from a Ldap DN string to an ObjectIdentifier
* from the attribute map or, if this keyword is an OID not
* in the attribute map, create a new ObjectIdentifier for the keyword
* if acceptUnknownOids is true.
*
* @param avaKeyword AVA keyword from a Ldap DN string.
*
* @return a ObjectIdentifier object
* @exception IOException if the keyword is an OID not in the attribute
* map and acceptUnknownOids is false, or
* if an error occurs during conversion.
*/
public ObjectIdentifier parseAVAKeyword(String avaKeyword) throws IOException {
String keyword = avaKeyword.toUpperCase().trim();
String oid_str = null;
ObjectIdentifier oid, new_oid;
if (Character.digit(keyword.charAt(0), 10) != -1) {
// value is an oid string of 1.2.3.4
oid_str = keyword;
} else if (keyword.startsWith("oid.") || keyword.startsWith("OID.")) {
// value is an oid string of oid.1.2.3.4 or OID.1.2...
oid_str = keyword.substring(4);
}
if (oid_str != null) {
// value is an oid string of 1.2.3.4 or oid.1.2.3.4 or OID.1.2...
new_oid = new ObjectIdentifier(oid_str);
oid = attrMap.getOid(new_oid);
if (oid == null) {
if (!acceptUnknownOids)
throw new IOException("Unknown AVA OID.");
oid = new_oid;
}
} else {
oid = attrMap.getOid(keyword);
if (oid == null)
throw new IOException("Unknown AVA keyword '" + keyword + "'.");
}
return oid;
}
Aggregations