public class ChargingIdentity extends IetfAttrSyntax
The X.509 Attribute Certificate profile (RFC 5755)
specifies the ChargingIdentity attribute to be included as attribute in an AttributeCertificate for identifying the holder of
the attribute certificate for charging purposes. For instance, the ChargingIdentity
attribute maybe used to identify the holder's company which may be charged for
some service.
Each attribute is associated with a specific attribute type object identifier.
The OID for the ChargingIdentity attribute is defined as follows:
id-pkix OBJECT IDENTIFIER ::=
{ iso(1) identified-organization(3) dod(6) internet(1)
security(5) mechanisms(5) pkix(7) }
id-aca OBJECT IDENTIFIER ::= { id-pkix 10 }
id-aca-chargingIdentity OBJECT IDENTIFIER ::= { id-aca 3 }
which corresponds to the OID string "1.3.6.1.5.5.7.10.3".
The ASN.1 structure of the ChargingIdentity attribute is defined by the
the IetfAttrSyntax (see RFC 5755):
IetfAttrSyntax ::= SEQUENCE {
policyAuthority [0] GeneralNames OPTIONAL,
values SEQUENCE OF CHOICE {
octets OCTET STRING,
oid OBJECT IDENTIFIER,
string UTF8String
}
}
The policyAuthority field maybe set to separate between the
AC issuer and the attribute policy authority.
Although the values field is specified as SEQUENCE OF CHOICE
of OCTET_STRING, ObjectID, or UTF8String types, only one of
these types must be present. This means that in practice values
only can be a SEQUENCE OF OCTET_STRING objects, a SEQUENCE OF ObjectID objects,
or a SEQUENCE OF UTF8String objects.
When creating a ChargingIdentity attribute the values have to be supplied as
array of byte[] values, or array of
ObjectID values, or array of String values, e.g.:
String value1 = "IAIK";
String value2 = "SIC";
String[] values = { value1, value2 };
ChargingIdentity chargingIdentity = new ChargingIdentity(values);
If required to separate between AC issuer and attribute policy authority, use method
setPolicyAuthority for specifying
the attribute policy authotity:
GeneralNames policyAuthority = ...; chargingIdentity.setPolicyAuthority(policyAuthority);Finally use method
addAttribute
of class AttributeCertificate to add the ChargingIdentity
object as attribute to an AttributeCertificate:
// create attribute certificate AttributeCertificate ac = new AttributeCertificate(); ... // set holder, issuer, validity,... ... // add ChargingIdentity attribute ac.addAttribute(new Attribute(chargingIdentity)); ... // sign and encode certificate ac.sign(...); byte[] encodedAc = ac.getEncoded();On the receiving side use method
getAttribute
of class AttributeCertificate to get a ChargingIdentity
attribute -- if included -- from an Attribute Certificate:
// the AttributeCertificate:
AttributeCertificate ac = new AttributeCertificate(encodedAc);
...
// verify signature, check validity,...
...
// query for ChargingIdentity attribute:
Attribute chargingIdentityAttribute = ac.getAttribute(ChargingIdentity.oid);
if (chargingIdentityAttribute != null) {
// ChargingIdentity is only allowed to be a single-valued attribute
ChargingIdentity chargingIdentity = (ChargingIdentity)chargingIdentityAttribute.getAttributeValue();
// get values
ASN valueType = chargingIdentity.getASN1TypeOfValues();
System.out.println("ASN.1 type of values is " + valueType.getName());
Enumeration values = chargingIdentity.getValues();
while (values.hasMoreElements()) {
// we know that we only have used UTF8String values
String value = (String)values.nextElement();
System.out.println("Responsible for charging is: " + value);
}
// get policy authority, if included
GeneralNames policyAuthority = chargingIdentity.getPolicyAuthority();
if (policyAuthority != null) {
...
}
}
| Modifier and Type | Field and Description |
|---|---|
static ObjectID |
oid
The attributeType object identifier of the ChargingIdentity attribute.
|
| Constructor and Description |
|---|
ChargingIdentity()
Empty default constructor.
|
ChargingIdentity(ASN1Object obj)
Creates a ChargingIdentity object from its ASN.1 representation.
|
ChargingIdentity(byte[][] values)
Creates a ChargingIdentity object for the given byte[] values array.
|
ChargingIdentity(ObjectID[] values)
Creates a ChargingIdentity object for the given ObjectID values array.
|
ChargingIdentity(java.lang.String[] values)
Creates a ChargingIdentity object for the given String values array.
|
| Modifier and Type | Method and Description |
|---|---|
ObjectID |
getAttributeType()
Returns the OID (1.3.6.1.5.5.7.10.3) identifying the ChargingIdentity
attribute type.
|
boolean |
multipleAllowed()
Returns whether multiple ChargingIdentity values are allowed
in the
SET OF AttributeValue of the Attribute object to which
this ChargingIdentity AttributeValue may belong to. |
containsValue, decode, getASN1TypeOfValues, getPolicyAuthority, getValues, numberOfValues, setPolicyAuthority, toASN1Object, toStringgetNamepublic static final ObjectID oid
public ChargingIdentity()
public ChargingIdentity(byte[][] values)
throws java.lang.IllegalArgumentException
Use method setPolicyAuthority for
specifying an attribute policy authority, if required.
values - a number of byte arrays representing the
OCTET_STRING values of this ChargingIdentityjava.lang.IllegalArgumentException - if this ChargingIdentity only
allows one value but the given array contains more than
one valuejava.lang.NullPointerException - if values is nullpublic ChargingIdentity(ObjectID[] values) throws java.lang.IllegalArgumentException
Use method setPolicyAuthority for
specifying an attribute policy authority, if required.
values - an ObjectID array representing the
ObjectID values of this ChargingIdentityjava.lang.IllegalArgumentException - if this ChargingIdentity only
allows one value but the given array contains more than
one valuejava.lang.NullPointerException - if values is nullpublic ChargingIdentity(java.lang.String[] values)
throws java.lang.IllegalArgumentException
Use method setPolicyAuthority for
specifying an attribute policy authority, if required.
values - an array of String objects representing the
UTF8String values of this ChargingIdentityjava.lang.IllegalArgumentException - if this ChargingIdentity only
allows one value but the given array contains more than
one valuejava.lang.NullPointerException - if values is nullpublic ChargingIdentity(ASN1Object obj) throws CodingException
policyAuthority
and values fields from the given ASN.1 object:
ChargingIdentity ::= SEQUENCE {
policyAuthority [0] GeneralNames OPTIONAL,
values SEQUENCE OF CHOICE {
octets OCTET STRING,
oid OBJECT IDENTIFIER,
string UTF8String
}
}
The policyAuthority field maybe set to separate between the
AC issuer and the attribute policy authority.
Although the values field is specified as SEQUENCE OF CHOICE
of OCTET_STRING, ObjectID, or UTF8String types, only one of
these types must be present. This means that in practice values
only can be a SEQUENCE OF OCTET_STRING objects, a SEQUENCE OF ObjectID objects,
or a SEQUENCE OF UTF8String objects.obj - the ChargingIdentity as ASN1ObjectCodingException - if the ASN.1 object cannot be parsed or is
invalid structured (e.g. if the values component
does not contain only OCTET_STRING, ObjectID, or
UTF8String objectspublic ObjectID getAttributeType()
getAttributeType in class AttributeValuepublic boolean multipleAllowed()
SET OF AttributeValue of the Attribute object to which
this ChargingIdentity AttributeValue may belong to.
false because a ChargingIdentity
attribute must be single-valued, meaning that only one ChargingIdentity
attribute value can be contained in the SET OF AttributeValue
of the Attribute object.
However, this does not reflect the values field
of the ChargingIdentity which may contain an arbitrary number
of UTF8String, ObjectID or OCTET_STRING values, all of the same
ASN.1 type.multipleAllowed in class AttributeValuefalse since only one ChargingIdentity is
allowed in the SET OF AttributeValue