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


Java PolicyQualifierInfo类代码示例

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


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

示例1: PolicyInformation

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Create an instance of PolicyInformation, decoding from
 * the passed DerValue.
 *
 * @param val the DerValue to construct the PolicyInformation from.
 * @exception IOException on decoding errors.
 */
public PolicyInformation(DerValue val) throws IOException {
    if (val.tag != DerValue.tag_Sequence) {
        throw new IOException("Invalid encoding of PolicyInformation");
    }
    policyIdentifier = new CertificatePolicyId(val.data.getDerValue());
    if (val.data.available() != 0) {
        policyQualifiers = new LinkedHashSet<PolicyQualifierInfo>();
        DerValue opt = val.data.getDerValue();
        if (opt.tag != DerValue.tag_Sequence)
            throw new IOException("Invalid encoding of PolicyInformation");
        if (opt.data.available() == 0)
            throw new IOException("No data available in policyQualifiers");
        while (opt.data.available() != 0)
            policyQualifiers.add(new PolicyQualifierInfo
                    (opt.data.getDerValue().toByteArray()));
    } else {
        policyQualifiers = Collections.emptySet();
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:PolicyInformation.java

示例2: CertificatePolicies

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
public CertificatePolicies (final List<OID> policies,
                            final Map<OID, List<PolicyQualifierInfo>> policyQualifierInfos)
{
  for (Iterator it = policies.iterator(); it.hasNext(); )
    if (!(it.next() instanceof OID))
      throw new IllegalArgumentException ("policies must be OIDs");
  for (Iterator it = policyQualifierInfos.entrySet().iterator(); it.hasNext();)
    {
      Map.Entry e = (Map.Entry) it.next();
      if (!(e.getKey() instanceof OID) || !policies.contains (e.getKey()))
        throw new IllegalArgumentException
          ("policyQualifierInfos keys must be OIDs");
      if (!(e.getValue() instanceof List))
        throw new IllegalArgumentException
          ("policyQualifierInfos values must be Lists of PolicyQualifierInfos");
      for (Iterator it2 = ((List) e.getValue()).iterator(); it.hasNext(); )
        if (!(it2.next() instanceof PolicyQualifierInfo))
          throw new IllegalArgumentException
            ("policyQualifierInfos values must be Lists of PolicyQualifierInfos");
    }
  this.policies = Collections.unmodifiableList (new ArrayList<OID>(policies));
  this.policyQualifierInfos = Collections.unmodifiableMap
    (new HashMap<OID, List<PolicyQualifierInfo>>(policyQualifierInfos));
}
 
开发者ID:vilie,项目名称:javify,代码行数:25,代码来源:CertificatePolicies.java

示例3: testPolicyQualifierInfo04

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #4 for <code>PolicyQualifierInfo</code> constructor<br>
 * Assertion: The encoded byte array is copied on construction
 *
 * @throws IOException
 */
@TestTargetNew(
    level = TestLevel.PARTIAL_COMPLETE,
    notes = "Verifies constructor with encoded byte array copied on construction.",
    method = "PolicyQualifierInfo",
    args = {byte[].class}
)
public final void testPolicyQualifierInfo04() throws IOException  {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    byte[] encodingCopy = encoding.clone();
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encodingCopy);
    // get encoding
    byte[] encodingRet = i.getEncoded();
    // check returned array
    assertTrue(Arrays.equals(encoding, encodingRet));
    // modify input
    encodingCopy[0] = (byte)0;
    // get encoding again
    byte[] encodingRet1 = i.getEncoded();
    // check that above modification did not change
    // internal state of the PolicyQualifierInfo instance
    assertTrue(Arrays.equals(encoding, encodingRet1));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:31,代码来源:PolicyQualifierInfoTest.java

示例4: testGetEncoded01

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #1 for <code>getEncoded()</code> method
 * Assertion: Returns the ASN.1 DER encoded form of
 * this <code>PolicyQualifierInfo</code>
 *
 * @throws IOException
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getEncoded",
    args = {}
)
public final void testGetEncoded01() throws IOException {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
    // get encoding
    byte[] encodingRet = i.getEncoded();
    // check returned array
    assertTrue(Arrays.equals(encoding, encodingRet));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:24,代码来源:PolicyQualifierInfoTest.java

示例5: testGetEncoded02

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #2 for <code>getEncoded()</code> method
 * Assertion: a copy is returned each time
 *
 * @throws IOException
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getEncoded",
    args = {}
)
public final void testGetEncoded02() throws IOException {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    byte[] encodingCopy = encoding.clone();
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encodingCopy);
    // get encoding
    byte[] encodingRet = i.getEncoded();
    // modify returned array
    encodingRet[0] = (byte)0;
    // get encoding again
    byte[] encodingRet1 = i.getEncoded();
    // check that above modification did not change
    // internal state of the PolicyQualifierInfo instance
    assertTrue(Arrays.equals(encoding, encodingRet1));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:29,代码来源:PolicyQualifierInfoTest.java

示例6: testGetPolicyQualifier01

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #1 for <code>getPolicyQualifier()</code> method
 * Assertion: Returns the ASN.1 DER encoded form of
 * this <code>PolicyQualifierInfo</code>
 *
 * @throws IOException
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "getPolicyQualifier",
    args = {}
)
public final void testGetPolicyQualifier01() throws IOException {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    // get policy qualifier encoding
    byte[] pqEncoding = new byte[28];
    System.arraycopy(encoding, 12, pqEncoding, 0, pqEncoding.length);
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
    // get encoding
    byte[] pqEncodingRet = i.getPolicyQualifier();
    // check returned array
    assertTrue(Arrays.equals(pqEncoding, pqEncodingRet));
}
 
开发者ID:keplersj,项目名称:In-the-Box-Fork,代码行数:27,代码来源:PolicyQualifierInfoTest.java

示例7: testPolicyQualifierInfo04

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #4 for <code>PolicyQualifierInfo</code> constructor<br>
 * Assertion: The encoded byte array is copied on construction
 * 
 * @throws IOException
 */
public final void testPolicyQualifierInfo04() throws IOException  {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    byte[] encodingCopy = encoding.clone();
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encodingCopy);
    // get encoding
    byte[] encodingRet = i.getEncoded();
    // check returned array
    assertTrue(Arrays.equals(encoding, encodingRet));
    // modify input
    encodingCopy[0] = (byte)0;
    // get encoding again
    byte[] encodingRet1 = i.getEncoded();
    // check that above modification did not change
    // internal state of the PolicyQualifierInfo instance
    assertTrue(Arrays.equals(encoding, encodingRet1));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:25,代码来源:PolicyQualifierInfoTest.java

示例8: testGetEncoded02

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #2 for <code>getEncoded()</code> method
 * Assertion: a copy is returned each time
 * 
 * @throws IOException
 */
public final void testGetEncoded02() throws IOException {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    byte[] encodingCopy = encoding.clone();
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encodingCopy);
    // get encoding
    byte[] encodingRet = i.getEncoded();
    // modify returned array
    encodingRet[0] = (byte)0;
    // get encoding again
    byte[] encodingRet1 = i.getEncoded();
    // check that above modification did not change
    // internal state of the PolicyQualifierInfo instance
    assertTrue(Arrays.equals(encoding, encodingRet1));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:23,代码来源:PolicyQualifierInfoTest.java

示例9: testGetPolicyQualifier02

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Test #2 for <code>getPolicyQualifier()</code> method
 * Assertion: a copy is returned each time
 * 
 * @throws IOException
 */
public final void testGetPolicyQualifier02() throws IOException {
    // get valid encoding
    byte[] encoding = getDerEncoding();
    // get policy qualifier encoding
    byte[] pqEncoding = new byte[28];
    System.arraycopy(encoding, 12, pqEncoding, 0, pqEncoding.length);
    // pass valid array
    PolicyQualifierInfo i = new PolicyQualifierInfo(encoding);
    // get encoding
    byte[] pqEncodingRet = i.getPolicyQualifier();
    // modify returned array
    pqEncodingRet[0] = (byte)0;
    // get encoding again
    byte[] pqEncodingRet1 = i.getPolicyQualifier();
    //
    assertNotSame(pqEncodingRet, pqEncodingRet1);
    // check that above modification did not change
    // internal state of the PolicyQualifierInfo instance
    assertTrue(Arrays.equals(pqEncoding, pqEncodingRet1));
}
 
开发者ID:shannah,项目名称:cn1,代码行数:27,代码来源:PolicyQualifierInfoTest.java

示例10: getQualifierSet

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
protected static final Set getQualifierSet(ASN1Sequence qualifiers)
    throws CertPathValidatorException
{
    Set pq = new HashSet();

    if (qualifiers == null)
    {
        return pq;
    }

    ByteArrayOutputStream bOut = new ByteArrayOutputStream();
    ASN1OutputStream aOut = new ASN1OutputStream(bOut);

    Enumeration e = qualifiers.getObjects();

    while (e.hasMoreElements())
    {
        try
        {
            aOut.writeObject((ASN1Encodable)e.nextElement());

            pq.add(new PolicyQualifierInfo(bOut.toByteArray()));
        }
        catch (IOException ex)
        {
            throw new ExtCertPathValidatorException("Policy qualifier info cannot be decoded.", ex);
        }

        bOut.reset();
    }

    return pq;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:34,代码来源:CertPathValidatorUtilities.java

示例11: set

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Set the attribute value.
 */
@SuppressWarnings("unchecked") // Checked with instanceof
public void set(String name, Object obj) throws IOException {
    if (name.equalsIgnoreCase(ID)) {
        if (obj instanceof CertificatePolicyId)
            policyIdentifier = (CertificatePolicyId)obj;
        else
            throw new IOException("Attribute value must be instance " +
                "of CertificatePolicyId.");
    } else if (name.equalsIgnoreCase(QUALIFIERS)) {
        if (policyIdentifier == null) {
            throw new IOException("Attribute must have a " +
                "CertificatePolicyIdentifier value before " +
                "PolicyQualifierInfo can be set.");
        }
        if (obj instanceof Set) {
            Iterator<?> i = ((Set<?>)obj).iterator();
            while (i.hasNext()) {
                Object obj1 = i.next();
                if (!(obj1 instanceof PolicyQualifierInfo)) {
                    throw new IOException("Attribute value must be a" +
                                "Set of PolicyQualifierInfo objects.");
                }
            }
            policyQualifiers = (Set<PolicyQualifierInfo>) obj;
        } else {
            throw new IOException("Attribute value must be of type Set.");
        }
    } else {
        throw new IOException("Attribute name [" + name +
            "] not recognized by PolicyInformation");
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:PolicyInformation.java

示例12: encode

import java.security.cert.PolicyQualifierInfo; //导入依赖的package包/类
/**
 * Write the PolicyInformation to the DerOutputStream.
 *
 * @param out the DerOutputStream to write the extension to.
 * @exception IOException on encoding errors.
 */
public void encode(DerOutputStream out) throws IOException {
    DerOutputStream tmp = new DerOutputStream();
    policyIdentifier.encode(tmp);
    if (!policyQualifiers.isEmpty()) {
        DerOutputStream tmp2 = new DerOutputStream();
        for (PolicyQualifierInfo pq : policyQualifiers) {
            tmp2.write(pq.getEncoded());
        }
        tmp.write(DerValue.tag_Sequence, tmp2);
    }
    out.write(DerValue.tag_Sequence, tmp);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:PolicyInformation.java


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