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


Java X509AttributeCertificate.getAttributes方法代码示例

本文整理汇总了Java中org.bouncycastle.x509.X509AttributeCertificate.getAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java X509AttributeCertificate.getAttributes方法的具体用法?Java X509AttributeCertificate.getAttributes怎么用?Java X509AttributeCertificate.getAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.x509.X509AttributeCertificate的用法示例。


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

示例1: VOMSAttribute

import org.bouncycastle.x509.X509AttributeCertificate; //导入方法依赖的package包/类
/**
 * Parses the contents of an attribute certificate.<br>
 * <b>NOTE:</b> Cryptographic signatures, time stamps etc. will <b>not</b> be checked.
 *
 * @param ac the attribute certificate to parse for VOMS attributes
 */
public VOMSAttribute(X509AttributeCertificate ac) 
{
    if (ac == null) 
    {
        throw new IllegalArgumentException("VOMSAttribute: AttributeCertificate is NULL");
    }

    myAC = ac;

    X509Attribute[] l = ac.getAttributes(VOMS_ATTR_OID);

    if (l == null) 
    {
        return;
    }

    try 
    {
        for (int i = 0; i != l.length; i++) 
        {
            IetfAttrSyntax attr = IetfAttrSyntax.getInstance(l[i].getValues()[0]);

            // policyAuthority is on the format <vo>/<host>:<port>
            String url = ((DERIA5String)attr.getPolicyAuthority().getNames()[0].getName()).getString();
            int idx = url.indexOf("://");

            if ((idx < 0) || (idx == (url.length() - 1)))
            {
                throw new IllegalArgumentException("Bad encoding of VOMS policyAuthority : [" + url + "]");
            }

            myVo = url.substring(0, idx);
            myHostPort = url.substring(idx + 3);

            if (attr.getValueType() != IetfAttrSyntax.VALUE_OCTETS)
            {
                throw new IllegalArgumentException(
                    "VOMS attribute values are not encoded as octet strings, policyAuthority = " + url);
            }

            ASN1OctetString[]   values = (ASN1OctetString[])attr.getValues();
            for (int j = 0; j != values.length; j++)        
            {
                String fqan = new String(values[j].getOctets());
                FQAN f = new FQAN(fqan);

                if (!myStringList.contains(fqan) && fqan.startsWith("/" + myVo + "/"))
           {
                    myStringList.add(fqan);
                    myFQANs.add(f);
                }
            }
        }
    }
    catch (IllegalArgumentException ie) 
    {
        throw ie;
    }
    catch (Exception e) 
    {
        throw new IllegalArgumentException("Badly encoded VOMS extension in AC issued by " +
            ac.getIssuer());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:71,代码来源:VOMSAttribute.java


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