Skip to content

Commit b0da045

Browse files
committed
Fixes
1 parent 78fb489 commit b0da045

File tree

5 files changed

+84
-13
lines changed

5 files changed

+84
-13
lines changed

src/main/java/com/authlete/jaxrs/server/api/vci/AbstractCredentialEndpoint.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,7 @@ private String processAccessToken(final HttpServletRequest request)
5252
// The value of the "Authorization" header.
5353
final String authorization = request.getHeader(HttpHeaders.AUTHORIZATION);
5454

55-
// If an access token have been set
56-
final String accessToken = request.getParameter("access_token");
57-
58-
return super.extractAccessToken(authorization, accessToken);
55+
return super.extractAccessToken(authorization, null);
5956
}
6057

6158

src/main/java/com/authlete/jaxrs/server/api/vci/CredentialEndpoint.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ public Response post(@Context HttpServletRequest request,
6161

6262
final CredentialIssuanceOrder order =
6363
CredentialUtil.toOrder(introspection, credential);
64+
if(order == null)
65+
{
66+
return ExceptionUtil.badRequest(String.format("Unsupported credential format %s.", formatId));
67+
}
6468

6569
// Issue
6670
return credentialIssue(api, order, accessToken);

src/main/java/com/authlete/jaxrs/server/api/vci/JWKSetMetadataEndpoint.java renamed to src/main/java/com/authlete/jaxrs/server/api/vci/CredentialJWKSetEndpoint.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929
import com.authlete.jaxrs.server.util.ResponseUtil;
3030

3131

32-
@Path("/.well-known/jwks.json")
33-
public class JWKSetMetadataEndpoint extends AbstractCredentialEndpoint
32+
@Path("/api/vci/jwks")
33+
public class CredentialJWKSetEndpoint extends AbstractCredentialEndpoint
3434
{
3535
@GET
3636
public Response get()
3737
{
3838
final AuthleteApi api = AuthleteApiFactory.getDefaultApi();
3939

40-
return metadata(api);
40+
return process(api);
4141
}
4242

4343

44-
private Response metadata(final AuthleteApi api)
44+
private Response process(final AuthleteApi api)
4545
throws WebApplicationException
4646
{
4747
final CredentialIssuerJwksRequest request =

src/main/java/com/authlete/jaxrs/server/api/vci/DeferredCredentialEndpoint.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import com.authlete.jaxrs.server.util.ResponseUtil;
4040

4141

42-
@Path("/api/credential_deferred")
42+
@Path("/api/deferred_credential")
4343
public class DeferredCredentialEndpoint extends AbstractCredentialEndpoint
4444
{
4545
@POST
@@ -64,7 +64,7 @@ public Response post(@Context HttpServletRequest request,
6464

6565
if (order.isIssuanceDeferred())
6666
{
67-
return ResponseUtil.badRequest("Issuance not ready yet.");
67+
return ResponseUtil.badRequestJson("{\"error\": \"issuance_pending\"");
6868
}
6969

7070
// Issue
@@ -110,10 +110,10 @@ private CredentialRequestInfo credentialDeferredParse(final AuthleteApi api,
110110
private Response credentialIssue(final AuthleteApi api,
111111
final CredentialIssuanceOrder order)
112112
{
113-
final CredentialDeferredIssueRequest credentialSingleIssueRequest = new CredentialDeferredIssueRequest()
113+
final CredentialDeferredIssueRequest request = new CredentialDeferredIssueRequest()
114114
.setOrder(order);
115115

116-
final CredentialDeferredIssueResponse response = api.credentialDeferredIssue(credentialSingleIssueRequest);
116+
final CredentialDeferredIssueResponse response = api.credentialDeferredIssue(request);
117117
final String content = response.getResponseContent();
118118

119119
switch (response.getAction())
@@ -125,7 +125,7 @@ private Response credentialIssue(final AuthleteApi api,
125125
return ResponseUtil.forbiddenJson(content);
126126

127127
case OK:
128-
return ResponseUtil.ok(content);
128+
return ResponseUtil.okJson(content);
129129

130130
case INTERNAL_SERVER_ERROR:
131131
default:
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Copyright (C) 2023 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.GET;
21+
import javax.ws.rs.Path;
22+
import javax.ws.rs.WebApplicationException;
23+
import javax.ws.rs.core.Response;
24+
import com.authlete.common.api.AuthleteApi;
25+
import com.authlete.common.api.AuthleteApiFactory;
26+
import com.authlete.common.dto.CredentialIssuerJwksRequest;
27+
import com.authlete.common.dto.CredentialIssuerJwksResponse;
28+
import com.authlete.common.dto.CredentialJwtIssuerMetadataRequest;
29+
import com.authlete.common.dto.CredentialJwtIssuerMetadataResponse;
30+
import com.authlete.jaxrs.server.util.ExceptionUtil;
31+
import com.authlete.jaxrs.server.util.ResponseUtil;
32+
33+
34+
@Path("/.well-known/jwt-issuer")
35+
public class JWTIssuerMetadataEndpoint extends AbstractCredentialEndpoint
36+
{
37+
@GET
38+
public Response get()
39+
{
40+
final AuthleteApi api = AuthleteApiFactory.getDefaultApi();
41+
42+
return metadata(api);
43+
}
44+
45+
46+
private Response metadata(final AuthleteApi api)
47+
throws WebApplicationException
48+
{
49+
final CredentialJwtIssuerMetadataRequest request =
50+
new CredentialJwtIssuerMetadataRequest()
51+
.setPretty(false);
52+
53+
final CredentialJwtIssuerMetadataResponse response =
54+
api.credentialJwtIssuerMetadata(request);
55+
final String content = response.getResponseContent();
56+
57+
switch (response.getAction())
58+
{
59+
case NOT_FOUND:
60+
return ResponseUtil.notFoundJson(content);
61+
62+
case OK:
63+
return ResponseUtil.okJson(content);
64+
65+
case INTERNAL_SERVER_ERROR:
66+
default:
67+
throw ExceptionUtil.internalServerErrorExceptionJson(content);
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)