本文整理汇总了Java中org.bouncycastle.asn1.DERUniversalString类的典型用法代码示例。如果您正苦于以下问题:Java DERUniversalString类的具体用法?Java DERUniversalString怎么用?Java DERUniversalString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DERUniversalString类属于org.bouncycastle.asn1包,在下文中一共展示了DERUniversalString类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
public static DirectoryString getInstance(Object o)
{
if (o == null || o instanceof DirectoryString)
{
return (DirectoryString)o;
}
if (o instanceof DERT61String)
{
return new DirectoryString((DERT61String)o);
}
if (o instanceof DERPrintableString)
{
return new DirectoryString((DERPrintableString)o);
}
if (o instanceof DERUniversalString)
{
return new DirectoryString((DERUniversalString)o);
}
if (o instanceof DERUTF8String)
{
return new DirectoryString((DERUTF8String)o);
}
if (o instanceof DERBMPString)
{
return new DirectoryString((DERBMPString)o);
}
throw new IllegalArgumentException("illegal object in getInstance: " + o.getClass().getName());
}
开发者ID:Appdome,项目名称:ipack,代码行数:35,代码来源:DirectoryString.java
示例2: rdnValueToString
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
public static String rdnValueToString(ASN1Encodable value) {
ParamUtil.requireNonNull("value", value);
if (value instanceof ASN1String && !(value instanceof DERUniversalString)) {
return ((ASN1String) value).getString();
} else {
try {
return "#" + bytesToString(
Hex.encode(value.toASN1Primitive().getEncoded(ASN1Encoding.DER)));
} catch (IOException ex) {
throw new IllegalArgumentException("other value has no encoded form");
}
}
}
开发者ID:xipki,项目名称:xitk,代码行数:14,代码来源:X509Util.java
示例3: dumpString
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
private String dumpString(ASN1String asn1String) {
StringBuilder sb = new StringBuilder();
sb.append(indentSequence.toString(indentLevel));
if (asn1String instanceof DERBMPString) {
sb.append("BMP STRING=");
} else if (asn1String instanceof DERGeneralString) {
sb.append("GENERAL STRING=");
} else if (asn1String instanceof DERIA5String) {
sb.append("IA5 STRING=");
} else if (asn1String instanceof DERNumericString) {
sb.append("NUMERIC STRING=");
} else if (asn1String instanceof DERPrintableString) {
sb.append("PRINTABLE STRING=");
} else if (asn1String instanceof DERT61String) {
sb.append("TELETEX STRING=");
} else if (asn1String instanceof DERUniversalString) {
sb.append("UNIVERSAL STRING=");
} else if (asn1String instanceof DERUTF8String) {
sb.append("UTF8 STRING=");
} else if (asn1String instanceof DERVisibleString) {
sb.append("VISIBLE STRING=");
} else {
sb.append("UNKNOWN STRING=");
}
sb.append("'");
sb.append(asn1String.getString());
sb.append("'");
sb.append(NEWLINE);
return sb.toString();
}
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:35,代码来源:Asn1Dump.java
示例4: createPostalAddressRdn
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
private static RDN createPostalAddressRdn(ASN1ObjectIdentifier type, ASN1Encodable rdnValue,
RdnControl control, int index) throws BadCertTemplateException {
ParamUtil.requireNonNull("type", type);
if (!(rdnValue instanceof ASN1Sequence)) {
throw new BadCertTemplateException(
"rdnValue of RDN postalAddress has incorrect syntax");
}
ASN1Sequence seq = (ASN1Sequence) rdnValue;
final int size = seq.size();
if (size < 1 || size > 6) {
throw new BadCertTemplateException(
"Sequence size of RDN postalAddress is not within [1, 6]: " + size);
}
ASN1EncodableVector vec = new ASN1EncodableVector();
for (int i = 0; i < size; i++) {
ASN1Encodable line = seq.getObjectAt(i);
String text;
if (line instanceof ASN1String && !(line instanceof DERUniversalString)) {
text = ((ASN1String) line).getString();
} else {
throw new BadCertTemplateException(
String.format("postalAddress[%d] has incorrect syntax", i));
}
ASN1Encodable asn1Line = createRdnValue(text, type, control, index);
vec.add(asn1Line);
}
return new RDN(type, new DERSequence(vec));
}
开发者ID:xipki,项目名称:xipki,代码行数:34,代码来源:BaseX509Certprofile.java
示例5: X509Name
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
/**
* Constructor from ASN1Sequence
*
* the principal will be a list of constructed sets, each containing an (OID, String) pair.
* @deprecated use X500Name.getInstance()
*/
public X509Name(
ASN1Sequence seq)
{
this.seq = seq;
Enumeration e = seq.getObjects();
while (e.hasMoreElements())
{
ASN1Set set = ASN1Set.getInstance(((ASN1Encodable)e.nextElement()).toASN1Primitive());
for (int i = 0; i < set.size(); i++)
{
ASN1Sequence s = ASN1Sequence.getInstance(set.getObjectAt(i).toASN1Primitive());
if (s.size() != 2)
{
throw new IllegalArgumentException("badly sized pair");
}
ordering.addElement(ASN1ObjectIdentifier.getInstance(s.getObjectAt(0)));
ASN1Encodable value = s.getObjectAt(1);
if (value instanceof ASN1String && !(value instanceof DERUniversalString))
{
String v = ((ASN1String)value).getString();
if (v.length() > 0 && v.charAt(0) == '#')
{
values.addElement("\\" + v);
}
else
{
values.addElement(v);
}
}
else
{
try
{
values.addElement("#" + bytesToString(Hex.encode(value.toASN1Primitive().getEncoded(ASN1Encoding.DER))));
}
catch (IOException e1)
{
throw new IllegalArgumentException("cannot encode value");
}
}
added.addElement((i != 0) ? TRUE : FALSE); // to allow earlier JDK compatibility
}
}
}
开发者ID:Appdome,项目名称:ipack,代码行数:57,代码来源:X509Name.java
示例6: DirectoryString
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
private DirectoryString(
DERUniversalString string)
{
this.string = string;
}
开发者ID:Appdome,项目名称:ipack,代码行数:6,代码来源:DirectoryString.java
示例7: valueToString
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
public static String valueToString(ASN1Encodable value)
{
StringBuffer vBuf = new StringBuffer();
if (value instanceof ASN1String && !(value instanceof DERUniversalString))
{
String v = ((ASN1String)value).getString();
if (v.length() > 0 && v.charAt(0) == '#')
{
vBuf.append("\\" + v);
}
else
{
vBuf.append(v);
}
}
else
{
try
{
vBuf.append("#" + bytesToString(Hex.encode(value.toASN1Primitive().getEncoded(ASN1Encoding.DER))));
}
catch (IOException e)
{
throw new IllegalArgumentException("Other value has no encoded form");
}
}
int end = vBuf.length();
int index = 0;
if (vBuf.length() >= 2 && vBuf.charAt(0) == '\\' && vBuf.charAt(1) == '#')
{
index += 2;
}
while (index != end)
{
if ((vBuf.charAt(index) == ',')
|| (vBuf.charAt(index) == '"')
|| (vBuf.charAt(index) == '\\')
|| (vBuf.charAt(index) == '+')
|| (vBuf.charAt(index) == '=')
|| (vBuf.charAt(index) == '<')
|| (vBuf.charAt(index) == '>')
|| (vBuf.charAt(index) == ';'))
{
vBuf.insert(index, "\\");
index++;
end++;
}
index++;
}
int start = 0;
if (vBuf.length() > 0)
{
while (vBuf.charAt(start) == ' ')
{
vBuf.insert(start, "\\");
start += 2;
}
}
int endBuf = vBuf.length() - 1;
while (endBuf >= 0 && vBuf.charAt(endBuf) == ' ')
{
vBuf.insert(endBuf, '\\');
endBuf--;
}
return vBuf.toString();
}
开发者ID:Appdome,项目名称:ipack,代码行数:76,代码来源:IETFUtils.java
示例8: valueToString
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
public static String valueToString(ASN1Encodable value)
{
StringBuffer vBuf = new StringBuffer();
if (value instanceof ASN1String && !(value instanceof DERUniversalString))
{
String v = ((ASN1String)value).getString();
if (v.length() > 0 && v.charAt(0) == '#')
{
vBuf.append("\\" + v);
}
else
{
vBuf.append(v);
}
}
else
{
try
{
vBuf.append("#" + bytesToString(Hex.encode(value.toASN1Primitive().getEncoded(ASN1Encoding.DER))));
}
catch (IOException e)
{
throw new IllegalArgumentException("Other value has no encoded form");
}
}
int end = vBuf.length();
int index = 0;
if (vBuf.length() >= 2 && vBuf.charAt(0) == '\\' && vBuf.charAt(1) == '#')
{
index += 2;
}
while (index != end)
{
if ((vBuf.charAt(index) == ',')
|| (vBuf.charAt(index) == '"')
|| (vBuf.charAt(index) == '\\')
|| (vBuf.charAt(index) == '+')
|| (vBuf.charAt(index) == '=')
|| (vBuf.charAt(index) == '<')
|| (vBuf.charAt(index) == '>')
|| (vBuf.charAt(index) == ';'))
{
vBuf.insert(index, "\\");
index++;
end++;
}
index++;
}
int start = 0;
if (vBuf.length() > 0)
{
while (vBuf.length() > start && vBuf.charAt(start) == ' ')
{
vBuf.insert(start, "\\");
start += 2;
}
}
int endBuf = vBuf.length() - 1;
while (endBuf >= 0 && vBuf.charAt(endBuf) == ' ')
{
vBuf.insert(endBuf, '\\');
endBuf--;
}
return vBuf.toString();
}
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:76,代码来源:IETFUtils.java
示例9: valueToString
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
public static String valueToString(ASN1Encodable value)
{
StringBuilder vBuf = new StringBuilder();
if (value instanceof ASN1String && !(value instanceof DERUniversalString))
{
String v = ((ASN1String)value).getString();
if (v.length() > 0 && v.charAt(0) == '#')
{
vBuf.append("\\");
vBuf.append(v);
}
else
{
vBuf.append(v);
}
}
else
{
try
{
vBuf.append("#");
vBuf.append(bytesToString(Hex.encode(value.toASN1Primitive().getEncoded(ASN1Encoding.DER))));
}
catch (IOException e)
{
throw new IllegalArgumentException("Other value has no encoded form");
}
}
int end = vBuf.length();
int index = 0;
if (vBuf.length() >= 2 && vBuf.charAt(0) == '\\' && vBuf.charAt(1) == '#')
{
index += 2;
}
while (index != end)
{
if ((vBuf.charAt(index) == ',')
|| (vBuf.charAt(index) == '"')
|| (vBuf.charAt(index) == '\\')
|| (vBuf.charAt(index) == '+')
|| (vBuf.charAt(index) == '=')
|| (vBuf.charAt(index) == '<')
|| (vBuf.charAt(index) == '>')
|| (vBuf.charAt(index) == ';'))
{
vBuf.insert(index, "\\");
index++;
end++;
}
index++;
}
int start = 0;
if (vBuf.length() > 0)
{
while (vBuf.length() > start && vBuf.charAt(start) == ' ')
{
vBuf.insert(start, "\\");
start += 2;
}
}
int endBuf = vBuf.length() - 1;
while (endBuf >= 0 && vBuf.charAt(endBuf) == ' ')
{
vBuf.insert(endBuf, '\\');
endBuf--;
}
return vBuf.toString();
}
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:78,代码来源:ExtendedIETFUtils.java
示例10: perform
import org.bouncycastle.asn1.DERUniversalString; //导入依赖的package包/类
public TestResult perform()
{
byte[] data = { 0, 1, 0, 1, 0, 0, 1 };
ASN1Primitive values[] = {
new BERConstructedOctetString(data),
new BERSequence(new DERPrintableString("hello world")),
new BERSet(new DERPrintableString("hello world")),
new BERTaggedObject(0, new DERPrintableString("hello world")),
new DERApplicationSpecific(0, data),
new DERBitString(data),
new DERBMPString("hello world"),
new DERBoolean(true),
new DERBoolean(false),
new DEREnumerated(100),
new DERGeneralizedTime("20070315173729Z"),
new DERGeneralString("hello world"),
new DERIA5String("hello"),
new DERInteger(1000),
new DERNull(),
new DERNumericString("123456"),
new DERObjectIdentifier("1.1.1.10000.1"),
new DEROctetString(data),
new DERPrintableString("hello world"),
new DERSequence(new DERPrintableString("hello world")),
new DERSet(new DERPrintableString("hello world")),
new DERT61String("hello world"),
new DERTaggedObject(0, new DERPrintableString("hello world")),
new DERUniversalString(data),
new DERUTCTime(new Date()),
new DERUTF8String("hello world"),
new DERVisibleString("hello world")
};
try
{
ByteArrayOutputStream bOut = new ByteArrayOutputStream();
ASN1OutputStream aOut = new ASN1OutputStream(bOut);
for (int i = 0; i != values.length; i++)
{
aOut.writeObject(values[i]);
}
ASN1Primitive[] readValues = new ASN1Primitive[values.length];
ByteArrayInputStream bIn = new ByteArrayInputStream(bOut.toByteArray());
ASN1InputStream aIn = new ASN1InputStream(bIn);
for (int i = 0; i != values.length; i++)
{
ASN1Primitive o = aIn.readObject();
if (!o.equals(values[i]))
{
return new SimpleTestResult(false, getName() + ": Failed equality test for " + o.getClass());
}
if (o.hashCode() != values[i].hashCode())
{
return new SimpleTestResult(false, getName() + ": Failed hashCode test for " + o.getClass());
}
}
}
catch (Exception e)
{
return new SimpleTestResult(false, getName() + ": Failed - exception " + e.toString(), e);
}
return new SimpleTestResult(true, getName() + ": Okay");
}
开发者ID:credentials,项目名称:irma_future_id,代码行数:71,代码来源:EqualsAndHashCodeTest.java
注:本文中的org.bouncycastle.asn1.DERUniversalString类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论