public class TargetCert extends Target
TargetCert
type specified by the
X.509 Attribute Certificate profile (RFC 5755)
to be used within TargetInformation
or ProxyInfo
attribute certificate extensions.
A TargetCert, when included in a TargetInformation
extension, may specify some server/service for which the
attribute certificate that contains the TargetInformation can be used.
A TargetCert, when included in a ProxyInfo
extension, may specify some server/service which represents a
valid sender (proxy) or recipient of the attribute certificate that contains
the ProxyInfo extension.
Both, TargetInformation and ProxyInfo extensions are defined as an ASN.1
SEQUENCE OF Targets, where each Targets
object itself can hold any number of Target
elements:
TargetInformation ::= SEQUENCE OF Targets ProxyInfo ::= SEQUENCE OF Targets Targets ::= SEQUENCE OF TargetA Target element can be a
TargetCert
, TargetGroup
or TargetCert
(RFC 5755 recommends to use the TargetName or TargetGroup choice, but
TargetCert MUST NOT be used):
Target ::= CHOICE { targetName [0] GeneralName targetGroup [1] GeneralName targetCert [2] TargetCert } TargetCert ::= SEQUENCE { targetCertificate IssuerSerial, targetName GeneralName OPTIONAL, certDigestInfo ObjectDigestInfo OPTIONAL }As seen from above a TargetCert must contain the
targetCertificate
field and may contain optional targetName
and certDigestInfo
fields. Thus an IssuerSerial
object has to be
specified when creating
a TargetCert for naming some
specific server/service as target for an attribute certificate by referencing the server
certificate, e.g.:
// server certificate X509Certificate serverCert = ...; // create IssuerSerial IssuerSerial issuerSerial = new IssuerSerial(serverCert); // create TargetCert TargetCert = new TargetCert(issuerSerial);Optional
targetName
and certDigestInfo
fields have
to be created as GeneralName
and
ObjectDigestInfo
objects, respectively, e.g.:
// targetName field GeneralName targetName = new GeneralName(GeneralName.uniformResourceIdentifier, "www.iaik.at"); targetCert.setTargetName(targetName); // certDigestInfo field ObjectDigestInfo certDigestInfo = new ObjectDigestInfo(serverCert, AlgorithmID.sha1); targetCert.setCertDigestInfo(certDigestInfo);After having created a TargetCert element it typically may be added to a
Targets
object to then be included into a TargetInformation
or ProxyInfo
extension, e.g.:
Targets targets = new Targets(); targets.addTarget(targetCert); ProxyInfo proxyInfo = new ProxyInfo(); proxyInfo.addTargets(targets);For a TargetInformation (which shall contain one single Targets object only) it is also possible to immediately
add
the TargetCert element:
TargetInformation targetInformation = new TargetInformation(); targetInformation.addTargetElement(targetCert);An AC verifier, when receiving an attribute certificate that contains a TargetInformation or ProxyInfo extension, may query for the included Target elements, e.g.:
... TargetInformation targetInformation = (TargetInformation)attributeCertificate.getExtension(TargetInformation.oid); if (targetInformation != null) { Target[] targetElements = targetInformation.getTargetElements(); for (int i = 0; i < targetElements; i++) { if (targetElements[i].getType() == Target.TARGET_NAME) { TargetCert targetCert = (TargetCert)targetElements[i]; ... } } }However, typically the AC verifier only will call the TargetInformation
isTargetFor
or ProxyInfo
checkProxy
methods to
check if the received attribute certificate can be accepted by the current server, e.g.:
TargetCert server = ...; if (targetInformation.isTargetFor(server) { // ok; accept ac } else { // reject ac }When calling
TargetInformation.isTargetFor
or ProxyInfo.checkProxy
the targeting check is
controlled by the TargetChecker
. When checking a server
if it is referenced by a TargetCert contained in an attribute certificate, the default
TargetChecker implementation requires that the server object is given as TargetCert
itself. The server TargetCert then is checked if it is equal to the AC TargetCert.
plug-in
its own TargetChecker
implementation for enforcing a more sophisticated target checking policy which
may be tailored to application specific requirements that cannot be considered
by a general default implementation.TARGET_CERT, TARGET_GROUP, TARGET_NAME
Constructor and Description |
---|
TargetCert(ASN1Object asn1Obj)
Creates a TargetCert form its ASN.1 representation.
|
TargetCert(IssuerSerial targetCertificate)
Creates a new TargetCert object with the given issuer and serial number.
|
Modifier and Type | Method and Description |
---|---|
void |
decodeUnTaggedASN1Object(ASN1Object obj)
Decodes (parses) the untagged ASN.1 representation of this TargetCert object.
|
boolean |
equals(java.lang.Object obj)
Compares this
TargetCert with the specified object. |
ObjectDigestInfo |
getCertDigestInfo()
Gets the certificate digest info.
|
IssuerSerial |
getTargetCertificate()
Gets the target certificate.
|
GeneralName |
getTargetName()
Gets the target name.
|
int |
getType()
Returns the type this Target represents.
|
protected java.lang.String |
getTypeAsString()
Gets the type (as String "TargetCert") this target represents.
|
int |
hashCode()
Returns a hashcode for this TargetCert
|
void |
setCertDigestInfo(ObjectDigestInfo certDigestInfo)
Sets the certificate digest info.
|
void |
setTargetName(GeneralName targetName)
Sets the target name.
|
java.lang.String |
toString()
Gets a string giving some information about this
TargetCert object. |
ASN1Object |
toUnTaggedASN1Object()
Gets the untagged ASN.1 representation of this TargetCert object.
|
decode, isTargetFor, parseTarget, setTargetChecker, toASN1Object
public TargetCert(IssuerSerial targetCertificate)
// server certificate X509Certificate serverCert = ...; // create IssuerSerial IssuerSerial issuerSerial = new IssuerSerial(serverCert); // create TargetCert TargetCert = new TargetCert(issuerSerial);
targetCertificate
- the issuer and serial numberpublic TargetCert(ASN1Object asn1Obj) throws CodingException
Target ::= CHOICE { targetName [0] GeneralName targetGroup [1] GeneralName targetCert [2] TargetCert } TargetCert ::= SEQUENCE { targetCertificate IssuerSerial, targetName GeneralName OPTIONAL, certDigestInfo ObjectDigestInfo OPTIONAL }
asn1Obj
- the TargetCert as ASN1Object (context specific tagged
CHOICE with tag number 2)CodingException
- if an error occurs when parsing the ASN1Objectpublic int getType()
protected java.lang.String getTypeAsString()
getTypeAsString
in class Target
public IssuerSerial getTargetCertificate()
public void setTargetName(GeneralName targetName)
GeneralName
object, e.g.:
GeneralName targetName = new GeneralName(GeneralName.uniformResourceIdentifier, "www.iaik.at"); targetCert.setTargetName(targetName);
targetName
- the name of the targetpublic GeneralName getTargetName()
null
if not setpublic void setCertDigestInfo(ObjectDigestInfo certDigestInfo)
ObjectDigestInfo
object, e.g.:
ObjectDigestInfo certDigestInfo = new ObjectDigestInfo(serverCert, AlgorithmID.sha1); targetCert.setCertDigestInfo(certDigestInfo);
certDigestInfo
- the certificate digest infopublic ObjectDigestInfo getCertDigestInfo()
null
if not setpublic boolean equals(java.lang.Object obj)
TargetCert
with the specified object.public int hashCode()
public void decodeUnTaggedASN1Object(ASN1Object obj) throws CodingException
A Target is defined as ASN.1 CHOICE of targetName, targetGroup or targetCert, which are context specific tagged with tag number 0, 1, 2, respectively (see RFC 5755):
Target ::= CHOICE { targetName [0] GeneralName, targetGroup [1] GeneralName, targetCert [2] TargetCert } TargetCert ::= SEQUENCE { targetCertificate IssuerSerial, targetName GeneralName OPTIONAL, certDigestInfo ObjectDigestInfo OPTIONAL }This method decodes/parses the untagged ASN.1 representation of an ASN.1 TargetCert; thus the given ASN1Object must represent an ASN.1 SEQUENCE holding at least the targetCertificate IssuerSerial component. For decoding the tagged ASN.1 representation (a CHOICE with tag number [2]), method
decode
is used.decodeUnTaggedASN1Object
in class Target
obj
- the untagged ASN.1 TargetCert to be decoded/parsedCodingException
- if a decoding/parsing error occurspublic ASN1Object toUnTaggedASN1Object() throws CodingException
Target ::= CHOICE { targetName [0] GeneralName, targetGroup [1] GeneralName, targetCert [2] TargetCert } TargetCert ::= SEQUENCE { targetCertificate IssuerSerial, targetName GeneralName OPTIONAL, certDigestInfo ObjectDigestInfo OPTIONAL }This method returns the untagged ASN.1 representation of this TargetCert (i.e. an ASN.1 SEQUENCE representing the value of this TargetCert). The tagged ASN.1 representation (i.e. a CHOICE with tag number [2], is returned by method
toASN1Object
.toUnTaggedASN1Object
in class Target
CodingException
- if an error occurs when creating the ASN.1 object