Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/main/java/com/authlete/jaxrs/server/db/UserDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,43 @@ public class UserDao

new UserEntity("1004", "inga", "inga", "Inga Silverstone", "inga@example.com",
new Address()
.setFormatted("114 Old State Hwy 127, Shoshone, CA 92384, USA")
.setCountry("USA")
.setLocality("Shoshone")
.setStreetAddress("114 0ld State Hwy 127")
.setStreetAddress("114 Old State Hwy 127")
.setPostaCode("CA 92384"),
null, null, "Inga", "Silverstone", null, null,
"https://example.com/inga/profile", "https://example.com/inga/me.jpg",
"https://example.com/inga/", "female", "America/Toronto", "en-US",
"inga", "1991-11-06", toDate("2022-04-30"))
.setAttribute(MDLConstants.DOC_TYPE_MDL, createMDLData1004())

// POTENTIAL Interop Event Track 2
// https://gitlab.opencode.de/potential/interop-event
.addExtraClaim("age_equal_or_over", mapOf("18", Boolean.TRUE))
.addExtraClaim("place_of_birth", mapOf("locality", "Shoshone"))
.addExtraClaim("issuing_authority", "US")
.addExtraClaim("issuing_country", "US")
);
};


/**
* A substitute for {@code Map.of}, which is unavailable in Java 8.
*/
private static Map<String, Object> mapOf(Object... keyValuePairs)
{
Map<String, Object> map = new LinkedHashMap<>();

for (int i = 0; i < keyValuePairs.length; i += 2)
{
map.put((String)keyValuePairs[i], keyValuePairs[i+1]);
}

return map;
}


private static Map<String, Object> createMDLData1004()
{
// Some string claim values in the data below have the prefix "cbor:".
Expand Down
27 changes: 23 additions & 4 deletions src/main/java/com/authlete/jaxrs/server/db/UserEntity.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2016-2022 Authlete, Inc.
* Copyright (C) 2016-2024 Authlete, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -36,7 +36,7 @@
*/
public class UserEntity implements User, Serializable
{
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = 2L;


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


// Extra claims
private Map<String, Object> extraClaims = new HashMap<>();


/**
* Constructor with initial values.
*/
Expand Down Expand Up @@ -356,9 +360,16 @@ public Object getClaim(String claimName, String languageTag)
return nationalities;

default:
// Unsupported claim.
return null;
break;
}

if (extraClaims.containsKey(claimName))
{
return extraClaims.get(claimName);
}

// Unsupported claim.
return null;
}


Expand Down Expand Up @@ -390,6 +401,14 @@ public UserEntity setAttribute(String attributeName, Object attributeValue)
}


public UserEntity addExtraClaim(String claimName, Object claimValue)
{
extraClaims.put(claimName, claimValue);

return this;
}


public List<String> getNationalities()
{
return nationalities;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Authlete, Inc.
* Copyright (C) 2023-2024 Authlete, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -154,7 +154,7 @@ protected Map<String, Object> collectClaims(
// "sub"
claims.put(KEY_SUB, user.getSubject());

// The CredentialDefinitionType has a set of claims.
// The VerifiableCredentialType has a set of claims.
// For each claim in the set.
for (String claimName : vct.getClaims())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2023 Authlete, Inc.
* Copyright (C) 2023-2024 Authlete, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -29,12 +29,60 @@ public enum VerifiableCredentialType
{
IDENTITY_CREDENTIAL(
"https://credentials.example.com/identity_credential",
new String[]{
new String[] {
StandardClaims.GIVEN_NAME,
StandardClaims.FAMILY_NAME,
StandardClaims.BIRTHDATE
}
);
),

/**
* The vct used in the <a href="https://www.digital-identity-wallet.eu/"
* >POTENTIAL</a> Interop Event Track 2.
*
* <blockquote>
* <table border="1" cellpadding="5" style="border-collapse: collapse;">
* <tr bgcolor="orange">
* <th>vct</th>
* <th>claims</th>
* </tr>
* <tr>
* <td style="vertical-align: top;">
* <code>urn:eu.europa.ec.eudi:pid:1</code>
* </td>
* <td style="vertical-align: top;">
* <ul>
* <li><code>family_name</code>
* <li><code>given_name</code>
* <li><code>birthdate</code>
* <li><code>age_equal_or_over/18</code>
* <li><code>place_of_birth/locality</code>
* <li><code>address/formatted</code>
* <li><code>issuing_authority</code>
* <li><code>issuing_country</code>
* </ul>
* </td>
* </tr>
* </table>
* </blockquote>
*
* @see <a href="https://gitlab.opencode.de/potential/interop-event/-/tree/master/track2/description"
* >POTENTIAL Interop Event Track 2 / description</a>
*/
EUDI_PID_1(
"urn:eu.europa.ec.eudi:pid:1",
new String[] {
StandardClaims.FAMILY_NAME,
StandardClaims.GIVEN_NAME,
StandardClaims.BIRTHDATE,
"age_equal_or_over",
"place_of_birth",
StandardClaims.ADDRESS,
"issuing_authority",
"issuing_country",
}
),
;


private final String id;
Expand Down