本文整理汇总了Java中org.bouncycastle.asn1.x509.Attribute类的典型用法代码示例。如果您正苦于以下问题:Java Attribute类的具体用法?Java Attribute怎么用?Java Attribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Attribute类属于org.bouncycastle.asn1.x509包,在下文中一共展示了Attribute类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAttributes
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
/**
* Return an array of attributes matching the passed in type OID.
*
* @param type the type of the attribute being looked for.
* @return an array of Attribute of the requested type, zero length if none present.
*/
public Attribute[] getAttributes(ASN1ObjectIdentifier type)
{
ASN1Sequence seq = attrCert.getAcinfo().getAttributes();
List list = new ArrayList();
for (int i = 0; i != seq.size(); i++)
{
Attribute attr = Attribute.getInstance(seq.getObjectAt(i));
if (attr.getAttrType().equals(type))
{
list.add(attr);
}
}
if (list.size() == 0)
{
return EMPTY_ARRAY;
}
return (Attribute[])list.toArray(new Attribute[list.size()]);
}
示例2: toASN1Primitive
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
/**
*
* <pre>
* SignerAttribute ::= SEQUENCE OF CHOICE {
* claimedAttributes [0] ClaimedAttributes,
* certifiedAttributes [1] CertifiedAttributes }
*
* ClaimedAttributes ::= SEQUENCE OF Attribute
* CertifiedAttributes ::= AttributeCertificate -- as defined in RFC 3281: see clause 4.1.
* </pre>
*/
public ASN1Primitive toASN1Primitive()
{
ASN1EncodableVector v = new ASN1EncodableVector();
for (int i = 0; i != values.length; i++)
{
if (values[i] instanceof Attribute[])
{
v.add(new DERTaggedObject(0, new DERSequence((Attribute[])values[i])));
}
else
{
v.add(new DERTaggedObject(1, (AttributeCertificate)values[i]));
}
}
return new DERSequence(v);
}
示例3: SignerAttribute
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
private SignerAttribute(
ASN1Sequence seq)
{
int index = 0;
values = new Object[seq.size()];
for (Enumeration e = seq.getObjects(); e.hasMoreElements();)
{
ASN1TaggedObject taggedObject = ASN1TaggedObject.getInstance(e.nextElement());
if (taggedObject.getTagNo() == 0)
{
ASN1Sequence attrs = ASN1Sequence.getInstance(taggedObject, true);
Attribute[] attributes = new Attribute[attrs.size()];
for (int i = 0; i != attributes.length; i++)
{
attributes[i] = Attribute.getInstance(attrs.getObjectAt(i));
}
values[index] = attributes;
}
else if (taggedObject.getTagNo() == 1)
{
values[index] = AttributeCertificate.getInstance(ASN1Sequence.getInstance(taggedObject, true));
}
else
{
throw new IllegalArgumentException("illegal tag: " + taggedObject.getTagNo());
}
index++;
}
}
示例4: getSubjectDirectoryAttributesStringValue
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
private String getSubjectDirectoryAttributesStringValue(byte[] value) throws IOException {
// @formatter:off
/*
* SubjectDirectoryAttributes ::= ASN1Sequence SIZE (1..MAX) OF Attribute
*
* Attribute ::= ASN1Sequence
* {
* type AttributeType,
* values SET OF AttributeValue
* }
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
SubjectDirectoryAttributes subjectDirectoryAttributes = SubjectDirectoryAttributes.getInstance(value);
for (Object attribute : subjectDirectoryAttributes.getAttributes()) {
ASN1ObjectIdentifier attributeType = ((Attribute) attribute).getAttrType();
String attributeTypeStr = attributeType.getId();
ASN1Encodable[] attributeValues = ((Attribute) attribute).getAttributeValues();
for (ASN1Encodable attributeValue : attributeValues) {
String attributeValueStr = getAttributeValueString(attributeType, attributeValue);
sb.append(MessageFormat.format("{0}={1}", attributeTypeStr, attributeValueStr));
sb.append(NEWLINE);
}
}
return sb.toString();
}
示例5: X509Attribute
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
/**
* @param at an object representing an attribute.
*/
X509Attribute(
ASN1Encodable at)
{
this.attr = Attribute.getInstance(at);
}
示例6: addAttribute
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
/**
* add an attribute
*/
public void addAttribute(
X509Attribute attribute)
{
acInfoGen.addAttribute(Attribute.getInstance(attribute.toASN1Object()));
}
示例7: VOMSAttribute
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的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(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());
}
}
示例8: getVeriSignNonVerified
import org.bouncycastle.asn1.x509.Attribute; //导入依赖的package包/类
private String getVeriSignNonVerified(byte[] octets) throws IOException {
/*
NonVerified ::= SET OF ATTRIBUTE
*/
StringBuilder sb = new StringBuilder();
ASN1Set asn1Set = ASN1Set.getInstance(octets);
for (ASN1Encodable attribute : asn1Set.toArray()) {
ASN1ObjectIdentifier attributeId = ((Attribute) attribute).getAttrType();
ASN1Set attributeValues = ((Attribute) attribute).getAttrValues();
for (ASN1Encodable attributeValue : attributeValues.toArray()) {
String attributeValueStr = getAttributeValueString(attributeId, attributeValue);
sb.append(MessageFormat.format("{0}={1}", attributeId.getId(), attributeValueStr));
sb.append(NEWLINE);
}
}
return sb.toString();
}