use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class LdapV3DNStrConverter method encodeAVA.
/**
* Converts a AVA to a Ldap v3 DN String (except in unicode).
*
* @param ava an AVA
*
* @return a Ldap v3 DN string (except in unicode).
*
* @exception IOException If an error is encountered during exception.
*/
@Override
public String encodeAVA(AVA ava) throws IOException {
if (ava == null) {
return "";
}
ObjectIdentifier oid = ava.getOid();
DerValue value = ava.getValue();
String keyword, valueStr;
// get attribute name
keyword = encodeOID(oid);
valueStr = encodeValue(value, oid);
return keyword + "=" + valueStr;
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class CertificateSubjectName method decodeEx.
/**
* Decode the name in DER form from the stream.
*
* @param in the InputStream to marshal the contents from.
* @exception IOException on errors.
*/
public void decodeEx(InputStream in) throws IOException {
DerValue derVal = new DerValue(in);
// dnName = new X500Name(derVal);
dnName = new X500Name(derVal.toByteArray());
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class DirStrConverter method getValue.
/**
* Like getValue(String) with specified DER tags as encoding order.
*/
@Override
public DerValue getValue(String valueString, byte[] tags) throws IOException {
if (tags == null || tags.length == 0)
tags = DefEncodingOrder;
for (int i = 0; i < tags.length; i++) {
try {
CharsetEncoder encoder = ASN1CharStrConvMap.getDefault().getEncoder(tags[i]);
if (encoder == null)
continue;
CharBuffer charBuffer = CharBuffer.wrap(valueString.toCharArray());
ByteBuffer byteBuffer = encoder.encode(charBuffer);
return new DerValue(tags[i], byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.limit());
} catch (CharacterCodingException e) {
continue;
}
}
throw new IOException("Cannot convert the directory string value to a ASN.1 type");
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class PrintableConverter method getValue.
@Override
public DerValue getValue(String valueString, byte[] tags) throws IOException {
try {
CharsetEncoder encoder = ASN1CharStrConvMap.getDefault().getEncoder(DerValue.tag_PrintableString);
if (encoder == null)
throw new IOException("No encoder for printable");
CharBuffer charBuffer = CharBuffer.wrap(valueString.toCharArray());
ByteBuffer byteBuffer = encoder.encode(charBuffer);
return new DerValue(DerValue.tag_PrintableString, byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.limit());
} catch (CharacterCodingException e) {
throw new IllegalArgumentException("Invalid Printable String AVA Value", e);
}
}
use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.
the class OtherName method decodeThis.
// Decode this extension value
private void decodeThis(DerValue derVal) throws IOException {
// if (derVal.tag != DerValue.tag_Sequence) {
// throw new IOException("Invalid encoding for other name");
// }
// Decode all the Attributes
mOID = derVal.data.getOID();
// skip tag
DerValue tag = derVal.data.getDerValue();
// read data
DerValue data = tag.data.getDerValue();
mData = data.toByteArray();
}
Aggregations