use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class ContentInfo method encode.
public void encode(DerOutputStream out) throws IOException {
DerOutputStream contentDerCode;
DerOutputStream seq;
DerValue taggedContent;
contentDerCode = new DerOutputStream();
content.encode(contentDerCode);
// Add the [0] EXPLICIT tag in front of the content encoding
taggedContent = new DerValue((byte) 0xA0, contentDerCode.toByteArray());
seq = new DerOutputStream();
seq.putOID(contentType);
seq.putDerValue(taggedContent);
out.write(DerValue.tag_Sequence, seq);
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class InhibitAnyPolicyExtension method decodeThis.
private void decodeThis() throws IOException {
DerValue val = new DerValue(this.extensionValue);
mSkipCerts = val.getInteger();
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class CertificateScopeOfUseExtension 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 CertificateWindow extension");
}
mEntries = new Vector<>();
while (val.data.available() != 0) {
mEntries.addElement(new CertificateScopeEntry(val.data.getDerValue()));
}
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class GenericASN1Extension method encodePattern.
// Encode pattern
private byte[] encodePattern() throws IOException, ParseException {
DerOutputStream tmp = new DerOutputStream();
String type = null;
String value = null;
String source = null;
while (index < pattern.length()) {
char ch = pattern.charAt(index);
switch(ch) {
case '{':
index++;
byte[] buff = encodePattern();
tmp.putDerValue(new DerValue(buff));
break;
case '}':
try (DerOutputStream os = new DerOutputStream()) {
os.write(DerValue.tag_Sequence, tmp);
return os.toByteArray();
}
default:
type = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_TYPE);
if (type.equalsIgnoreCase("integer")) {
int num = Integer.parseInt(mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE));
PutInteger(tmp, num);
} else if (type.equalsIgnoreCase("ia5string")) {
source = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_SOURCE);
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
if (source.equalsIgnoreCase("file"))
PutIA5String(tmp, getFromFile(value));
else
PutIA5String(tmp, value);
} else if (type.equalsIgnoreCase("octetstring")) {
source = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_SOURCE);
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
// It should be colon seperated ASCII Hexdecimal String
if (source.equalsIgnoreCase("file"))
PutOctetString(tmp, getFromFile(value));
else
PutOctetString(tmp, value);
} else if (type.equalsIgnoreCase("bmpstring")) {
source = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_SOURCE);
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
if (source.equalsIgnoreCase("file"))
PutBMPString(tmp, getFromFile(value));
else
PutBMPString(tmp, value);
} else if (type.equalsIgnoreCase("printablestring")) {
source = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_SOURCE);
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
if (source.equalsIgnoreCase("file"))
PutPrintableString(tmp, getFromFile(value));
else
PutPrintableString(tmp, value);
} else if (type.equalsIgnoreCase("visiblestring")) {
source = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_SOURCE);
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
if (source.equalsIgnoreCase("file"))
PutVisibleString(tmp, getFromFile(value));
else
PutVisibleString(tmp, value);
} else if (type.equalsIgnoreCase("utctime")) {
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
PutUTCtime(tmp, value);
} else if (type.equalsIgnoreCase("oid")) {
value = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
PutOID(tmp, value);
} else if (type.equalsIgnoreCase("boolean")) {
boolean bool = false;
String b = mConfig.get(PROP_ATTRIBUTE + "." + ch + "." + PROP_VALUE);
if (b.equalsIgnoreCase("true"))
bool = true;
else
bool = false;
PutBoolean(tmp, bool);
} else if (type.equalsIgnoreCase("null")) {
tmp.putNull();
} else {
throw new ParseException("Unknown Attribute Type", 0);
}
}
index++;
}
return tmp.toByteArray();
}
use of org.mozilla.jss.netscape.security.util.DerValue 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);
}
}
Aggregations