本文整理汇总了Java中sun.security.util.ObjectIdentifier类的典型用法代码示例。如果您正苦于以下问题:Java ObjectIdentifier类的具体用法?Java ObjectIdentifier怎么用?Java ObjectIdentifier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ObjectIdentifier类属于sun.security.util包,在下文中一共展示了ObjectIdentifier类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setPolicy
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Sets the policy constraint. The {@code X509Certificate} must
* include at least one of the specified policies in its certificate
* policies extension. If {@code certPolicySet} is empty, then the
* {@code X509Certificate} must include at least some specified policy
* in its certificate policies extension. If {@code certPolicySet} is
* {@code null}, no policy check will be performed.
* <p>
* Note that the {@code Set} is cloned to protect against
* subsequent modifications.
*
* @param certPolicySet a {@code Set} of certificate policy OIDs in
* string format (or {@code null}). Each OID is
* represented by a set of nonnegative integers
* separated by periods.
* @throws IOException if a parsing error occurs on the OID such as
* the first component is not 0, 1 or 2 or the second component is
* greater than 39.
* @see #getPolicy
*/
public void setPolicy(Set<String> certPolicySet) throws IOException {
if (certPolicySet == null) {
policySet = null;
policy = null;
} else {
// Snapshot set and parse it
Set<String> tempSet = Collections.unmodifiableSet
(new HashSet<String>(certPolicySet));
/* Convert to Vector of ObjectIdentifiers */
Iterator<String> i = tempSet.iterator();
Vector<CertificatePolicyId> polIdVector = new Vector<CertificatePolicyId>();
while (i.hasNext()) {
Object o = i.next();
if (!(o instanceof String)) {
throw new IOException("non String in certPolicySet");
}
polIdVector.add(new CertificatePolicyId(new ObjectIdentifier(
(String)o)));
}
// If everything went OK, make the changes
policySet = tempSet;
policy = new CertificatePolicySet(polIdVector);
}
}
示例2: ExtendedKeyUsageExtension
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Create the extension from its DER encoded value and criticality.
*
* @param critical true if the extension is to be treated as critical.
* @param value an array of DER encoded bytes of the actual value.
* @exception ClassCastException if value is not an array of bytes
* @exception IOException on error.
*/
public ExtendedKeyUsageExtension(Boolean critical, Object value)
throws IOException {
this.extensionId = PKIXExtensions.ExtendedKeyUsage_Id;
this.critical = critical.booleanValue();
this.extensionValue = (byte[]) value;
DerValue val = new DerValue(this.extensionValue);
if (val.tag != DerValue.tag_Sequence) {
throw new IOException("Invalid encoding for " +
"ExtendedKeyUsageExtension.");
}
keyUsages = new Vector<ObjectIdentifier>();
while (val.data.available() != 0) {
DerValue seq = val.data.getDerValue();
ObjectIdentifier usage = seq.getOID();
keyUsages.addElement(usage);
}
}
示例3: toString
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Return the extension as user readable string.
*/
public String toString() {
if (keyUsages == null) return "";
String usage = " ";
boolean first = true;
for (ObjectIdentifier oid: keyUsages) {
if(!first) {
usage += "\n ";
}
String result = map.get(oid);
if (result != null) {
usage += result;
} else {
usage += oid.toString();
}
first = false;
}
return super.toString() + "ExtendedKeyUsages [\n"
+ usage + "\n]\n";
}
示例4: init
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
private void init(ObjectIdentifier oid, Object value)
throws IllegalArgumentException {
this.oid = oid;
index = indexOf(oid, PKCS9_OIDS, 1);
Class<?> clazz = index == -1 ? BYTE_ARRAY_CLASS: VALUE_CLASSES[index];
if (!clazz.isInstance(value)) {
throw new IllegalArgumentException(
"Wrong value class " +
" for attribute " + oid +
" constructing PKCS9Attribute; was " +
value.getClass().toString() + ", should be " +
clazz.toString());
}
this.value = value;
}
示例5: CRLDistributionPointsExtension
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Creates the extension (also called by the subclass).
*/
protected CRLDistributionPointsExtension(ObjectIdentifier extensionId,
Boolean critical, Object value, String extensionName)
throws IOException {
this.extensionId = extensionId;
this.critical = critical.booleanValue();
if (!(value instanceof byte[])) {
throw new IOException("Illegal argument type");
}
extensionValue = (byte[])value;
DerValue val = new DerValue(extensionValue);
if (val.tag != DerValue.tag_Sequence) {
throw new IOException("Invalid encoding for " + extensionName +
" extension.");
}
distributionPoints = new ArrayList<DistributionPoint>();
while (val.data.available() != 0) {
DerValue seq = val.data.getDerValue();
DistributionPoint point = new DistributionPoint(seq);
distributionPoints.add(point);
}
this.extensionName = extensionName;
}
示例6: NamedCurve
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
NamedCurve(String name, String oid, EllipticCurve curve,
ECPoint g, BigInteger n, int h) {
super(curve, g, n, h);
this.name = name;
this.oid = oid;
DerOutputStream out = new DerOutputStream();
try {
out.putOID(new ObjectIdentifier(oid));
} catch (IOException e) {
throw new RuntimeException("Internal error", e);
}
encoded = out.toByteArray();
}
示例7: PKCS9Attributes
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Construct a set of PKCS9 Attributes from the given array of
* PKCS9 attributes.
* DER encoding on a DerInputStream. All attributes in
* <code>attribs</code> must be
* supported by class PKCS9Attribute.
*
* @exception IOException
* on i/o error, encoding syntax error, or unsupported or
* duplicate attribute.
*
* @see PKCS9Attribute
*/
public PKCS9Attributes(PKCS9Attribute[] attribs)
throws IllegalArgumentException, IOException {
ObjectIdentifier oid;
for (int i=0; i < attribs.length; i++) {
oid = attribs[i].getOID();
if (attributes.containsKey(oid))
throw new IllegalArgumentException(
"PKCSAttribute " + attribs[i].getOID() +
" duplicated while constructing " +
"PKCS9Attributes.");
attributes.put(oid, attribs[i]);
}
derEncoding = generateDerEncoding();
permittedAttributes = null;
}
示例8: setPolicy
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Sets the policy constraint. The {@code X509Certificate} must
* include at least one of the specified policies in its certificate
* policies extension. If {@code certPolicySet} is empty, then the
* {@code X509Certificate} must include at least some specified policy
* in its certificate policies extension. If {@code certPolicySet} is
* {@code null}, no policy check will be performed.
* <p>
* Note that the {@code Set} is cloned to protect against
* subsequent modifications.
*
* @param certPolicySet a {@code Set} of certificate policy OIDs in
* string format (or {@code null}). Each OID is
* represented by a set of nonnegative integers
* separated by periods.
* @throws IOException if a parsing error occurs on the OID such as
* the first component is not 0, 1 or 2 or the second component is
* greater than 39.
* @see #getPolicy
*/
public void setPolicy(Set<String> certPolicySet) throws IOException {
if (certPolicySet == null) {
policySet = null;
policy = null;
} else {
// Snapshot set and parse it
Set<String> tempSet = Collections.unmodifiableSet
(new HashSet<>(certPolicySet));
/* Convert to Vector of ObjectIdentifiers */
Iterator<String> i = tempSet.iterator();
Vector<CertificatePolicyId> polIdVector = new Vector<>();
while (i.hasNext()) {
Object o = i.next();
if (!(o instanceof String)) {
throw new IOException("non String in certPolicySet");
}
polIdVector.add(new CertificatePolicyId(new ObjectIdentifier(
(String)o)));
}
// If everything went OK, make the changes
policySet = tempSet;
policy = new CertificatePolicySet(polIdVector);
}
}
示例9: stringToOIDName
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
private OIDName stringToOIDName(String name)
throws Exception
{
OIDName oidName = null;
ObjectIdentifier oid = new ObjectIdentifier(name);
oidName = new OIDName(oid);
return oidName;
}
示例10: matchExtendedKeyUsage
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
private boolean matchExtendedKeyUsage(X509Certificate xcert) {
if ((keyPurposeSet == null) || keyPurposeSet.isEmpty()) {
return true;
}
try {
ExtendedKeyUsageExtension ext =
(ExtendedKeyUsageExtension)getExtensionObject(xcert,
EXTENDED_KEY_USAGE_ID);
if (ext != null) {
Vector<ObjectIdentifier> certKeyPurposeVector =
ext.get(ExtendedKeyUsageExtension.USAGES);
if (!certKeyPurposeVector.contains(ANY_EXTENDED_KEY_USAGE)
&& !certKeyPurposeVector.containsAll(keyPurposeOIDSet)) {
if (debug != null) {
debug.println("X509CertSelector.match: cert failed "
+ "extendedKeyUsage criterion");
}
return false;
}
}
} catch (IOException ex) {
if (debug != null) {
debug.println("X509CertSelector.match: "
+ "IOException in extended key usage check");
}
return false;
}
return true;
}
示例11: getAttributeValue
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Get an attribute value by type name.
*/
public Object getAttributeValue(String name) throws IOException {
ObjectIdentifier oid = PKCS9Attribute.getOID(name);
if (oid == null)
throw new IOException("Attribute name " + name +
" not recognized or not supported.");
return getAttributeValue(oid);
}
示例12: set
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Set the attribute value.
*/
@SuppressWarnings("unchecked") // Checked with instanceof
public void set(String name, Object obj) throws IOException {
if (name.equalsIgnoreCase(USAGES)) {
if (!(obj instanceof Vector)) {
throw new IOException("Attribute value should be of type Vector.");
}
this.keyUsages = (Vector<ObjectIdentifier>)obj;
} else {
throw new IOException("Attribute name [" + name +
"] not recognized by " +
"CertAttrSet:ExtendedKeyUsageExtension.");
}
encodeThis();
}
示例13: get
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
/**
* Get the attribute value.
*/
public Vector<ObjectIdentifier> get(String name) throws IOException {
if (name.equalsIgnoreCase(USAGES)) {
//XXXX May want to consider cloning this
return keyUsages;
} else {
throw new IOException("Attribute name [" + name +
"] not recognized by " +
"CertAttrSet:ExtendedKeyUsageExtension.");
}
}
示例14: getExtendedKeyUsage
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
public List<String> getExtendedKeyUsage() {
List<String> al = new ArrayList<String>(keyUsages.size());
for (ObjectIdentifier oid : keyUsages) {
al.add(oid.toString());
}
return al;
}
示例15: parseAlgParameters
import sun.security.util.ObjectIdentifier; //导入依赖的package包/类
private AlgorithmParameters parseAlgParameters(ObjectIdentifier algorithm,
DerInputStream in) throws IOException
{
AlgorithmParameters algParams = null;
try {
DerValue params;
if (in.available() == 0) {
params = null;
} else {
params = in.getDerValue();
if (params.tag == DerValue.tag_Null) {
params = null;
}
}
if (params != null) {
if (algorithm.equals(pbes2_OID)) {
algParams = AlgorithmParameters.getInstance("PBES2");
} else {
algParams = AlgorithmParameters.getInstance("PBE");
}
algParams.init(params.toByteArray());
}
} catch (Exception e) {
throw new IOException("parseAlgParameters failed: " +
e.getMessage(), e);
}
return algParams;
}