Skip to content

Commit db692a8

Browse files
committed
[Partisia] IssuedDocument - getCredentials() returns expired credentials
- #123
1 parent abfc334 commit db692a8

3 files changed

Lines changed: 29 additions & 12 deletions

File tree

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -284,14 +284,14 @@ Issued documents provide methods to work with individual credentials:
284284
val issuedDocument = documentManager.getDocumentById("document_id") as? IssuedDocument
285285
requireNotNull(issuedDocument)
286286

287-
// Get the number of valid credentials for the document
288-
val numberOfValidCredentials = issuedDocument.credentialsCount()
287+
// Get the number of credentials (does not filter by temporal validity)
288+
val numberOfCredentials = issuedDocument.credentialsCount()
289289

290290
// Get the initial number of credentials for the document
291291
val initialNumberOfCredentials = issuedDocument.initialCredentialsCount()
292292

293-
// Get a list of all valid credentials for the document
294-
val validCredentials = issuedDocument.getCredentials()
293+
// Get all credentials (does not filter by temporal validity — may include expired credentials)
294+
val credentials = issuedDocument.getCredentials()
295295

296296
// Find an available credential (automatically selects the best one based on policy)
297297
val credential = issuedDocument?.findCredential()
@@ -503,7 +503,8 @@ Documents can be certified to verify their authenticity:
503503
val issuedDocument = documentManager.getDocumentById("document_id") as? IssuedDocument
504504
val isCertified = issuedDocument?.isCertified() == true
505505

506-
// Check if any of the document's key has been invalidated
506+
// Check if any of the document's credentials have been invalidated
507+
// Note: getCredentials() does not filter by temporal validity (validFrom/validUntil)
507508
val invalidatedKeys: Map<String, Boolean> = issuedDocument?.getCredentials()
508509
?.associate { it.alias to it.isInvalidated() }
509510
?: emptyMap()

document-manager/src/main/java/eu/europa/ec/eudi/wallet/document/Document.kt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,12 +63,16 @@ sealed interface Document {
6363
val isKeyInvalidated: Boolean
6464

6565
/**
66-
* Returns the number of valid credentials associated with this document.
66+
* Returns the number of credentials associated with this document that pass structural
67+
* validity checks.
6768
*
68-
* For UnsignedDocument, this counts credentials that can be used for proof of possession.
69-
* For IssuedDocument, this counts valid credentials according to the credential policy.
69+
* For [UnsignedDocument], this counts credentials that can be used for proof of possession.
70+
* For [IssuedDocument], this counts credentials according to the credential policy but
71+
* does **not** filter by temporal validity (`validFrom`/`validUntil`). The count may include
72+
* expired or not-yet-valid credentials. Use [IssuedDocument.findCredential] to check if a
73+
* credential is valid at a specific point in time.
7074
*
71-
* @return The number of valid credentials available for this document
75+
* @return The number of credentials that pass structural validity checks
7276
*/
7377
suspend fun credentialsCount(): Int
7478
}

document-manager/src/main/java/eu/europa/ec/eudi/wallet/document/IssuedDocument.kt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,20 @@ class IssuedDocument(
113113
}
114114

115115
/**
116-
* Retrieves all valid credentials associated with this document.
116+
* Retrieves all credentials associated with this document that pass structural validity checks.
117117
*
118118
* This method filters the document's credentials based on several criteria:
119119
* - Only certified credentials bound to a secure area
120120
* - Only credentials that are not invalidated
121121
* - Only credentials that belong to the current document manager
122122
* - For OneTimeUse policy, only credentials that haven't been used (usageCount == 0)
123-
* - For RotateUse policy, all valid credentials
123+
* - For RotateUse policy, all credentials regardless of usage count
124124
*
125-
* @return A list of valid [SecureAreaBoundCredential] objects
125+
* **Note:** This method does **not** filter by temporal validity (`validFrom`/`validUntil`).
126+
* The returned list may include credentials that are expired or not yet valid.
127+
* Use [findCredential] to obtain a credential that is valid at a specific point in time.
128+
*
129+
* @return A list of [SecureAreaBoundCredential] objects that pass structural validity checks
126130
*/
127131
suspend fun getCredentials(): List<SecureAreaBoundCredential> {
128132
return baseDocument.getCertifiedCredentials()
@@ -169,6 +173,14 @@ class IssuedDocument(
169173
return candidate
170174
}
171175

176+
/**
177+
* Returns the number of credentials that pass structural validity checks.
178+
*
179+
* Delegates to [getCredentials], which does **not** filter by temporal validity.
180+
* This count may include expired or not-yet-valid credentials.
181+
* To check how many credentials are currently usable, filter [getCredentials] by
182+
* `validFrom`/`validUntil` or use [findCredential] to check if at least one is valid.
183+
*/
172184
override suspend fun credentialsCount(): Int {
173185
return getCredentials().size
174186
}

0 commit comments

Comments
 (0)