Skip to content

Commit

Permalink
remove signing-algorithm from service initialization and provide it w…
Browse files Browse the repository at this point in the history
…hen getting authorization url from the selected credential or use the first supported one
  • Loading branch information
vkanellopoulos committed Nov 25, 2024
1 parent 5a94240 commit aaa1544
Show file tree
Hide file tree
Showing 27 changed files with 190 additions and 118 deletions.
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,9 @@ val rqesService = RQESService(
authFlowRedirectionURI = URI("rqes:redirect"),
scaBaseURL = URL("https://example.com"),
),
// set the hashing and singing algorithms that will be used
hashAlgorithm = HashAlgorithmOID.SHA_256,
signingAlgorithm = SigningAlgorithmOID.RSA_SHA256,
// set the hashing algorithm that will be used
// default is SHA-256 as shown below
hashAlgorithm = HashAlgorithmOID.SHA_256,
// optionally provide a HttpClientFactory to create a HttpClient for the service
// this is useful for logging, testing, etc.
httpClientFactory = {
Expand Down Expand Up @@ -153,6 +153,10 @@ val unsignedDocuments = UnsignedDocuments(
val credentialAuthorizationUrl = authorizedService.getCredentialAuthorizationUrl(
credential = credential,
documents = unsignedDocuments,
// optionally provide the signing algorithm to use when signing the documents
// if not provided the first available supported algorithm from the credential
// will be used
signingAlgorithmOID = SigningAlgorithmOID.ECDSA_SHA256
).getOrThrow()

// After the user has authorized the credential will be redirected to the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# AuthorizedImpl

[androidJvm]\
constructor(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, hashAlgorithm: HashAlgorithmOID, signingAlgorithm: SigningAlgorithmOID)
constructor(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, hashAlgorithm: HashAlgorithmOID)

Creates an authorized service implementation.

Expand All @@ -17,4 +17,3 @@ androidJvm
| client | The client. |
| serviceAccessAuthorized | The service access authorized. |
| hashAlgorithm | The algorithm OID, for hashing the documents. |
| signingAlgorithm | The algorithm OID, for signing the documents. |
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# getCredentialAuthorizationUrl

[androidJvm]\
open suspend override fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md)): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)<HttpsUrl>
open suspend override fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md), signingAlgorithmOID: SigningAlgorithmOID?): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)<HttpsUrl>

Get the credential authorization URL. This method is used to get the credential authorization URL.

Expand All @@ -20,4 +20,5 @@ androidJvm
| | |
|---|---|
| credential | The credential info. |
| documents | The list of documents to be signed. Implementations should use the default hash algorithm if this parameter is null. Implementations should use the default certificates if this parameter is null. |
| documents | The list of documents to be signed. |
| signingAlgorithmOID | The signing algorithm OID. Implementations should use the default hash algorithm if this parameter is null. Implementations should use the default certificates if this parameter is null. |
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# AuthorizedImpl

class [AuthorizedImpl](index.md)(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, val hashAlgorithm: HashAlgorithmOID, val signingAlgorithm: SigningAlgorithmOID) : [RQESService.Authorized](../../-r-q-e-s-service/-authorized/index.md)
class [AuthorizedImpl](index.md)(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, val hashAlgorithm: HashAlgorithmOID) : [RQESService.Authorized](../../-r-q-e-s-service/-authorized/index.md)

The authorized service implementation.

Expand All @@ -16,26 +16,24 @@ androidJvm
| client | The client. |
| serviceAccessAuthorized | The service access authorized. |
| hashAlgorithm | The algorithm OID, for hashing the documents. |
| signingAlgorithm | The algorithm OID, for signing the documents. |

## Constructors

| | |
|---|---|
| [AuthorizedImpl](-authorized-impl.md) | [androidJvm]<br>constructor(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, hashAlgorithm: HashAlgorithmOID, signingAlgorithm: SigningAlgorithmOID)<br>Creates an authorized service implementation. |
| [AuthorizedImpl](-authorized-impl.md) | [androidJvm]<br>constructor(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, hashAlgorithm: HashAlgorithmOID)<br>Creates an authorized service implementation. |

## Properties

| Name | Summary |
|---|---|
| [hashAlgorithm](hash-algorithm.md) | [androidJvm]<br>val [hashAlgorithm](hash-algorithm.md): HashAlgorithmOID<br>The algorithm OID, for hashing the documents. |
| [signingAlgorithm](signing-algorithm.md) | [androidJvm]<br>val [signingAlgorithm](signing-algorithm.md): SigningAlgorithmOID<br>The algorithm OID, for signing the documents. |

## Functions

| Name | Summary |
|---|---|
| [authorizeCredential](authorize-credential.md) | [androidJvm]<br>open suspend override fun [authorizeCredential](authorize-credential.md)(authorizationCode: AuthorizationCode): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;[RQESService.CredentialAuthorized](../../-r-q-e-s-service/-credential-authorized/index.md)&gt;<br>Authorize the credential. This method is used to authorize the credential that will be used to sign the documents. Once the authorizationCode is obtained using the credential authorization URL, it can be used to authorize the credential. The authorized credential can be used to sign the documents. |
| [getCredentialAuthorizationUrl](get-credential-authorization-url.md) | [androidJvm]<br>open suspend override fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md)): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;HttpsUrl&gt;<br>Get the credential authorization URL. This method is used to get the credential authorization URL. |
| [getCredentialAuthorizationUrl](get-credential-authorization-url.md) | [androidJvm]<br>open suspend override fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md), signingAlgorithmOID: SigningAlgorithmOID?): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;HttpsUrl&gt;<br>Get the credential authorization URL. This method is used to get the credential authorization URL. |
| [listCredentials](list-credentials.md) | [androidJvm]<br>open suspend override fun [listCredentials](list-credentials.md)(request: CredentialsListRequest?): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;CredentialInfo&gt;&gt;<br>List the credentials. This method is used to list the credentials. The credentials are the user's credentials that can be used to sign the documents. |
| [signDocuments](../../sign-documents.md) | [androidJvm]<br>suspend fun [RQESService.Authorized](../../-r-q-e-s-service/-authorized/index.md).[signDocuments](../../sign-documents.md)(authorizationCode: AuthorizationCode): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;[SignedDocuments](../../-signed-documents/index.md)&gt;<br>Sign the documents with the given authorization code. |

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
//[rqes-core](../../../../index.md)/[eu.europa.ec.eudi.rqes.core](../../index.md)/[RQESServiceImpl](../index.md)/[Companion](index.md)

# Companion

[androidJvm]\
object [Companion](index.md)
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# RQESServiceImpl

[androidJvm]\
constructor(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID, signingAlgorithm: SigningAlgorithmOID, clientFactory: () -&gt; HttpClient? = null)
constructor(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID, clientFactory: () -&gt; HttpClient? = null)

Creates a RQES service implementation.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# RQESServiceImpl

class [RQESServiceImpl](index.md)(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, val hashAlgorithm: HashAlgorithmOID, val signingAlgorithm: SigningAlgorithmOID, clientFactory: () -&gt; HttpClient? = null) : [RQESService](../-r-q-e-s-service/index.md)
class [RQESServiceImpl](index.md)(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, val hashAlgorithm: HashAlgorithmOID, clientFactory: () -&gt; HttpClient? = null) : [RQESService](../-r-q-e-s-service/index.md)

The RQES service implementation. This class provides the implementation of the RQES service.

Expand All @@ -22,21 +22,21 @@ androidJvm

| | |
|---|---|
| [RQESServiceImpl](-r-q-e-s-service-impl.md) | [androidJvm]<br>constructor(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID, signingAlgorithm: SigningAlgorithmOID, clientFactory: () -&gt; HttpClient? = null)<br>Creates a RQES service implementation. |
| [RQESServiceImpl](-r-q-e-s-service-impl.md) | [androidJvm]<br>constructor(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID, clientFactory: () -&gt; HttpClient? = null)<br>Creates a RQES service implementation. |

## Types

| Name | Summary |
|---|---|
| [AuthorizedImpl](-authorized-impl/index.md) | [androidJvm]<br>class [AuthorizedImpl](-authorized-impl/index.md)(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, val hashAlgorithm: HashAlgorithmOID, val signingAlgorithm: SigningAlgorithmOID) : [RQESService.Authorized](../-r-q-e-s-service/-authorized/index.md)<br>The authorized service implementation. |
| [AuthorizedImpl](-authorized-impl/index.md) | [androidJvm]<br>class [AuthorizedImpl](-authorized-impl/index.md)(serverState: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), client: CSCClient, serviceAccessAuthorized: ServiceAccessAuthorized, val hashAlgorithm: HashAlgorithmOID) : [RQESService.Authorized](../-r-q-e-s-service/-authorized/index.md)<br>The authorized service implementation. |
| [Companion](-companion/index.md) | [androidJvm]<br>object [Companion](-companion/index.md) |
| [CredentialAuthorizedImpl](-credential-authorized-impl/index.md) | [androidJvm]<br>class [CredentialAuthorizedImpl](-credential-authorized-impl/index.md)(client: CSCClient, documentsToSign: [List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;DocumentToSign&gt;, documentDigestList: DocumentDigestList, credentialAuthorized: CredentialAuthorized, val signingAlgorithm: SigningAlgorithmOID) : [RQESService.CredentialAuthorized](../-r-q-e-s-service/-credential-authorized/index.md)<br>The credential authorized implementation. |

## Properties

| Name | Summary |
|---|---|
| [hashAlgorithm](hash-algorithm.md) | [androidJvm]<br>open override val [hashAlgorithm](hash-algorithm.md): HashAlgorithmOID<br>The algorithm OID, for hashing the documents. |
| [signingAlgorithm](signing-algorithm.md) | [androidJvm]<br>open override val [signingAlgorithm](signing-algorithm.md): SigningAlgorithmOID<br>The algorithm OID, for signing the documents. |

## Functions

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# getCredentialAuthorizationUrl

[androidJvm]\
abstract suspend fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md)): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;HttpsUrl&gt;
abstract suspend fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md), signingAlgorithmOID: SigningAlgorithmOID? = null): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;HttpsUrl&gt;

Get the credential authorization URL. This method is used to get the credential authorization URL.

Expand All @@ -20,4 +20,5 @@ androidJvm
| | |
|---|---|
| credential | The credential info. |
| documents | The list of documents to be signed. Implementations should use the default hash algorithm if this parameter is null. Implementations should use the default certificates if this parameter is null. |
| documents | The list of documents to be signed. |
| signingAlgorithmOID | The signing algorithm OID. Implementations should use the default hash algorithm if this parameter is null. Implementations should use the default certificates if this parameter is null. |
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ The authorized service interface. This interface provides the methods to interac
| Name | Summary |
|---|---|
| [authorizeCredential](authorize-credential.md) | [androidJvm]<br>abstract suspend fun [authorizeCredential](authorize-credential.md)(authorizationCode: AuthorizationCode): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;[RQESService.CredentialAuthorized](../-credential-authorized/index.md)&gt;<br>Authorize the credential. This method is used to authorize the credential that will be used to sign the documents. Once the authorizationCode is obtained using the credential authorization URL, it can be used to authorize the credential. The authorized credential can be used to sign the documents. |
| [getCredentialAuthorizationUrl](get-credential-authorization-url.md) | [androidJvm]<br>abstract suspend fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md)): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;HttpsUrl&gt;<br>Get the credential authorization URL. This method is used to get the credential authorization URL. |
| [getCredentialAuthorizationUrl](get-credential-authorization-url.md) | [androidJvm]<br>abstract suspend fun [getCredentialAuthorizationUrl](get-credential-authorization-url.md)(credential: CredentialInfo, documents: [UnsignedDocuments](../../-unsigned-documents/index.md), signingAlgorithmOID: SigningAlgorithmOID? = null): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;HttpsUrl&gt;<br>Get the credential authorization URL. This method is used to get the credential authorization URL. |
| [listCredentials](list-credentials.md) | [androidJvm]<br>abstract suspend fun [listCredentials](list-credentials.md)(request: CredentialsListRequest? = null): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;[List](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-list/index.html)&lt;CredentialInfo&gt;&gt;<br>List the credentials. This method is used to list the credentials. The credentials are the user's credentials that can be used to sign the documents. |
| [signDocuments](../../sign-documents.md) | [androidJvm]<br>suspend fun [RQESService.Authorized](index.md).[signDocuments](../../sign-documents.md)(authorizationCode: AuthorizationCode): [Result](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-result/index.html)&lt;[SignedDocuments](../../-signed-documents/index.md)&gt;<br>Sign the documents with the given authorization code. |
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ object [Companion](index.md)

| Name | Summary |
|---|---|
| [invoke](invoke.md) | [androidJvm]<br>operator fun [invoke](invoke.md)(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID = HashAlgorithmOID.SHA_256, signingAlgorithm: SigningAlgorithmOID = SigningAlgorithmOID.RSA_SHA256, httpClientFactory: () -&gt; HttpClient? = null): [RQESService](../index.md)<br>Create the RQES service. |
| [invoke](invoke.md) | [androidJvm]<br>operator fun [invoke](invoke.md)(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID = HashAlgorithmOID.SHA_256, httpClientFactory: () -&gt; HttpClient? = null): [RQESService](../index.md)<br>Create the RQES service. |
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# invoke

[androidJvm]\
operator fun [invoke](invoke.md)(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID = HashAlgorithmOID.SHA_256, signingAlgorithm: SigningAlgorithmOID = SigningAlgorithmOID.RSA_SHA256, httpClientFactory: () -&gt; HttpClient? = null): [RQESService](../index.md)
operator fun [invoke](invoke.md)(serviceEndpointUrl: [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html), config: CSCClientConfig, hashAlgorithm: HashAlgorithmOID = HashAlgorithmOID.SHA_256, httpClientFactory: () -&gt; HttpClient? = null): [RQESService](../index.md)

Create the RQES service.

Expand All @@ -20,5 +20,4 @@ androidJvm
| serviceEndpointUrl | The service endpoint URL. |
| config | The CSC client configuration. |
| hashAlgorithm | The hash algorithm OID. |
| signingAlgorithm | The signing algorithm OID. |
| httpClientFactory | The HTTP client factory. |
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ HTTP client factory should be used. This property is optional can be used to pro
| Name | Summary |
|---|---|
| [hashAlgorithm](hash-algorithm.md) | [androidJvm]<br>abstract val [hashAlgorithm](hash-algorithm.md): HashAlgorithmOID<br>The algorithm OID, for hashing the documents. |
| [signingAlgorithm](signing-algorithm.md) | [androidJvm]<br>abstract val [signingAlgorithm](signing-algorithm.md): SigningAlgorithmOID<br>The algorithm OID, for signing the documents. |

## Functions

Expand Down

This file was deleted.

Loading

0 comments on commit aaa1544

Please sign in to comment.