Java 类org.bouncycastle.asn1.DERPrintableString 实例源码

项目:ipack    文件:Iso4217CurrencyCode.java   
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");
}
项目:ipack    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:ipack    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:gwt-crypto    文件:Iso4217CurrencyCode.java   
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");
}
项目:gwt-crypto    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:gwt-crypto    文件:DeclarationOfMajority.java   
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));
    }
}
项目:gwt-crypto    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:gwt-crypto    文件:BCStyle.java   
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);
}
项目:Aki-SSL    文件:Iso4217CurrencyCode.java   
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");
}
项目:Aki-SSL    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:Aki-SSL    文件:DeclarationOfMajority.java   
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));
    }
}
项目:Aki-SSL    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:Aki-SSL    文件:BCStyle.java   
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);
}
项目:keystore-explorer    文件:DialogHelper.java   
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);
            }
        }
    }
}
项目:TinyTravelTracker    文件:Iso4217CurrencyCode.java   
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");
}
项目:TinyTravelTracker    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:TinyTravelTracker    文件:DeclarationOfMajority.java   
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));
    }
}
项目:TinyTravelTracker    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:TinyTravelTracker    文件:BCStyle.java   
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);
}
项目:CryptMeme    文件:Iso4217CurrencyCode.java   
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");
}
项目:CryptMeme    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:CryptMeme    文件:DeclarationOfMajority.java   
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));
    }
}
项目:CryptMeme    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:nsi-dds    文件:ExtendedRFC4519Style.java   
@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);
}
项目:xipki    文件:SubjectChecker.java   
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;
}
项目:irma_future_id    文件:Iso4217CurrencyCode.java   
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");
}
项目:irma_future_id    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:irma_future_id    文件:DeclarationOfMajority.java   
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));
    }
}
项目:irma_future_id    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:bc-java    文件:Iso4217CurrencyCode.java   
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");
}
项目:bc-java    文件:ProcurationSyntax.java   
/**
 * 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);
}
项目:bc-java    文件:DeclarationOfMajority.java   
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));
    }
}
项目:bc-java    文件:ProfessionInfo.java   
/**
 * 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);
}
项目:ipack    文件:LDSVersionInfo.java   
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));
}
项目:ipack    文件:PersonalData.java   
/**
 * 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());
        }
    }
}
项目:ipack    文件:PersonalData.java   
/**
 * 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);
}
项目:ipack    文件:X509DefaultEntryConverter.java   
/**
 * 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);
}
项目:ipack    文件:Iso4217CurrencyCode.java   
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);
}
项目:ipack    文件:ProcurationSyntax.java   
/**
 * Constructor from ASN1Sequence.
 * <p/>
 * The sequence is of type ProcurationSyntax:
 * <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>
 *
 * @param seq The ASN.1 sequence.
 */
private ProcurationSyntax(ASN1Sequence seq)
{
    if (seq.size() < 1 || seq.size() > 3)
    {
        throw new IllegalArgumentException("Bad sequence size: " + seq.size());
    }
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements())
    {
        ASN1TaggedObject o = ASN1TaggedObject.getInstance(e.nextElement());
        switch (o.getTagNo())
        {
            case 1:
                country = DERPrintableString.getInstance(o, true).getString();
                break;
            case 2:
                typeOfSubstitution = DirectoryString.getInstance(o, true);
                break;
            case 3:
                ASN1Encodable signingFor = o.getObject();
                if (signingFor instanceof ASN1TaggedObject)
                {
                    thirdPerson = GeneralName.getInstance(signingFor);
                }
                else
                {
                    certRef = IssuerSerial.getInstance(signingFor);
                }
                break;
            default:
                throw new IllegalArgumentException("Bad tag number: " + o.getTagNo());
        }
    }
}
项目:ipack    文件:MonetaryLimit.java   
private MonetaryLimit(ASN1Sequence seq)
{
    if (seq.size() != 3)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }
    Enumeration e = seq.getObjects();
    currency = DERPrintableString.getInstance(e.nextElement());
    amount = ASN1Integer.getInstance(e.nextElement());
    exponent = ASN1Integer.getInstance(e.nextElement());
}