|
| 1 | +/* |
| 2 | + * Copyright (C) 2026 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.attestation; |
| 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.AttestationChallengeRequest; |
| 26 | +import com.authlete.jaxrs.BaseAttestationChallengeEndpoint; |
| 27 | + |
| 28 | + |
| 29 | +/** |
| 30 | + * An implementation of the challenge endpoint defined in the <a href= |
| 31 | + * "https://datatracker.ietf.org/doc/draft-ietf-oauth-attestation-based-client-auth/" |
| 32 | + * >OAuth 2.0 Attestation-Based Client Authentication</a>. |
| 33 | + * |
| 34 | + * @see <a href="https://datatracker.ietf.org/doc/draft-ietf-oauth-attestation-based-client-auth/"> |
| 35 | + * OAuth 2.0 Attestation-Based Client Authentication</a> |
| 36 | + */ |
| 37 | +@Path("/api/challenge") |
| 38 | +public class AttestationChallengeEndpoint extends BaseAttestationChallengeEndpoint |
| 39 | +{ |
| 40 | + /** |
| 41 | + * The challenge endpoint. |
| 42 | + * |
| 43 | + * <p> |
| 44 | + * From <a href= |
| 45 | + * "https://datatracker.ietf.org/doc/draft-ietf-oauth-attestation-based-client-auth/" |
| 46 | + * >OAuth 2.0 Attestation-Based Client Authentication</a>: |
| 47 | + * </p> |
| 48 | + * |
| 49 | + * <blockquote> |
| 50 | + * <p> |
| 51 | + * A request for a Challenge is made by sending an HTTP POST request to the URL |
| 52 | + * provided in the {@code challenge_endpoint} of the Authorization Serve metadata. |
| 53 | + * </p> |
| 54 | + * </blockquote> |
| 55 | + * |
| 56 | + * @return |
| 57 | + * A response from the challenge endpoint. |
| 58 | + */ |
| 59 | + @POST |
| 60 | + public Response post() |
| 61 | + { |
| 62 | + // Authlete API interface |
| 63 | + AuthleteApi api = AuthleteApiFactory.getDefaultApi(); |
| 64 | + |
| 65 | + // Request to the Authlete's /api/{service-id}/attestation/challenge API |
| 66 | + AttestationChallengeRequest request = |
| 67 | + new AttestationChallengeRequest() |
| 68 | + .setPretty(true); |
| 69 | + |
| 70 | + // Process the request. |
| 71 | + return handle(api, request); |
| 72 | + } |
| 73 | +} |
0 commit comments