Skip to content

Commit 27cea72

Browse files
Merge pull request #79 from authlete/feat/nonce_endpoint
feat: Nonce Endpoint
2 parents 01c8183 + 08751ca commit 27cea72

6 files changed

Lines changed: 102 additions & 63 deletions

File tree

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
<properties>
1313
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1414

15-
<authlete.java.common.version>4.22</authlete.java.common.version>
16-
<authlete.java.jaxrs.version>2.86</authlete.java.jaxrs.version>
17-
<authlete.cbor.version>1.18</authlete.cbor.version>
15+
<authlete.java.common.version>4.33</authlete.java.common.version>
16+
<authlete.java.jaxrs.version>2.90</authlete.java.jaxrs.version>
17+
<authlete.cbor.version>1.21</authlete.cbor.version>
1818
<javax.servlet-api.version>3.0.1</javax.servlet-api.version>
1919
<jersey.version>2.34</jersey.version>
2020
<jetty.version>9.4.27.v20200227</jetty.version>
Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 Authlete, Inc.
2+
* Copyright (C) 2023-2025 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.
@@ -19,49 +19,28 @@
1919

2020
import javax.ws.rs.GET;
2121
import javax.ws.rs.Path;
22-
import javax.ws.rs.WebApplicationException;
2322
import javax.ws.rs.core.Response;
2423
import com.authlete.common.api.AuthleteApi;
2524
import com.authlete.common.api.AuthleteApiFactory;
2625
import com.authlete.common.dto.CredentialJwtIssuerMetadataRequest;
27-
import com.authlete.common.dto.CredentialJwtIssuerMetadataResponse;
28-
import com.authlete.jaxrs.server.util.ResponseUtil;
26+
import com.authlete.jaxrs.BaseCredentialJwtIssuerMetadataEndpoint;
2927

3028

3129
@Path("/.well-known/{path : jwt-issuer|jwt-vc-issuer}")
32-
public class CredentialJwtIssuerEndpoint extends AbstractCredentialEndpoint
30+
public class CredentialJwtIssuerEndpoint extends BaseCredentialJwtIssuerMetadataEndpoint
3331
{
3432
@GET
3533
public Response get()
3634
{
37-
final AuthleteApi api = AuthleteApiFactory.getDefaultApi();
35+
// Authlete API interface
36+
AuthleteApi api = AuthleteApiFactory.getDefaultApi();
3837

39-
return metadata(api);
40-
}
41-
42-
43-
private Response metadata(AuthleteApi api) throws WebApplicationException
44-
{
38+
// Request to the Authlete's /api/{service-id}/vci/jwtissuer API
4539
CredentialJwtIssuerMetadataRequest request =
4640
new CredentialJwtIssuerMetadataRequest()
4741
.setPretty(true);
4842

49-
CredentialJwtIssuerMetadataResponse response =
50-
api.credentialJwtIssuerMetadata(request);
51-
52-
String content = response.getResponseContent();
53-
54-
switch (response.getAction())
55-
{
56-
case NOT_FOUND:
57-
return ResponseUtil.notFoundJson(content);
58-
59-
case OK:
60-
return ResponseUtil.okJson(content);
61-
62-
case INTERNAL_SERVER_ERROR:
63-
default:
64-
return ResponseUtil.internalServerError(content);
65-
}
43+
// Process the request.
44+
return handle(api, request);
6645
}
6746
}
Lines changed: 9 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2023 Authlete, Inc.
2+
* Copyright (C) 2023-2025 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.
@@ -19,50 +19,28 @@
1919

2020
import javax.ws.rs.GET;
2121
import javax.ws.rs.Path;
22-
import javax.ws.rs.WebApplicationException;
2322
import javax.ws.rs.core.Response;
2423
import com.authlete.common.api.AuthleteApi;
2524
import com.authlete.common.api.AuthleteApiFactory;
2625
import com.authlete.common.dto.CredentialIssuerMetadataRequest;
27-
import com.authlete.common.dto.CredentialIssuerMetadataResponse;
28-
import com.authlete.jaxrs.server.util.ExceptionUtil;
29-
import com.authlete.jaxrs.server.util.ResponseUtil;
26+
import com.authlete.jaxrs.BaseCredentialIssuerMetadataEndpoint;
3027

3128

3229
@Path("/.well-known/openid-credential-issuer")
33-
public class CredentialMetadataEndpoint extends AbstractCredentialEndpoint
30+
public class CredentialMetadataEndpoint extends BaseCredentialIssuerMetadataEndpoint
3431
{
3532
@GET
3633
public Response get()
3734
{
38-
final AuthleteApi api = AuthleteApiFactory.getDefaultApi();
35+
// Authlete API interface
36+
AuthleteApi api = AuthleteApiFactory.getDefaultApi();
3937

40-
return metadata(api);
41-
}
42-
43-
44-
private Response metadata(final AuthleteApi api)
45-
throws WebApplicationException
46-
{
47-
final CredentialIssuerMetadataRequest request =
38+
// Request to the Authlete's /api/{service-id}/vci/metadata API
39+
CredentialIssuerMetadataRequest request =
4840
new CredentialIssuerMetadataRequest()
4941
.setPretty(true);
5042

51-
final CredentialIssuerMetadataResponse response =
52-
api.credentialIssuerMetadata(request);
53-
final String content = response.getResponseContent();
54-
55-
switch (response.getAction())
56-
{
57-
case NOT_FOUND:
58-
return ResponseUtil.notFoundJson(content);
59-
60-
case OK:
61-
return ResponseUtil.okJson(response.getResponseContent());
62-
63-
case INTERNAL_SERVER_ERROR:
64-
default:
65-
throw ExceptionUtil.internalServerErrorExceptionJson(content);
66-
}
43+
// Process the request.
44+
return handle(api, request);
6745
}
6846
}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/*
2+
* Copyright (C) 2025 Authlete, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing,
11+
* software distributed under the License is distributed on an
12+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
13+
* either express or implied. See the License for the specific
14+
* language governing permissions and limitations under the
15+
* License.
16+
*/
17+
package com.authlete.jaxrs.server.api.vci;
18+
19+
20+
import javax.ws.rs.POST;
21+
import javax.ws.rs.Path;
22+
import javax.ws.rs.core.Response;
23+
import com.authlete.common.api.AuthleteApi;
24+
import com.authlete.common.api.AuthleteApiFactory;
25+
import com.authlete.common.dto.CredentialNonceRequest;
26+
import com.authlete.jaxrs.BaseCredentialNonceEndpoint;
27+
28+
29+
/**
30+
* An implementation of the nonce endpoint defined in the <a href=
31+
* "https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html"
32+
* >OpenID for Verifiable Credential Issuance 1&#x2E;0</a> specification.
33+
*
34+
* @see <a href="https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html">
35+
* OpenID for Verifiable Credential Issuance 1.0</a>
36+
*/
37+
@Path("/api/nonce")
38+
public class CredentialNonceEndpoint extends BaseCredentialNonceEndpoint
39+
{
40+
/**
41+
* The nonce endpoint.
42+
*
43+
* <p>
44+
* From <a href=
45+
* "https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html#section-7.1"
46+
* >Section 7.1. Nonce Request</a> of <a href=
47+
* "https://openid.net/specs/openid-4-verifiable-credential-issuance-1_0.html"
48+
* >OpenID for Verifiable Credential Issuance 1.0</a>:
49+
* </p>
50+
*
51+
* <blockquote>
52+
* <p>
53+
* A request for a nonce is made by sending an HTTP POST request to the URL
54+
* provided in the {@code nonce_endpoint} Credential Issuer Metadata parameter.
55+
* The Nonce Endpoint is not a protected resource, meaning the Wallet does
56+
* not need to supply an access token to access it.
57+
* </p>
58+
* </blockquote>
59+
*
60+
* @return
61+
* A response from the nonce endpoint.
62+
*/
63+
@POST
64+
public Response post()
65+
{
66+
// Authlete API interface
67+
AuthleteApi api = AuthleteApiFactory.getDefaultApi();
68+
69+
// Request to the Authlete's /api/{service-id}/vci/nonce API
70+
CredentialNonceRequest request =
71+
new CredentialNonceRequest()
72+
.setPretty(true);
73+
74+
// Process the request.
75+
return handle(api, request);
76+
}
77+
}

src/main/webapp/WEB-INF/web.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
com.authlete.jaxrs.server.api.vci.BatchCredentialEndpoint,
4141
com.authlete.jaxrs.server.api.vci.CredentialEndpoint,
4242
com.authlete.jaxrs.server.api.vci.CredentialMetadataEndpoint,
43+
com.authlete.jaxrs.server.api.vci.CredentialNonceEndpoint,
4344
com.authlete.jaxrs.server.api.vci.CredentialJwtIssuerEndpoint,
4445
com.authlete.jaxrs.server.api.vci.DeferredCredentialEndpoint,
4546
com.authlete.jaxrs.server.api.vci.CredentialOfferEndpoint,

src/main/webapp/index.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@
7979
<td valign="top">JWT VC Issuer Metadata Endpoint</td>
8080
<td><a href="/.well-known/jwt-vc-issuer">/.well-known/jwt-vc-issuer</a></td>
8181
</tr>
82+
<tr>
83+
<td valign="top">Credential Issuer Nonce Endpoint</td>
84+
<td>/api/nonce</td>
85+
</tr>
8286
</tbody>
8387
</table>
8488

0 commit comments

Comments
 (0)