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

项目:springboot-shiro-cas-mybatis    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * Get UPN String.
 *
 * @param seq ASN1Sequence abstraction representing subject alternative name.
 * First element is the object identifier, second is the object itself.
 *
 * @return UPN string or null
 */
private String getUPNStringFromSequence(final ASN1Sequence seq) {
    if (seq != null) {
        // First in sequence is the object identifier, that we must check
        final ASN1ObjectIdentifier id = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
        if (id != null && UPN_OBJECTID.equals(id.getId())) {
            final ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1);
            ASN1Primitive prim = obj.getObject();

            // Due to bug in java cert.getSubjectAltName, it can be tagged an extra time
            if (prim instanceof ASN1TaggedObject) {
                prim = ASN1TaggedObject.getInstance(((ASN1TaggedObject) prim)).getObject();
            }

            if (prim instanceof ASN1OctetString) {
                return new String(((ASN1OctetString) prim).getOctets());
            } else if (prim instanceof ASN1String) {
                return ((ASN1String) prim).getString();
            } else{
                return null;
            }
        }
    }
    return null;
}
项目:cas-5.1.0    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * Get UPN String.
 *
 * @param seq ASN1Sequence abstraction representing subject alternative name.
 *            First element is the object identifier, second is the object itself.
 * @return UPN string or null
 */
private static String getUPNStringFromSequence(final ASN1Sequence seq) {
    if (seq != null) {
        // First in sequence is the object identifier, that we must check
        final ASN1ObjectIdentifier id = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
        if (id != null && UPN_OBJECTID.equals(id.getId())) {
            final ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1);
            ASN1Primitive prim = obj.getObject();

            // Due to bug in java cert.getSubjectAltName, it can be tagged an extra time
            if (prim instanceof ASN1TaggedObject) {
                prim = ASN1TaggedObject.getInstance(prim).getObject();
            }

            if (prim instanceof ASN1OctetString) {
                return new String(((ASN1OctetString) prim).getOctets(), StandardCharsets.UTF_8);
            }
            if (prim instanceof ASN1String) {
                return ((ASN1String) prim).getString();
            }
            return null;
        }
    }
    return null;
}
项目:ipack    文件:NameOrPseudonym.java   
public static NameOrPseudonym getInstance(Object obj)
{
    if (obj == null || obj instanceof NameOrPseudonym)
    {
        return (NameOrPseudonym)obj;
    }

    if (obj instanceof ASN1String)
    {
        return new NameOrPseudonym(DirectoryString.getInstance(obj));
    }

    if (obj instanceof ASN1Sequence)
    {
        return new NameOrPseudonym((ASN1Sequence)obj);
    }

    throw new IllegalArgumentException("illegal object in getInstance: "
        + obj.getClass().getName());
}
项目:ipack    文件:NameOrPseudonym.java   
/**
 * Constructor from ASN1Sequence.
 * <p/>
 * The sequence is of type NameOrPseudonym:
 * <p/>
 * <pre>
 *       NameOrPseudonym ::= CHOICE {
 *            surAndGivenName SEQUENCE {
 *              surName DirectoryString,
 *              givenName SEQUENCE OF DirectoryString
 *         },
 *            pseudonym DirectoryString
 *       }
 * </pre>
 *
 * @param seq The ASN.1 sequence.
 */
private NameOrPseudonym(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }

    if (!(seq.getObjectAt(0) instanceof ASN1String))
    {
        throw new IllegalArgumentException("Bad object encountered: "
            + seq.getObjectAt(0).getClass());
    }

    surname = DirectoryString.getInstance(seq.getObjectAt(0));
    givenName = ASN1Sequence.getInstance(seq.getObjectAt(1));
}
项目:ipack    文件:RoleSyntax.java   
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        ASN1Encodable value = names[i].getName();
        if(value instanceof ASN1String)
        {
            namesString[i] = ((ASN1String)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
项目:ipack    文件:X509Name.java   
private String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    return value;
}
项目:ipack    文件:SPUserNotice.java   
private SPUserNotice(
    ASN1Sequence seq)
{
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1Encodable object = (ASN1Encodable)e.nextElement();
        if (object instanceof DisplayText || object instanceof ASN1String)
        {
            explicitText = DisplayText.getInstance(object);
        }
        else if (object instanceof NoticeReference || object instanceof ASN1Sequence)
        {
            noticeRef = NoticeReference.getInstance(object);
        }
        else
        {
            throw new IllegalArgumentException("Invalid element in 'SPUserNotice': " + object.getClass().getName());
        }
    }
}
项目:ipack    文件:IETFUtils.java   
public static String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    value = stripInternalSpaces(value);

    return value;
}
项目:cas-server-4.2.1    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * Get UPN String.
 *
 * @param seq ASN1Sequence abstraction representing subject alternative name.
 * First element is the object identifier, second is the object itself.
 *
 * @return UPN string or null
 */
private String getUPNStringFromSequence(final ASN1Sequence seq) {
    if (seq != null) {
        // First in sequence is the object identifier, that we must check
        final ASN1ObjectIdentifier id = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
        if (id != null && UPN_OBJECTID.equals(id.getId())) {
            final ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1);
            ASN1Primitive prim = obj.getObject();

            // Due to bug in java cert.getSubjectAltName, it can be tagged an extra time
            if (prim instanceof ASN1TaggedObject) {
                prim = ASN1TaggedObject.getInstance(((ASN1TaggedObject) prim)).getObject();
            }

            if (prim instanceof ASN1OctetString) {
                return new String(((ASN1OctetString) prim).getOctets());
            } else if (prim instanceof ASN1String) {
                return ((ASN1String) prim).getString();
            } else{
                return null;
            }
        }
    }
    return null;
}
项目:itext2    文件:PdfPKCS7.java   
/**
 * Constructs an X509 name
 * @param seq an ASN1 Sequence
 */
public X509Name(ASN1Sequence seq) {
    Enumeration e = seq.getObjects();

    while (e.hasMoreElements()) {
        ASN1Set set = (ASN1Set)e.nextElement();

        for (int i = 0; i < set.size(); i++) {
            ASN1Sequence s = (ASN1Sequence)set.getObjectAt(i);
            String id = (String)DefaultSymbols.get(s.getObjectAt(0));
            if (id == null)
                continue;
            ArrayList vs = (ArrayList)values.get(id);
            if (vs == null) {
                vs = new ArrayList();
                values.put(id, vs);
            }
            vs.add(((ASN1String)s.getObjectAt(1)).getString());
        }
    }
}
项目:gwt-crypto    文件:NameOrPseudonym.java   
public static NameOrPseudonym getInstance(Object obj)
{
    if (obj == null || obj instanceof NameOrPseudonym)
    {
        return (NameOrPseudonym)obj;
    }

    if (obj instanceof ASN1String)
    {
        return new NameOrPseudonym(DirectoryString.getInstance(obj));
    }

    if (obj instanceof ASN1Sequence)
    {
        return new NameOrPseudonym((ASN1Sequence)obj);
    }

    throw new IllegalArgumentException("illegal object in getInstance: "
        + obj.getClass().getName());
}
项目:gwt-crypto    文件:NameOrPseudonym.java   
/**
 * Constructor from ASN1Sequence.
 * <p>
 * The sequence is of type NameOrPseudonym:
 * <pre>
 *       NameOrPseudonym ::= CHOICE {
 *            surAndGivenName SEQUENCE {
 *              surName DirectoryString,
 *              givenName SEQUENCE OF DirectoryString
 *         },
 *            pseudonym DirectoryString
 *       }
 * </pre>
 * </p>
 * @param seq The ASN.1 sequence.
 */
private NameOrPseudonym(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }

    if (!(seq.getObjectAt(0) instanceof ASN1String))
    {
        throw new IllegalArgumentException("Bad object encountered: "
            + seq.getObjectAt(0).getClass());
    }

    surname = DirectoryString.getInstance(seq.getObjectAt(0));
    givenName = ASN1Sequence.getInstance(seq.getObjectAt(1));
}
项目:gwt-crypto    文件:RoleSyntax.java   
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        ASN1Encodable value = names[i].getName();
        if(value instanceof ASN1String)
        {
            namesString[i] = ((ASN1String)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
项目:gwt-crypto    文件:X509Name.java   
private String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    return value;
}
项目:gwt-crypto    文件:SPUserNotice.java   
private SPUserNotice(
    ASN1Sequence seq)
{
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1Encodable object = (ASN1Encodable)e.nextElement();
        if (object instanceof DisplayText || object instanceof ASN1String)
        {
            explicitText = DisplayText.getInstance(object);
        }
        else if (object instanceof NoticeReference || object instanceof ASN1Sequence)
        {
            noticeRef = NoticeReference.getInstance(object);
        }
        else
        {
            throw new IllegalArgumentException("Invalid element in 'SPUserNotice': " + object.getClass().getName());
        }
    }
}
项目:gwt-crypto    文件:StringTest.java   
private void checkString(ASN1String shortString, ASN1String longString)
    throws IOException
{
    ASN1String short2 = (ASN1String)ASN1Primitive.fromByteArray(((ASN1Primitive)shortString).getEncoded());

    if (!shortString.toString().equals(short2.toString()))
    {
        fail(short2.getClass().getName() + " shortBytes result incorrect");
    }

    ASN1String long2 = (ASN1String)ASN1Primitive.fromByteArray(((ASN1Primitive)longString).getEncoded());

    if (!longString.toString().equals(long2.toString()))
    {
        fail(long2.getClass().getName() + " longBytes result incorrect");
    }
}
项目:cas4.1.9    文件:X509SubjectAlternativeNameUPNPrincipalResolver.java   
/**
 * Get UPN String.
 *
 * @param seq ASN1Sequence abstraction representing subject alternative name.
 * First element is the object identifier, second is the object itself.
 *
 * @return UPN string or null
 */
private String getUPNStringFromSequence(final ASN1Sequence seq) {
    if (seq != null) {
        // First in sequence is the object identifier, that we must check
        final ASN1ObjectIdentifier id = ASN1ObjectIdentifier.getInstance(seq.getObjectAt(0));
        if (id != null && UPN_OBJECTID.equals(id.getId())) {
            final ASN1TaggedObject obj = (ASN1TaggedObject) seq.getObjectAt(1);
            ASN1Primitive prim = obj.getObject();

            // Due to bug in java cert.getSubjectAltName, it can be tagged an extra time
            if (prim instanceof ASN1TaggedObject) {
                prim = ASN1TaggedObject.getInstance(((ASN1TaggedObject) prim)).getObject();
            }

            if (prim instanceof ASN1OctetString) {
                return new String(((ASN1OctetString) prim).getOctets());
            } else if (prim instanceof ASN1String) {
                return ((ASN1String) prim).getString();
            } else{
                return null;
            }
        }
    }
    return null;
}
项目:Aki-SSL    文件:NameOrPseudonym.java   
public static NameOrPseudonym getInstance(Object obj)
{
    if (obj == null || obj instanceof NameOrPseudonym)
    {
        return (NameOrPseudonym)obj;
    }

    if (obj instanceof ASN1String)
    {
        return new NameOrPseudonym(DirectoryString.getInstance(obj));
    }

    if (obj instanceof ASN1Sequence)
    {
        return new NameOrPseudonym((ASN1Sequence)obj);
    }

    throw new IllegalArgumentException("illegal object in getInstance: "
        + obj.getClass().getName());
}
项目:Aki-SSL    文件:NameOrPseudonym.java   
/**
 * Constructor from ASN1Sequence.
 * <p>
 * The sequence is of type NameOrPseudonym:
 * <pre>
 *       NameOrPseudonym ::= CHOICE {
 *            surAndGivenName SEQUENCE {
 *              surName DirectoryString,
 *              givenName SEQUENCE OF DirectoryString
 *         },
 *            pseudonym DirectoryString
 *       }
 * </pre>
 * </p>
 * @param seq The ASN.1 sequence.
 */
private NameOrPseudonym(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }

    if (!(seq.getObjectAt(0) instanceof ASN1String))
    {
        throw new IllegalArgumentException("Bad object encountered: "
            + seq.getObjectAt(0).getClass());
    }

    surname = DirectoryString.getInstance(seq.getObjectAt(0));
    givenName = ASN1Sequence.getInstance(seq.getObjectAt(1));
}
项目:Aki-SSL    文件:RoleSyntax.java   
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        ASN1Encodable value = names[i].getName();
        if(value instanceof ASN1String)
        {
            namesString[i] = ((ASN1String)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
项目:Aki-SSL    文件:X509Name.java   
private String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    return value;
}
项目:Aki-SSL    文件:SPUserNotice.java   
private SPUserNotice(
    ASN1Sequence seq)
{
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1Encodable object = (ASN1Encodable)e.nextElement();
        if (object instanceof DisplayText || object instanceof ASN1String)
        {
            explicitText = DisplayText.getInstance(object);
        }
        else if (object instanceof NoticeReference || object instanceof ASN1Sequence)
        {
            noticeRef = NoticeReference.getInstance(object);
        }
        else
        {
            throw new IllegalArgumentException("Invalid element in 'SPUserNotice': " + object.getClass().getName());
        }
    }
}
项目:TinyTravelTracker    文件:NameOrPseudonym.java   
public static NameOrPseudonym getInstance(Object obj)
{
    if (obj == null || obj instanceof NameOrPseudonym)
    {
        return (NameOrPseudonym)obj;
    }

    if (obj instanceof ASN1String)
    {
        return new NameOrPseudonym(DirectoryString.getInstance(obj));
    }

    if (obj instanceof ASN1Sequence)
    {
        return new NameOrPseudonym((ASN1Sequence)obj);
    }

    throw new IllegalArgumentException("illegal object in getInstance: "
        + obj.getClass().getName());
}
项目:TinyTravelTracker    文件:NameOrPseudonym.java   
/**
 * Constructor from ASN1Sequence.
 * <p>
 * The sequence is of type NameOrPseudonym:
 * <pre>
 *       NameOrPseudonym ::= CHOICE {
 *            surAndGivenName SEQUENCE {
 *              surName DirectoryString,
 *              givenName SEQUENCE OF DirectoryString
 *         },
 *            pseudonym DirectoryString
 *       }
 * </pre>
 * </p>
 * @param seq The ASN.1 sequence.
 */
private NameOrPseudonym(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }

    if (!(seq.getObjectAt(0) instanceof ASN1String))
    {
        throw new IllegalArgumentException("Bad object encountered: "
            + seq.getObjectAt(0).getClass());
    }

    surname = DirectoryString.getInstance(seq.getObjectAt(0));
    givenName = ASN1Sequence.getInstance(seq.getObjectAt(1));
}
项目:TinyTravelTracker    文件:RoleSyntax.java   
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        ASN1Encodable value = names[i].getName();
        if(value instanceof ASN1String)
        {
            namesString[i] = ((ASN1String)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
项目:TinyTravelTracker    文件:X509Name.java   
private String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    return value;
}
项目:TinyTravelTracker    文件:SPUserNotice.java   
private SPUserNotice(
    ASN1Sequence seq)
{
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1Encodable object = (ASN1Encodable)e.nextElement();
        if (object instanceof DisplayText || object instanceof ASN1String)
        {
            explicitText = DisplayText.getInstance(object);
        }
        else if (object instanceof NoticeReference || object instanceof ASN1Sequence)
        {
            noticeRef = NoticeReference.getInstance(object);
        }
        else
        {
            throw new IllegalArgumentException("Invalid element in 'SPUserNotice': " + object.getClass().getName());
        }
    }
}
项目:CryptMeme    文件:NameOrPseudonym.java   
public static NameOrPseudonym getInstance(Object obj)
{
    if (obj == null || obj instanceof NameOrPseudonym)
    {
        return (NameOrPseudonym)obj;
    }

    if (obj instanceof ASN1String)
    {
        return new NameOrPseudonym(DirectoryString.getInstance(obj));
    }

    if (obj instanceof ASN1Sequence)
    {
        return new NameOrPseudonym((ASN1Sequence)obj);
    }

    throw new IllegalArgumentException("illegal object in getInstance: "
        + obj.getClass().getName());
}
项目:CryptMeme    文件:NameOrPseudonym.java   
/**
 * Constructor from ASN1Sequence.
 * <p/>
 * The sequence is of type NameOrPseudonym:
 * <p/>
 * <pre>
 *       NameOrPseudonym ::= CHOICE {
 *            surAndGivenName SEQUENCE {
 *              surName DirectoryString,
 *              givenName SEQUENCE OF DirectoryString
 *         },
 *            pseudonym DirectoryString
 *       }
 * </pre>
 *
 * @param seq The ASN.1 sequence.
 */
private NameOrPseudonym(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }

    if (!(seq.getObjectAt(0) instanceof ASN1String))
    {
        throw new IllegalArgumentException("Bad object encountered: "
            + seq.getObjectAt(0).getClass());
    }

    surname = DirectoryString.getInstance(seq.getObjectAt(0));
    givenName = ASN1Sequence.getInstance(seq.getObjectAt(1));
}
项目:CryptMeme    文件:RoleSyntax.java   
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        ASN1Encodable value = names[i].getName();
        if(value instanceof ASN1String)
        {
            namesString[i] = ((ASN1String)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
项目:CryptMeme    文件:X509Name.java   
private String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    return value;
}
项目:CryptMeme    文件:SPUserNotice.java   
private SPUserNotice(
    ASN1Sequence seq)
{
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1Encodable object = (ASN1Encodable)e.nextElement();
        if (object instanceof DisplayText || object instanceof ASN1String)
        {
            explicitText = DisplayText.getInstance(object);
        }
        else if (object instanceof NoticeReference || object instanceof ASN1Sequence)
        {
            noticeRef = NoticeReference.getInstance(object);
        }
        else
        {
            throw new IllegalArgumentException("Invalid element in 'SPUserNotice': " + object.getClass().getName());
        }
    }
}
项目:CryptMeme    文件:IETFUtils.java   
public static String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    value = stripInternalSpaces(value);

    return value;
}
项目:irma_future_id    文件:NameOrPseudonym.java   
public static NameOrPseudonym getInstance(Object obj)
{
    if (obj == null || obj instanceof NameOrPseudonym)
    {
        return (NameOrPseudonym)obj;
    }

    if (obj instanceof ASN1String)
    {
        return new NameOrPseudonym(DirectoryString.getInstance(obj));
    }

    if (obj instanceof ASN1Sequence)
    {
        return new NameOrPseudonym((ASN1Sequence)obj);
    }

    throw new IllegalArgumentException("illegal object in getInstance: "
        + obj.getClass().getName());
}
项目:irma_future_id    文件:NameOrPseudonym.java   
/**
 * Constructor from ASN1Sequence.
 * <p/>
 * The sequence is of type NameOrPseudonym:
 * <p/>
 * <pre>
 *       NameOrPseudonym ::= CHOICE {
 *            surAndGivenName SEQUENCE {
 *              surName DirectoryString,
 *              givenName SEQUENCE OF DirectoryString
 *         },
 *            pseudonym DirectoryString
 *       }
 * </pre>
 *
 * @param seq The ASN.1 sequence.
 */
private NameOrPseudonym(ASN1Sequence seq)
{
    if (seq.size() != 2)
    {
        throw new IllegalArgumentException("Bad sequence size: "
            + seq.size());
    }

    if (!(seq.getObjectAt(0) instanceof ASN1String))
    {
        throw new IllegalArgumentException("Bad object encountered: "
            + seq.getObjectAt(0).getClass());
    }

    surname = DirectoryString.getInstance(seq.getObjectAt(0));
    givenName = ASN1Sequence.getInstance(seq.getObjectAt(1));
}
项目:irma_future_id    文件:RoleSyntax.java   
/**
 * Gets the role authority as a <code>String[]</code> object.
 * @return the role authority of this RoleSyntax represented as a
 * <code>String[]</code> array.
 */
public String[] getRoleAuthorityAsString() 
{
    if(roleAuthority == null) 
    {
        return new String[0];
    }

    GeneralName[] names = roleAuthority.getNames();
    String[] namesString = new String[names.length];
    for(int i = 0; i < names.length; i++) 
    {
        ASN1Encodable value = names[i].getName();
        if(value instanceof ASN1String)
        {
            namesString[i] = ((ASN1String)value).getString();
        }
        else
        {
            namesString[i] = value.toString();
        }
    }
    return namesString;
}
项目:irma_future_id    文件:X509Name.java   
private String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    return value;
}
项目:irma_future_id    文件:SPUserNotice.java   
private SPUserNotice(
    ASN1Sequence seq)
{
    Enumeration e = seq.getObjects();
    while (e.hasMoreElements())
    {
        ASN1Encodable object = (ASN1Encodable)e.nextElement();
        if (object instanceof DisplayText || object instanceof ASN1String)
        {
            explicitText = DisplayText.getInstance(object);
        }
        else if (object instanceof NoticeReference || object instanceof ASN1Sequence)
        {
            noticeRef = NoticeReference.getInstance(object);
        }
        else
        {
            throw new IllegalArgumentException("Invalid element in 'SPUserNotice': " + object.getClass().getName());
        }
    }
}
项目:irma_future_id    文件:IETFUtils.java   
public static String canonicalize(String s)
{
    String value = Strings.toLowerCase(s.trim());

    if (value.length() > 0 && value.charAt(0) == '#')
    {
        ASN1Primitive obj = decodeObject(value);

        if (obj instanceof ASN1String)
        {
            value = Strings.toLowerCase(((ASN1String)obj).getString().trim());
        }
    }

    value = stripInternalSpaces(value);

    return value;
}
项目:irma_future_id    文件:StringTest.java   
private void checkString(ASN1String shortString, ASN1String longString)
    throws IOException
{
    ASN1String short2 = (ASN1String)ASN1Primitive.fromByteArray(((ASN1Primitive)shortString).getEncoded());

    if (!shortString.toString().equals(short2.toString()))
    {
        fail(short2.getClass().getName() + " shortBytes result incorrect");
    }

    ASN1String long2 = (ASN1String)ASN1Primitive.fromByteArray(((ASN1Primitive)longString).getEncoded());

    if (!longString.toString().equals(long2.toString()))
    {
        fail(long2.getClass().getName() + " longBytes result incorrect");
    }
}