当前位置: 首页>>代码示例>>Java>>正文


Java ASN1String类代码示例

本文整理汇总了Java中org.bouncycastle.asn1.ASN1String的典型用法代码示例。如果您正苦于以下问题:Java ASN1String类的具体用法?Java ASN1String怎么用?Java ASN1String使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ASN1String类属于org.bouncycastle.asn1包,在下文中一共展示了ASN1String类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getUPNStringFromSequence

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:33,代码来源:X509SubjectAlternativeNameUPNPrincipalResolver.java

示例2: getUPNStringFromSequence

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:32,代码来源:X509SubjectAlternativeNameUPNPrincipalResolver.java

示例3: getInstance

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
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());
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:NameOrPseudonym.java

示例4: NameOrPseudonym

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:35,代码来源:NameOrPseudonym.java

示例5: getRoleAuthorityAsString

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:29,代码来源:RoleSyntax.java

示例6: canonicalize

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:17,代码来源:X509Name.java

示例7: SPUserNotice

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
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());
        }
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:22,代码来源:SPUserNotice.java

示例8: canonicalize

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
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;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:19,代码来源:IETFUtils.java

示例9: X509Name

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
/**
 * 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());
        }
    }
}
 
开发者ID:albfernandez,项目名称:itext2,代码行数:25,代码来源:PdfPKCS7.java

示例10: NameOrPseudonym

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
/**
 * 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));
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:34,代码来源:NameOrPseudonym.java

示例11: checkString

import org.bouncycastle.asn1.ASN1String; //导入依赖的package包/类
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");
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:18,代码来源:StringTest.java


注:本文中的org.bouncycastle.asn1.ASN1String类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。