本文整理汇总了Java中org.bouncycastle.asn1.DERPrintableString类的典型用法代码示例。如果您正苦于以下问题:Java DERPrintableString类的具体用法?Java DERPrintableString怎么用?Java DERPrintableString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DERPrintableString类属于org.bouncycastle.asn1包,在下文中一共展示了DERPrintableString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInstance
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
public static Iso4217CurrencyCode getInstance(
Object obj)
{
if (obj == null || obj instanceof Iso4217CurrencyCode)
{
return (Iso4217CurrencyCode)obj;
}
if (obj instanceof ASN1Integer)
{
ASN1Integer numericobj = ASN1Integer.getInstance(obj);
int numeric = numericobj.getValue().intValue();
return new Iso4217CurrencyCode(numeric);
}
else
if (obj instanceof DERPrintableString)
{
DERPrintableString alphabetic = DERPrintableString.getInstance(obj);
return new Iso4217CurrencyCode(alphabetic.getString());
}
throw new IllegalArgumentException("unknown object in getInstance");
}
示例2: toASN1Primitive
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <p/>
* Returns:
* <p/>
* <pre>
* ProcurationSyntax ::= SEQUENCE {
* country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL,
* typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL,
* signingFor [3] EXPLICIT SigningFor
* }
* <p/>
* SigningFor ::= CHOICE
* {
* thirdPerson GeneralName,
* certRef IssuerSerial
* }
* </pre>
*
* @return a DERObject
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
if (country != null)
{
vec.add(new DERTaggedObject(true, 1, new DERPrintableString(country, true)));
}
if (typeOfSubstitution != null)
{
vec.add(new DERTaggedObject(true, 2, typeOfSubstitution));
}
if (thirdPerson != null)
{
vec.add(new DERTaggedObject(true, 3, thirdPerson));
}
else
{
vec.add(new DERTaggedObject(true, 3, certRef));
}
return new DERSequence(vec);
}
示例3: toASN1Primitive
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <p/>
* Returns:
* <p/>
* <pre>
* ProfessionInfo ::= SEQUENCE
* {
* namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
* professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
* professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
* registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
* addProfessionInfo OCTET STRING OPTIONAL
* }
* </pre>
*
* @return a DERObject
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
if (namingAuthority != null)
{
vec.add(new DERTaggedObject(true, 0, namingAuthority));
}
vec.add(professionItems);
if (professionOIDs != null)
{
vec.add(professionOIDs);
}
if (registrationNumber != null)
{
vec.add(new DERPrintableString(registrationNumber, true));
}
if (addProfessionInfo != null)
{
vec.add(addProfessionInfo);
}
return new DERSequence(vec);
}
示例4: toASN1Primitive
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <p>
* Returns:
* <pre>
* ProcurationSyntax ::= SEQUENCE {
* country [1] EXPLICIT PrintableString(SIZE(2)) OPTIONAL,
* typeOfSubstitution [2] EXPLICIT DirectoryString (SIZE(1..128)) OPTIONAL,
* signingFor [3] EXPLICIT SigningFor
* }
*
* SigningFor ::= CHOICE
* {
* thirdPerson GeneralName,
* certRef IssuerSerial
* }
* </pre>
*
* @return a DERObject
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
if (country != null)
{
vec.add(new DERTaggedObject(true, 1, new DERPrintableString(country, true)));
}
if (typeOfSubstitution != null)
{
vec.add(new DERTaggedObject(true, 2, typeOfSubstitution));
}
if (thirdPerson != null)
{
vec.add(new DERTaggedObject(true, 3, thirdPerson));
}
else
{
vec.add(new DERTaggedObject(true, 3, certRef));
}
return new DERSequence(vec);
}
示例5: DeclarationOfMajority
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
public DeclarationOfMajority(boolean fullAge, String country)
{
if (country.length() > 2)
{
throw new IllegalArgumentException("country can only be 2 characters");
}
if (fullAge)
{
declaration = new DERTaggedObject(false, 1, new DERSequence(new DERPrintableString(country, true)));
}
else
{
ASN1EncodableVector v = new ASN1EncodableVector();
v.add(ASN1Boolean.FALSE);
v.add(new DERPrintableString(country, true));
declaration = new DERTaggedObject(false, 1, new DERSequence(v));
}
}
示例6: toASN1Primitive
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <p>
* Returns:
* <pre>
* ProfessionInfo ::= SEQUENCE
* {
* namingAuthority [0] EXPLICIT NamingAuthority OPTIONAL,
* professionItems SEQUENCE OF DirectoryString (SIZE(1..128)),
* professionOIDs SEQUENCE OF OBJECT IDENTIFIER OPTIONAL,
* registrationNumber PrintableString(SIZE(1..128)) OPTIONAL,
* addProfessionInfo OCTET STRING OPTIONAL
* }
* </pre>
*
* @return a DERObject
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
if (namingAuthority != null)
{
vec.add(new DERTaggedObject(true, 0, namingAuthority));
}
vec.add(professionItems);
if (professionOIDs != null)
{
vec.add(professionOIDs);
}
if (registrationNumber != null)
{
vec.add(new DERPrintableString(registrationNumber, true));
}
if (addProfessionInfo != null)
{
vec.add(addProfessionInfo);
}
return new DERSequence(vec);
}
示例7: encodeStringValue
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid,
String value) {
if (oid.equals(EmailAddress) || oid.equals(DC))
{
return new DERIA5String(value);
}
else if (oid.equals(DATE_OF_BIRTH)) // accept time string as well as # (for compatibility)
{
return new ASN1GeneralizedTime(value);
}
else if (oid.equals(C) || oid.equals(SN) || oid.equals(DN_QUALIFIER)
|| oid.equals(TELEPHONE_NUMBER))
{
return new DERPrintableString(value);
}
return super.encodeStringValue(oid, value);
}
示例8: populateTextField
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的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);
}
}
}
}
示例9: encodeStringValue
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
@Override
protected ASN1Encodable encodeStringValue(ASN1ObjectIdentifier oid,
String value) {
if (oid.equals(dc) || oid.equals(emailAddress))
{
return new DERIA5String(value);
}
else if (oid.equals(c) || oid.equals(serialNumber) || oid.equals(dnQualifier)
|| oid.equals(telephoneNumber) || oid.equals(gender)
|| oid.equals(countryOfCitizenship) || oid.equals(countryOfResidence))
{
return new DERPrintableString(value);
}
return super.encodeStringValue(oid, value);
}
示例10: matchStringType
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
private static boolean matchStringType(ASN1Encodable atvValue, StringType stringType) {
boolean correctStringType = true;
switch (stringType) {
case bmpString:
correctStringType = (atvValue instanceof DERBMPString);
break;
case printableString:
correctStringType = (atvValue instanceof DERPrintableString);
break;
case teletexString:
correctStringType = (atvValue instanceof DERT61String);
break;
case utf8String:
correctStringType = (atvValue instanceof DERUTF8String);
break;
case ia5String:
correctStringType = (atvValue instanceof DERIA5String);
break;
default:
throw new RuntimeException("should not reach here, unknown StringType " + stringType);
} // end switch
return correctStringType;
}
示例11: LDSVersionInfo
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
private LDSVersionInfo(ASN1Sequence seq)
{
if (seq.size() != 2)
{
throw new IllegalArgumentException("sequence wrong size for LDSVersionInfo");
}
this.ldsVersion = DERPrintableString.getInstance(seq.getObjectAt(0));
this.unicodeVersion = DERPrintableString.getInstance(seq.getObjectAt(1));
}
示例12: PersonalData
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Constructor from ASN1Sequence.
* <p/>
* The sequence is of type NameOrPseudonym:
* <p/>
* <pre>
* PersonalData ::= SEQUENCE {
* nameOrPseudonym NameOrPseudonym,
* nameDistinguisher [0] INTEGER OPTIONAL,
* dateOfBirth [1] GeneralizedTime OPTIONAL,
* placeOfBirth [2] DirectoryString OPTIONAL,
* gender [3] PrintableString OPTIONAL,
* postalAddress [4] DirectoryString OPTIONAL
* }
* </pre>
*
* @param seq The ASN.1 sequence.
*/
private PersonalData(ASN1Sequence seq)
{
if (seq.size() < 1)
{
throw new IllegalArgumentException("Bad sequence size: "
+ seq.size());
}
Enumeration e = seq.getObjects();
nameOrPseudonym = NameOrPseudonym.getInstance(e.nextElement());
while (e.hasMoreElements())
{
ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement());
int tag = o.getTagNo();
switch (tag)
{
case 0:
nameDistinguisher = ASN1Integer.getInstance(o, false).getValue();
break;
case 1:
dateOfBirth = ASN1GeneralizedTime.getInstance(o, false);
break;
case 2:
placeOfBirth = DirectoryString.getInstance(o, true);
break;
case 3:
gender = DERPrintableString.getInstance(o, false).getString();
break;
case 4:
postalAddress = DirectoryString.getInstance(o, true);
break;
default:
throw new IllegalArgumentException("Bad tag number: " + o.getTagNo());
}
}
}
示例13: toASN1Primitive
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Produce an object suitable for an ASN1OutputStream.
* <p/>
* Returns:
* <p/>
* <pre>
* PersonalData ::= SEQUENCE {
* nameOrPseudonym NameOrPseudonym,
* nameDistinguisher [0] INTEGER OPTIONAL,
* dateOfBirth [1] GeneralizedTime OPTIONAL,
* placeOfBirth [2] DirectoryString OPTIONAL,
* gender [3] PrintableString OPTIONAL,
* postalAddress [4] DirectoryString OPTIONAL
* }
* </pre>
*
* @return a DERObject
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector vec = new ASN1EncodableVector();
vec.add(nameOrPseudonym);
if (nameDistinguisher != null)
{
vec.add(new DERTaggedObject(false, 0, new ASN1Integer(nameDistinguisher)));
}
if (dateOfBirth != null)
{
vec.add(new DERTaggedObject(false, 1, dateOfBirth));
}
if (placeOfBirth != null)
{
vec.add(new DERTaggedObject(true, 2, placeOfBirth));
}
if (gender != null)
{
vec.add(new DERTaggedObject(false, 3, new DERPrintableString(gender, true)));
}
if (postalAddress != null)
{
vec.add(new DERTaggedObject(true, 4, postalAddress));
}
return new DERSequence(vec);
}
示例14: getConvertedValue
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
/**
* Apply default coversion for the given value depending on the oid
* and the character range of the value.
*
* @param oid the object identifier for the DN entry
* @param value the value associated with it
* @return the ASN.1 equivalent for the string value.
*/
public ASN1Primitive getConvertedValue(
ASN1ObjectIdentifier oid,
String value)
{
if (value.length() != 0 && value.charAt(0) == '#')
{
try
{
return convertHexEncoded(value, 1);
}
catch (IOException e)
{
throw new RuntimeException("can't recode value for oid " + oid.getId());
}
}
else
{
if (value.length() != 0 && value.charAt(0) == '\\')
{
value = value.substring(1);
}
if (oid.equals(X509Name.EmailAddress) || oid.equals(X509Name.DC))
{
return new DERIA5String(value);
}
else if (oid.equals(X509Name.DATE_OF_BIRTH)) // accept time string as well as # (for compatibility)
{
return new DERGeneralizedTime(value);
}
else if (oid.equals(X509Name.C) || oid.equals(X509Name.SN) || oid.equals(X509Name.DN_QUALIFIER)
|| oid.equals(X509Name.TELEPHONE_NUMBER))
{
return new DERPrintableString(value);
}
}
return new DERUTF8String(value);
}
示例15: Iso4217CurrencyCode
import org.bouncycastle.asn1.DERPrintableString; //导入依赖的package包/类
public Iso4217CurrencyCode(
String alphabetic)
{
if (alphabetic.length() > ALPHABETIC_MAXSIZE)
{
throw new IllegalArgumentException("wrong size in alphabetic code : max size is " + ALPHABETIC_MAXSIZE);
}
obj = new DERPrintableString(alphabetic);
}