Skip to content

Commit

Permalink
Legg til fullmakt som initierbart frå app... mangler støtte i issuer?
Browse files Browse the repository at this point in the history
  • Loading branch information
shoyheim-dd committed Oct 14, 2024
1 parent bcb7a53 commit 4958ded
Show file tree
Hide file tree
Showing 5 changed files with 90 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ fun DocumentIdentifier.toUiName(resourceProvider: ResourceProvider): String {
is DocumentIdentifier.AGE -> resourceProvider.getString(R.string.age_verification)
is DocumentIdentifier.SAMPLE -> resourceProvider.getString(R.string.load_sample_data)
is DocumentIdentifier.PHOTOID -> resourceProvider.getString(R.string.photo_id)
is DocumentIdentifier.AUTHORIZATION -> resourceProvider.getString(R.string.authorization)
is DocumentIdentifier.OTHER -> docType
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ object TestsData {
const val mockedAgeVerificationNameSpace = "eu.europa.ec.eudi.pseudonym.age_over_18.1"
const val mockedPhotoIdDocType = "org.iso.23220.2.photoid.1"
const val mockedPhotoIdNameSpace = "org.iso.23220.2.photoid.1"
const val mockedAuthorizationDocType = "no.digdir.eudiw.fullmakt.1"
const val mockedAuthorizationNameSpace = "no.digdir.eudiw.fullmakt.1"
const val mockedAuthorizationId = "000005"

const val mockedUriPath1 = "eudi-wallet://example.com/path1"
const val mockedUriPath2 = "eudi-wallet://example.com/path2"
Expand Down Expand Up @@ -245,6 +248,41 @@ object TestsData {
readerAuth = mockedValidReaderAuth
)

val mockedAuthorizationWithBasicFieldsDocRequest = DocRequest(
docType = mockedAuthorizationDocType,
requestItems = listOf(
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmektig_etternavn"
),
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmaktsgiver"
),
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmektig_rettigheter",
),
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmektig",
),
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmektig_fornavn",
),
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmaktsgiver_fornavn",
),
DocItem(
namespace = mockedAuthorizationNameSpace,
elementIdentifier = "fullmaktsgiver_etternavn",
)
),
readerAuth = mockedValidReaderAuth
)

val mockedValidPidWithBasicFieldsRequestDocument = RequestDocument(
documentId = mockedPidId,
docType = mockedPidDocType,
Expand Down Expand Up @@ -614,6 +652,12 @@ object TestsData {
value = testFieldUi.value
)

is DocumentIdentifier.AUTHORIZATION -> mockCreateOptionalFieldForAuthorization(
docId = transformedRequestDataUi.documentId,
elementIdentifier = testFieldUi.elementIdentifier,
value = testFieldUi.value
)

is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> throw NotSupportedDocumentTypeException
}

Expand Down Expand Up @@ -689,6 +733,25 @@ object TestsData {
)
}

private fun mockCreateOptionalFieldForAuthorization(
docId: String,
elementIdentifier: String,
value: String,
checked: Boolean = true,
enabled: Boolean = true,
): RequestDataUi.OptionalField<Event> {
val uniqueId = mockedPhotoIdDocType + elementIdentifier + docId
return mockCreateOptionalField(
documentIdentifierUi = DocumentIdentifier.PHOTOID,
uniqueId = uniqueId,
elementIdentifier = elementIdentifier,
value = value,
checked = checked,
enabled = enabled,
event = Event.UserIdentificationClicked(itemId = uniqueId)
)
}

private fun mockCreateOptionalFieldForMdl(
docId: String,
elementIdentifier: String,
Expand Down Expand Up @@ -795,6 +858,13 @@ object TestsData {
docRequest = mockedPhotoIdWithBasicFieldsDocRequest
}

is DocumentIdentifier.AUTHORIZATION -> {
namespace = mockedAuthorizationNameSpace
docId = mockedAuthorizationId
docType = mockedAuthorizationDocType
docRequest = mockedAuthorizationWithBasicFieldsDocRequest
}

is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> throw NotSupportedDocumentTypeException
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,13 @@ sealed interface DocumentIdentifier {
get() = "org.iso.23220.2.photoid.1"
}

data object AUTHORIZATION : DocumentIdentifier {
override val nameSpace: String
get() = "no.digdir.eudiw.fullmakt.1"
override val docType: DocType
get() = "no.digdir.eudiw.fullmakt.1"
}

data class OTHER(
override val nameSpace: String,
override val docType: DocType,
Expand All @@ -69,7 +76,7 @@ sealed interface DocumentIdentifier {

fun DocumentIdentifier.isSupported(): Boolean {
return when (this) {
is DocumentIdentifier.PID, DocumentIdentifier.MDL, DocumentIdentifier.AGE, DocumentIdentifier.PHOTOID -> true
is DocumentIdentifier.PID, DocumentIdentifier.MDL, DocumentIdentifier.AGE, DocumentIdentifier.PHOTOID, DocumentIdentifier.AUTHORIZATION -> true
is DocumentIdentifier.SAMPLE, is DocumentIdentifier.OTHER -> false
}
}
Expand All @@ -84,6 +91,7 @@ fun DocType.toDocumentIdentifier(): DocumentIdentifier = when (this) {
DocumentIdentifier.SAMPLE.docType -> DocumentIdentifier.SAMPLE
DocumentIdentifier.AGE.docType -> DocumentIdentifier.AGE
DocumentIdentifier.PHOTOID.docType -> DocumentIdentifier.PHOTOID
DocumentIdentifier.AUTHORIZATION.docType -> DocumentIdentifier.AUTHORIZATION
else -> DocumentIdentifier.OTHER(
nameSpace = this,
docType = this
Expand Down Expand Up @@ -121,6 +129,9 @@ private fun createDocumentIdentifier(nameSpace: String, docType: DocType): Docum
nameSpace == DocumentIdentifier.PHOTOID.nameSpace
&& docType == DocumentIdentifier.PHOTOID.docType -> DocumentIdentifier.PHOTOID

nameSpace == DocumentIdentifier.AUTHORIZATION.nameSpace
&& docType == DocumentIdentifier.AUTHORIZATION.docType -> DocumentIdentifier.AUTHORIZATION

else -> DocumentIdentifier.OTHER(
nameSpace = nameSpace,
docType = docType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ class AddDocumentInteractorImpl(
icon = AppIcons.Id,
type = DocumentIdentifier.PHOTOID,
available = canCreateExtraDocument(flowType)
),
DocumentOptionItemUi(
text = DocumentIdentifier.AUTHORIZATION.toUiName(resourceProvider),
icon = AppIcons.Id,
type = DocumentIdentifier.AUTHORIZATION,
available = canCreateExtraDocument(flowType)
)
)
if (flowType == IssuanceFlowUiConfig.NO_DOCUMENT) {
Expand Down
1 change: 1 addition & 0 deletions resources-logic/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
<string name="age_verification">Age Verification</string>
<string name="load_sample_data">Load Sample Documents</string>
<string name="photo_id">Photo ID</string>
<string name="authorization">Fullmakt</string>

<!-- Biometric prompt -->
<string name="biometric_prompt_title">Biometric authentication</string>
Expand Down

0 comments on commit 4958ded

Please sign in to comment.