Skip to content

Commit 6e8b6c2

Browse files
Merge pull request #61 from authlete/misc/potential_interop_event_track2
[misc] POTENTIAL Interop Event Track 2
2 parents 3060a0d + dfb77aa commit 6e8b6c2

File tree

4 files changed

+101
-10
lines changed

4 files changed

+101
-10
lines changed

src/main/java/com/authlete/jaxrs/server/db/UserDao.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,19 +66,43 @@ public class UserDao
6666

6767
new UserEntity("1004", "inga", "inga", "Inga Silverstone", "inga@example.com",
6868
new Address()
69+
.setFormatted("114 Old State Hwy 127, Shoshone, CA 92384, USA")
6970
.setCountry("USA")
7071
.setLocality("Shoshone")
71-
.setStreetAddress("114 0ld State Hwy 127")
72+
.setStreetAddress("114 Old State Hwy 127")
7273
.setPostaCode("CA 92384"),
7374
null, null, "Inga", "Silverstone", null, null,
7475
"https://example.com/inga/profile", "https://example.com/inga/me.jpg",
7576
"https://example.com/inga/", "female", "America/Toronto", "en-US",
7677
"inga", "1991-11-06", toDate("2022-04-30"))
7778
.setAttribute(MDLConstants.DOC_TYPE_MDL, createMDLData1004())
79+
80+
// POTENTIAL Interop Event Track 2
81+
// https://gitlab.opencode.de/potential/interop-event
82+
.addExtraClaim("age_equal_or_over", mapOf("18", Boolean.TRUE))
83+
.addExtraClaim("place_of_birth", mapOf("locality", "Shoshone"))
84+
.addExtraClaim("issuing_authority", "US")
85+
.addExtraClaim("issuing_country", "US")
7886
);
7987
};
8088

8189

90+
/**
91+
* A substitute for {@code Map.of}, which is unavailable in Java 8.
92+
*/
93+
private static Map<String, Object> mapOf(Object... keyValuePairs)
94+
{
95+
Map<String, Object> map = new LinkedHashMap<>();
96+
97+
for (int i = 0; i < keyValuePairs.length; i += 2)
98+
{
99+
map.put((String)keyValuePairs[i], keyValuePairs[i+1]);
100+
}
101+
102+
return map;
103+
}
104+
105+
82106
private static Map<String, Object> createMDLData1004()
83107
{
84108
// Some string claim values in the data below have the prefix "cbor:".

src/main/java/com/authlete/jaxrs/server/db/UserEntity.java

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2016-2022 Authlete, Inc.
2+
* Copyright (C) 2016-2024 Authlete, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,7 +36,7 @@
3636
*/
3737
public class UserEntity implements User, Serializable
3838
{
39-
private static final long serialVersionUID = 1L;
39+
private static final long serialVersionUID = 2L;
4040

4141

4242
/**
@@ -112,6 +112,10 @@ public class UserEntity implements User, Serializable
112112
private Map<String, Object> attributes = new HashMap<>();
113113

114114

115+
// Extra claims
116+
private Map<String, Object> extraClaims = new HashMap<>();
117+
118+
115119
/**
116120
* Constructor with initial values.
117121
*/
@@ -356,9 +360,16 @@ public Object getClaim(String claimName, String languageTag)
356360
return nationalities;
357361

358362
default:
359-
// Unsupported claim.
360-
return null;
363+
break;
364+
}
365+
366+
if (extraClaims.containsKey(claimName))
367+
{
368+
return extraClaims.get(claimName);
361369
}
370+
371+
// Unsupported claim.
372+
return null;
362373
}
363374

364375

@@ -390,6 +401,14 @@ public UserEntity setAttribute(String attributeName, Object attributeValue)
390401
}
391402

392403

404+
public UserEntity addExtraClaim(String claimName, Object claimValue)
405+
{
406+
extraClaims.put(claimName, claimValue);
407+
408+
return this;
409+
}
410+
411+
393412
public List<String> getNationalities()
394413
{
395414
return nationalities;

src/main/java/com/authlete/jaxrs/server/vc/SdJwtOrderProcessor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 Authlete, Inc.
2+
* Copyright (C) 2023-2024 Authlete, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -154,7 +154,7 @@ protected Map<String, Object> collectClaims(
154154
// "sub"
155155
claims.put(KEY_SUB, user.getSubject());
156156

157-
// The CredentialDefinitionType has a set of claims.
157+
// The VerifiableCredentialType has a set of claims.
158158
// For each claim in the set.
159159
for (String claimName : vct.getClaims())
160160
{

src/main/java/com/authlete/jaxrs/server/vc/VerifiableCredentialType.java

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 Authlete, Inc.
2+
* Copyright (C) 2023-2024 Authlete, Inc.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -29,12 +29,60 @@ public enum VerifiableCredentialType
2929
{
3030
IDENTITY_CREDENTIAL(
3131
"https://credentials.example.com/identity_credential",
32-
new String[]{
32+
new String[] {
3333
StandardClaims.GIVEN_NAME,
3434
StandardClaims.FAMILY_NAME,
3535
StandardClaims.BIRTHDATE
3636
}
37-
);
37+
),
38+
39+
/**
40+
* The vct used in the <a href="https://www.digital-identity-wallet.eu/"
41+
* >POTENTIAL</a> Interop Event Track 2.
42+
*
43+
* <blockquote>
44+
* <table border="1" cellpadding="5" style="border-collapse: collapse;">
45+
* <tr bgcolor="orange">
46+
* <th>vct</th>
47+
* <th>claims</th>
48+
* </tr>
49+
* <tr>
50+
* <td style="vertical-align: top;">
51+
* <code>urn:eu.europa.ec.eudi:pid:1</code>
52+
* </td>
53+
* <td style="vertical-align: top;">
54+
* <ul>
55+
* <li><code>family_name</code>
56+
* <li><code>given_name</code>
57+
* <li><code>birthdate</code>
58+
* <li><code>age_equal_or_over/18</code>
59+
* <li><code>place_of_birth/locality</code>
60+
* <li><code>address/formatted</code>
61+
* <li><code>issuing_authority</code>
62+
* <li><code>issuing_country</code>
63+
* </ul>
64+
* </td>
65+
* </tr>
66+
* </table>
67+
* </blockquote>
68+
*
69+
* @see <a href="https://gitlab.opencode.de/potential/interop-event/-/tree/master/track2/description"
70+
* >POTENTIAL Interop Event Track 2 / description</a>
71+
*/
72+
EUDI_PID_1(
73+
"urn:eu.europa.ec.eudi:pid:1",
74+
new String[] {
75+
StandardClaims.FAMILY_NAME,
76+
StandardClaims.GIVEN_NAME,
77+
StandardClaims.BIRTHDATE,
78+
"age_equal_or_over",
79+
"place_of_birth",
80+
StandardClaims.ADDRESS,
81+
"issuing_authority",
82+
"issuing_country",
83+
}
84+
),
85+
;
3886

3987

4088
private final String id;

0 commit comments

Comments
 (0)