use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class Attribute method encodeValueSet.
// encode the attribute object
private void encodeValueSet(OutputStream out) throws IOException {
try (DerOutputStream tmp2 = new DerOutputStream()) {
DerOutputStream tmp = new DerOutputStream();
// get the attribute converter
AVAValueConverter converter = attrMap.getValueConverter(oid);
if (converter == null) {
converter = new GenericValueConverter();
// throw new IOException("Converter not found: unsupported attribute type");
}
// loop through all the values and encode
Enumeration<String> vals = valueSet.elements();
while (vals.hasMoreElements()) {
String val = vals.nextElement();
DerValue derobj = converter.getValue(val);
derobj.encode(tmp);
}
tmp2.write(DerValue.tag_SetOf, tmp);
out.write(tmp2.toByteArray());
}
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class Attribute method decodeValueSet.
// decode the attribute value set
private void decodeValueSet(DerValue val) throws IOException {
// pre-condition verification
if (val == null) {
throw new IOException("Invalid Input - null passed.");
}
AVAValueConverter converter = attrMap.getValueConverter(this.oid);
if (converter == null) {
converter = new GenericValueConverter();
// throw new IOException("Attribute is not supported - not in attr map");
}
if (val.tag != DerValue.tag_SetOf) {
throw new IOException("Invalid encoding for Attribute Value Set.");
}
if (val.data.available() == 0) {
throw new IOException("No data available in " + "passed DER encoded attribute value set.");
}
// get the value set
while (val.data.available() != 0) {
DerValue value = val.data.getDerValue();
valueSet.addElement(converter.getAsString(value));
}
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class DSAParameters method engineInit.
@Override
protected void engineInit(byte[] params) throws IOException {
DerValue encodedParams = new DerValue(params);
if (encodedParams.tag != DerValue.tag_Sequence) {
throw new IOException("DSA params parsing error");
}
encodedParams.data.reset();
this.p = encodedParams.data.getInteger().toBigInteger();
this.q = encodedParams.data.getInteger().toBigInteger();
this.g = encodedParams.data.getInteger().toBigInteger();
if (encodedParams.data.available() != 0) {
throw new IOException("encoded params have " + encodedParams.data.available() + " extra bytes");
}
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class ExtendedKeyUsageExtension 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");
}
if (oidSet == null)
oidSet = new Vector<>();
while (val.data.available() != 0) {
DerValue oidVal = val.data.getDerValue();
oidSet.addElement(oidVal.getOID());
}
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class CertificateAlgorithmId method decode.
/**
* Decode the algorithm identifier from the passed stream.
*
* @param in the InputStream to unmarshal the contents from.
* @exception IOException on errors.
*/
@Override
public void decode(InputStream in) throws IOException {
DerValue derVal = new DerValue(in);
algId = AlgorithmId.parse(derVal);
}
Aggregations