本文整理汇总了Java中org.bouncycastle.asn1.DERUTF8String类的典型用法代码示例。如果您正苦于以下问题:Java DERUTF8String类的具体用法?Java DERUTF8String怎么用?Java DERUTF8String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
DERUTF8String类属于org.bouncycastle.asn1包,在下文中一共展示了DERUTF8String类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getControl
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
/**
* Return a control value of the specified type.
*
* @param type the type OID for the control value we are checking for.
* @return the control value if present, null otherwise.
*/
public Control getControl(ASN1ObjectIdentifier type)
{
AttributeTypeAndValue found = findControl(type);
if (found != null)
{
if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_pkiArchiveOptions))
{
return new PKIArchiveControl(PKIArchiveOptions.getInstance(found.getValue()));
}
if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_regToken))
{
return new RegTokenControl(DERUTF8String.getInstance(found.getValue()));
}
if (found.getType().equals(CRMFObjectIdentifiers.id_regCtrl_authenticator))
{
return new AuthenticatorControl(DERUTF8String.getInstance(found.getValue()));
}
}
return null;
}
示例2: SignerLocation
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
public SignerLocation(
DERUTF8String countryName,
DERUTF8String localityName,
ASN1Sequence postalAddress)
{
if (postalAddress != null && postalAddress.size() > 6)
{
throw new IllegalArgumentException("postal address must contain less than 6 strings");
}
if (countryName != null)
{
this.countryName = DERUTF8String.getInstance(countryName.toASN1Primitive());
}
if (localityName != null)
{
this.localityName = DERUTF8String.getInstance(localityName.toASN1Primitive());
}
if (postalAddress != null)
{
this.postalAddress = ASN1Sequence.getInstance(postalAddress.toASN1Primitive());
}
}
示例3: EncKeyWithID
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private EncKeyWithID(ASN1Sequence seq)
{
this.privKeyInfo = PrivateKeyInfo.getInstance(seq.getObjectAt(0));
if (seq.size() > 1)
{
if (!(seq.getObjectAt(1) instanceof DERUTF8String))
{
this.identifier = GeneralName.getInstance(seq.getObjectAt(1));
}
else
{
this.identifier = (ASN1Encodable)seq.getObjectAt(1);
}
}
else
{
this.identifier = null;
}
}
示例4: MetaData
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private MetaData(ASN1Sequence seq)
{
this.hashProtected = ASN1Boolean.getInstance(seq.getObjectAt(0));
int index = 1;
if (index < seq.size() && seq.getObjectAt(index) instanceof DERUTF8String)
{
this.fileName = DERUTF8String.getInstance(seq.getObjectAt(index++));
}
if (index < seq.size() && seq.getObjectAt(index) instanceof DERIA5String)
{
this.mediaType = DERIA5String.getInstance(seq.getObjectAt(index++));
}
if (index < seq.size())
{
this.otherMetaData = Attributes.getInstance(seq.getObjectAt(index++));
}
}
示例5: toASN1Primitive
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
@Override
public ASN1Primitive toASN1Primitive() {
ASN1EncodableVector vector = new ASN1EncodableVector();
vector.add(new Asn1P11SlotIdentifier(slotId));
vector.add(new DERUTF8String(label));
vector.add(new ASN1Integer(keysize));
if (publicExponent != null) {
vector.add(new ASN1Integer(publicExponent));
}
return new DERSequence(vector);
}
示例6: parseOtherName
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private static Pair<String, String> parseOtherName(byte[] otherName) {
try {
ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
if (asn1Primitive instanceof DERTaggedObject) {
ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
if (inner instanceof DLSequence) {
DLSequence sequence = (DLSequence) inner;
if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
String oid = sequence.getObjectAt(0).toString();
ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
if (value instanceof DERUTF8String) {
return new Pair<>(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new Pair<>(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
示例7: checkConstruction
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private void checkConstruction(
ContentHints hints,
ASN1ObjectIdentifier contentType,
DERUTF8String description)
throws IOException
{
checkValues(hints, contentType, description);
hints = ContentHints.getInstance(hints);
checkValues(hints, contentType, description);
ASN1InputStream aIn = new ASN1InputStream(hints.toASN1Primitive().getEncoded());
ASN1Sequence seq = (ASN1Sequence)aIn.readObject();
hints = ContentHints.getInstance(seq);
checkValues(hints, contentType, description);
}
示例8: parseOtherName
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private static OtherName parseOtherName(byte[] otherName) {
try {
ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
if (asn1Primitive instanceof DERTaggedObject) {
ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
if (inner instanceof DLSequence) {
DLSequence sequence = (DLSequence) inner;
if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
String oid = sequence.getObjectAt(0).toString();
ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
if (value instanceof DERUTF8String) {
return new OtherName(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new OtherName(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
示例9: verifyCertificateCommonName
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
static void verifyCertificateCommonName(X500Name subject, String commonName) {
List<AttributeTypeAndValue> attributesAndValues = Arrays.stream(subject.getRDNs())
.flatMap(rdn -> rdn.isMultiValued() ?
Stream.of(rdn.getTypesAndValues()) : Stream.of(rdn.getFirst()))
.filter(attr -> attr.getType() == BCStyle.CN)
.collect(Collectors.toList());
if (attributesAndValues.size() != 1) {
throw new IllegalArgumentException("Only 1 common name should be set");
}
String actualCommonName = DERUTF8String.getInstance(attributesAndValues.get(0).getValue()).getString();
if (! actualCommonName.equals(commonName)) {
throw new IllegalArgumentException("Expected common name to be " + commonName + ", but was " + actualCommonName);
}
}
示例10: CertificateTrustBlock
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
CertificateTrustBlock(byte[] encoded)
{
ASN1Sequence seq = ASN1Sequence.getInstance(encoded);
for (Enumeration en = seq.getObjects(); en.hasMoreElements();)
{
ASN1Encodable obj = (ASN1Encodable)en.nextElement();
if (obj instanceof ASN1Sequence)
{
this.uses = ASN1Sequence.getInstance(obj);
}
else if (obj instanceof ASN1TaggedObject)
{
this.prohibitions = ASN1Sequence.getInstance((ASN1TaggedObject)obj, false);
}
else if (obj instanceof DERUTF8String)
{
this.alias = DERUTF8String.getInstance(obj).getString();
}
}
}
示例11: toASN1Sequence
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
ASN1Sequence toASN1Sequence()
{
ASN1EncodableVector v = new ASN1EncodableVector();
if (uses != null)
{
v.add(uses);
}
if (prohibitions != null)
{
v.add(new DERTaggedObject(false, 0, prohibitions));
}
if (alias != null)
{
v.add(new DERUTF8String(alias));
}
return new DERSequence(v);
}
示例12: populateTextField
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private static void populateTextField(Attribute[] attrs, JTextField textField, ASN1ObjectIdentifier pkcs9Attr) {
if (attrs != null) {
for (Attribute attribute : attrs) {
ASN1ObjectIdentifier attributeOid = attribute.getAttrType();
if (attributeOid.equals(pkcs9Attr)) {
ASN1Encodable challenge = attribute.getAttributeValues()[0];
// data type can be one of IA5String or UTF8String
if (challenge instanceof DERPrintableString) {
textField.setText(((DERPrintableString) challenge).getString());
} else if (challenge instanceof DERUTF8String) {
textField.setText(((DERUTF8String) challenge).getString());
}
textField.setCaretPosition(0);
}
}
}
}
示例13: parseOtherName
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
private static Pair<String, String> parseOtherName(byte[] otherName) {
try {
ASN1Primitive asn1Primitive = ASN1Primitive.fromByteArray(otherName);
if (asn1Primitive instanceof DERTaggedObject) {
ASN1Primitive inner = ((DERTaggedObject) asn1Primitive).getObject();
if (inner instanceof DLSequence) {
DLSequence sequence = (DLSequence) inner;
if (sequence.size() >= 2 && sequence.getObjectAt(1) instanceof DERTaggedObject) {
String oid = sequence.getObjectAt(0).toString();
ASN1Primitive value = ((DERTaggedObject) sequence.getObjectAt(1)).getObject();
if (value instanceof DERUTF8String) {
return new Pair<>(oid, ((DERUTF8String) value).getString());
} else if (value instanceof DERIA5String) {
return new Pair<>(oid, ((DERIA5String) value).getString());
}
}
}
}
return null;
} catch (IOException e) {
return null;
}
}
示例14: toASN1Primitive
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
ASN1Primitive toASN1Primitive(boolean includeChecksum) {
DEROctetString checksumEncodable = includeChecksum
? new DEROctetString(checksum())
: null;
ASN1Integer flagsEncodable = flags.map(ASN1Integer::new)
.orElse(null);
ASN1EncodableVector vector = DER.vector(
new DERUTF8String(name),
DER.toSet(keys),
DER.toSet(serviceKeyIDs),
checksumEncodable,
flagsEncodable,
signatureInfo.orElse(null));
DERSequence sequence = new DERSequence(vector);
return DER.toApplicationSpecific(APPLICATION_TAG, sequence);
}
示例15: toASN1Primitive
import org.bouncycastle.asn1.DERUTF8String; //导入依赖的package包/类
@Override
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(new DERUTF8String(boardName));
v.add(new DERUTF8String(host));
v.add(new ASN1Integer(messageCount));
if (backupHost != null)
{
v.add(new DERUTF8String(backupHost));
}
return new DERSequence(v);
}