Java 类org.bouncycastle.asn1.x509.IetfAttrSyntax 实例源码

项目:ipack    文件:VOMSAttribute.java   
/**
 * 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());
    }
}
项目:Aki-SSL    文件:VOMSAttribute.java   
/**
 * 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(X509AttributeCertificateHolder ac)
{
    if (ac == null) 
    {
        throw new IllegalArgumentException("VOMSAttribute: AttributeCertificate is NULL");
    }

    myAC = ac;

    Attribute[] l = ac.getAttributes(new ASN1ObjectIdentifier(VOMS_ATTR_OID));

    if (l == null) 
    {
        return;
    }

    try 
    {
        for (int i = 0; i != l.length; i++) 
        {
            IetfAttrSyntax attr = IetfAttrSyntax.getInstance(l[i].getAttributeValues()[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());
    }
}
项目:irma_future_id    文件:VOMSAttribute.java   
/**
 * 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());
    }
}
项目:bc-java    文件:VOMSAttribute.java   
/**
 * 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());
    }
}