Skip to content

Commit

Permalink
Remove data provider from issuing agent's constructor parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
nodh committed Oct 21, 2024
1 parent 477d764 commit 1e92653
Show file tree
Hide file tree
Showing 18 changed files with 25 additions and 111 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Release 5.1.0:
- Add `credentialScheme` and `subjectPublicKey` to internal `CredentialToBeIssued`
- Refactor `issueCredential` of `Issuer` to directly get the credential-to-be-issued
- Replace `buildIssuerCredentialDataProviderOverride` in `CredentialIssuer` with `credentialProvider` to extract user information into a credential
- Remove `dataProvider` from `IssuerAgent`s constructor, as it is not needed with the new issuing interface anyway

Release 5.0.1:
- Update JsonPath4K to 2.4.0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CredentialJsonInteropTest : FreeSpec({
holderKeyMaterial = EphemeralKeyWithoutCert()
subjectCredentialStore = InMemorySubjectCredentialStore()
holderAgent = HolderAgent(holderKeyMaterial, subjectCredentialStore)
issuerAgent = IssuerAgent(EphemeralKeyWithSelfSignedCert(), DummyCredentialDataProvider())
issuerAgent = IssuerAgent(EphemeralKeyWithSelfSignedCert())
}

"Plain jwt credential path resolving" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,7 @@ private suspend fun Holder.storeJwtCredential(
credentialScheme: ConstantIndex.CredentialScheme,
) {
storeCredential(
IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
credentialScheme,
Expand All @@ -286,10 +283,7 @@ private suspend fun Holder.storeSdJwtCredential(
credentialScheme: ConstantIndex.CredentialScheme,
) {
storeCredential(
IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
credentialScheme,
Expand All @@ -303,10 +297,7 @@ private suspend fun Holder.storeIsoCredential(
holderKeyMaterial: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) = storeCredential(
IssuerAgent(
EphemeralKeyWithSelfSignedCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent(EphemeralKeyWithSelfSignedCert()).issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
credentialScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,10 +206,7 @@ private suspend fun Holder.storeSdJwtCredential(
credentialScheme: ConstantIndex.CredentialScheme,
) {
storeCredential(
IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
credentialScheme,
Expand All @@ -223,10 +220,7 @@ private suspend fun Holder.storeIsoCredential(
holderKeyMaterial: KeyMaterial,
credentialScheme: ConstantIndex.CredentialScheme,
) = storeCredential(
IssuerAgent(
EphemeralKeyWithSelfSignedCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent(EphemeralKeyWithSelfSignedCert()).issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
credentialScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,7 @@ class OidcSiopInteropTest : FreeSpec({
beforeEach {
holderKeyMaterial = EphemeralKeyWithoutCert()
holderAgent = HolderAgent(holderKeyMaterial)
val issuerAgent = IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
)
val issuerAgent = IssuerAgent()
holderAgent.storeCredential(
issuerAgent.issueCredential(
DummyCredentialDataProvider().getCredential(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ class OidcSiopIsoProtocolTest : FreeSpec({
walletUrl = "https://example.com/wallet/${uuid4()}"
holderAgent = HolderAgent(holderKeyMaterial)

val issuerAgent = IssuerAgent(
EphemeralKeyWithSelfSignedCert(),
DummyCredentialDataProvider(),
)
val issuerAgent = IssuerAgent(EphemeralKeyWithSelfSignedCert())
holderAgent.storeCredential(
issuerAgent.issueCredential(
DummyCredentialDataProvider().getCredential(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,7 @@ class OidcSiopProtocolTest : FreeSpec({
holderAgent = HolderAgent(holderKeyMaterial)

holderAgent.storeCredential(
IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,7 @@ class OidcSiopSdJwtProtocolTest : FreeSpec({
verifierAgent = VerifierAgent(verifierKeyMaterial)

holderAgent.storeCredential(
IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,8 @@ class OidcSiopWalletScopeSupportTest : FreeSpec({
}

"get empty scope works even without available credentials" {
val issuerAgent = IssuerAgent(
EphemeralKeyWithSelfSignedCert(),
DummyCredentialDataProvider(),
)
holderAgent.storeCredential(
issuerAgent.issueCredential(
IssuerAgent(EphemeralKeyWithSelfSignedCert()).issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
Expand Down Expand Up @@ -134,12 +130,8 @@ class OidcSiopWalletScopeSupportTest : FreeSpec({
}

"get MdocMdlWithGivenName scope with available credentials succeeds" {
val issuerAgent = IssuerAgent(
EphemeralKeyWithSelfSignedCert(),
DummyCredentialDataProvider(),
)
holderAgent.storeCredential(
issuerAgent.issueCredential(
IssuerAgent(EphemeralKeyWithSelfSignedCert()).issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
MobileDrivingLicenceScheme,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ class OidcSiopX509SanDnsTest : FreeSpec({
verifierKeyMaterial = EphemeralKeyWithSelfSignedCert(extensions = extensions)
holderAgent = HolderAgent(holderKeyMaterial)
holderAgent.storeCredential(
IssuerAgent(
EphemeralKeyWithoutCert(),
DummyCredentialDataProvider(),
).issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ class IssuerAgent(
private val validator: Validator,
private val issuerCredentialStore: IssuerCredentialStore = InMemoryIssuerCredentialStore(),
private val revocationListBaseUrl: String = "https://wallet.a-sit.at/backend/credentials/status",
private val dataProvider: IssuerCredentialDataProvider = EmptyCredentialDataProvider,
private val zlibService: ZlibService = DefaultZlibService(),
private val revocationListLifetime: Duration = 48.hours,
private val jwsService: JwsService,
Expand All @@ -46,28 +45,14 @@ class IssuerAgent(
private val timePeriodProvider: TimePeriodProvider = FixedTimePeriodProvider,
) : Issuer {

constructor(
keyMaterial: KeyMaterial = EphemeralKeyWithoutCert(),
dataProvider: IssuerCredentialDataProvider = EmptyCredentialDataProvider,
) : this(
validator = Validator(),
jwsService = DefaultJwsService(DefaultCryptoService(keyMaterial)),
coseService = DefaultCoseService(DefaultCryptoService(keyMaterial)),
dataProvider = dataProvider,
keyMaterial = keyMaterial,
cryptoAlgorithms = setOf(keyMaterial.signatureAlgorithm),
)

constructor(
keyMaterial: KeyMaterial = EphemeralKeyWithoutCert(),
issuerCredentialStore: IssuerCredentialStore = InMemoryIssuerCredentialStore(),
dataProvider: IssuerCredentialDataProvider = EmptyCredentialDataProvider,
) : this(
validator = Validator(),
issuerCredentialStore = issuerCredentialStore,
jwsService = DefaultJwsService(DefaultCryptoService(keyMaterial)),
coseService = DefaultCoseService(DefaultCryptoService(keyMaterial)),
dataProvider = dataProvider,
keyMaterial = keyMaterial,
cryptoAlgorithms = setOf(keyMaterial.signatureAlgorithm),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ class AgentRevocationTest : FreeSpec({

beforeEach {
issuerCredentialStore = InMemoryIssuerCredentialStore()
issuer = IssuerAgent(
EphemeralKeyWithoutCert(),
issuerCredentialStore,
DummyCredentialDataProvider()
)
issuer = IssuerAgent(EphemeralKeyWithoutCert(), issuerCredentialStore)
verifierKeyMaterial = EphemeralKeyWithoutCert()
verifier = VerifierAgent(verifierKeyMaterial)
expectedRevokedIndexes = issuerCredentialStore.revokeRandomCredentials()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ class AgentSdJwtTest : FreeSpec({
beforeEach {
issuerCredentialStore = InMemoryIssuerCredentialStore()
holderCredentialStore = InMemorySubjectCredentialStore()
issuer = IssuerAgent(
EphemeralKeyWithoutCert(),
issuerCredentialStore,
DummyCredentialDataProvider(),
)
issuer = IssuerAgent(EphemeralKeyWithoutCert(), issuerCredentialStore)
holderKeyMaterial = EphemeralKeyWithSelfSignedCert()
holder = HolderAgent(holderKeyMaterial, holderCredentialStore)
verifier = VerifierAgent()
Expand Down Expand Up @@ -160,11 +156,10 @@ private fun buildPresentationDefinition(vararg attributeName: String) = Presenta
)

suspend fun createFreshSdJwtKeyBinding(challenge: String, verifierId: String): String {
val issuer = IssuerAgent(EphemeralKeyWithoutCert(), DummyCredentialDataProvider())
val holderKeyMaterial = EphemeralKeyWithoutCert()
val holder = HolderAgent(holderKeyMaterial)
holder.storeCredential(
issuer.issueCredential(
IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,7 @@ class AgentTest : FreeSpec({
beforeEach {
issuerCredentialStore = InMemoryIssuerCredentialStore()
holderCredentialStore = InMemorySubjectCredentialStore()
issuer = IssuerAgent(
EphemeralKeyWithoutCert(),
issuerCredentialStore,
DummyCredentialDataProvider(),
)
issuer = IssuerAgent(EphemeralKeyWithoutCert(), issuerCredentialStore)
holderKeyMaterial = EphemeralKeyWithoutCert()
holder = HolderAgent(holderKeyMaterial, holderCredentialStore)
verifier = VerifierAgent(holderKeyMaterial)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class ValidatorVcTest : FreeSpec() {
beforeEach {
issuerCredentialStore = InMemoryIssuerCredentialStore()
issuerKeyMaterial = EphemeralKeyWithoutCert()
issuer = IssuerAgent(issuerKeyMaterial, issuerCredentialStore, dataProvider)
issuer = IssuerAgent(issuerKeyMaterial, issuerCredentialStore)
issuerJwsService = DefaultJwsService(DefaultCryptoService(issuerKeyMaterial))
verifierKeyMaterial = EphemeralKeyWithoutCert()
verifier = VerifierAgent(verifierKeyMaterial)
}

"credentials are valid for" {
val credential = issuer.issueCredential(
DummyCredentialDataProvider().getCredential(
dataProvider.getCredential(
verifierKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
ConstantIndex.CredentialRepresentation.PLAIN_JWT,
Expand All @@ -57,7 +57,7 @@ class ValidatorVcTest : FreeSpec() {

"revoked credentials are not valid" {
val credential = issuer.issueCredential(
DummyCredentialDataProvider().getCredential(
dataProvider.getCredential(
verifierKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
ConstantIndex.CredentialRepresentation.PLAIN_JWT,
Expand All @@ -82,7 +82,7 @@ class ValidatorVcTest : FreeSpec() {

"wrong subject keyId is not be valid" {
val credential = issuer.issueCredential(
DummyCredentialDataProvider().getCredential(
dataProvider.getCredential(
EphemeralKeyWithoutCert().publicKey,
ConstantIndex.AtomicAttribute2023,
ConstantIndex.CredentialRepresentation.PLAIN_JWT,
Expand All @@ -96,7 +96,7 @@ class ValidatorVcTest : FreeSpec() {

"credential with invalid JWS format is not valid" {
val credential = issuer.issueCredential(
DummyCredentialDataProvider().getCredential(
dataProvider.getCredential(
verifierKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
ConstantIndex.CredentialRepresentation.PLAIN_JWT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,7 @@ class ValidatorVpTest : FreeSpec({
beforeEach {
validator = Validator()
issuerCredentialStore = InMemoryIssuerCredentialStore()
issuer = IssuerAgent(
EphemeralKeyWithoutCert(),
issuerCredentialStore,
DummyCredentialDataProvider(),
)
issuer = IssuerAgent(EphemeralKeyWithoutCert(), issuerCredentialStore)
holderCredentialStore = InMemorySubjectCredentialStore()
holderKeyMaterial = EphemeralKeyWithoutCert()
holder = HolderAgent(holderKeyMaterial, holderCredentialStore)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,8 @@ class Tag24SerializationTest : FreeSpec({
}

"IssuerSigned from IssuerAgent" {
val issuerAgent = IssuerAgent(dataProvider = DummyCredentialDataProvider())
val holderKeyMaterial = EphemeralKeyWithSelfSignedCert()
val issuedCredential = issuerAgent.issueCredential(
val issuedCredential = IssuerAgent().issueCredential(
DummyCredentialDataProvider().getCredential(
holderKeyMaterial.publicKey,
ConstantIndex.AtomicAttribute2023,
Expand Down

0 comments on commit 1e92653

Please sign in to comment.