Class IssuerSignedBuilder
IssuerSigned
instance.
An IssuerSigned
instanced is used to create a Document
instance.
- Since:
- 1.5
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()
Build anIssuerSigned
instance.Get theCBORizer
to convert given claim values into CBOR items.Get the claims used to createIssuerSignedItem
s.Get the device key.Get the DocType.Get the signer to sign the Issuer Auth structure.Get the certificate chain for the issuer key.Get the issuer key used to sign theIssuerAuth
structure (COSESign1
).Get the validity information of the Mobile Security Object.setCBORizer
(CBORizer cborizer) Set theCBORizer
to convert given claim values into CBOR items.Set the claims used to createIssuerSignedItem
s.setDeviceKey
(COSEKey deviceKey) Set the device key.setDocType
(String docType) Set the DocType.Set the signer to sign the Issuer Auth structure.setIssuerCertChain
(List<X509Certificate> chain) Set the certificate chain for the issuer key.setIssuerKey
(COSEEC2Key issuerKey) Set the issuer key used to sign theIssuerAuth
structure (COSESign1
).setValidityInfo
(ValidityInfo info) Set the validity information of the Mobile Security Object.
-
Constructor Details
-
IssuerSignedBuilder
public IssuerSignedBuilder()
-
-
Method Details
-
getDocType
Get the DocType.The value is used as the value of the
"docType"
parameter of theMobileSecurityObject
.- Returns:
- The DocType.
-
setDocType
Set the DocType.The value is used as the value of the
"docType"
parameter of theMobileSecurityObject
structure.- Parameters:
docType
- The DocType.- Returns:
- return
this
object.
-
getClaims
Get the claims used to createIssuerSignedItem
s.See the description of the
setClaims(Map)
method for details about the format.- Returns:
- The claims used to create
IssuerSignedItem
s.
-
setClaims
Set the claims used to createIssuerSignedItem
s.The keys of the top-level properties in the
claims
map must be strings representing name spaces, and their values must be JSON objects, each of which contains claims under the corresponding name space.The following JSON shows the structure that the
claims
map should have.{ "com.example.namespace1" : { "claimName1": "claimValue1", "claimName2": true, "claimName3": 1 }, "com.example.namespace2" : { "claimName4": [ "element1", "element2" ], "claimName5": { "subClaimName1": "subClaimValue1" } } }
Types of claim values can be strings, boolean values, integers, floating-point numbers, arrays (
List
) and maps (Map
), which are natural representations of JSON values.However, there may be cases where CBOR-specific data need to be embedded. For example, the
"birth_date"
claim may require the "full-date" tag (defined in RFC 8943) and the"portrait"
claim may require binary data.To embed CBOR-specific data, a
CBORizer
instance with an implementation of theCBORDiagnosticNotationParser
interface needs to be set by calling thesetCBORizer(CBORizer)
method. SuchCBORizer
will interpret strings written in the CBOR Diagnostic Notation (RFC 8949 Section 8, RFC 8610 Appendix G) with a special prefix (e.g."cbor:"
), and convert them into CBOR-specific data. As a result, input data like below will be accepted and CBOR-specific data will be embedded accordingly.{ "com.example.namespace3": { "birth_date": "cbor:1004(\"1974-05-06\")", "portrait": "cbor:h'0102.....'" } }
- Parameters:
claims
- The claims used to createIssuerSignedItem
s.- Returns:
this
object.
-
getValidityInfo
Get the validity information of the Mobile Security Object.The value is used as the value of the
"validityInfo"
parameter of theMobileSecurityObject
structure.- Returns:
- The validity information of the Mobile Security Object.
-
setValidityInfo
Set the validity information of the Mobile Security Object.The value is used as the value of the
"validityInfo"
parameter of theMobileSecurityObject
structure.- Parameters:
info
- The validity information of the Mobile Security Object.- Returns:
this
object.
-
getDeviceKey
Get the device key.The value is used as the value of the
"deviceKey"
parameter of theDeviceKeyInfo
structure.- Returns:
- The device key.
-
setDeviceKey
Set the device key.The value is used as the value of the
"deviceKey"
parameter of theDeviceKeyInfo
structure.- Parameters:
deviceKey
- The device key.- Returns:
this
object.
-
getIssuerKey
Get the issuer key used to sign theIssuerAuth
structure (COSESign1
).- Returns:
- The issuer key.
-
setIssuerKey
Set the issuer key used to sign theIssuerAuth
structure (COSESign1
).If a signer is not provided through the
setIssuerAuthSigner(SigStructureSigner)
method, a private key must be set. Conversely, if a signer is provided, a key still needs to be set, but it does not necessarily have to be a private key. In this case, the key set by this method is not used for signing the Issuer Auth structure.- Parameters:
issuerKey
- The issuer key.- Returns:
this
object.- See Also:
-
getIssuerCertChain
Get the certificate chain for the issuer key.The value is embedded in the unprotected header of the
IssuerAuth
structure (COSESign1
) as the value of thex5chain
header parameter.- Returns:
- The certificate chain for the issuer key.
- See Also:
-
setIssuerCertChain
Set the certificate chain for the issuer key.The value is embedded in the unprotected header of the
IssuerAuth
structure (COSESign1
) as the value of thex5chain
header parameter.- Parameters:
chain
- The certificate chain for the issuer key.- Returns:
this
object.- See Also:
-
getCBORizer
Get theCBORizer
to convert given claim values into CBOR items.If there are claim values expressed in the CBOR Diagnostic Notation like
"cbor:h'0102'"
and"cbor:0(\"2013-03-21T20:04:00Z\")"
, aCBORizer
instance withCBORDiagnosticNotationParser
needs to be explicitly set. Otherwise, strings expressed in the CBOR Diagnostic Notation are embedded as CBOR text strings without any conversion.- Returns:
- The
CBORizer
.
-
setCBORizer
Set theCBORizer
to convert given claim values into CBOR items.If there are claim values expressed in the CBOR Diagnostic Notation like
"cbor:h'0102'"
and"cbor:0(\"2013-03-21T20:04:00Z\")"
, aCBORizer
instance withCBORDiagnosticNotationParser
needs to be explicitly set. Otherwise, strings expressed in the CBOR Diagnostic Notation are embedded as CBOR text strings without any conversion.- Parameters:
cborizer
- TheCBORizer
.- Returns:
this
object.
-
getIssuerAuthSigner
Get the signer to sign the Issuer Auth structure.- Returns:
- The signer to sign the Issuer Auth structure.
- Since:
- 1.20
-
setIssuerAuthSigner
Set the signer to sign the Issuer Auth structure.If a signer is provided through this method, it will be used to sign the Issuer Auth structure. Conversely, if no signer is provided, a new
COSESigner
instance will be created with the private key set by thesetIssuerKey(COSEEC2Key)
method, and the instance will be used to sign the Issuer Auth structure.- Parameters:
signer
- The signer to sign the Issuer Auth structure.- Returns:
this
object.- Since:
- 1.20
- See Also:
-
build
Build anIssuerSigned
instance.- Returns:
- A new
IssuerSigned
instance. - Throws:
COSEException
- Signing with the issuer key failed.CertificateEncodingException
- The DER representation of an X.509 certificate in the issuer's certificate chain failed to be obtained.
-