├── mvn-config └── spotbugs │ ├── spotbugs-exclude.xml │ └── spotbugs-include.xml ├── .gitignore ├── src ├── main │ ├── java │ │ └── com │ │ │ └── authlete │ │ │ └── common │ │ │ ├── util │ │ │ ├── package-info.java │ │ │ ├── BaseJsonSerializer.java │ │ │ ├── PropertiesWrapper.java │ │ │ ├── JoseUtils.java │ │ │ ├── security │ │ │ │ ├── Utils.java │ │ │ │ └── StandardCipherTransformations.java │ │ │ └── BaseJsonDeserializer.java │ │ │ ├── web │ │ │ ├── package-info.java │ │ │ └── DpopToken.java │ │ │ ├── types │ │ │ ├── package-info.java │ │ │ ├── HashAlg.java │ │ │ ├── TokenStatus.java │ │ │ ├── ClientClaims.java │ │ │ ├── HokMethod.java │ │ │ ├── Plan.java │ │ │ ├── AssertionTarget.java │ │ │ ├── ClaimRuleOperation.java │ │ │ ├── EnumHelper.java │ │ │ ├── User.java │ │ │ ├── CodeChallengeMethod.java │ │ │ └── Sns.java │ │ │ ├── dto │ │ │ ├── package-info.java │ │ │ ├── TokenCreateBatchResponse.java │ │ │ ├── TokenRevokeResponse.java │ │ │ ├── TokenCreateBatchStatusResponse.java │ │ │ ├── TokenCreateBatchStatusRequest.java │ │ │ ├── AuthorizationTicketInfo.java │ │ │ ├── AuthorizedClientListResponse.java │ │ │ ├── AuthzDetailsSerializer.java │ │ │ ├── AuthorizationTicketInfoRequest.java │ │ │ ├── ClientLockFlagUpdateRequest.java │ │ │ ├── ClientSecretRefreshResponse.java │ │ │ ├── ClientSecretUpdateResponse.java │ │ │ ├── AuthzDetailsDeserializer.java │ │ │ ├── CredentialIssuerJwksRequest.java │ │ │ ├── CredentialNonceRequest.java │ │ │ ├── BackchannelAuthenticationIssueRequest.java │ │ │ ├── CredentialIssuerMetadataRequest.java │ │ │ ├── NamedUri.java │ │ │ ├── GrantSerializer.java │ │ │ ├── AuthzDetailsElementSerializer.java │ │ │ ├── NativeSsoLogoutRequest.java │ │ │ ├── TaggedValue.java │ │ │ ├── CredentialOfferInfoRequest.java │ │ │ ├── HskListResponse.java │ │ │ ├── AuthorizationTicketUpdateRequest.java │ │ │ ├── SnsCredentials.java │ │ │ ├── HskResponse.java │ │ │ ├── AuthzDetailsElementDeserializer.java │ │ │ ├── Pair.java │ │ │ ├── ClientAuthorizationDeleteRequest.java │ │ │ ├── GrantDeserializer.java │ │ │ ├── TrustAnchor.java │ │ │ ├── StringArray.java │ │ │ ├── CredentialJwtIssuerMetadataRequest.java │ │ │ ├── ApiResponse.java │ │ │ ├── CredentialDeferredIssueRequest.java │ │ │ ├── AuthorizationTicketInfoResponse.java │ │ │ ├── AuthorizationTicketUpdateResponse.java │ │ │ ├── GrantScope.java │ │ │ ├── ClaimRule.java │ │ │ ├── CredentialOfferCreateResponse.java │ │ │ ├── ServiceCreatableResponse.java │ │ │ ├── CredentialOfferInfoResponse.java │ │ │ ├── CredentialSingleParseRequest.java │ │ │ ├── CredentialBatchParseRequest.java │ │ │ ├── CredentialSingleIssueRequest.java │ │ │ └── ClientSecretUpdateRequest.java │ │ │ ├── api │ │ │ ├── package-info.java │ │ │ ├── Options.java │ │ │ └── ConnectionContext.java │ │ │ ├── conf │ │ │ ├── package-info.java │ │ │ ├── AuthleteApiVersion.java │ │ │ └── AuthleteConfiguration.java │ │ │ ├── package-info.java │ │ │ └── assurance │ │ │ ├── constraint │ │ │ ├── ConstraintException.java │ │ │ ├── Constraint.java │ │ │ └── Helper.java │ │ │ ├── IdentityAssuranceException.java │ │ │ ├── EvidenceArray.java │ │ │ └── Claims.java │ └── resources │ │ └── dataset-extractor-messages.properties └── test │ └── java │ └── com │ └── authlete │ └── common │ ├── dto │ └── DtoTest.java │ └── types │ └── ResponseModeTest.java ├── HOW-TO-RELEASE.md └── bin └── authlete-cli.sh /mvn-config/spotbugs/spotbugs-exclude.xml: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | authlete.properties 3 | .settings 4 | .project 5 | .classpath 6 | .DS_Store 7 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utility classes. 3 | */ 4 | package com.authlete.common.util; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/web/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Utility classes related to Web. 3 | */ 4 | package com.authlete.common.web; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Enum definitions and lists of pre-defined constants. 3 | */ 4 | package com.authlete.common.types; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Requests to and responses from Authlete APIs and some data structures. 3 | */ 4 | package com.authlete.common.dto; 5 | 6 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/api/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The definition of Authlete API ({@link com.authlete.common.api.AuthleteApi 3 | * AuthleteApi}) and the factory class ({@link com.authlete.common.api.AuthleteApiFactory 4 | * AuthleteApiFactory}). 5 | */ 6 | package com.authlete.common.api; 7 | 8 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/conf/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * The definition of Authlete configuration ({@link 3 | * com.authlete.common.conf.AuthleteConfiguration AuthleteConfiguration}) 4 | * and its implementations. 5 | * 6 | *

7 | * {@link com.authlete.common.api.AuthleteApiFactory AuthleteApiFactory} 8 | * requires an instance of {@link 9 | * com.authlete.common.conf.AuthleteConfiguration AuthleteConfiguration} 10 | * to build an instance of {@link com.authlete.common.api.AuthleteApi 11 | * AuthleteApi}. 12 | *

13 | */ 14 | package com.authlete.common.conf; 15 | 16 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/package-info.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Authlete Java library used commonly by service implementations and 3 | * the Authlete server. 4 | * 5 | *

6 | * Source code is hosted at 7 | * GitHub. 8 | *

9 | * 10 | *

11 | * For Maven: 12 | *

13 | * 16 | *
17 |  * <dependency>
18 |  *     <groupId>com.authlete</groupId>
19 |  *     <artifactId>authlete-java-common</artifactId>
20 |  *     <version>4.23</version>
21 |  * </dependency>
23 | * 24 | * @version 4.23 25 | */ 26 | package com.authlete.common; 27 | 28 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/HashAlg.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * Hash algorithm. 21 | * 22 | * @author Takahiko Kawasaki 23 | */ 24 | public enum HashAlg 25 | { 26 | SHA_256, 27 | SHA_384, 28 | SHA_512 29 | } 30 | -------------------------------------------------------------------------------- /mvn-config/spotbugs/spotbugs-include.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/TokenStatus.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * Token status. 21 | * 22 | * @since 3.97 23 | */ 24 | public enum TokenStatus 25 | { 26 | /** 27 | * All valid tokens. 28 | */ 29 | VALID, 30 | 31 | 32 | /** 33 | * All invalid (expired) tokens. 34 | */ 35 | INVALID, 36 | 37 | 38 | /** 39 | * All tokens. 40 | */ 41 | ALL, 42 | ; 43 | } 44 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/ClientClaims.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | public class ClientClaims 20 | { 21 | public static final String CLIENT_NAME = "client_name"; 22 | public static final String LOGO_URI = "logo_uri"; 23 | public static final String CLIENT_URI = "client_uri"; 24 | public static final String POLICY_URI = "policy_uri"; 25 | public static final String TOS_URI = "tos_uri"; 26 | public static final String DESCRIPTION = "urn:fdc:authlete.com:2014:openid:client_claim:description"; 27 | } 28 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/HokMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018-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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * Values for Holder-of-Key method. 21 | * 22 | * @since 2.21 23 | */ 24 | public enum HokMethod 25 | { 26 | /** 27 | * This represents 28 | * Mutual-TLS Client Certificate-Bound Access Tokens. 29 | */ 30 | MTLS, 31 | 32 | 33 | /** 34 | * This represents 35 | * OAuth 2.0 Token Binding 36 | */ 37 | OAUTB, 38 | ; 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/TokenCreateBatchResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /auth/token/create/batch} API. 21 | * 22 | * @author Hideki Ikeda 23 | * 24 | * @since 3.96 25 | */ 26 | public class TokenCreateBatchResponse extends ApiResponse 27 | { 28 | private static final long serialVersionUID = 1L; 29 | 30 | 31 | private String requestId; 32 | 33 | 34 | /** 35 | * Get the request ID. 36 | * 37 | * @return 38 | * The request ID. 39 | */ 40 | public String getRequestId() 41 | { 42 | return requestId; 43 | } 44 | 45 | 46 | /** 47 | * @param requestId 48 | * The request ID. 49 | * 50 | * @return 51 | * {@this} object. 52 | */ 53 | public TokenCreateBatchResponse setRequestId(String requestId) 54 | { 55 | this.requestId = requestId; 56 | 57 | return this; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/TokenRevokeResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /auth/token/revoke} API. 21 | * 22 | * @since 3.26 23 | * @since Authlete 2.2.29 24 | */ 25 | public class TokenRevokeResponse extends ApiResponse 26 | { 27 | private static final long serialVersionUID = 1L; 28 | 29 | 30 | private int count; 31 | 32 | 33 | /** 34 | * Get the number of revoked tokens. 35 | * 36 | * @return 37 | * The number of revoked tokens. 38 | */ 39 | public int getCount() 40 | { 41 | return count; 42 | } 43 | 44 | 45 | /** 46 | * Set the number of revoked tokens. 47 | * 48 | * @param count 49 | * The number of revoked tokens. 50 | * 51 | * @return 52 | * {@code this} object. 53 | */ 54 | public TokenRevokeResponse setCount(int count) 55 | { 56 | this.count = count; 57 | 58 | return this; 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/TokenCreateBatchStatusResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /auth/token/create/batch/status} API. 21 | * 22 | * @author Hideki Ikeda 23 | * 24 | * @since 3.96 25 | */ 26 | public class TokenCreateBatchStatusResponse extends ApiResponse 27 | { 28 | private static final long serialVersionUID = 1L; 29 | 30 | 31 | private TokenBatchStatus status; 32 | 33 | 34 | /** 35 | * Get the batch status. 36 | * 37 | * @return 38 | * The batch status. 39 | */ 40 | public TokenBatchStatus getStatus() 41 | { 42 | return status; 43 | } 44 | 45 | 46 | /** 47 | * Set the batch status. 48 | * 49 | * @param status 50 | * The batch stasus. 51 | * 52 | * @return 53 | * {@code this} object. 54 | */ 55 | public TokenCreateBatchStatusResponse setStatus(TokenBatchStatus status) 56 | { 57 | this.status = status; 58 | 59 | return this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/BaseJsonSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.util; 17 | 18 | 19 | import com.google.gson.JsonArray; 20 | import com.google.gson.JsonElement; 21 | import com.google.gson.JsonNull; 22 | import com.google.gson.JsonObject; 23 | 24 | 25 | /** 26 | * The base class for implementations of 27 | * {@link com.google.gson.JsonSerializer JsonSerializer}. 28 | * 29 | * @since 2.57 30 | */ 31 | public class BaseJsonSerializer 32 | { 33 | public JsonElement fromStringArray(String[] array) 34 | { 35 | if (array == null) 36 | { 37 | return JsonNull.INSTANCE; 38 | } 39 | 40 | JsonArray jarray = new JsonArray(); 41 | 42 | for (String string : array) 43 | { 44 | jarray.add(string); 45 | } 46 | 47 | return jarray; 48 | } 49 | 50 | 51 | public void addUnlessNull(JsonObject target, String name, JsonElement element) 52 | { 53 | if (element != null && element.isJsonNull() == false) 54 | { 55 | target.add(name, element); 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/TokenCreateBatchStatusRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * The request to {@code /auth/token/create/batch/status} API. 24 | * 25 | * @author Hideki Ikeda 26 | * 27 | * @since 3.96 28 | */ 29 | public class TokenCreateBatchStatusRequest implements Serializable 30 | { 31 | private static final long serialVersionUID = 1L; 32 | 33 | 34 | private String requestId; 35 | 36 | 37 | /** 38 | * Get the request ID associated with the batch status to retrieve. 39 | * 40 | * @return 41 | * The request ID associated with the batch status to retrieve. 42 | */ 43 | public String getRequestId() 44 | { 45 | return requestId; 46 | } 47 | 48 | 49 | /** 50 | * Set the request ID associated with the batch status to retrieve. 51 | * 52 | * @return 53 | * {@code this} object. 54 | */ 55 | public TokenCreateBatchStatusRequest setRequestId(String requestId) 56 | { 57 | this.requestId = requestId; 58 | 59 | return this; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/api/Options.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2024 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 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.api; 17 | 18 | 19 | import java.util.Collections; 20 | import java.util.Map; 21 | 22 | 23 | /** 24 | * Request options. 25 | * 26 | * @author hidebike712 27 | * 28 | * @since 4.15 29 | */ 30 | public class Options 31 | { 32 | Map headers; 33 | 34 | 35 | /** 36 | * Get the custom request headers for a request. Note that the returned map 37 | * is immutable. 38 | * 39 | * @return 40 | * The custom request headers. Note that the returned map is immutable. 41 | */ 42 | public Map getHeaders() 43 | { 44 | return headers == null ? null : Collections.unmodifiableMap(headers); 45 | } 46 | 47 | 48 | /** 49 | * Set the custom request headers for a request. 50 | * 51 | * @param headers 52 | * The custom request headers. 53 | * 54 | * @return 55 | * {@code this} object. 56 | */ 57 | public Options setHeaders(Map headers) 58 | { 59 | this.headers = headers; 60 | 61 | return this; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthorizationTicketInfo.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Information about a ticket that has been issued from the 24 | * {@code /auth/authorization} API. 25 | * 26 | * @since 3.88 27 | * @since Authlete 3.0 28 | */ 29 | public class AuthorizationTicketInfo implements Serializable 30 | { 31 | private static final long serialVersionUID = 1L; 32 | 33 | 34 | /** 35 | * The arbitrary text attached to the ticket. 36 | */ 37 | private String context; 38 | 39 | 40 | /** 41 | * Get the arbitrary text attached to the ticket. 42 | * 43 | * @return 44 | * The arbitrary text. 45 | */ 46 | public String getContext() 47 | { 48 | return context; 49 | } 50 | 51 | 52 | /** 53 | * Set the arbitrary text attached to the ticket. 54 | * 55 | * @param context 56 | * The arbitrary text. 57 | * 58 | * @return 59 | * {@code this} object. 60 | */ 61 | public AuthorizationTicketInfo setContext(String context) 62 | { 63 | this.context = context; 64 | 65 | return this; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthorizedClientListResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /client/authorization/get/list} API. 21 | * 22 | * @author Takahiko Kawasaki 23 | * 24 | * @since 1.36 25 | */ 26 | public class AuthorizedClientListResponse extends ClientListResponse 27 | { 28 | private static final long serialVersionUID = 1L; 29 | 30 | 31 | /** 32 | * The identifier of the user who has granted authorization 33 | * to the client applications. 34 | * @since Authlete 1.1 35 | */ 36 | private String subject; 37 | 38 | 39 | /** 40 | * Get the identifier of the user who has granted authorization 41 | * to the client applications. 42 | * 43 | * @return 44 | * The identifier of the user. 45 | */ 46 | public String getSubject() 47 | { 48 | return subject; 49 | } 50 | 51 | 52 | /** 53 | * Set the identifier of the user who has granted authorization 54 | * to the client applications. 55 | * 56 | * @param subject 57 | * The identifier of the user. 58 | * 59 | * @return 60 | * {@code this} object. 61 | */ 62 | public AuthorizedClientListResponse setSubject(String subject) 63 | { 64 | this.subject = subject; 65 | 66 | return this; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthzDetailsSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.lang.reflect.Type; 20 | import com.authlete.common.util.BaseJsonSerializer; 21 | import com.google.gson.JsonArray; 22 | import com.google.gson.JsonElement; 23 | import com.google.gson.JsonNull; 24 | import com.google.gson.JsonSerializationContext; 25 | import com.google.gson.JsonSerializer; 26 | 27 | 28 | /** 29 | * JSON serializer for {@link AuthzDetails}. 30 | * 31 | * @since 2.57 32 | */ 33 | public class AuthzDetailsSerializer extends BaseJsonSerializer 34 | implements JsonSerializer 35 | { 36 | @Override 37 | public JsonElement serialize( 38 | AuthzDetails details, Type type, JsonSerializationContext context) 39 | { 40 | if (details == null) 41 | { 42 | return JsonNull.INSTANCE; 43 | } 44 | 45 | AuthzDetailsElement[] elements = details.getElements(); 46 | if (elements == null) 47 | { 48 | return JsonNull.INSTANCE; 49 | } 50 | 51 | JsonArray jarray = new JsonArray(); 52 | 53 | AuthzDetailsElementSerializer elementSerializer = new AuthzDetailsElementSerializer(); 54 | 55 | for (int i = 0; i < elements.length; ++i) 56 | { 57 | jarray.add(elementSerializer.serialize(elements[i], null, null)); 58 | } 59 | 60 | return jarray; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthorizationTicketInfoRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /auth/authorization/ticket/info} API. 24 | * 25 | *

26 | * The API is used to get information about a ticket that has been issued from 27 | * the {@code /auth/authorization} API. 28 | *

29 | * 30 | * @since 3.88 31 | * @since Authlete 3.0 32 | */ 33 | public class AuthorizationTicketInfoRequest implements Serializable 34 | { 35 | private static final long serialVersionUID = 1L; 36 | 37 | 38 | /** 39 | * The ticket that has been issued from the {@code /auth/authorization} API. 40 | */ 41 | private String ticket; 42 | 43 | 44 | /** 45 | * Get the ticket that has been issued from the {@code /auth/authorization} API. 46 | * 47 | * @return 48 | * The ticket. 49 | */ 50 | public String getTicket() 51 | { 52 | return ticket; 53 | } 54 | 55 | 56 | /** 57 | * Set the ticket that has been issued from the {@code /auth/authorization} API. 58 | * 59 | * @param ticket 60 | * The ticket. 61 | * 62 | * @return 63 | * {@code this} object. 64 | */ 65 | public AuthorizationTicketInfoRequest setTicket(String ticket) 66 | { 67 | this.ticket = ticket; 68 | 69 | return this; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/conf/AuthleteApiVersion.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.conf; 17 | 18 | 19 | /** 20 | * Authlete API version. 21 | * 22 | * @since 3.23 23 | */ 24 | public enum AuthleteApiVersion 25 | { 26 | V2, 27 | V3, 28 | ; 29 | 30 | 31 | /** 32 | * Parse the given string as {@link AuthleteApiVersion}. 33 | * 34 | *

35 | * When the given string is {@code null} or does not match any known version, 36 | * this method returns {@code null} without throwing any exception. 37 | *

38 | * 39 | * @param version 40 | * A string representing a version. For example, {@code "V2"}. 41 | * 42 | * @return 43 | * An instance of {@link AuthleteApiVersion}, or {@code null} 44 | * if the given string does not match any known version. 45 | */ 46 | public static AuthleteApiVersion parse(String version) 47 | { 48 | if (version == null) 49 | { 50 | return null; 51 | } 52 | 53 | try 54 | { 55 | // Parse the given string as AuthleteApiVersion. If the string 56 | // does not match any known version, valueOf() will throw an 57 | // IllegalArgumentException instance. 58 | return AuthleteApiVersion.valueOf(version); 59 | } 60 | catch (Exception e) 61 | { 62 | // The given string did not match any known version. 63 | return null; 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ClientLockFlagUpdateRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's /api/client/lock_flag/update/{clientIdentifier} API. 24 | * 25 | *

26 | * The API is used to update the lock flag of a client application. 27 | *

28 | * 29 | * @since 3.10 30 | */ 31 | public class ClientLockFlagUpdateRequest implements Serializable 32 | { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | private boolean clientLocked; 37 | 38 | 39 | /** 40 | * Get the value to which this request updates the lock flag of a client 41 | * application. 42 | * 43 | * @return 44 | * The value to which this request updates the lock flag of a client 45 | * application. 46 | */ 47 | public boolean isClientLocked() 48 | { 49 | return clientLocked; 50 | } 51 | 52 | 53 | /** 54 | * Set the value to which this request updates the lock flag of a client 55 | * application. 56 | * 57 | * @param clientLocked 58 | * The value to which this request updates the lock flag of a client 59 | * application. 60 | * 61 | * @return 62 | * {@code this} object. 63 | */ 64 | public ClientLockFlagUpdateRequest setClientLocked(boolean clientLocked) 65 | { 66 | this.clientLocked = clientLocked; 67 | 68 | return this; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /HOW-TO-RELEASE.md: -------------------------------------------------------------------------------- 1 | How To Release 2 | ============== 3 | 4 | One-Time Setup 5 | -------------- 6 | 7 | Import Authlete's private key. 8 | 9 | $ gpg --import admin_at_authlete_com-sec.asc 10 | 11 | If the private key was imported successfully, the following command shows 12 | a key owned by _"Authlete, Inc."_. 13 | 14 | $ gpg --list-secret-keys 15 | 16 | Edit `~/.m2/settings.xml` for automated signing and releasing. 17 | 18 | 23 | 24 | 25 | authlete 26 | authlete 27 | {password} 28 | 29 | 30 | 31 | 32 | 33 | authlete 34 | 35 | E834481D 36 | 37 | 38 | 39 | 40 | 41 | 42 | Update Documents 43 | ---------------- 44 | 45 | Update version numbers hard-coded in `README.md`, `README.ja.md` and 46 | `src/main/java/com/authlete/common/package-info.java`. 47 | 48 | Update `CHANGES.md` and `CHANGES.ja.md`. 49 | 50 | Don't forget to add `@since {version}` to JavaDoc if you added new methods, 51 | classes and enums. 52 | 53 | 54 | Generate and Release Package 55 | ---------------------------- 56 | 57 | $ mvn clean 58 | $ mvn -P external release:prepare 59 | $ mvn -P external release:perform 60 | 61 | 62 | Publish JavaDoc 63 | --------------- 64 | 65 | $ mkdir -p ../docs 66 | $ cd ../docs 67 | $ git clone https://github.com/authlete/authlete-java-common 68 | $ cd authlete-java-common 69 | $ git checkout gh-pages 70 | $ rm -rf * 71 | $ jar xf ../../authlete-java-common/target/authlete-java-common-{version}-javadoc.jar 72 | $ rm -rf META-INF 73 | $ git add . 74 | $ git commit -m 'Updated JavaDoc for version {version}' 75 | $ git push origin gh-pages 76 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/conf/AuthleteConfiguration.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2022 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.conf; 17 | 18 | 19 | /** 20 | * Authlete configuration. 21 | */ 22 | public interface AuthleteConfiguration 23 | { 24 | /** 25 | * Get the Authlete API version. 26 | * 27 | * @since 3.23 28 | */ 29 | String getApiVersion(); 30 | 31 | 32 | /** 33 | * Get the base URL. 34 | */ 35 | String getBaseUrl(); 36 | 37 | 38 | /** 39 | * Get the service owner API key. 40 | */ 41 | String getServiceOwnerApiKey(); 42 | 43 | 44 | /** 45 | * Get the service owner API secret. 46 | */ 47 | String getServiceOwnerApiSecret(); 48 | 49 | 50 | /** 51 | * Get the service owner API access token 52 | */ 53 | String getServiceOwnerAccessToken(); 54 | 55 | 56 | /** 57 | * Get the service API key. 58 | */ 59 | String getServiceApiKey(); 60 | 61 | 62 | /** 63 | * Get the service API secret. 64 | */ 65 | String getServiceApiSecret(); 66 | 67 | 68 | /** 69 | * Get the service API access token 70 | */ 71 | String getServiceAccessToken(); 72 | 73 | 74 | /** 75 | * Get the public/private key pair used for DPoP 76 | * signatures in JWK format. 77 | * 78 | * @since 2.73 79 | */ 80 | String getDpopKey(); 81 | 82 | 83 | /** 84 | * Get the certificate used for MTLS bound 85 | * access tokens in PEM format. 86 | * 87 | * @since 2.73 88 | */ 89 | String getClientCertificate(); 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ClientSecretRefreshResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 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.common.dto; 18 | 19 | 20 | /** 21 | * Response from Authlete's {@code /api/client/secret/refresh} API. 22 | * 23 | * @author Takahiko Kawasaki 24 | * 25 | * @since 2.11 26 | * @since Authlete 1.1.12 27 | */ 28 | public class ClientSecretRefreshResponse extends ApiResponse 29 | { 30 | private static final long serialVersionUID = 1L; 31 | 32 | 33 | private String newClientSecret; 34 | private String oldClientSecret; 35 | 36 | 37 | /** 38 | * Get the new client secret. 39 | * 40 | * @return 41 | * The new client secret. 42 | */ 43 | public String getNewClientSecret() 44 | { 45 | return newClientSecret; 46 | } 47 | 48 | 49 | /** 50 | * Set the new client secret. 51 | * 52 | * @param secret 53 | * The new client secret. 54 | */ 55 | public void setNewClientSecret(String secret) 56 | { 57 | this.newClientSecret = secret; 58 | } 59 | 60 | 61 | /** 62 | * Get the old client secret. 63 | * 64 | * @return 65 | * The old client secret. 66 | */ 67 | public String getOldClientSecret() 68 | { 69 | return oldClientSecret; 70 | } 71 | 72 | 73 | /** 74 | * Set the old client secret. 75 | * 76 | * @param secret 77 | * The old client secret. 78 | */ 79 | public void setOldClientSecret(String secret) 80 | { 81 | this.oldClientSecret = secret; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ClientSecretUpdateResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 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.common.dto; 18 | 19 | 20 | /** 21 | * Response from Authlete's {@code /api/client/secret/update} API. 22 | * 23 | * @author Takahiko Kawasaki 24 | * 25 | * @since 2.11 26 | * @since Authlete 1.1.12 27 | */ 28 | public class ClientSecretUpdateResponse extends ApiResponse 29 | { 30 | private static final long serialVersionUID = 1L; 31 | 32 | 33 | private String newClientSecret; 34 | private String oldClientSecret; 35 | 36 | 37 | /** 38 | * Get the new client secret. 39 | * 40 | * @return 41 | * The new client secret. 42 | */ 43 | public String getNewClientSecret() 44 | { 45 | return newClientSecret; 46 | } 47 | 48 | 49 | /** 50 | * Set the new client secret. 51 | * 52 | * @param secret 53 | * The new client secret. 54 | */ 55 | public void setNewClientSecret(String secret) 56 | { 57 | this.newClientSecret = secret; 58 | } 59 | 60 | 61 | /** 62 | * Get the old client secret. 63 | * 64 | * @return 65 | * The old client secret. 66 | */ 67 | public String getOldClientSecret() 68 | { 69 | return oldClientSecret; 70 | } 71 | 72 | 73 | /** 74 | * Set the old client secret. 75 | * 76 | * @param secret 77 | * The old client secret. 78 | */ 79 | public void setOldClientSecret(String secret) 80 | { 81 | this.oldClientSecret = secret; 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthzDetailsDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.lang.reflect.Type; 20 | import com.authlete.common.util.BaseJsonDeserializer; 21 | import com.google.gson.JsonArray; 22 | import com.google.gson.JsonDeserializationContext; 23 | import com.google.gson.JsonDeserializer; 24 | import com.google.gson.JsonElement; 25 | import com.google.gson.JsonParseException; 26 | 27 | 28 | /** 29 | * JSON deserializer for {@link AuthzDetails}. 30 | * 31 | * @since 2.57 32 | */ 33 | public class AuthzDetailsDeserializer extends BaseJsonDeserializer 34 | implements JsonDeserializer 35 | { 36 | @Override 37 | public AuthzDetails deserialize( 38 | JsonElement jelement, Type type, JsonDeserializationContext context) throws JsonParseException 39 | { 40 | if (jelement == null || jelement.isJsonNull()) 41 | { 42 | return null; 43 | } 44 | 45 | JsonArray jarray = jelement.getAsJsonArray(); 46 | int size = jarray.size(); 47 | 48 | AuthzDetails details = new AuthzDetails(); 49 | 50 | AuthzDetailsElement[] elements = new AuthzDetailsElement[size]; 51 | details.setElements(elements); 52 | 53 | AuthzDetailsElementDeserializer elementDeserializer = 54 | new AuthzDetailsElementDeserializer(); 55 | 56 | for (int i = 0; i < size; ++i) 57 | { 58 | elements[i] = elementDeserializer.deserialize(jarray.get(i), null, null); 59 | } 60 | 61 | return details; 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/Plan.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * Plan. 21 | * 22 | * @author Takahiko Kawasaki 23 | * 24 | * @see Pricing 25 | * 26 | * @since 1.17 27 | */ 28 | public enum Plan 29 | { 30 | /** 31 | * Free plan. 32 | */ 33 | FREE((short)0), 34 | 35 | 36 | /** 37 | * Lite plan. 38 | */ 39 | LITE((short)1), 40 | 41 | 42 | /** 43 | * Premium plan. 44 | */ 45 | PREMIUM((short)2), 46 | 47 | 48 | /** 49 | * Enterprise plan. 50 | */ 51 | ENTERPRISE((short)3) 52 | ; 53 | 54 | 55 | private static final Plan[] sValues = values(); 56 | private final short mValue; 57 | 58 | 59 | private Plan(short value) 60 | { 61 | mValue = value; 62 | } 63 | 64 | 65 | /** 66 | * Get the integer representation of this enum instance. 67 | */ 68 | public short getValue() 69 | { 70 | return mValue; 71 | } 72 | 73 | 74 | /** 75 | * Find an instance of this enum by a value. 76 | * 77 | * @param value 78 | * The integer representation of the instance to find. 79 | * 80 | * @return 81 | * An instance of this enum, or {@code null} if not found. 82 | */ 83 | public static Plan getByValue(short value) 84 | { 85 | if (value < 0 || sValues.length <= value) 86 | { 87 | // Not found. 88 | return null; 89 | } 90 | 91 | return sValues[value]; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/PropertiesWrapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.util; 17 | 18 | 19 | import java.util.Properties; 20 | 21 | 22 | /** 23 | * Properties wrapper. 24 | * 25 | * @author Takahiko Kawasaki 26 | */ 27 | public class PropertiesWrapper extends StringBasedTypedProperties 28 | { 29 | private final Properties properties; 30 | 31 | 32 | /** 33 | * Constructor with a {@code Properties} instance to be wrapped. 34 | * 35 | * @param properties 36 | * {@code Properties} instance to be wrapped. 37 | * 38 | * @throws IllegalArgumentException 39 | * {@code properties} is {@code null}. 40 | */ 41 | public PropertiesWrapper(Properties properties) 42 | { 43 | if (properties == null) 44 | { 45 | throw new IllegalArgumentException("properties is null."); 46 | } 47 | 48 | this.properties = properties; 49 | } 50 | 51 | 52 | @Override 53 | public boolean contains(String key) 54 | { 55 | return properties.containsKey(key); 56 | } 57 | 58 | 59 | @Override 60 | public String getString(String key, String defaultValue) 61 | { 62 | return properties.getProperty(key, defaultValue); 63 | } 64 | 65 | 66 | @Override 67 | public void setString(String key, String value) 68 | { 69 | properties.setProperty(key, value); 70 | } 71 | 72 | 73 | @Override 74 | public void remove(String key) 75 | { 76 | properties.remove(key); 77 | 78 | } 79 | 80 | 81 | @Override 82 | public void clear() 83 | { 84 | properties.clear(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialIssuerJwksRequest.java: -------------------------------------------------------------------------------- 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /vci/jwks} API. 24 | * 25 | *

26 | * The Authlete API can be used to implement an endpoint that returns the 27 | * JWK Set document of the credential issuer that contains public keys only. 28 | *

29 | * 30 | * @since 3.72 31 | * @since Authlete 3.0 32 | * 33 | * @see OpenID for Verifiable Credential Issuance 35 | */ 36 | public class CredentialIssuerJwksRequest implements Serializable 37 | { 38 | private static final long serialVersionUID = 1L; 39 | 40 | 41 | private boolean pretty; 42 | 43 | 44 | /** 45 | * Get the flag indicating whether the JWK Set document is written in 46 | * the pretty format or not. 47 | * 48 | * @return 49 | * {@code true} if the JWK Set document is written in the pretty 50 | * format. 51 | */ 52 | public boolean isPretty() 53 | { 54 | return pretty; 55 | } 56 | 57 | 58 | /** 59 | * Set the flag indicating whether the JWK Set document is written in 60 | * the pretty format or not. 61 | * 62 | * @param pretty 63 | * {@code true} to write the JWK Set document in the pretty format. 64 | * 65 | * @return 66 | * {@code this} object. 67 | */ 68 | public CredentialIssuerJwksRequest setPretty(boolean pretty) 69 | { 70 | this.pretty = pretty; 71 | 72 | return this; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialNonceRequest.java: -------------------------------------------------------------------------------- 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /vci/nonce} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be used from within the implementation of 27 | * the nonce endpoint of the credential issuer. 28 | *

29 | * 30 | * @since 4.27 31 | * @since Authlete 3.0.22 32 | * 33 | * @see 34 | * OpenID for Verifiable Credential Issuance 1.0, 35 | * Section 7. Nonce Endpoint 36 | */ 37 | public class CredentialNonceRequest implements Serializable 38 | { 39 | private static final long serialVersionUID = 1L; 40 | 41 | 42 | private boolean pretty; 43 | 44 | 45 | 46 | /** 47 | * Get the flag indicating whether the nonce response is written in the pretty 48 | * format or not. 49 | * 50 | * @return 51 | * {@code true} if the nonce response is written in the pretty format. 52 | */ 53 | public boolean isPretty() 54 | { 55 | return pretty; 56 | } 57 | 58 | 59 | /** 60 | * Set the flag indicating whether the nonce response is written in the pretty 61 | * format or not. 62 | * 63 | * @param pretty 64 | * {@code true} to write the nonce response in the pretty format. 65 | * 66 | * @return 67 | * {@code this} object. 68 | */ 69 | public CredentialNonceRequest setPretty(boolean pretty) 70 | { 71 | this.pretty = pretty; 72 | 73 | return this; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/BackchannelAuthenticationIssueRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /api/backchannel/authentication/issue} API. 24 | * 25 | *

26 | * The API prepares JSON that contains an {@code auth_req_id}. The JSON should 27 | * be used as the response body of the response which is returned to the client 28 | * from the backchannel authentication endpoint. 29 | *

30 | * 31 | * @since 2.32 32 | */ 33 | public class BackchannelAuthenticationIssueRequest implements Serializable 34 | { 35 | private static final long serialVersionUID = 1L; 36 | 37 | 38 | /** 39 | * The ticket issued by Authlete's /api/backchannel/authentication API. 40 | */ 41 | private String ticket; 42 | 43 | 44 | /** 45 | * Get the ticket which is necessary to call Authlete's 46 | * {@code /api/backchannel/authentication/issue} API. 47 | * 48 | * @return 49 | * A ticket. 50 | */ 51 | public String getTicket() 52 | { 53 | return ticket; 54 | } 55 | 56 | 57 | /** 58 | * Set the ticket which is necessary to call Authlete's 59 | * {@code /api/backchannel/authentication/issue} API. 60 | * 61 | * @param ticket 62 | * A ticket previously issued by Authlete's 63 | * {@code /api/backchannel/authentication} API. 64 | * 65 | * @return 66 | * {@code this} object. 67 | */ 68 | public BackchannelAuthenticationIssueRequest setTicket(String ticket) 69 | { 70 | this.ticket = ticket; 71 | 72 | return this; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialIssuerMetadataRequest.java: -------------------------------------------------------------------------------- 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /vci/metadata} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be used from within the implementation of 27 | * the credential issuer metadata endpoint 28 | * ({@code /.well-known/openid-credential-issuer}). 29 | *

30 | * 31 | * @since 3.55 32 | * @since Authlete 3.0 33 | * 34 | * @see OpenID for Verifiable Credential Issuance 36 | */ 37 | public class CredentialIssuerMetadataRequest implements Serializable 38 | { 39 | private static final long serialVersionUID = 2L; 40 | 41 | 42 | private boolean pretty; 43 | 44 | 45 | /** 46 | * Get the flag indicating whether the metadata is written in the pretty 47 | * format or not. 48 | * 49 | * @return 50 | * {@code true} if the metadata is written in the pretty format. 51 | * 52 | * @since 3.56 53 | */ 54 | public boolean isPretty() 55 | { 56 | return pretty; 57 | } 58 | 59 | 60 | /** 61 | * Set the flag indicating whether the metadata is written in the pretty 62 | * format or not. 63 | * 64 | * @param pretty 65 | * {@code true} to write the metadata in the pretty format. 66 | * 67 | * @return 68 | * {@code this} object. 69 | * 70 | * @since 3.56 71 | */ 72 | public CredentialIssuerMetadataRequest setPretty(boolean pretty) 73 | { 74 | this.pretty = pretty; 75 | 76 | return this; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/NamedUri.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | import java.net.URI; 21 | 22 | 23 | /** 24 | * Named URI. 25 | * 26 | * @since 2.49 27 | */ 28 | public class NamedUri implements Serializable 29 | { 30 | private static final long serialVersionUID = 1L; 31 | 32 | 33 | /** 34 | * The name of the URI. 35 | */ 36 | private String name; 37 | 38 | 39 | /** 40 | * The value of the URI. 41 | */ 42 | private URI uri; 43 | 44 | 45 | /** 46 | * Get the name of the URI. 47 | * 48 | * @return 49 | * The name of the URI. 50 | */ 51 | public String getName() 52 | { 53 | return name; 54 | } 55 | 56 | 57 | /** 58 | * Set the name of the URI. 59 | * 60 | * @param name 61 | * The name of the URI. 62 | * 63 | * @return 64 | * {@code this} object. 65 | */ 66 | public NamedUri setName(String name) 67 | { 68 | this.name = name; 69 | 70 | return this; 71 | } 72 | 73 | 74 | /** 75 | * Get the value of the URI. 76 | * 77 | * @return 78 | * The value of the URI. 79 | */ 80 | public URI getUri() 81 | { 82 | return uri; 83 | } 84 | 85 | 86 | /** 87 | * Set the value of the URI. 88 | * 89 | * @param uri 90 | * The value of the URI. 91 | * 92 | * @return 93 | * {@code this} object. 94 | */ 95 | public NamedUri setUri(URI uri) 96 | { 97 | this.uri = uri; 98 | 99 | return this; 100 | } 101 | } 102 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/assurance/constraint/ConstraintException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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.common.assurance.constraint; 18 | 19 | 20 | /** 21 | * An exception that indicates the structure does not conform to the 22 | * specification (OpenID Connect for Identity Assurance 1.0). 25 | * 26 | * @see OpenID Connect for Identity Assurance 1.0 28 | * 29 | * @since 2.63 30 | */ 31 | public class ConstraintException extends RuntimeException 32 | { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | /** 37 | * The default constructor. 38 | */ 39 | public ConstraintException() 40 | { 41 | } 42 | 43 | 44 | /** 45 | * The constructor with a message. 46 | * 47 | * @param message 48 | * A message that explains this exception. 49 | */ 50 | public ConstraintException(String message) 51 | { 52 | super(message); 53 | } 54 | 55 | 56 | /** 57 | * The constructor with a cause. 58 | * 59 | * @param cause 60 | * The cause of this exception. 61 | */ 62 | public ConstraintException(Throwable cause) 63 | { 64 | super(cause); 65 | } 66 | 67 | 68 | /** 69 | * The constructor with a message and a cause. 70 | * 71 | * @param message 72 | * A message that explains this exception. 73 | * 74 | * @param cause 75 | * The cause of this exception. 76 | */ 77 | public ConstraintException(String message, Throwable cause) 78 | { 79 | super(message, cause); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/web/DpopToken.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.web; 17 | 18 | 19 | import java.util.regex.Matcher; 20 | import java.util.regex.Pattern; 21 | 22 | 23 | /** 24 | * Utility class for DPoP Token. 25 | * 26 | * @since 2.70 27 | */ 28 | public class DpopToken 29 | { 30 | /** 31 | * Regular expression to parse {@code Authorization} header. 32 | */ 33 | private static final Pattern CHALLENGE_PATTERN 34 | = Pattern.compile("^DPoP *([^ ]+) *$", Pattern.CASE_INSENSITIVE); 35 | 36 | 37 | private DpopToken() 38 | { 39 | } 40 | 41 | 42 | /** 43 | * Extract the DPoP access token embedded in the input string. 44 | * 45 | *

46 | * This method assumes that the input string comes from the 47 | * Authorization Request Header Field. 48 | * 49 | * @param input 50 | * The input string to be parsed. 51 | * 52 | * @return 53 | * The extracted DPoP access token, or null if not found. 54 | * 55 | */ 56 | public static String parse(String input) 57 | { 58 | if (input == null) 59 | { 60 | return null; 61 | } 62 | 63 | // Check whether the input matches the pattern 64 | // "DPoP {access-token}". 65 | Matcher matcher = CHALLENGE_PATTERN.matcher(input); 66 | 67 | // If the input matches the pattern. 68 | if (matcher.matches()) 69 | { 70 | // Return the value as is. Note that it is not Base64-encoded. 71 | // See https://www.ietf.org/mail-archive/web/oauth/current/msg08489.html 72 | return matcher.group(1); 73 | } 74 | else 75 | { 76 | return null; 77 | } 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/assurance/IdentityAssuranceException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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.common.assurance; 18 | 19 | 20 | /** 21 | * An exception that indicates the structure does not conform to the 22 | * specification (OpenID Connect for Identity Assurance 1.0). 25 | * 26 | * @see OpenID Connect for Identity Assurance 1.0 28 | * 29 | * @since 2.63 30 | */ 31 | public class IdentityAssuranceException extends RuntimeException 32 | { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | /** 37 | * The default constructor. 38 | */ 39 | public IdentityAssuranceException() 40 | { 41 | } 42 | 43 | 44 | /** 45 | * The constructor with a message. 46 | * 47 | * @param message 48 | * A message that explains this exception. 49 | */ 50 | public IdentityAssuranceException(String message) 51 | { 52 | super(message); 53 | } 54 | 55 | 56 | /** 57 | * The constructor with a cause. 58 | * 59 | * @param cause 60 | * The cause of this exception. 61 | */ 62 | public IdentityAssuranceException(Throwable cause) 63 | { 64 | super(cause); 65 | } 66 | 67 | 68 | /** 69 | * The constructor with a message and a cause. 70 | * 71 | * @param message 72 | * A message that explains this exception. 73 | * 74 | * @param cause 75 | * The cause of this exception. 76 | */ 77 | public IdentityAssuranceException(String message, Throwable cause) 78 | { 79 | super(message, cause); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/main/resources/dataset-extractor-messages.properties: -------------------------------------------------------------------------------- 1 | DE01 = A transformed claim was found. 2 | DE02 = The property is unavailable, and therefore omitted. 3 | DE03 = The property is available as array or object, but omitted for the data minimization policy. 4 | DE04 = The request does not have constraints for the property, and therefore the property is put in the copy unconditionally. 5 | DE05 = The request format is invalid, so matching fails. 6 | DE06 = The property does not satisfy the constraint, so matching fails. 7 | DE07 = The property does not satisfy the constraint, and therefore the property is omitted. 8 | DE08 = The property satisfies the constraint, and therefore the property is put in the copy. 9 | DE09 = The request has no constraint for the property, and therefore the property is put in the copy unconditionally. 10 | DE10 = The request has no constraint for the property, but the property is omitted because its value is unavailable. 11 | DE11 = The request has sub properties but the actual data in the original dataset is a single value, so matching fails. 12 | DE12 = The element in the array in the original dataset is not an object. The element is ignored. 13 | DE13 = The element in the array in the original dataset meets conditions of the request, so the element is put in the copy. 14 | DE14 = None of the elements in the array in the original dataset meet conditions of the request, so matching fails. 15 | DE15 = The request is an array, but the property in the original dataset is neither an object nor an array. Therefore, matching fails. 16 | DE16 = The element in the array in the request is not an object. It is a specification violation. The element is ignored. 17 | DE17 = The property in the original dataset satisfies conditions of the element in the array in the request. 18 | DE18 = The element in the array in the original dataset is not an object. The element is ignored. 19 | DE19 = The element in the array in the request is not an object. It is a specification violation. The element is ignored. 20 | DE20 = The element in the array in the original dataset satisfies conditions of the element in the array in the request. 21 | DE21 = None of the elements in the array in the original dataset satisfy any of the elements in the array in the request. Therefore, matching fails. 22 | DE22 = Some elements in the array in the original dataset satisfy any of the elements in the array in the request. 23 | DE23 = All available sub-elements under 'assurance_details' are unconditionally returned based on the special rule for the property. 24 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/AssertionTarget.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * The part of the service that an assertion processor will be applied to. 21 | * 22 | * @since 2.39 23 | */ 24 | public enum AssertionTarget 25 | { 26 | /** 27 | * The assertion processor is used for the OAuth Dynamic Client Registration 28 | * protocol's "software_statement" field, which contains a signed assertion 29 | * of client attributes. 30 | */ 31 | CLIENT_REGISTRATION_SOFTWARE_STATEMENT((short)1, "software_statement") 32 | ; 33 | 34 | 35 | private static final AssertionTarget[] sValues = values(); 36 | private final short mValue; 37 | private final String mString; 38 | 39 | 40 | private AssertionTarget(short value, String string) 41 | { 42 | mValue = value; 43 | mString = string; 44 | } 45 | 46 | 47 | /** 48 | * Get the numerical value for this target. 49 | * 50 | * @return 51 | * The numerical value for this target. 52 | * 53 | * @since 2.39 54 | */ 55 | public short getValue() 56 | { 57 | return mValue; 58 | } 59 | 60 | 61 | @Override 62 | public String toString() 63 | { 64 | return mString; 65 | } 66 | 67 | 68 | /** 69 | * Get the enum object with the given numerical value, or {@code null} if not 70 | * found. 71 | * 72 | * @param value 73 | * The numerical value to search for. 74 | * 75 | * @return 76 | * The enum object, or {@code null} if not found. 77 | * 78 | * @since 2.39 79 | */ 80 | public static AssertionTarget getByValue(short value) 81 | { 82 | if (value < 1 || sValues.length < value) 83 | { 84 | // not found 85 | return null; 86 | } 87 | 88 | return sValues[value - 1]; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/java/com/authlete/common/dto/DtoTest.java: -------------------------------------------------------------------------------- 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 | * https://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import static org.junit.Assert.fail; 20 | import com.fasterxml.jackson.databind.ObjectMapper; 21 | import org.junit.Test; 22 | import org.reflections.Reflections; 23 | import org.reflections.scanners.SubTypesScanner; 24 | import java.io.IOException; 25 | import java.util.Set; 26 | 27 | 28 | public class DtoTest 29 | { 30 | private static final String PACKAGE_NAME = "com.authlete.common.dto"; 31 | 32 | private final ObjectMapper mapper = new ObjectMapper(); 33 | 34 | 35 | /** 36 | * Attempt to JSON parse all dto objects. 37 | * This will pick up any ambiguous setter related errors. 38 | *

39 | * Running this test directly without the "process-classes" maven step will cause the test to fail. 40 | */ 41 | @Test 42 | public void checkAmbiguousJsonSetterMethodsForAllDtos() 43 | { 44 | Reflections reflections = new Reflections(PACKAGE_NAME, new SubTypesScanner(false)); 45 | Set> classes = reflections.getSubTypesOf(Object.class); 46 | 47 | for (Class aClass : classes) 48 | { 49 | // Attempt to parse a blank object as each class this will ensure that the class itself passes the jackson setter validation 50 | try 51 | { 52 | mapper.readValue("{}", aClass); 53 | } 54 | catch (IOException e) 55 | { 56 | // Most likely this is due to duplicate ambiguous setter definitions that exist within a class 57 | // One way to resolve is to use the @JsonSetter annotation on one of the setter methods 58 | // (generally the one that matches the getter return value). 59 | 60 | // You can check on JsonSetterAnnotationProcessor to check why methods are not being annotated correctly. 61 | fail(e.getMessage()); 62 | } 63 | } 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/GrantSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.lang.reflect.Type; 20 | import com.authlete.common.util.BaseJsonSerializer; 21 | import com.google.gson.Gson; 22 | import com.google.gson.JsonElement; 23 | import com.google.gson.JsonNull; 24 | import com.google.gson.JsonObject; 25 | import com.google.gson.JsonSerializationContext; 26 | import com.google.gson.JsonSerializer; 27 | 28 | 29 | /** 30 | * JSON serializer for {@link Grant}. 31 | * 32 | * @since 3.1 33 | */ 34 | public class GrantSerializer extends BaseJsonSerializer 35 | implements JsonSerializer 36 | { 37 | @Override 38 | public JsonElement serialize( 39 | Grant grant, Type type, JsonSerializationContext context) 40 | { 41 | if (grant == null) 42 | { 43 | return JsonNull.INSTANCE; 44 | } 45 | 46 | // Object to set up. 47 | JsonObject jGrant = new JsonObject(); 48 | 49 | // "scopes" 50 | addScopes(grant, jGrant); 51 | 52 | // "claims" 53 | addClaims(grant, jGrant); 54 | 55 | // "authorization_details" 56 | addAuthorizationDetails(grant, jGrant); 57 | 58 | return jGrant; 59 | } 60 | 61 | 62 | private void addScopes(Grant grant, JsonObject jGrant) 63 | { 64 | JsonElement element = new Gson().toJsonTree(grant.getScopes()); 65 | 66 | addUnlessNull(jGrant, "scopes", element); 67 | } 68 | 69 | 70 | private void addClaims(Grant grant, JsonObject jGrant) 71 | { 72 | JsonElement element = fromStringArray(grant.getClaims()); 73 | 74 | addUnlessNull(jGrant, "claims", element); 75 | } 76 | 77 | 78 | private void addAuthorizationDetails(Grant grant, JsonObject jGrant) 79 | { 80 | JsonElement element = new AuthzDetailsSerializer().serialize( 81 | grant.getAuthorizationDetails(), null, null); 82 | 83 | addUnlessNull(jGrant, "authorization_details", element); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthzDetailsElementSerializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.lang.reflect.Type; 20 | import com.authlete.common.util.BaseJsonSerializer; 21 | import com.google.gson.JsonElement; 22 | import com.google.gson.JsonNull; 23 | import com.google.gson.JsonObject; 24 | import com.google.gson.JsonParser; 25 | import com.google.gson.JsonSerializationContext; 26 | import com.google.gson.JsonSerializer; 27 | 28 | 29 | /** 30 | * JSON serializer for {@link AuthzDetailsElement}. 31 | * 32 | *

33 | * "Other fields" (the string returned from {@link AuthzDetailsElement#getOtherFields()}) 34 | * are expanded and merged with the independent fields such as {@code type} and 35 | * {@code locations}. 36 | *

37 | * 38 | * @since 2.57 39 | */ 40 | public class AuthzDetailsElementSerializer extends BaseJsonSerializer 41 | implements JsonSerializer 42 | { 43 | @Override 44 | public JsonElement serialize( 45 | AuthzDetailsElement element, Type type, JsonSerializationContext context) 46 | { 47 | if (element == null) 48 | { 49 | return JsonNull.INSTANCE; 50 | } 51 | 52 | JsonObject jobject; 53 | 54 | String otherFields = element.getOtherFields(); 55 | 56 | if (otherFields != null) 57 | { 58 | jobject = (JsonObject)new JsonParser().parse(otherFields); 59 | } 60 | else 61 | { 62 | jobject = new JsonObject(); 63 | } 64 | 65 | jobject.addProperty("type", element.getType()); 66 | jobject.add( "locations", fromStringArray(element.getLocations())); 67 | jobject.add( "actions", fromStringArray(element.getActions())); 68 | jobject.add( "datatypes", fromStringArray(element.getDataTypes())); 69 | jobject.addProperty("identifier", element.getIdentifier()); 70 | jobject.add( "privileges", fromStringArray(element.getPrivileges())); 71 | 72 | return jobject; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/NativeSsoLogoutRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2025 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * A request to Authlete's {@code /nativesso/logout} API. 24 | * 25 | *

26 | * The {@code /nativesso/logout} API is provided to support the concept of 27 | * "logout from all applications" in the context of Native SSO. 29 | * This is accomplished by deleting access/refresh token records associated 30 | * with the specified session ID. 31 | *

32 | * 33 | *

34 | * In Authlete's implementation, access/refresh token records can be associated 35 | * with a session ID only through the mechanism introduced by the "OpenID Connect 37 | * Native SSO for Mobile Apps 1.0" specification ("Native SSO"). 38 | *

39 | * 40 | * @since 4.20 41 | * @since Authlete 3.0 42 | * 43 | * @see OpenID Connect Native SSO for Mobile Apps 1.0 45 | */ 46 | public class NativeSsoLogoutRequest implements Serializable 47 | { 48 | private static final long serialVersionUID = 1L; 49 | 50 | 51 | /** 52 | * The session ID of a user's authentication session. 53 | */ 54 | private String sessionId; 55 | 56 | 57 | /** 58 | * Get the session ID of a user's authentication session. 59 | * 60 | * @return 61 | * The session ID. 62 | */ 63 | public String getSessionId() 64 | { 65 | return sessionId; 66 | } 67 | 68 | 69 | /** 70 | * Set the session ID of a user's authentication session. 71 | * 72 | * @param sessionId 73 | * The session ID. 74 | * 75 | * @return 76 | * {@code this} object. 77 | */ 78 | public NativeSsoLogoutRequest setSessionId(String sessionId) 79 | { 80 | this.sessionId = sessionId; 81 | 82 | return this; 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/TaggedValue.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * A string value with a language tag 25 | * 26 | * @author Takahiko Kawasaki 27 | * 28 | * @see Language tag 29 | */ 30 | public class TaggedValue implements Serializable 31 | { 32 | private static final long serialVersionUID = 1L; 33 | 34 | 35 | private String tag; 36 | private String value; 37 | 38 | 39 | /** 40 | * The default constructor. 41 | */ 42 | public TaggedValue() 43 | { 44 | } 45 | 46 | 47 | /** 48 | * Constructor with a tag and a value. 49 | * 50 | * @param tag 51 | * @param value 52 | */ 53 | public TaggedValue(String tag, String value) 54 | { 55 | this.tag = tag; 56 | this.value = value; 57 | } 58 | 59 | 60 | /** 61 | * Get the tag. 62 | * 63 | * @return 64 | * The tag. 65 | */ 66 | public String getTag() 67 | { 68 | return tag; 69 | } 70 | 71 | 72 | /** 73 | * Set the tag. 74 | * 75 | * @param tag 76 | * 77 | * @return 78 | * {@code this} object. 79 | */ 80 | public TaggedValue setTag(String tag) 81 | { 82 | this.tag = tag; 83 | 84 | return this; 85 | } 86 | 87 | 88 | /** 89 | * Get the value. 90 | * 91 | * @return 92 | * The value. 93 | */ 94 | public String getValue() 95 | { 96 | return value; 97 | } 98 | 99 | 100 | /** 101 | * Set the value. 102 | * 103 | * @param value 104 | * 105 | * @return 106 | * {@code this} object. 107 | */ 108 | public TaggedValue setValue(String value) 109 | { 110 | this.value = value; 111 | 112 | return this; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/assurance/constraint/Constraint.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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.common.assurance.constraint; 18 | 19 | 20 | /** 21 | * The basic interface that classes representing constraints in 22 | * {@code verified_claims} implement. 23 | * 24 | * @see OpenID Connect for Identity Assurance 1.0 26 | * 27 | * @since 2.63 28 | */ 29 | public interface Constraint 30 | { 31 | /** 32 | * Check if the key that represents the constraint exists. It does not 33 | * matter whether the value of the key is null or not. 34 | * 35 | *

36 | * For example, {@code exists()} method of an instance that represents 37 | * {@code given_name} in the JSON below will return {@code true}. 38 | *

39 | * 40 | *
41 |      * {
42 |      *   "verified_claims": {
43 |      *     "claims": {
44 |      *       "given_name": null
45 |      *     }
46 |      *   }
47 |      * }
48 |      * 
49 | * 50 | * @return 51 | * {@code true} if the key that represents the constraint exists. 52 | */ 53 | boolean exists(); 54 | 55 | 56 | /** 57 | * Check if the value of the constraint is null. 58 | * 59 | *

60 | * For example, {@code isNull()} method of an instance that represents 61 | * {@code given_name} in the JSON below will return {@code true}. 62 | *

63 | * 64 | *
65 |      * {
66 |      *   "verified_claims": {
67 |      *     "claims": {
68 |      *       "given_name": null
69 |      *     }
70 |      *   }
71 |      * }
72 |      * 
73 | * 74 | * But, the method returns {@code false} in the following case. 75 | * 76 | *
77 |      * {
78 |      *   "verified_claims": {
79 |      *     "claims": {
80 |      *       "given_name": {
81 |      *       }
82 |      *     }
83 |      *   }
84 |      * }
85 |      * 
86 | * 87 | * @return 88 | * {@code true} if the value of the constraint is null. 89 | */ 90 | boolean isNull(); 91 | } 92 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialOfferInfoRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /vci/offer/info} API. 24 | * 25 | *

26 | * The API is used to get information about a credential offer. 27 | *

28 | * 29 | * @since 3.59 30 | * @since Authlete 3.0 31 | * 32 | * @see OpenID for Verifiable Credential Issuance 34 | */ 35 | public class CredentialOfferInfoRequest implements Serializable 36 | { 37 | private static final long serialVersionUID = 1L; 38 | 39 | 40 | /** 41 | * The identifier of the credential offer. 42 | */ 43 | private String identifier; 44 | 45 | 46 | /** 47 | * Get the identifier of the credential offer. 48 | * 49 | *

50 | * The identifier is one assigned by Authlete's {@code /vci/offer/create} 51 | * API. The value is a base64url string with 256-bit entropy consisting of 52 | * 43 characters. 53 | *

54 | * 55 | *

56 | * This property is mandatory. 57 | *

58 | * 59 | * @return 60 | * The identifier of the credential offer. 61 | */ 62 | public String getIdentifier() 63 | { 64 | return identifier; 65 | } 66 | 67 | 68 | /** 69 | * Set the identifier of the credential offer. 70 | * 71 | *

72 | * The identifier is one assigned by Authlete's {@code /vci/offer/create} 73 | * API. The value is a base64url string with 256-bit entropy consisting of 74 | * 43 characters. 75 | *

76 | * 77 | *

78 | * This property is mandatory. 79 | *

80 | * 81 | * @param identifier 82 | * The identifier of the credential offer. 83 | * 84 | * @return 85 | * {@code this} object. 86 | */ 87 | public CredentialOfferInfoRequest setIdentifier(String identifier) 88 | { 89 | this.identifier = identifier; 90 | 91 | return this; 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/ClaimRuleOperation.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * The operation that a claim rule will apply to any claims 21 | * it processes. 22 | * 23 | * @since 2.39 24 | */ 25 | public enum ClaimRuleOperation 26 | { 27 | /** 28 | * The rule will fail if the claim is present and has a value. 29 | */ 30 | PROHIBITED((short)1, "prohibited"), 31 | 32 | 33 | /** 34 | * The rule will pass if the claim is present and has a value. 35 | */ 36 | PRESENT((short)2, "present"), 37 | 38 | 39 | /** 40 | * The rule will pass if the claim is present and its value 41 | * equals the claim rule's comparison value. 42 | */ 43 | EQUALS((short)3, "equals") 44 | ; 45 | 46 | 47 | private static final ClaimRuleOperation[] sValues = values(); 48 | private final short mValue; 49 | private final String mString; 50 | 51 | 52 | private ClaimRuleOperation(short value, String string) 53 | { 54 | mValue = value; 55 | mString = string; 56 | } 57 | 58 | 59 | /** 60 | * Get the numerical value for this operation. 61 | * 62 | * @return 63 | * The numerical value for this operation. 64 | * 65 | * @since 2.39 66 | */ 67 | public short getValue() 68 | { 69 | return mValue; 70 | } 71 | 72 | 73 | @Override 74 | public String toString() 75 | { 76 | return mString; 77 | } 78 | 79 | 80 | /** 81 | * Get the enum object with the given numerical value, or {@code null} if not 82 | * found. 83 | * 84 | * @param value 85 | * The numerical value to search for. 86 | * 87 | * @return 88 | * The enum object, or {@code null} if not found. 89 | * 90 | * @since 2.39 91 | */ 92 | public static ClaimRuleOperation getByValue(short value) 93 | { 94 | if (value < 1 || sValues.length < value) 95 | { 96 | // not found 97 | return null; 98 | } 99 | 100 | return sValues[value - 1]; 101 | } 102 | } -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/HskListResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /api/hsk/get/list} API. 21 | * 22 | * @since 2.97 23 | * @since Authlete 2.2.12 24 | */ 25 | public class HskListResponse extends ApiResponse 26 | { 27 | private static final long serialVersionUID = 1L; 28 | 29 | 30 | /** 31 | * The result of the API call. 32 | */ 33 | public enum Action 34 | { 35 | /** 36 | * The API call succeeded. 37 | */ 38 | SUCCESS, 39 | 40 | /** 41 | * The API call was wrong. 42 | */ 43 | INVALID_REQUEST, 44 | 45 | /** 46 | * An error occurred on Authlete side. 47 | */ 48 | SERVER_ERROR, 49 | } 50 | 51 | 52 | private Action action; 53 | private Hsk[] hsks; 54 | 55 | 56 | /** 57 | * Get the result of the API call. 58 | * 59 | * @return 60 | * The result of the API call. 61 | */ 62 | public Action getAction() 63 | { 64 | return action; 65 | } 66 | 67 | 68 | /** 69 | * Set the result of the API call. 70 | * 71 | * @param action 72 | * The result of the API call. 73 | * 74 | * @return 75 | * {@code this} object. 76 | */ 77 | public HskListResponse setAction(Action action) 78 | { 79 | this.action = action; 80 | 81 | return this; 82 | } 83 | 84 | 85 | /** 86 | * Get the information about the keys on the HSM. 87 | * 88 | * @return 89 | * Information about the keys. 90 | */ 91 | public Hsk[] getHsks() 92 | { 93 | return hsks; 94 | } 95 | 96 | 97 | /** 98 | * Set the information about the keys on the HSM. 99 | * 100 | * @param hsks 101 | * Information about the keys. 102 | * 103 | * @return 104 | * {@code this} object. 105 | */ 106 | public HskListResponse setHsks(Hsk[] hsks) 107 | { 108 | this.hsks = hsks; 109 | 110 | return this; 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/JoseUtils.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.util; 17 | 18 | 19 | import com.authlete.common.types.JWEAlg; 20 | 21 | 22 | /** 23 | * Utilities for JOSE (JavaScript Object Signing and Encryption). 24 | * 25 | * @author Takahiko Kawasaki 26 | */ 27 | public class JoseUtils 28 | { 29 | private JoseUtils() 30 | { 31 | } 32 | 33 | 34 | /** 35 | * Check whether the given JWE algorithm is supported by Authlete. 36 | * 37 | *

38 | * This method returns {@code true} when the given JWE algorithm 39 | * is one of the following. (All the algorithms listed in {@code 40 | * JWEAlg} are supported as of Dec. 15, 2015.) 41 | *

42 | * 43 | *
44 | *
    45 | *
  1. {@link JWEAlg#RSA1_5 RSA1_5} 46 | *
  2. {@link JWEAlg#RSA_OAEP RSA-OAEP} 47 | *
  3. {@link JWEAlg#RSA_OAEP_256 RSA-OAEP-256} 48 | *
  4. {@link JWEAlg#A128KW A128KW} 49 | *
  5. {@link JWEAlg#A192KW A192KW} 50 | *
  6. {@link JWEAlg#A256KW A256KW} 51 | *
  7. {@link JWEAlg#DIR dir} 52 | *
  8. {@link JWEAlg#ECDH_ES ECDH-ES} 53 | *
  9. {@link JWEAlg#ECDH_ES_A128KW ECDH-ES+A128KW} 54 | *
  10. {@link JWEAlg#ECDH_ES_A192KW ECDH-ES+A192KW} 55 | *
  11. {@link JWEAlg#ECDH_ES_A256KW ECDH-ES+A256KW} 56 | *
  12. {@link JWEAlg#A128GCMKW A128GCMKW} 57 | *
  13. {@link JWEAlg#A192GCMKW A192GCMKW} 58 | *
  14. {@link JWEAlg#A256GCMKW A256GCMKW} 59 | *
  15. {@link JWEAlg#PBES2_HS256_A128KW PBSE2-HS256-A128KW} 60 | *
  16. {@link JWEAlg#PBES2_HS384_A192KW PBSE2-HS384-A192KW} 61 | *
  17. {@link JWEAlg#PBES2_HS512_A256KW PBSE2-HS512-A256KW} 62 | *
63 | *
64 | * 65 | * @param alg 66 | * A JWE algorithm. 67 | * 68 | * @return 69 | * {@code true} if the given JWE algorithm is supported 70 | * by Authlete. {@code false} if the given JWE algorithm 71 | * is not supported by Authlete. When {@code null} is 72 | * given, this method returns {@code false}. 73 | */ 74 | public static boolean isSupported(JWEAlg alg) 75 | { 76 | // All the algorithms listed in JWEAlg are supported. 77 | return (alg != null); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /bin/authlete-cli.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # LICENSE 4 | # ------- 5 | # 6 | # Copyright (C) 2017 Authlete, Inc. 7 | # 8 | # Licensed under the Apache License, Version 2.0 (the "License"); 9 | # you may not use this file except in compliance with the License. 10 | # You may obtain a copy of the License at 11 | # 12 | # http://www.apache.org/licenses/LICENSE-2.0 13 | # 14 | # Unless required by applicable law or agreed to in writing, software 15 | # distributed under the License is distributed on an "AS IS" BASIS, 16 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | # See the License for the specific language governing permissions and 18 | # limitations under the License. 19 | # 20 | # 21 | # OVERVIEW 22 | # -------- 23 | # 24 | # Command line interface for Authlete API. 25 | # 26 | # 27 | # USAGE 28 | # ----- 29 | # 30 | # authlete-cli.sh [options] {API name} [arguments] 31 | # 32 | # 33 | # API NAME AND ARGUMENTS 34 | # ---------------------- 35 | # 36 | # getClient {clientId} 37 | # getClientAuthorizationList subject={subject} [developer={developer}] [start={start}] [end={end}] 38 | # getClientList [developer={developer}] [start={start}] [end={end}] 39 | # getService {serviceApiKey} 40 | # getServiceConfiguration [pretty={true|false}] 41 | # getServiceJwks [pretty={true|false}] [includePrivateKeys={true|false}] 42 | # getServiceList [start={start}] [end={end}] 43 | # 44 | # Note: API name is case-insensitive. 45 | # 46 | # 47 | # EXAMPLES 48 | # -------- 49 | # 50 | # $ bin/authlete-cli.sh getClient 4326385670 51 | # $ bin/authlete-cli.sh getClientAuthorizationList subject=authlete_5526908833 52 | # $ bin/authlete-cli.sh getClientList developer=authlete_5526908833 53 | # $ bin/authlete-cli.sh getService 5526908833 54 | # $ bin/authlete-cli.sh getServiceConfiguration pretty=true 55 | # $ bin/authlete-cli.sh getServiceJwks pretty=true includePrivateKeys=true 56 | # $ bin/authlete-cli.sh getServiceList start=1 57 | # 58 | # 59 | # NOTE 60 | # ---- 61 | # 62 | # "authlete.properties" must exist in the top directory. 63 | # 64 | 65 | 66 | #-------------------------------------------------- 67 | # Entry point 68 | #-------------------------------------------------- 69 | __main() 70 | { 71 | # Top directory of this source tree. 72 | local top_dir=$(dirname $(dirname $0)) 73 | 74 | # Move to the top directory. 75 | cd "${top_dir}" 76 | 77 | # Check if "authlete.properties" exists. 78 | if [ ! -e "authlete.properties" ]; then 79 | echo "ERROR: 'authlete.properties' file is not found." 80 | exit 1 81 | fi 82 | 83 | # Command line to execute. 84 | local command_line=(mvn -q exec:java -Dexec.args="$*") 85 | 86 | # Execute the command line. 87 | exec "${command_line[@]}" 88 | } 89 | 90 | 91 | #-------------------------------------------------- 92 | # S T A R T 93 | #-------------------------------------------------- 94 | __main "$@" 95 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthorizationTicketUpdateRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /auth/authorization/ticket/update} API. 24 | * 25 | *

26 | * The API is used to update information about a ticket that has been issued 27 | * from the {@code /auth/authorization} API. 28 | *

29 | * 30 | * @since 3.88 31 | * @since Authlete 3.0 32 | */ 33 | public class AuthorizationTicketUpdateRequest implements Serializable 34 | { 35 | private static final long serialVersionUID = 1L; 36 | 37 | 38 | /** 39 | * The ticket. 40 | */ 41 | private String ticket; 42 | 43 | 44 | /** 45 | * The information about the ticket. 46 | */ 47 | private AuthorizationTicketInfo info; 48 | 49 | 50 | /** 51 | * Get the ticket that has been issued from the {@code /auth/authorization} API. 52 | * 53 | * @return 54 | * The ticket. 55 | */ 56 | public String getTicket() 57 | { 58 | return ticket; 59 | } 60 | 61 | 62 | /** 63 | * Set the ticket that has been issued from the {@code /auth/authorization} API. 64 | * 65 | * @param ticket 66 | * The ticket. 67 | * 68 | * @return 69 | * {@code this} object. 70 | */ 71 | public AuthorizationTicketUpdateRequest setTicket(String ticket) 72 | { 73 | this.ticket = ticket; 74 | 75 | return this; 76 | } 77 | 78 | 79 | /** 80 | * Get the information about the ticket. 81 | * 82 | * @return 83 | * The information about the ticket. 84 | */ 85 | public AuthorizationTicketInfo getInfo() 86 | { 87 | return info; 88 | } 89 | 90 | 91 | /** 92 | * Set the information about the ticket. 93 | * 94 | * @param info 95 | * The information about the ticket. 96 | * 97 | * @return 98 | * {@code this} object. 99 | */ 100 | public AuthorizationTicketUpdateRequest setInfo(AuthorizationTicketInfo info) 101 | { 102 | this.info = info; 103 | 104 | return this; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/security/Utils.java: -------------------------------------------------------------------------------- 1 | package com.authlete.common.util.security; 2 | 3 | 4 | import java.io.UnsupportedEncodingException; 5 | import javax.crypto.spec.IvParameterSpec; 6 | import javax.crypto.spec.SecretKeySpec; 7 | 8 | 9 | /** 10 | * Utility methods for internal implementation. 11 | * 12 | * @author Takahiko Kawasaki 13 | * @since 4.23 14 | */ 15 | class Utils 16 | { 17 | private Utils() 18 | { 19 | } 20 | 21 | 22 | /** 23 | * Get bytes by {@code input.getBytes("UTF-8")}. 24 | */ 25 | public static byte[] getBytesUTF8(String string) 26 | { 27 | if (string == null) 28 | { 29 | return null; 30 | } 31 | 32 | try 33 | { 34 | // Convert the string to a byte array encoded in UTF-8. 35 | return string.getBytes("UTF-8"); 36 | } 37 | catch (UnsupportedEncodingException e) 38 | { 39 | // This won't happen. 40 | return null; 41 | } 42 | } 43 | 44 | 45 | /** 46 | * Build a {@code String} instance by {@code new String(input, "UTF-8")}. 47 | */ 48 | public static String toStringUTF8(byte[] input) 49 | { 50 | if (input == null) 51 | { 52 | return null; 53 | } 54 | 55 | try 56 | { 57 | return new String(input, "UTF-8"); 58 | } 59 | catch (UnsupportedEncodingException e) 60 | { 61 | // This won't happen. 62 | return null; 63 | } 64 | } 65 | 66 | 67 | public static byte[] ensureSize(byte[] data, int size) 68 | { 69 | if (data == null) 70 | { 71 | return new byte[size]; 72 | } 73 | 74 | if (size <= data.length) 75 | { 76 | return data; 77 | } 78 | 79 | byte[] data2 = new byte[size]; 80 | 81 | System.arraycopy(data, 0, data2, 0, data.length); 82 | 83 | return data2; 84 | } 85 | 86 | 87 | public static SecretKeySpec createSecretKeySpec(String key, String algorithm, int size) 88 | { 89 | return createSecretKeySpec(getBytesUTF8(key), algorithm, size); 90 | } 91 | 92 | 93 | public static SecretKeySpec createSecretKeySpec(byte[] key, String algorithm, int size) 94 | { 95 | key = ensureSize(key, size); 96 | 97 | return new SecretKeySpec(key, 0, size, algorithm); 98 | } 99 | 100 | 101 | public static IvParameterSpec createIvParameterSpec(String iv, int size) 102 | { 103 | return createIvParameterSpec(getBytesUTF8(iv), size); 104 | } 105 | 106 | 107 | public static IvParameterSpec createIvParameterSpec(byte[] iv, int size) 108 | { 109 | iv = ensureSize(iv, size); 110 | 111 | return new IvParameterSpec(iv, 0, size); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/SnsCredentials.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | import com.authlete.common.types.Sns; 21 | 22 | 23 | /** 24 | * SNS credentials (API key and API secret). 25 | * 26 | * @author Takahiko Kawasaki 27 | * 28 | * @since 1.3 29 | */ 30 | public class SnsCredentials implements Serializable 31 | { 32 | private static final long serialVersionUID = 1L; 33 | 34 | 35 | private Sns sns; 36 | private String apiKey; 37 | private String apiSecret; 38 | 39 | 40 | /** 41 | * Get the SNS. 42 | * 43 | * @return 44 | * The SNS. 45 | */ 46 | public Sns getSns() 47 | { 48 | return sns; 49 | } 50 | 51 | 52 | /** 53 | * Set the SNS. 54 | * 55 | * @param sns 56 | * The SNS. 57 | * 58 | * @return 59 | * {@code this} object. 60 | */ 61 | public SnsCredentials setSns(Sns sns) 62 | { 63 | this.sns = sns; 64 | 65 | return this; 66 | } 67 | 68 | 69 | /** 70 | * Get the API key. 71 | * 72 | * @return 73 | * The API key. 74 | */ 75 | public String getApiKey() 76 | { 77 | return apiKey; 78 | } 79 | 80 | 81 | /** 82 | * Set the API key. 83 | * 84 | * @param apiKey 85 | * The API key. 86 | * 87 | * @return 88 | * {@code this} object. 89 | */ 90 | public SnsCredentials setApiKey(String apiKey) 91 | { 92 | this.apiKey = apiKey; 93 | 94 | return this; 95 | } 96 | 97 | 98 | /** 99 | * Get the API secret. 100 | * 101 | * @return 102 | * The API secret. 103 | */ 104 | public String getApiSecret() 105 | { 106 | return apiSecret; 107 | } 108 | 109 | 110 | /** 111 | * Set the API secret. 112 | * 113 | * @param apiSecret 114 | * The API secret. 115 | * 116 | * @return 117 | * {@code this} object. 118 | */ 119 | public SnsCredentials setApiSecret(String apiSecret) 120 | { 121 | this.apiSecret = apiSecret; 122 | 123 | return this; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/BaseJsonDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.util; 17 | 18 | 19 | import com.google.gson.JsonArray; 20 | import com.google.gson.JsonElement; 21 | import com.google.gson.JsonObject; 22 | 23 | 24 | /** 25 | * The base class for implementations of 26 | * {@link com.google.gson.JsonDeserializer JsonDeserializer}. 27 | * 28 | * @since 2.57 29 | */ 30 | public class BaseJsonDeserializer 31 | { 32 | public JsonElement getFromObject(JsonObject jobject, String name) 33 | { 34 | JsonElement jelement = jobject.get(name); 35 | 36 | if (jelement == null || jelement.isJsonNull()) 37 | { 38 | return null; 39 | } 40 | 41 | return jelement; 42 | } 43 | 44 | 45 | public String getAsStringFromObject(JsonObject jobject, String name) 46 | { 47 | JsonElement jelement = getFromObject(jobject, name); 48 | 49 | if (jelement == null) 50 | { 51 | return null; 52 | } 53 | 54 | return jelement.getAsString(); 55 | } 56 | 57 | 58 | public String getAsStringFromArray(JsonArray jarray, int index) 59 | { 60 | JsonElement jelement = jarray.get(index); 61 | 62 | if (jelement == null || jelement.isJsonNull()) 63 | { 64 | return null; 65 | } 66 | 67 | return jelement.getAsString(); 68 | } 69 | 70 | 71 | public JsonArray getAsArrayFromObject(JsonObject jobject, String name) 72 | { 73 | JsonElement jelement = getFromObject(jobject, name); 74 | 75 | if (jelement == null) 76 | { 77 | return null; 78 | } 79 | 80 | return jelement.getAsJsonArray(); 81 | } 82 | 83 | 84 | public String[] getAsStringArrayFromObject(JsonObject jobject, String name) 85 | { 86 | JsonArray jarray = getAsArrayFromObject(jobject, name); 87 | 88 | if (jarray == null) 89 | { 90 | return null; 91 | } 92 | 93 | int size = jarray.size(); 94 | String[] array = new String[size]; 95 | 96 | for (int i = 0; i < size; ++i) 97 | { 98 | array[i] = getAsStringFromArray(jarray, i); 99 | } 100 | 101 | return array; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/api/ConnectionContext.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.api; 17 | 18 | 19 | import java.io.Closeable; 20 | import java.io.IOException; 21 | import java.io.InputStream; 22 | import java.io.OutputStream; 23 | import java.net.HttpURLConnection; 24 | 25 | 26 | class ConnectionContext 27 | { 28 | private final HttpURLConnection mCon; 29 | private InputStream mIn; 30 | private OutputStream mOut; 31 | private InputStream mErr; 32 | 33 | 34 | public ConnectionContext(HttpURLConnection connection) 35 | { 36 | mCon = connection; 37 | } 38 | 39 | 40 | public HttpURLConnection connection() 41 | { 42 | return mCon; 43 | } 44 | 45 | 46 | public int contentLength() 47 | { 48 | return mCon.getContentLength(); 49 | } 50 | 51 | 52 | public void property(String key, String value) 53 | { 54 | mCon.setRequestProperty(key, value); 55 | } 56 | 57 | 58 | public void doOutput(boolean dooutput) 59 | { 60 | mCon.setDoOutput(dooutput); 61 | } 62 | 63 | 64 | public InputStream inputStream() throws IOException 65 | { 66 | if (mIn == null) 67 | { 68 | mIn = mCon.getInputStream(); 69 | } 70 | 71 | return mIn; 72 | } 73 | 74 | 75 | public OutputStream outputStream() throws IOException 76 | { 77 | if (mOut == null) 78 | { 79 | mOut = mCon.getOutputStream(); 80 | } 81 | 82 | return mOut; 83 | } 84 | 85 | 86 | public InputStream errorStream() 87 | { 88 | if (mErr == null) 89 | { 90 | mErr = mCon.getErrorStream(); 91 | } 92 | 93 | return mErr; 94 | } 95 | 96 | 97 | public void close() 98 | { 99 | closeQuietly(mIn); 100 | closeQuietly(mOut); 101 | closeQuietly(mErr); 102 | } 103 | 104 | 105 | private static void closeQuietly(Closeable closeable) 106 | { 107 | if (closeable == null) 108 | { 109 | return; 110 | } 111 | 112 | try 113 | { 114 | closeable.close(); 115 | } 116 | catch (IOException e) 117 | { 118 | // Ignored. 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/assurance/EvidenceArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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.common.assurance; 18 | 19 | 20 | import java.util.ArrayList; 21 | import java.util.List; 22 | import java.util.Map; 23 | 24 | 25 | /** 26 | * The class that represents {@code verified_claims/verification/evidence}. 27 | * 28 | * @see OpenID Connect for Identity Assurance 1.0 30 | * 31 | * @since 2.63 32 | */ 33 | public class EvidenceArray extends ArrayList 34 | { 35 | private static final long serialVersionUID = 1L; 36 | 37 | 38 | /** 39 | * Create an {@code EvidenceArray} instance from an object in the given map. 40 | * 41 | * @param map 42 | * A map that may contain {@code "evidence"}. 43 | * 44 | * @param key 45 | * The key that identifies the object in the map. In normal cases, 46 | * the key is {@code "evidence"}. 47 | * 48 | * @return 49 | * An {@code EvidenceArray} instance that represents {@code "evidence"}. 50 | * If the map does not contain the given key, null is returned. 51 | * 52 | * @throws IdentityAssuranceException 53 | * The structure of the map does not conform to the specification 54 | * (OpenID Connect for Identity Assurance 1.0). 56 | */ 57 | public static EvidenceArray extract(Map map, String key) throws IdentityAssuranceException 58 | { 59 | Object object = map.get(key); 60 | 61 | if (object == null) 62 | { 63 | return null; 64 | } 65 | 66 | EvidenceArray instance = new EvidenceArray(); 67 | 68 | fill(instance, object, key); 69 | 70 | return instance; 71 | } 72 | 73 | 74 | private static void fill(EvidenceArray instance, Object object, String key) 75 | { 76 | List list = Helper.ensureList(object, key); 77 | int size = list.size(); 78 | 79 | // "minItems": 1 80 | if (size < 1) 81 | { 82 | throw Helper.exception("'%s' is empty.", key); 83 | } 84 | 85 | for (int i = 0; i < size; ++i) 86 | { 87 | instance.add(Evidence.extract(list, i, key)); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/HskResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /api/hsk/create} API, 21 | * /api/hsk/delete/{handle} API and 22 | * /api/hsk/get/{handle} API. 23 | * 24 | * @since 2.97 25 | * @since Authlete 2.2.12 26 | */ 27 | public class HskResponse extends ApiResponse 28 | { 29 | private static final long serialVersionUID = 1L; 30 | 31 | 32 | /** 33 | * The result of the API call. 34 | */ 35 | public enum Action 36 | { 37 | /** 38 | * The API call succeeded. 39 | */ 40 | SUCCESS, 41 | 42 | /** 43 | * The API call was wrong. 44 | */ 45 | INVALID_REQUEST, 46 | 47 | /** 48 | * There is no record that corresponds to the specified handle. 49 | */ 50 | NOT_FOUND, 51 | 52 | /** 53 | * An error occurred on Authlete side. 54 | */ 55 | SERVER_ERROR, 56 | } 57 | 58 | 59 | private Action action; 60 | private Hsk hsk; 61 | 62 | 63 | /** 64 | * Get the result of the API call. 65 | * 66 | * @return 67 | * The result of the API call. 68 | */ 69 | public Action getAction() 70 | { 71 | return action; 72 | } 73 | 74 | 75 | /** 76 | * Set the result of the API call. 77 | * 78 | * @param action 79 | * The result of the API call. 80 | * 81 | * @return 82 | * {@code this} object. 83 | */ 84 | public HskResponse setAction(Action action) 85 | { 86 | this.action = action; 87 | 88 | return this; 89 | } 90 | 91 | 92 | /** 93 | * Get the information about the key on the HSM. 94 | * 95 | * @return 96 | * Information about the key. 97 | */ 98 | public Hsk getHsk() 99 | { 100 | return hsk; 101 | } 102 | 103 | 104 | /** 105 | * Set the information about the key on the HSM. 106 | * 107 | * @param hsk 108 | * Information about the key. 109 | * 110 | * @return 111 | * {@code this} object. 112 | */ 113 | public HskResponse setHsk(Hsk hsk) 114 | { 115 | this.hsk = hsk; 116 | 117 | return this; 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthzDetailsElementDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019-2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.lang.reflect.Type; 20 | import com.authlete.common.util.BaseJsonDeserializer; 21 | import com.google.gson.JsonDeserializationContext; 22 | import com.google.gson.JsonDeserializer; 23 | import com.google.gson.JsonElement; 24 | import com.google.gson.JsonObject; 25 | import com.google.gson.JsonParseException; 26 | 27 | 28 | /** 29 | * JSON deserializer for {@link AuthzDetailsElement}. 30 | * 31 | *

32 | * Other fields than the independent fields such as {@code type} and 33 | * {@code locations} are packed into one {@code otherFields} string. 34 | *

35 | * 36 | * @since 2.57 37 | */ 38 | public class AuthzDetailsElementDeserializer extends BaseJsonDeserializer 39 | implements JsonDeserializer 40 | { 41 | private static String[] INDEPENDENT_FIELDS = new String[] { 42 | "type", "locations", "actions", "datatypes", "identifier", "privileges" 43 | }; 44 | 45 | 46 | @Override 47 | public AuthzDetailsElement deserialize( 48 | JsonElement jelement, Type type, JsonDeserializationContext context) throws JsonParseException 49 | { 50 | if (jelement == null || jelement.isJsonNull()) 51 | { 52 | return null; 53 | } 54 | 55 | JsonObject jobject = jelement.getAsJsonObject(); 56 | 57 | return new AuthzDetailsElement() 58 | .setType(getAsStringFromObject(jobject, "type")) 59 | .setLocations(getAsStringArrayFromObject(jobject, "locations")) 60 | .setActions(getAsStringArrayFromObject(jobject, "actions")) 61 | .setDataTypes(getAsStringArrayFromObject(jobject, "datatypes")) 62 | .setIdentifier(getAsStringFromObject(jobject, "identifier")) 63 | .setPrivileges(getAsStringArrayFromObject(jobject, "privileges")) 64 | .setOtherFields(getOtherFieldsFromObject(jobject)) 65 | ; 66 | } 67 | 68 | 69 | private static String getOtherFieldsFromObject(JsonObject jobject) 70 | { 71 | JsonObject copy = jobject.deepCopy(); 72 | 73 | for (String name : INDEPENDENT_FIELDS) 74 | { 75 | copy.remove(name); 76 | } 77 | 78 | if (copy.size() == 0) 79 | { 80 | return null; 81 | } 82 | 83 | return copy.toString(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/Pair.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * A pair of a string key and a string value. 24 | * 25 | *

26 | * {@code java.util.AbstractMap.SimpleEntry} class provides the same 27 | * functionality in a more generic way, but the class is not available 28 | * in Java SE 1.5. 29 | *

30 | * 31 | * @since 1.39 32 | * 33 | * @author Takahiko Kawasaki 34 | */ 35 | public class Pair implements Serializable 36 | { 37 | private static final long serialVersionUID = 1L; 38 | 39 | 40 | private String key; 41 | private String value; 42 | 43 | 44 | /** 45 | * Constructor with a {@code null} key and a {@code null} value. 46 | */ 47 | public Pair() 48 | { 49 | this(null, null); 50 | } 51 | 52 | 53 | /** 54 | * Constructor with an initial key and an initial value. 55 | * 56 | * @param key 57 | * The initial value of the key. 58 | * 59 | * @param value 60 | * The initial value of the value. 61 | */ 62 | public Pair(String key, String value) 63 | { 64 | this.key = key; 65 | this.value = value; 66 | } 67 | 68 | 69 | /** 70 | * Get the key of this pair. 71 | * 72 | * @return 73 | * The key. 74 | */ 75 | public String getKey() 76 | { 77 | return key; 78 | } 79 | 80 | 81 | /** 82 | * Set the key of this pair. 83 | * 84 | * @param key 85 | * The key. 86 | * 87 | * @return 88 | * {@code this} object. 89 | */ 90 | public Pair setKey(String key) 91 | { 92 | this.key = key; 93 | 94 | return this; 95 | } 96 | 97 | 98 | /** 99 | * Get the value of this pair. 100 | * 101 | * @return 102 | * The value. 103 | */ 104 | public String getValue() 105 | { 106 | return value; 107 | } 108 | 109 | 110 | /** 111 | * Set the value of this pair. 112 | * 113 | * @param value 114 | * The value. 115 | * 116 | * @return 117 | * {@code this} object. 118 | */ 119 | public Pair setValue(String value) 120 | { 121 | this.value = value; 122 | 123 | return this; 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/EnumHelper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | import java.util.EnumSet; 20 | 21 | 22 | abstract class EnumHelper> 23 | { 24 | private final Class mClass; 25 | private final TEnum[] mValues; 26 | 27 | 28 | public EnumHelper(Class enumClass, TEnum[] enumValues) 29 | { 30 | mClass = enumClass; 31 | mValues = enumValues; 32 | } 33 | 34 | 35 | public int toBits(TEnum[] array) 36 | { 37 | if (array == null) 38 | { 39 | return 0; 40 | } 41 | 42 | int bits = 0; 43 | 44 | for (TEnum entry : array) 45 | { 46 | bits |= (1 << getValue(entry)); 47 | } 48 | 49 | return bits; 50 | } 51 | 52 | 53 | public int toBits(EnumSet set) 54 | { 55 | if (set == null) 56 | { 57 | return 0; 58 | } 59 | 60 | int bits = 0; 61 | 62 | for (TEnum entry : set) 63 | { 64 | bits |= (1 << getValue(entry)); 65 | } 66 | 67 | return bits; 68 | } 69 | 70 | 71 | public TEnum[] toArray(int bits) 72 | { 73 | return toArray(toSet(bits)); 74 | } 75 | 76 | 77 | public TEnum[] toArray(EnumSet set) 78 | { 79 | if (set == null) 80 | { 81 | return null; 82 | } 83 | 84 | return set.toArray(newArray(set.size())); 85 | } 86 | 87 | 88 | public EnumSet toSet(int bits) 89 | { 90 | EnumSet set = EnumSet.noneOf(mClass); 91 | 92 | for (TEnum entry : mValues) 93 | { 94 | if ((bits & (1 << getValue(entry))) != 0) 95 | { 96 | set.add(entry); 97 | } 98 | } 99 | 100 | return set; 101 | } 102 | 103 | 104 | public EnumSet toSet(TEnum[] array) 105 | { 106 | if (array == null) 107 | { 108 | return null; 109 | } 110 | 111 | EnumSet set = EnumSet.noneOf(mClass); 112 | 113 | for (TEnum entry : array) 114 | { 115 | set.add(entry); 116 | } 117 | 118 | return set; 119 | } 120 | 121 | 122 | protected abstract short getValue(TEnum entry); 123 | protected abstract TEnum[] newArray(int size); 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ClientAuthorizationDeleteRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's /api/client/authorization/delete/{clientId} API. 24 | * 25 | *
26 | *
27 | *
subject
28 | *
29 | *

30 | * The subject (= unique identifier) of the end-user who has granted authorization 31 | * to the client application. 32 | *

33 | *
34 | *
35 | *
36 | * 37 | * @author Takahiko Kawasaki 38 | * 39 | * @since 2.1 40 | */ 41 | public class ClientAuthorizationDeleteRequest implements Serializable 42 | { 43 | private static final long serialVersionUID = 1L; 44 | 45 | 46 | private String subject; 47 | 48 | 49 | /** 50 | * The default constructor. 51 | * 52 | *

53 | * Because the {@code subject} parameter is mandatory for 54 | * /api/client/authorization/delete/{clientId} API, 55 | * a non-null value should be set using {@link #setSubject(String)} 56 | * method later. 57 | *

58 | */ 59 | public ClientAuthorizationDeleteRequest() 60 | { 61 | } 62 | 63 | 64 | /** 65 | * A constructor with a subject value. 66 | * 67 | * @param subject 68 | * The subject (= unique identifier) of the end-user. 69 | */ 70 | public ClientAuthorizationDeleteRequest(String subject) 71 | { 72 | this.subject = subject; 73 | } 74 | 75 | 76 | /** 77 | * Get the subject (= unique identifier) of the end-user who has granted 78 | * authorization to the client application. 79 | * 80 | * @return 81 | * The subject (= unique identifier) of the end-user. 82 | */ 83 | public String getSubject() 84 | { 85 | return subject; 86 | } 87 | 88 | 89 | /** 90 | * Set the subject (= unique identifier) of the end-user who has granted 91 | * authorization to the client application. 92 | * 93 | * @param subject 94 | * The subject (= unique identifier) of the end-user. 95 | * 96 | * @return 97 | * {@code this} object. 98 | */ 99 | public ClientAuthorizationDeleteRequest setSubject(String subject) 100 | { 101 | this.subject = subject; 102 | 103 | return this; 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/User.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016-2019 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.common.types; 18 | 19 | 20 | /** 21 | * An interface that represents a resource owner (in the context of 22 | * OAuth 2.0) or 23 | * an end user (in the context of OpenID Connect). 25 | * 26 | * @since 1.26 27 | * 28 | * @author Takahiko Kawasaki 29 | */ 30 | public interface User 31 | { 32 | /** 33 | * Get the subject (= unique identifier) of the user. 34 | * 35 | * @return 36 | * The subject (= unique identifier) of the user. 37 | */ 38 | String getSubject(); 39 | 40 | 41 | /** 42 | * Get the value of a claim of the user. 43 | * 44 | * @param claimName 45 | * A claim name such as {@code name} and {@code family_name}. 46 | * Standard claim names are listed in "5.1. Standard Claims" of OpenID 50 | * Connect Core 1.0. Java constant values that represent the 51 | * standard claims are listed in {@link com.authlete.common.types.StandardClaims 52 | * StandardClaims} class. 53 | * 54 | * @param languageTag 55 | * A language tag such as {@code en} and {@code ja}. Implementations 56 | * should take this into account whenever possible. See "5.2. Claims Languages and Scripts" in OpenID 60 | * Connect Core 1.0 for details. 61 | * 62 | * @return 63 | * The claim value. {@code null} if the claim value of the claim 64 | * is not available. 65 | */ 66 | Object getClaim(String claimName, String languageTag); 67 | 68 | 69 | /** 70 | * Get the value of an attribute of the user. 71 | * 72 | * @param attributeName 73 | * An attribute name. 74 | * 75 | * @return 76 | * The attribute value. {@code null} if the attribute value of the 77 | * attribute is not available. 78 | * 79 | * @since 2.33 80 | */ 81 | Object getAttribute(String attributeName); 82 | } 83 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/util/security/StandardCipherTransformations.java: -------------------------------------------------------------------------------- 1 | package com.authlete.common.util.security; 2 | 3 | 4 | /** 5 | * List of standard cipher transformations which are valid as 6 | * arguments for {@link javax.crypto.Cipher#getInstance(String)}. 7 | * 8 | *

9 | * The list here is a copy from Java SE 7 JavaDoc. Therefore, 10 | * they may not be supported in older Java SE environments. 11 | *

12 | * 13 | * @see javax.crypto.Cipher 15 | * 16 | * @author Takahiko Kawasaki 17 | * @since 4.23 18 | */ 19 | public class StandardCipherTransformations 20 | { 21 | /** 22 | * AES/CBC/NoPadding (128) 23 | */ 24 | public static final String AES_CBC_NOPADDING = "AES/CBC/NoPadding"; 25 | 26 | 27 | /** 28 | * AES/CBC/PKCS5Padding (128) 29 | */ 30 | public static final String AES_CBC_PKCS5PADDING = "AES/CBC/PKCS5Padding"; 31 | 32 | 33 | /** 34 | * AES/ECB/NoPadding (128) 35 | */ 36 | public static final String AES_ECB_NOPADDING = "AES/ECB/NoPadding"; 37 | 38 | 39 | /** 40 | * AES/ECB/PKCS5Padding (128) 41 | */ 42 | public static final String AES_ECB_PKCS5PADDING = "AES/ECB/PKCS5Padding"; 43 | 44 | 45 | /** 46 | * DES/CBC/NoPadding (56) 47 | */ 48 | public static final String DES_CBC_NOPADDING = "DES/CBC/NoPadding"; 49 | 50 | 51 | /** 52 | * DES/CBC/PKCS5Padding (56) 53 | */ 54 | public static final String DES_CBC_PKCS5PADDING = "DES/CBC/PKCS5Padding"; 55 | 56 | 57 | /** 58 | * DES/ECB/NoPadding (56) 59 | */ 60 | public static final String DES_ECB_NOPADDING = "DES/ECB/NoPadding"; 61 | 62 | 63 | /** 64 | * DES/ECB/PKCS5Padding (56) 65 | */ 66 | public static final String DES_ECB_PKCS5PADDING = "DES/ECB/PKCS5Padding"; 67 | 68 | 69 | /** 70 | * DESede/CBC/NoPadding (168) 71 | */ 72 | public static final String DESEDE_CBC_NOPADDING = "DESede/CBC/NoPadding"; 73 | 74 | 75 | /** 76 | * DESede/CBC/PKCS5Padding (168) 77 | */ 78 | public static final String DESEDE_CBC_PKCS5PADDING = "DESede/CBC/PKCS5Padding"; 79 | 80 | 81 | /** 82 | * DESede/ECB/NoPadding (168) 83 | */ 84 | public static final String DESEDE_ECB_NOPADDING = "DESede/ECB/NoPadding"; 85 | 86 | 87 | /** 88 | * DESede/ECB/PKCS5Padding (168) 89 | */ 90 | public static final String DESEDE_ECB_PKCS5PADDING = "DESede/ECB/PKCS5Padding"; 91 | 92 | 93 | /** 94 | * RSA/ECB/PKCS1Padding (1024, 2048) 95 | */ 96 | public static final String RSA_ECB_PKCS1PADDING = "RSA/ECB/PKCS1Padding"; 97 | 98 | 99 | /** 100 | * RSA/ECB/OAEPWithSHA-1AndMGF1Padding (1024, 2048) 101 | */ 102 | public static final String RSA_ECB_OAEPWITHSHA1ANDMGF1PADDING = "RSA/ECB/OAEPWithSHA-1AndMGF1Padding"; 103 | 104 | 105 | /** 106 | * RSA/ECB/OAEPWithSHA-256AndMGF1Padding (1024, 2048) 107 | */ 108 | public static final String RSA_ECB_OAEPWITHSHA256ANDMGF1PADDING = "RSA/ECB/OAEPWithSHA-256AndMGF1Padding"; 109 | 110 | 111 | private StandardCipherTransformations() 112 | { 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/GrantDeserializer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.lang.reflect.Type; 20 | import com.authlete.common.util.BaseJsonDeserializer; 21 | import com.google.gson.Gson; 22 | import com.google.gson.JsonArray; 23 | import com.google.gson.JsonDeserializationContext; 24 | import com.google.gson.JsonDeserializer; 25 | import com.google.gson.JsonElement; 26 | import com.google.gson.JsonObject; 27 | import com.google.gson.JsonParseException; 28 | 29 | 30 | /** 31 | * JSON deserializer for {@link Grant}. 32 | * 33 | * @since 3.1 34 | */ 35 | public class GrantDeserializer extends BaseJsonDeserializer 36 | implements JsonDeserializer 37 | { 38 | @Override 39 | public Grant deserialize( 40 | JsonElement jelement, Type type, JsonDeserializationContext context) throws JsonParseException 41 | { 42 | if (jelement == null || jelement.isJsonNull()) 43 | { 44 | return null; 45 | } 46 | 47 | JsonObject jGrant = jelement.getAsJsonObject(); 48 | 49 | // Object to set up. 50 | Grant grant = new Grant(); 51 | 52 | // scopes 53 | addScopes(jGrant, grant); 54 | 55 | // claims 56 | addClaims(jGrant, grant); 57 | 58 | // authorizationDetails 59 | addAuthorizationDetails(jGrant, grant); 60 | 61 | return grant; 62 | } 63 | 64 | 65 | private void addScopes(JsonObject jGrant, Grant grant) 66 | { 67 | JsonArray jScopes = getAsArrayFromObject(jGrant, "scopes"); 68 | 69 | if (jScopes == null || jScopes.isJsonNull()) 70 | { 71 | return; 72 | } 73 | 74 | int size = jScopes.size(); 75 | GrantScope[] scopes = new GrantScope[size]; 76 | 77 | Gson gson = new Gson(); 78 | 79 | for (int i = 0; i < size; ++i) 80 | { 81 | scopes[i] = gson.fromJson(jScopes.get(i), GrantScope.class); 82 | } 83 | 84 | grant.setScopes(scopes); 85 | } 86 | 87 | 88 | private void addClaims(JsonObject jGrant, Grant grant) 89 | { 90 | String[] claims = getAsStringArrayFromObject(jGrant, "claims"); 91 | 92 | grant.setClaims(claims); 93 | } 94 | 95 | 96 | private void addAuthorizationDetails(JsonObject jGrant, Grant grant) 97 | { 98 | AuthzDetails details = new AuthzDetailsDeserializer().deserialize( 99 | getAsArrayFromObject(jGrant, "authorization_details"), null, null); 100 | 101 | grant.setAuthorizationDetails(details); 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/TrustAnchor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2022-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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | import java.net.URI; 21 | 22 | 23 | /** 24 | * Trust anchor. 25 | * 26 | * @since 3.22 27 | * 28 | * @see OpenID Federation 1.0 30 | */ 31 | public class TrustAnchor implements Serializable 32 | { 33 | private static final long serialVersionUID = 1L; 34 | 35 | 36 | /** 37 | * The entity ID of the trust anchor. 38 | */ 39 | private URI entityId; 40 | 41 | 42 | /** 43 | * The JWK Set document containing public keys of the trust anchor. 44 | */ 45 | private String jwks; 46 | 47 | 48 | /** 49 | * Get the entity ID of the trust anchor. 50 | * 51 | * @return 52 | * The entity ID. 53 | */ 54 | public URI getEntityId() 55 | { 56 | return entityId; 57 | } 58 | 59 | 60 | /** 61 | * Set the entity ID of the trust anchor. 62 | * 63 | * @param entityId 64 | * The entity ID. 65 | * 66 | * @return 67 | * {@code this} object. 68 | */ 69 | public TrustAnchor setEntityId(URI entityId) 70 | { 71 | this.entityId = entityId; 72 | 73 | return this; 74 | } 75 | 76 | 77 | /** 78 | * Get the JWK Set document containing public keys of the trust anchor. 79 | * 80 | *

81 | * The keys are used to verify signatures of entity statements issued 82 | * by the trust anchor. 83 | *

84 | * 85 | * @return 86 | * The JWK Set document containing public keys of the trust anchor. 87 | * 88 | * @see RFC 7517 JSON Web Key (JWK) 90 | */ 91 | public String getJwks() 92 | { 93 | return jwks; 94 | } 95 | 96 | 97 | /** 98 | * Set the JWK Set document containing public keys of the trust anchor. 99 | * 100 | *

101 | * The keys are used to verify signatures of entity statements issued 102 | * by the trust anchor. 103 | *

104 | * 105 | * @param jwks 106 | * The JWK Set document containing public keys of the trust anchor. 107 | * 108 | * @return 109 | * {@code this} object. 110 | * 111 | * @see RFC 7517 JSON Web Key (JWK) 113 | */ 114 | public TrustAnchor setJwks(String jwks) 115 | { 116 | this.jwks = jwks; 117 | 118 | return this; 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/StringArray.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * A class that holds a string array. 24 | * 25 | *

26 | * MOXy, a JSON processor, had a critical bug. It could not process 27 | * multidimensional arrays. The bug was reported as "Bug 389815 29 | * - Enhancement Request - JSON specific multidimensional array support" 30 | * on September 18, 2012. The PR which fixed the bug was PR 417. 32 | * The PR was merged on June 14, 2019. 33 | *

34 | * 35 | *

36 | * Because MOXy was adopted as the default JSON processor for GrassFish 4 37 | * ("MOXy is the New Default JSON-Binding Provider in GlassFish 4"), 39 | * the range of influence of the bug expanded. Developers had to avoid using 40 | * multidimensional arrays when they used GlassFish. 41 | *

42 | * 43 | *

44 | * The PR for the bug was merged in June 2019 (about two years and five months 45 | * ago as of this writing), but it is not an easy task to clean up dependencies 46 | * on the old buggy MOXy implementation. We still have to avoid using 47 | * multidimensional arrays. 48 | *

49 | * 50 | * @since 3.8 51 | */ 52 | public class StringArray implements Serializable 53 | { 54 | private static final long serialVersionUID = 1L; 55 | 56 | 57 | private String[] array; 58 | 59 | 60 | /** 61 | * The default constructor. 62 | */ 63 | public StringArray() 64 | { 65 | } 66 | 67 | 68 | /** 69 | * A constructor with the initial value of string array this instance holds. 70 | * 71 | * @param array 72 | * A string array. 73 | */ 74 | public StringArray(String[] array) 75 | { 76 | this.array = array; 77 | } 78 | 79 | 80 | /** 81 | * Get the string array this instance holds. 82 | * 83 | * @return 84 | * The string array. 85 | */ 86 | public String[] getArray() 87 | { 88 | return array; 89 | } 90 | 91 | 92 | /** 93 | * Set a string array to let this instance hold. 94 | * 95 | * @param array 96 | * A string array. 97 | * 98 | * @return 99 | * {@code this} object. 100 | */ 101 | public StringArray setArray(String[] array) 102 | { 103 | this.array = array; 104 | 105 | return this; 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialJwtIssuerMetadataRequest.java: -------------------------------------------------------------------------------- 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to Authlete's {@code /vci/jwtissuer} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be called from within the implementation of 27 | * the JWT VC issuer metadata endpoint ({@code /.well-known/jwt-vc-issuer}) of 28 | * the credential issuer. 29 | *

30 | * 31 | *

32 | * The API will generate JSON like below. 33 | *

34 | * 35 | *
36 | *
 37 |  * {
 38 |  *   "issuer": "{@link Service}.{@link Service#getCredentialIssuerMetadata()
 39 |  *              getCredentialIssuerMetadata()}.{@link CredentialIssuerMetadata#getCredentialIssuer()
 40 |  *              getCredentialIssuer()}",
 41 |  *   "jwks_uri": "{@link Service}.{@link Service#getCredentialJwksUri()
 42 |  *              getCredentialJwksUri()}"
 43 |  * }
 44 |  * 
45 | *
46 | * 47 | *

48 | * Note that the JWT VC issuer metadata endpoint ({@code /.well-known/jwt-vc-issuer}) 49 | * is different from the credential issuer metadata endpoint 50 | * ({@code /.well-known/openid-credential-issuer}). 51 | *

52 | * 53 | *

54 | * NOTE: The well-known path has been changed from {@code /.well-known/jwt-issuer} 55 | * to {@code /.well-known/jwt-vc-issuer} by a breaking change of the SD-JWT VC 56 | * specification. 57 | *

58 | * 59 | * @since 3.79 60 | * @since Authlete 3.0 61 | * 62 | * @see CredentialJwtIssuerMetadataResponse 63 | * @see SD-JWT-based Verifiable Credentials (SD-JWT VC) 65 | */ 66 | public class CredentialJwtIssuerMetadataRequest implements Serializable 67 | { 68 | private static final long serialVersionUID = 1L; 69 | 70 | 71 | private boolean pretty; 72 | 73 | 74 | /** 75 | * Get the flag indicating whether the metadata is written in the pretty 76 | * format or not. 77 | * 78 | * @return 79 | * {@code true} if the metadata is written in the pretty format. 80 | */ 81 | public boolean isPretty() 82 | { 83 | return pretty; 84 | } 85 | 86 | 87 | /** 88 | * Set the flag indicating whether the metadata is written in the pretty 89 | * format or not. 90 | * 91 | * @param pretty 92 | * {@code true} to write the metadata in the pretty format. 93 | * 94 | * @return 95 | * {@code this} object. 96 | */ 97 | public CredentialJwtIssuerMetadataRequest setPretty(boolean pretty) 98 | { 99 | this.pretty = pretty; 100 | 101 | return this; 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ApiResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | import java.util.List; 21 | import java.util.Map; 22 | 23 | 24 | /** 25 | * The base class of an API response from an Authlete API call. 26 | * 27 | * @author Takahiko Kawasaki 28 | * @since Authlete 1.1 29 | */ 30 | public class ApiResponse implements Serializable 31 | { 32 | private static final long serialVersionUID = 1L; 33 | 34 | 35 | private String resultCode; 36 | private String resultMessage; 37 | private Map> responseHeaders; 38 | 39 | 40 | /** 41 | * Get the code of the result of an Authlete API call. 42 | * 43 | * @return 44 | * The result code. For example, "A004001". 45 | */ 46 | public String getResultCode() 47 | { 48 | return resultCode; 49 | } 50 | 51 | 52 | /** 53 | * Set the code of the result of an Authlete API call. 54 | * 55 | * @param code 56 | * The result code. 57 | */ 58 | public void setResultCode(String code) 59 | { 60 | this.resultCode = code; 61 | } 62 | 63 | 64 | /** 65 | * Get the message of the result of an Authlete API call. 66 | * 67 | * @return 68 | * The result message. For example, 69 | * "[A001202] /client/get/list, Authorization header is missing." 70 | */ 71 | public String getResultMessage() 72 | { 73 | return resultMessage; 74 | } 75 | 76 | 77 | /** 78 | * Set the message of the result of an Authlete API call. 79 | * 80 | * @param message 81 | * The result message. 82 | */ 83 | public void setResultMessage(String message) 84 | { 85 | this.resultMessage = message; 86 | } 87 | 88 | 89 | /** 90 | * Get the HTTP response headers returned from an Authlete API call. 91 | * 92 | * @return 93 | * A map of HTTP response headers. May be {@code null} or empty. 94 | * 95 | * @since 4.23 96 | */ 97 | public Map> getResponseHeaders() 98 | { 99 | return responseHeaders; 100 | } 101 | 102 | 103 | /** 104 | * Set the HTTP response headers returned from an Authlete API call. 105 | * 106 | * @param responseHeaders 107 | * A map of HTTP response headers where each key is a header name 108 | * and the corresponding value is a list of header values. 109 | * 110 | * @since 4.23 111 | */ 112 | public void setResponseHeaders(Map> responseHeaders) 113 | { 114 | this.responseHeaders = responseHeaders; 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/assurance/constraint/Helper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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.common.assurance.constraint; 18 | 19 | 20 | import java.util.List; 21 | import java.util.Map; 22 | import com.google.gson.Gson; 23 | import com.google.gson.GsonBuilder; 24 | 25 | 26 | class Helper 27 | { 28 | public static ConstraintException exception(String format, Object... args) 29 | { 30 | return new ConstraintException(String.format(format, args)); 31 | } 32 | 33 | 34 | public static void ensureNotNull(Object object, String key) 35 | { 36 | if (object == null) 37 | { 38 | throw exception("'%s' is null.", key); 39 | } 40 | } 41 | 42 | 43 | public static Map ensureMap(Object object, String key) 44 | { 45 | if (!(object instanceof Map)) 46 | { 47 | throw exception("'%s' is not an object.", key); 48 | } 49 | 50 | return (Map)object; 51 | } 52 | 53 | 54 | public static List ensureList(Object object, String key) 55 | { 56 | if (!(object instanceof List)) 57 | { 58 | throw exception("'%s' is not an array.", key); 59 | } 60 | 61 | return (List)object; 62 | } 63 | 64 | 65 | public static boolean ensureBoolean(Object object, String key) 66 | { 67 | if (!(object instanceof Boolean)) 68 | { 69 | throw exception("'%s' is not a boolean value."); 70 | } 71 | 72 | return ((Boolean)object).booleanValue(); 73 | } 74 | 75 | 76 | public static long ensureLong(Object object, String key) 77 | { 78 | if (!(object instanceof Number)) 79 | { 80 | throw exception("'%s' is not a number."); 81 | } 82 | 83 | return ((Number)object).longValue(); 84 | } 85 | 86 | 87 | public static String ensureString(Object object, String key) 88 | { 89 | if (!(object instanceof String)) 90 | { 91 | throw exception("'%s' is not a string."); 92 | } 93 | 94 | return (String)object; 95 | } 96 | 97 | 98 | public static String toJson(Object object) 99 | { 100 | return toJson(object, false); 101 | } 102 | 103 | 104 | public static String toJson(Object object, boolean pretty) 105 | { 106 | if (object == null) 107 | { 108 | return "null"; 109 | } 110 | 111 | return createGson(pretty).toJson(object); 112 | } 113 | 114 | 115 | private static Gson createGson(boolean pretty) 116 | { 117 | GsonBuilder builder = new GsonBuilder().serializeNulls(); 118 | 119 | if (pretty) 120 | { 121 | builder.setPrettyPrinting(); 122 | } 123 | 124 | return builder.create(); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialDeferredIssueRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * A request to Authlete's {@code /vci/deferred/issue} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be called by the implementation of the 27 | * deferred credential endpoint. The endpoint is defined in the "OpenID for Verifiable Credential Issuance" (OID4VCI) specification. 30 | *

31 | * 32 | *

33 | * The implementation of the deferred credential endpoint is expected to call 34 | * the following Authlete APIs in the order. 35 | *

36 | * 37 | *
    38 | *
  1. {@code /auth/introspection} 39 | *
  2. {@code /vci/deferred/parse} 40 | *
  3. {@code /vci/deferred/issue} 41 | *
42 | * 43 | *

44 | * The role of the {@code /vci/deferred/issue} API is to issue a credential. 45 | *

46 | * 47 | *

48 | * If the credential for the transaction ID is not ready, the implementation 49 | * of the deferred credential endpoint should prepare an error response with 50 | * {@code "error":"issuance_pending"} manually and return it to the request 51 | * sender, without calling the {@code /vci/deferred/issue} API. 52 | *

53 | * 54 | *
 55 |  * HTTP/1.1 400 Bad Request
 56 |  * Content-Type: application/json
 57 |  * Cache-Control: no-store
 58 |  *
 59 |  * {
 60 |  *   "error": "issuance_pending"
 61 |  * }
 62 |  * 
63 | * 64 | * @since 3.70 65 | * @since Authlete 3.0 66 | * 67 | * @see OpenID for Verifiable Credential Issuance 69 | */ 70 | public class CredentialDeferredIssueRequest implements Serializable 71 | { 72 | private static final long serialVersionUID = 1L; 73 | 74 | 75 | /** 76 | * The instruction for credential issuance. 77 | */ 78 | private CredentialIssuanceOrder order; 79 | 80 | 81 | /** 82 | * Get the credential order that provides an instruction for issuing a 83 | * credential. 84 | * 85 | * @return 86 | * The instruction for credential issuance. 87 | */ 88 | public CredentialIssuanceOrder getOrder() 89 | { 90 | return order; 91 | } 92 | 93 | 94 | /** 95 | * Set the credential order that provides an instruction for issuing a 96 | * credential. 97 | * 98 | * @param order 99 | * The instruction for credential issuance. 100 | * 101 | * @return 102 | * {@code this} object. 103 | */ 104 | public CredentialDeferredIssueRequest setOrder(CredentialIssuanceOrder order) 105 | { 106 | this.order = order; 107 | 108 | return this; 109 | } 110 | } 111 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthorizationTicketInfoResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /auth/authorization/ticket/info} API. 21 | * 22 | *

23 | * The API is used to get information about a ticket that has been issued from 24 | * the {@code /auth/authorization} API. 25 | *

26 | * 27 | * @since 3.88 28 | * @since Authlete 3.0 29 | */ 30 | public class AuthorizationTicketInfoResponse extends ApiResponse 31 | { 32 | private static final long serialVersionUID = 1L; 33 | 34 | 35 | /** 36 | * The result of the {@code /auth/authorization/ticket/info} API call. 37 | */ 38 | public enum Action 39 | { 40 | /** 41 | * Information about the ticket has been obtained successfully. 42 | */ 43 | OK, 44 | 45 | 46 | /** 47 | * The ticket was not found. 48 | */ 49 | NOT_FOUND, 50 | 51 | 52 | /** 53 | * The API call was wrong. For example, the {@code ticket} request 54 | * parameter was missing. 55 | */ 56 | CALLER_ERROR, 57 | 58 | 59 | /** 60 | * An error occurred on Authlete side. 61 | */ 62 | AUTHLETE_ERROR, 63 | } 64 | 65 | 66 | /** 67 | * The result of the {@code /auth/authorization/ticket/info} API call. 68 | */ 69 | private Action action; 70 | 71 | 72 | /** 73 | * Information about the ticket. 74 | */ 75 | private AuthorizationTicketInfo info; 76 | 77 | 78 | /** 79 | * Get the result of the {@code /auth/authorization/ticket/info} API call. 80 | * 81 | * @return 82 | * The result of the API call. 83 | */ 84 | public Action getAction() 85 | { 86 | return action; 87 | } 88 | 89 | 90 | /** 91 | * Set the result of the {@code /auth/authorization/ticket/info} API call. 92 | * 93 | * @param action 94 | * The result of the API call. 95 | * 96 | * @return 97 | * {@code this} object. 98 | */ 99 | public AuthorizationTicketInfoResponse setAction(Action action) 100 | { 101 | this.action = action; 102 | 103 | return this; 104 | } 105 | 106 | 107 | /** 108 | * Get the information about the ticket. 109 | * 110 | * @return 111 | * The information about the ticket. 112 | */ 113 | public AuthorizationTicketInfo getInfo() 114 | { 115 | return info; 116 | } 117 | 118 | 119 | /** 120 | * Set the information about the ticket. 121 | * 122 | * @param info 123 | * The information about the ticket. 124 | * 125 | * @return 126 | * {@code this} object. 127 | */ 128 | public AuthorizationTicketInfoResponse setInfo(AuthorizationTicketInfo info) 129 | { 130 | this.info = info; 131 | 132 | return this; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/CodeChallengeMethod.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | /** 20 | * Values for {@code code_challenge_method}. 21 | * 22 | * @see RFC 7636 (Proof Key for Code Exchange by OAuth Public Clients) 23 | * 24 | * @author Takahiko Kawasaki 25 | * 26 | * @since 1.21 27 | */ 28 | public enum CodeChallengeMethod 29 | { 30 | /** 31 | * {@code plain}, meaning {@code code_challenge = code_verifier}. 32 | * See RFC 7636 for details. 33 | */ 34 | PLAIN((short)1, "plain"), 35 | 36 | 37 | /** 38 | * {@code S256}, meaning 39 | * {@code code_challenge = BASE64URL-ENCODE(SHA256(ASCII(code_verifier)))}. 40 | * See RFC 7636 for details. 41 | */ 42 | S256((short)2, "S256") 43 | ; 44 | 45 | 46 | private static final CodeChallengeMethod[] sValues = values(); 47 | private final short mValue; 48 | private final String mString; 49 | 50 | 51 | private CodeChallengeMethod(short value, String string) 52 | { 53 | mValue = value; 54 | mString = string; 55 | } 56 | 57 | 58 | /** 59 | * Get the integer representation of this enum instance. 60 | */ 61 | public short getValue() 62 | { 63 | return mValue; 64 | } 65 | 66 | 67 | @Override 68 | public String toString() 69 | { 70 | return mString; 71 | } 72 | 73 | 74 | /** 75 | * Find an instance of this enum by a value. 76 | * 77 | * @param value 78 | * The integer representation of the instance to find. 79 | * 80 | * @return 81 | * An instance of this enum, or {@code null} if not found. 82 | */ 83 | public static CodeChallengeMethod getByValue(short value) 84 | { 85 | if (value < 1 || sValues.length < value) 86 | { 87 | // Not found. 88 | return null; 89 | } 90 | 91 | return sValues[value - 1]; 92 | } 93 | 94 | 95 | /** 96 | * Convert {@code String} to {@code CodeChallengeMethod}. 97 | * 98 | * @param method 99 | * A value of {@code code_challenge_method} parameter. 100 | * For example, {@code "plain"}. 101 | * 102 | * @return 103 | * {@code CodeChallengeMethod} instance, or {@code null}. 104 | */ 105 | public static CodeChallengeMethod parse(String method) 106 | { 107 | if (method == null) 108 | { 109 | return null; 110 | } 111 | 112 | for (CodeChallengeMethod value : sValues) 113 | { 114 | if (value.mString.equals(method)) 115 | { 116 | // Found. 117 | return value; 118 | } 119 | } 120 | 121 | // Not found. 122 | return null; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/AuthorizationTicketUpdateResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /auth/authorization/ticket/update} API. 21 | * 22 | *

23 | * The API is used to update information about a ticket that has been issued 24 | * from the {@code /auth/authorization} API. 25 | *

26 | * 27 | * @since 3.88 28 | * @since Authlete 3.0 29 | */ 30 | public class AuthorizationTicketUpdateResponse extends ApiResponse 31 | { 32 | private static final long serialVersionUID = 1L; 33 | 34 | 35 | /** 36 | * The result of the {@code /auth/authorization/ticket/update} API call. 37 | */ 38 | public enum Action 39 | { 40 | /** 41 | * Information about the ticket has been updated successfully. 42 | */ 43 | OK, 44 | 45 | 46 | /** 47 | * The ticket was not found. 48 | */ 49 | NOT_FOUND, 50 | 51 | 52 | /** 53 | * The API call was wrong. For example, the {@code ticket} request 54 | * parameter was missing. 55 | */ 56 | CALLER_ERROR, 57 | 58 | 59 | /** 60 | * An error occurred on Authlete side. 61 | */ 62 | AUTHLETE_ERROR, 63 | } 64 | 65 | 66 | /** 67 | * The result of the {@code /auth/authorization/ticket/info} API call. 68 | */ 69 | private Action action; 70 | 71 | 72 | /** 73 | * Information about the ticket. 74 | */ 75 | private AuthorizationTicketInfo info; 76 | 77 | 78 | /** 79 | * Get the result of the {@code /auth/authorization/ticket/update} API call. 80 | * 81 | * @return 82 | * The result of the API call. 83 | */ 84 | public Action getAction() 85 | { 86 | return action; 87 | } 88 | 89 | 90 | /** 91 | * Set the result of the {@code /auth/authorization/ticket/update} API call. 92 | * 93 | * @param action 94 | * The result of the API call. 95 | * 96 | * @return 97 | * {@code this} object. 98 | */ 99 | public AuthorizationTicketUpdateResponse setAction(Action action) 100 | { 101 | this.action = action; 102 | 103 | return this; 104 | } 105 | 106 | 107 | /** 108 | * Get the information about the ticket. 109 | * 110 | * @return 111 | * The information about the ticket. 112 | */ 113 | public AuthorizationTicketInfo getInfo() 114 | { 115 | return info; 116 | } 117 | 118 | 119 | /** 120 | * Set the information about the ticket. 121 | * 122 | * @param info 123 | * The information about the ticket. 124 | * 125 | * @return 126 | * {@code this} object. 127 | */ 128 | public AuthorizationTicketUpdateResponse setInfo(AuthorizationTicketInfo info) 129 | { 130 | this.info = info; 131 | 132 | return this; 133 | } 134 | } 135 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/GrantScope.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Scope representation in a grant. 24 | * 25 | *

26 | * This class holds the same information as each entry in the {@code "scopes"} 27 | * array in the response from the Grant Management Endpoint on the grant 28 | * management action 'query' does. 29 | *

30 | * 31 | * @see Grant Management for OAuth 2.0 33 | * 34 | * @since 3.1 35 | */ 36 | public class GrantScope implements Serializable 37 | { 38 | private static final long serialVersionUID = 1L; 39 | 40 | 41 | /** 42 | * Space-delimited scopes. 43 | */ 44 | private String scope; 45 | 46 | 47 | /** 48 | * List of resource indicators. 49 | */ 50 | private String[] resource; 51 | 52 | 53 | /** 54 | * The default constructor with no argument. 55 | */ 56 | public GrantScope() 57 | { 58 | } 59 | 60 | 61 | /** 62 | * A constructor with initial property values. 63 | * 64 | * @param scope 65 | * A space-delimited scopes. 66 | * 67 | * @param resource 68 | * A list of resource indicators. 69 | */ 70 | public GrantScope(String scope, String[] resource) 71 | { 72 | this.scope = scope; 73 | this.resource = resource; 74 | } 75 | 76 | 77 | /** 78 | * Get the space-delimited scopes. 79 | * 80 | * @return 81 | * The space-delimited scopes. 82 | */ 83 | public String getScope() 84 | { 85 | return scope; 86 | } 87 | 88 | 89 | /** 90 | * Set the space-delimited scopes. 91 | * 92 | * @param scope 93 | * The space-delimited scopes. 94 | * 95 | * @return 96 | * {@code this} object. 97 | */ 98 | public GrantScope setScope(String scope) 99 | { 100 | this.scope = scope; 101 | 102 | return this; 103 | } 104 | 105 | 106 | /** 107 | * Get the resource. 108 | * 109 | * @return 110 | * A list of resource indicators. 111 | * 112 | * @see Resource Indicators for OAuth 2.0 114 | */ 115 | public String[] getResource() 116 | { 117 | return resource; 118 | } 119 | 120 | 121 | /** 122 | * Set the resource. 123 | * 124 | * @param resource 125 | * A list of resource indicators. 126 | * 127 | * @return 128 | * {@code this} object. 129 | * 130 | * @see Resource Indicators for OAuth 2.0 132 | */ 133 | public GrantScope setResource(String[] resource) 134 | { 135 | this.resource = resource; 136 | 137 | return this; 138 | } 139 | } 140 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ClaimRule.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import com.authlete.common.types.ClaimRuleOperation; 20 | 21 | 22 | /** 23 | * A rule for processing a claim. 24 | * 25 | * @since 2.39 26 | */ 27 | public class ClaimRule 28 | { 29 | private ClaimRuleOperation operation; 30 | private String claimName; 31 | private String comparisonValue; 32 | 33 | 34 | /** 35 | * Get the operation that this rule will apply to any claims it processes. 36 | * 37 | * @return 38 | * The operation. 39 | * 40 | * @since 2.39 41 | */ 42 | public ClaimRuleOperation getOperation() 43 | { 44 | return operation; 45 | } 46 | 47 | 48 | /** 49 | * Set the operation that this rule will apply to any claims it processes. 50 | * 51 | * @param operation 52 | * The operation. 53 | * 54 | * @return 55 | * {@code this} object. 56 | * 57 | * @since 2.39 58 | */ 59 | public ClaimRule setOperation(ClaimRuleOperation operation) 60 | { 61 | this.operation = operation; 62 | 63 | return this; 64 | } 65 | 66 | 67 | /** 68 | * Get the name of the claim that this rule applies to. 69 | * 70 | * @return 71 | * The claim name. 72 | * 73 | * @since 2.39 74 | */ 75 | public String getClaimName() 76 | { 77 | return claimName; 78 | } 79 | 80 | 81 | /** 82 | * Set the name of the claim that this rule applies to. 83 | * 84 | * @param claimName 85 | * The claim name. 86 | * 87 | * @return 88 | * {@code this} object. 89 | * 90 | * @since 2.39 91 | */ 92 | public ClaimRule setClaimName(String claimName) 93 | { 94 | this.claimName = claimName; 95 | 96 | return this; 97 | } 98 | 99 | 100 | /** 101 | * Get the value to compare the claim value to, if the operation is {@link 102 | * ClaimRuleOperation#EQUALS EQUALS}. Values are compared based on their 103 | * serialization as strings. 104 | * 105 | * @return 106 | * The comparison value, as a string. 107 | * 108 | * @since 2.39 109 | */ 110 | public String getComparisonValue() 111 | { 112 | return comparisonValue; 113 | } 114 | 115 | 116 | /** 117 | * Set the value to compare the claim value to, if the operation is {@link 118 | * ClaimRuleOperation#EQUALS EQUALS}. Values are compared based on their 119 | * serialization as strings. 120 | * 121 | * @param comparisonValue 122 | * The comparison value, as a string. 123 | * 124 | * @return 125 | * {@code this} object. 126 | * 127 | * @since 2.39 128 | */ 129 | public ClaimRule setComparisonValue(String comparisonValue) 130 | { 131 | this.comparisonValue = comparisonValue; 132 | 133 | return this; 134 | } 135 | } 136 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialOfferCreateResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /vci/offer/create} API. 21 | * 22 | *

23 | * The API is used to create a credential offer. 24 | *

25 | * 26 | * @since 3.59 27 | * @since Authlete 3.0 28 | * 29 | * @see OpenID for Verifiable Credential Issuance 31 | */ 32 | public class CredentialOfferCreateResponse extends ApiResponse 33 | { 34 | private static final long serialVersionUID = 1L; 35 | 36 | 37 | /** 38 | * The result of the {@code /vci/offer/create} API call. 39 | */ 40 | public enum Action 41 | { 42 | /** 43 | * The {@code /vci/offer/create} API has created a credential offer 44 | * successfully. 45 | */ 46 | CREATED, 47 | 48 | 49 | /** 50 | * The feature of Verifiable Credentials is not enabled in the service 51 | * configuration. 52 | */ 53 | FORBIDDEN, 54 | 55 | 56 | /** 57 | * The API call was wrong. For example, the {@code subject} request 58 | * parameter was missing. 59 | */ 60 | CALLER_ERROR, 61 | 62 | 63 | /** 64 | * An error occurred on Authlete side. 65 | */ 66 | AUTHLETE_ERROR, 67 | } 68 | 69 | 70 | /** 71 | * The result of the {@code /vci/offer/create} API call. 72 | */ 73 | private Action action; 74 | 75 | 76 | /** 77 | * Information about the credential offer. 78 | */ 79 | private CredentialOfferInfo info; 80 | 81 | 82 | /** 83 | * Get the result of the {@code /vci/offer/create} API call. 84 | * 85 | * @return 86 | * The result of the API call. 87 | */ 88 | public Action getAction() 89 | { 90 | return action; 91 | } 92 | 93 | 94 | /** 95 | * Set the result of the {@code /vci/offer/create} API call. 96 | * 97 | * @param action 98 | * The result of the API call. 99 | * 100 | * @return 101 | * {@code this} object. 102 | */ 103 | public CredentialOfferCreateResponse setAction(Action action) 104 | { 105 | this.action = action; 106 | 107 | return this; 108 | } 109 | 110 | 111 | /** 112 | * Get information about the credential offer. 113 | * 114 | * @return 115 | * Information about the credential offer. 116 | */ 117 | public CredentialOfferInfo getInfo() 118 | { 119 | return info; 120 | } 121 | 122 | 123 | /** 124 | * Set information about the credential offer. 125 | * 126 | * @param info 127 | * Information about the credential offer. 128 | * 129 | * @return 130 | * {@code this} object. 131 | */ 132 | public CredentialOfferCreateResponse setInfo(CredentialOfferInfo info) 133 | { 134 | this.info = info; 135 | 136 | return this; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ServiceCreatableResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | import com.authlete.common.types.Plan; 21 | 22 | 23 | /** 24 | * Response from Authlete's {@code /api/service/creatable} API. 25 | * 26 | * @author Takahiko Kawasaki 27 | */ 28 | public class ServiceCreatableResponse implements Serializable 29 | { 30 | private static final long serialVersionUID = 1L; 31 | 32 | 33 | private boolean creatable; 34 | private int count; 35 | private int limit; 36 | private Plan plan; 37 | 38 | 39 | /** 40 | * Check whether the service owner can create a new service. 41 | * 42 | * @return 43 | * {@code true} if the service owner can create a new service. 44 | * {@code false} if the current number of services that the 45 | * service owner has reached or exceeded the maximum number 46 | * of services allowed in the plan. 47 | */ 48 | public boolean isCreatable() 49 | { 50 | return creatable; 51 | } 52 | 53 | 54 | /** 55 | * Set the flag to indicate whether the service owner can create 56 | * a new service. 57 | * 58 | * @param creatable 59 | * {@code true} if the service owner can create a new service. 60 | * Otherwise, {@code false}. 61 | */ 62 | public void setCreatable(boolean creatable) 63 | { 64 | this.creatable = creatable; 65 | } 66 | 67 | 68 | /** 69 | * Get the current number of services that the service owner has. 70 | * 71 | * @return 72 | * The number of services. 73 | */ 74 | public int getCount() 75 | { 76 | return count; 77 | } 78 | 79 | 80 | /** 81 | * Set the current number of services that the service owner has. 82 | * 83 | * @param count 84 | * The number of services. 85 | */ 86 | public void setCount(int count) 87 | { 88 | this.count = count; 89 | } 90 | 91 | 92 | /** 93 | * Get the maximum number of services that can be created in the plan. 94 | * 95 | * @return 96 | * The maximum number of services that can be created. 97 | */ 98 | public int getLimit() 99 | { 100 | return limit; 101 | } 102 | 103 | 104 | /** 105 | * Set the maximum number of services that can be created in the plan. 106 | * 107 | * @param limit 108 | * The maximum number of services that can be created. 109 | */ 110 | public void setLimit(int limit) 111 | { 112 | this.limit = limit; 113 | } 114 | 115 | 116 | /** 117 | * Get the plan of the service owner. 118 | * 119 | * @return 120 | * The plan. 121 | */ 122 | public Plan getPlan() 123 | { 124 | return plan; 125 | } 126 | 127 | 128 | /** 129 | * Set the plan of the service owner. 130 | * 131 | * @param plan 132 | * The plan. 133 | */ 134 | public void setPlan(Plan plan) 135 | { 136 | this.plan = plan; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/types/Sns.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2014-2015 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | import java.util.EnumSet; 20 | 21 | 22 | public enum Sns 23 | { 24 | /** 25 | * {@code "facebook"} (1). 26 | */ 27 | FACEBOOK((short)1, "facebook"), 28 | ; 29 | 30 | 31 | private static final Sns[] sValues = values(); 32 | private static final Helper sHelper = new Helper(sValues); 33 | private final short mValue; 34 | private final String mString; 35 | 36 | 37 | private Sns(short value, String string) 38 | { 39 | mValue = value; 40 | mString = string; 41 | } 42 | 43 | 44 | /** 45 | * Get the integer representation of this enum instance. 46 | */ 47 | public short getValue() 48 | { 49 | return mValue; 50 | } 51 | 52 | 53 | @Override 54 | public String toString() 55 | { 56 | return mString; 57 | } 58 | 59 | 60 | /** 61 | * Find an instance of this enum by a value. 62 | * 63 | * @param value 64 | * The integer representation of the instance to find. 65 | * 66 | * @return 67 | * An instance of this enum, or {@code null} if not found. 68 | */ 69 | public static Sns getByValue(short value) 70 | { 71 | if (value < 1 || sValues.length < value) 72 | { 73 | // Not found. 74 | return null; 75 | } 76 | 77 | return sValues[value - 1]; 78 | } 79 | 80 | 81 | /** 82 | * Convert {@code String} to {@code Sns}. 83 | * 84 | * @param sns 85 | * An SNS. For example, {@code "facebook"}. 86 | * 87 | * @return 88 | * {@code Sns} instance, or {@code null}. 89 | */ 90 | public static Sns parse(String sns) 91 | { 92 | if (sns == null) 93 | { 94 | return null; 95 | } 96 | 97 | for (Sns entry : sValues) 98 | { 99 | if (entry.mString.equals(sns)) 100 | { 101 | // Found. 102 | return entry; 103 | } 104 | } 105 | 106 | // Not found. 107 | return null; 108 | } 109 | 110 | 111 | public static int toBits(EnumSet set) 112 | { 113 | return sHelper.toBits(set); 114 | } 115 | 116 | 117 | public static Sns[] toArray(int bits) 118 | { 119 | return sHelper.toArray(bits); 120 | } 121 | 122 | 123 | public static EnumSet toSet(int bits) 124 | { 125 | return sHelper.toSet(bits); 126 | } 127 | 128 | 129 | public static EnumSet toSet(Sns[] array) 130 | { 131 | return sHelper.toSet(array); 132 | } 133 | 134 | 135 | private static class Helper extends EnumHelper 136 | { 137 | public Helper(Sns[] values) 138 | { 139 | super(Sns.class, values); 140 | } 141 | 142 | 143 | @Override 144 | protected short getValue(Sns entry) 145 | { 146 | return entry.getValue(); 147 | } 148 | 149 | 150 | @Override 151 | protected Sns[] newArray(int size) 152 | { 153 | return new Sns[size]; 154 | } 155 | } 156 | } 157 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialOfferInfoResponse.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | /** 20 | * Response from Authlete's {@code /vci/offer/info} API. 21 | * 22 | *

23 | * The API is used to get information about a credential offer. 24 | *

25 | * 26 | * @since 3.59 27 | * @since Authlete 3.0 28 | * 29 | * @see OpenID for Verifiable Credential Issuance 31 | */ 32 | public class CredentialOfferInfoResponse extends ApiResponse 33 | { 34 | private static final long serialVersionUID = 1L; 35 | 36 | 37 | /** 38 | * The result of the {@code /vci/offer/info} API call. 39 | */ 40 | public enum Action 41 | { 42 | /** 43 | * Information about the credential offer has been obtained 44 | * successfully. 45 | */ 46 | OK, 47 | 48 | 49 | /** 50 | * The feature of Verifiable Credentials is not enabled in the service 51 | * configuration. 52 | */ 53 | FORBIDDEN, 54 | 55 | 56 | /** 57 | * The credential offer specified by the identifier was not found. 58 | */ 59 | NOT_FOUND, 60 | 61 | 62 | /** 63 | * The API call was wrong. For example, the {@code identifier} request 64 | * parameter was missing. 65 | */ 66 | CALLER_ERROR, 67 | 68 | 69 | /** 70 | * An error occurred on Authlete side. 71 | */ 72 | AUTHLETE_ERROR, 73 | } 74 | 75 | 76 | /** 77 | * The result of the {@code /vci/offer/info} API call. 78 | */ 79 | private Action action; 80 | 81 | 82 | /** 83 | * Information about the credential offer. 84 | */ 85 | private CredentialOfferInfo info; 86 | 87 | 88 | /** 89 | * Get the result of the {@code /vci/offer/info} API call. 90 | * 91 | * @return 92 | * The result of the API call. 93 | */ 94 | public Action getAction() 95 | { 96 | return action; 97 | } 98 | 99 | 100 | /** 101 | * Set the result of the {@code /vci/offer/info} API call. 102 | * 103 | * @param action 104 | * The result of the API call. 105 | * 106 | * @return 107 | * {@code this} object. 108 | */ 109 | public CredentialOfferInfoResponse setAction(Action action) 110 | { 111 | this.action = action; 112 | 113 | return this; 114 | } 115 | 116 | 117 | /** 118 | * Get information about the credential offer. 119 | * 120 | * @return 121 | * Information about the credential offer. 122 | */ 123 | public CredentialOfferInfo getInfo() 124 | { 125 | return info; 126 | } 127 | 128 | 129 | /** 130 | * Set information about the credential offer. 131 | * 132 | * @param info 133 | * Information about the credential offer. 134 | * 135 | * @return 136 | * {@code this} object. 137 | */ 138 | public CredentialOfferInfoResponse setInfo(CredentialOfferInfo info) 139 | { 140 | this.info = info; 141 | 142 | return this; 143 | } 144 | } 145 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/assurance/Claims.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 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.common.assurance; 18 | 19 | 20 | import java.util.LinkedHashMap; 21 | import java.util.Map; 22 | 23 | 24 | /** 25 | * The class that represents {@code verified_claims/claims}. 26 | * 27 | * @see OpenID Connect for Identity Assurance 1.0 29 | * 30 | * @since 2.63 31 | */ 32 | public class Claims extends LinkedHashMap 33 | { 34 | private static final long serialVersionUID = 1L; 35 | 36 | 37 | /** 38 | * Put a claim to this object. 39 | * 40 | *

41 | * This method internally calls {@code put(String, Object)} method to 42 | * register the given pair of claim name and claim value and then 43 | * returns {@code this} object. 44 | *

45 | * 46 | * @param claimName 47 | * The claim name. 48 | * 49 | * @param claimValue 50 | * The claim value. 51 | * 52 | * @return 53 | * {@code this} object. 54 | * 55 | * @since 2.65 56 | */ 57 | public Claims putClaim(String claimName, Object claimValue) 58 | { 59 | put(claimName, claimValue); 60 | 61 | return this; 62 | } 63 | 64 | 65 | /** 66 | * Create a {@code Claims} instance from an object in the given map. 67 | * 68 | * @param map 69 | * A map that may contain {@code "claims"}. 70 | * 71 | * @param key 72 | * The key that identifies the object in the map. In normal cases, 73 | * the key is {@code "claims"}. 74 | * 75 | * @return 76 | * A {@code Claims} instance that represents {@code "claims"}. 77 | * If the map does not contain the given key, null is returned. 78 | * 79 | * @throws IdentityAssuranceException 80 | * The structure of the map does not conform to the specification 81 | * (OpenID Connect for Identity Assurance 1.0). 83 | */ 84 | public static Claims extract(Map map, String key) throws IdentityAssuranceException 85 | { 86 | Object object = map.get(key); 87 | 88 | if (object == null) 89 | { 90 | return null; 91 | } 92 | 93 | Claims instance = new Claims(); 94 | 95 | fill(instance, object, key); 96 | 97 | return instance; 98 | } 99 | 100 | 101 | private static void fill(Claims instance, Object object, String key) 102 | { 103 | Map map = Helper.ensureMap(object, key); 104 | 105 | for (Map.Entry entry : map.entrySet()) 106 | { 107 | if (!(entry.getKey() instanceof String)) 108 | { 109 | throw Helper.exception("A key in '%s' is not a string.", key); 110 | } 111 | 112 | instance.put((String)entry.getKey(), entry.getValue()); 113 | } 114 | 115 | // "minProperties": 1 116 | if (instance.size() < 1) 117 | { 118 | throw Helper.exception("'%s' is empty.", key); 119 | } 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialSingleParseRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to the {@code /vci/single/parse} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be used to parse a credential request that 27 | * the credential endpoint received. 28 | *

29 | * 30 | *

31 | * Note that the implementation of the credential endpoint should call the 32 | * {@code /auth/introspection} API to check whether the access token is valid 33 | * BEFORE calling the {@code /vci/single/parse} API. The validation on the 34 | * access token by the {@code /vci/single/parse} API is limited and not 35 | * exhaustive. For example, the {@code /vci/single/parse} API does not check 36 | * certificate binding (RFC 8705). 38 | *

39 | * 40 | * @since 3.66 41 | * @since Authlete 3.0 42 | * 43 | * @see OpenID for Verifiable Credential Issuance 45 | */ 46 | public class CredentialSingleParseRequest implements Serializable 47 | { 48 | private static final long serialVersionUID = 1L; 49 | 50 | 51 | /** 52 | * The access token that came along with the credential request. 53 | */ 54 | private String accessToken; 55 | 56 | 57 | /** 58 | * The message body of the credential request. 59 | */ 60 | private String requestContent; 61 | 62 | 63 | /** 64 | * Get the access token that came along with the credential request. 65 | * 66 | * @return 67 | * The access token that the credential endpoint received. 68 | */ 69 | public String getAccessToken() 70 | { 71 | return accessToken; 72 | } 73 | 74 | 75 | /** 76 | * Set the access token that came along with the credential request. 77 | * 78 | * @param accessToken 79 | * The access token that the credential endpoint received. 80 | * 81 | * @return 82 | * {@code this} object. 83 | */ 84 | public CredentialSingleParseRequest setAccessToken(String accessToken) 85 | { 86 | this.accessToken = accessToken; 87 | 88 | return this; 89 | } 90 | 91 | 92 | /** 93 | * Get the message body of the credential request. The expected format is 94 | * JSON Object that contains at least the {@code "format"} parameter. 95 | * 96 | * @return 97 | * The message body of the credential request. 98 | */ 99 | public String getRequestContent() 100 | { 101 | return requestContent; 102 | } 103 | 104 | 105 | /** 106 | * Set the message body of the credential request. The expected format is 107 | * JSON Object that contains at least the {@code "format"} parameter. 108 | * 109 | * @param requestContent 110 | * The message body of the credential request. 111 | * 112 | * @return 113 | * {@code this} object. 114 | */ 115 | public CredentialSingleParseRequest setRequestContent(String requestContent) 116 | { 117 | this.requestContent = requestContent; 118 | 119 | return this; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/test/java/com/authlete/common/types/ResponseModeTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.authlete.common.types; 17 | 18 | 19 | import org.junit.Test; 20 | import static org.junit.Assert.*; 21 | import static com.authlete.common.types.ResponseMode.*; 22 | 23 | 24 | public class ResponseModeTest 25 | { 26 | @Test 27 | public void testJwtRequired() 28 | { 29 | assertFalse(QUERY .isJwtRequired()); 30 | assertFalse(FRAGMENT .isJwtRequired()); 31 | assertFalse(FORM_POST .isJwtRequired()); 32 | assertTrue( JWT .isJwtRequired()); 33 | assertTrue( QUERY_JWT .isJwtRequired()); 34 | assertTrue( FRAGMENT_JWT .isJwtRequired()); 35 | assertTrue( FORM_POST_JWT.isJwtRequired()); 36 | } 37 | 38 | 39 | @Test 40 | public void testQueryRequired() 41 | { 42 | assertTrue( QUERY .isQueryRequired()); 43 | assertFalse(FRAGMENT .isQueryRequired()); 44 | assertFalse(FORM_POST .isQueryRequired()); 45 | assertFalse(JWT .isQueryRequired()); 46 | assertTrue( QUERY_JWT .isQueryRequired()); 47 | assertFalse(FRAGMENT_JWT .isQueryRequired()); 48 | assertFalse(FORM_POST_JWT.isQueryRequired()); 49 | } 50 | 51 | 52 | @Test 53 | public void testFragmentRequired() 54 | { 55 | assertFalse(QUERY .isFragmentRequired()); 56 | assertTrue( FRAGMENT .isFragmentRequired()); 57 | assertFalse(FORM_POST .isFragmentRequired()); 58 | assertFalse(JWT .isFragmentRequired()); 59 | assertFalse(QUERY_JWT .isFragmentRequired()); 60 | assertTrue( FRAGMENT_JWT .isFragmentRequired()); 61 | assertFalse(FORM_POST_JWT.isFragmentRequired()); 62 | } 63 | 64 | 65 | @Test 66 | public void testFormPostRequired() 67 | { 68 | assertFalse(QUERY .isFormPostRequired()); 69 | assertFalse(FRAGMENT .isFormPostRequired()); 70 | assertTrue( FORM_POST .isFormPostRequired()); 71 | assertFalse(JWT .isFormPostRequired()); 72 | assertFalse(QUERY_JWT .isFormPostRequired()); 73 | assertFalse(FRAGMENT_JWT .isFormPostRequired()); 74 | assertTrue( FORM_POST_JWT.isFormPostRequired()); 75 | } 76 | 77 | 78 | @Test 79 | public void testWithJwt() 80 | { 81 | assertEquals(QUERY_JWT, QUERY .withJwt()); 82 | assertEquals(FRAGMENT_JWT, FRAGMENT .withJwt()); 83 | assertEquals(FORM_POST_JWT, FORM_POST .withJwt()); 84 | assertEquals(JWT, JWT .withJwt()); 85 | assertEquals(QUERY_JWT, QUERY_JWT .withJwt()); 86 | assertEquals(FRAGMENT_JWT, FRAGMENT_JWT .withJwt()); 87 | assertEquals(FORM_POST_JWT, FORM_POST_JWT.withJwt()); 88 | } 89 | 90 | 91 | @Test 92 | public void testWithoutJwt() 93 | { 94 | assertEquals(QUERY, QUERY .withoutJwt()); 95 | assertEquals(FRAGMENT, FRAGMENT .withoutJwt()); 96 | assertEquals(FORM_POST, FORM_POST .withoutJwt()); 97 | assertEquals(null, JWT .withoutJwt()); 98 | assertEquals(QUERY, QUERY_JWT .withoutJwt()); 99 | assertEquals(FRAGMENT, FRAGMENT_JWT .withoutJwt()); 100 | assertEquals(FORM_POST, FORM_POST_JWT.withoutJwt()); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialBatchParseRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * Request to the {@code /vci/batch/parse} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be used to parse a batch credential request 27 | * that the batch credential endpoint received. 28 | *

29 | * 30 | *

31 | * Note that the implementation of the batch credential endpoint should call 32 | * the {@code /auth/introspection} API to check whether the access token is 33 | * valid BEFORE calling the {@code /vci/batch/parse} API. The validation on 34 | * the access token by the {@code /vci/batch/parse} API is limited and not 35 | * exhaustive. For example, the {@code /vci/batch/parse} API does not check 36 | * certificate binding (RFC 8705). 38 | *

39 | * 40 | * @since 3.71 41 | * @since Authlete 3.0 42 | * 43 | * @see OpenID for Verifiable Credential Issuance 45 | */ 46 | public class CredentialBatchParseRequest implements Serializable 47 | { 48 | private static final long serialVersionUID = 1L; 49 | 50 | 51 | /** 52 | * The access token that came along with the batch credential request. 53 | */ 54 | private String accessToken; 55 | 56 | 57 | /** 58 | * The message body of the batch credential request. 59 | */ 60 | private String requestContent; 61 | 62 | 63 | /** 64 | * Get the access token that came along with the batch credential request. 65 | * 66 | * @return 67 | * The access token that the batch credential endpoint received. 68 | */ 69 | public String getAccessToken() 70 | { 71 | return accessToken; 72 | } 73 | 74 | 75 | /** 76 | * Set the access token that came along with the batch credential request. 77 | * 78 | * @param accessToken 79 | * The access token that the batch credential endpoint received. 80 | * 81 | * @return 82 | * {@code this} object. 83 | */ 84 | public CredentialBatchParseRequest setAccessToken(String accessToken) 85 | { 86 | this.accessToken = accessToken; 87 | 88 | return this; 89 | } 90 | 91 | 92 | /** 93 | * Get the message body of the batch credential request. The expected format 94 | * is JSON Object that contains the {@code "credential_requests"} parameter. 95 | * 96 | * @return 97 | * The message body of the batch credential request. 98 | */ 99 | public String getRequestContent() 100 | { 101 | return requestContent; 102 | } 103 | 104 | 105 | /** 106 | * Set the message body of the batch credential request. The expected format 107 | * is JSON Object that contains the {@code "credential_requests"} parameter. 108 | * 109 | * @param requestContent 110 | * The message body of the batch credential request. 111 | * 112 | * @return 113 | * {@code this} object. 114 | */ 115 | public CredentialBatchParseRequest setRequestContent(String requestContent) 116 | { 117 | this.requestContent = requestContent; 118 | 119 | return this; 120 | } 121 | } 122 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/CredentialSingleIssueRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2023 Authlete, Inc. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 | * use this file except in compliance with the License. You may obtain a copy of 6 | * 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, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 12 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 | * License for the specific language governing permissions and limitations under 14 | * the License. 15 | */ 16 | package com.authlete.common.dto; 17 | 18 | 19 | import java.io.Serializable; 20 | 21 | 22 | /** 23 | * A request to Authlete's {@code /vci/single/issue} API. 24 | * 25 | *

26 | * The Authlete API is supposed to be called by the implementation of the 27 | * credential endpoint. The endpoint is defined in the "OpenID for Verifiable Credential Issuance" (OID4VCI) specification. 30 | *

31 | * 32 | *

33 | * The implementation of the credential endpoint is expected to call the 34 | * following Authlete APIs in the order. 35 | *

36 | * 37 | *
    38 | *
  1. {@code /auth/introspection} 39 | *
  2. {@code /vci/single/parse} 40 | *
  3. {@code /vci/single/issue} 41 | *
42 | * 43 | *

44 | * The role of the {@code /vci/single/issue} API is to issue a credential or 45 | * a transaction ID and to prepare a response that should be returned from 46 | * the credential endpoint. 47 | *

48 | * 49 | * @since 3.67 50 | * @since Authlete 3.0 51 | * 52 | * @see OpenID for Verifiable Credential Issuance 54 | */ 55 | public class CredentialSingleIssueRequest implements Serializable 56 | { 57 | private static final long serialVersionUID = 1L; 58 | 59 | 60 | /** 61 | * The access token that was presented at the credential endpoint. 62 | */ 63 | private String accessToken; 64 | 65 | 66 | /** 67 | * The instruction for credential issuance. 68 | */ 69 | private CredentialIssuanceOrder order; 70 | 71 | 72 | /** 73 | * Get the access token that was presented at the credential endpoint. 74 | * 75 | * @return 76 | * The access token that was presented at the credential endpoint. 77 | */ 78 | public String getAccessToken() 79 | { 80 | return accessToken; 81 | } 82 | 83 | 84 | /** 85 | * Set the access token that was presented at the credential endpoint. 86 | * 87 | * @param accessToken 88 | * The access token that was presented at the credential endpoint. 89 | * 90 | * @return 91 | * {@code this} object. 92 | */ 93 | public CredentialSingleIssueRequest setAccessToken(String accessToken) 94 | { 95 | this.accessToken = accessToken; 96 | 97 | return this; 98 | } 99 | 100 | 101 | /** 102 | * Get the credential order that provides an instruction for issuing a 103 | * credential. 104 | * 105 | * @return 106 | * The instruction for credential issuance. 107 | */ 108 | public CredentialIssuanceOrder getOrder() 109 | { 110 | return order; 111 | } 112 | 113 | 114 | /** 115 | * Set the credential order that provides an instruction for issuing a 116 | * credential. 117 | * 118 | * @param order 119 | * The instruction for credential issuance. 120 | * 121 | * @return 122 | * {@code this} object. 123 | */ 124 | public CredentialSingleIssueRequest setOrder(CredentialIssuanceOrder order) 125 | { 126 | this.order = order; 127 | 128 | return this; 129 | } 130 | } 131 | -------------------------------------------------------------------------------- /src/main/java/com/authlete/common/dto/ClientSecretUpdateRequest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 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.common.dto; 18 | 19 | 20 | import java.io.Serializable; 21 | 22 | 23 | /** 24 | * Request to Authlete's {@code /api/client/secret/update} API. 25 | * 26 | *
27 | *
28 | *
clientSecret (REQUIRED)
29 | *
30 | *

31 | * A new value of the client secret. 32 | * Valid characters for a client secret are {@code A-Z}, 33 | * {@code a-z}, {@code 0-9}, {@code -}, and {@code _}. 34 | * The maximum length of a client secret is 86. 35 | *

36 | *
37 | *
38 | *
39 | * 40 | * @author Takahiko Kawasaki 41 | * 42 | * @since 2.11 43 | */ 44 | public class ClientSecretUpdateRequest implements Serializable 45 | { 46 | private static final long serialVersionUID = 1L; 47 | 48 | 49 | private String clientSecret; 50 | 51 | 52 | /** 53 | * Get the client secret. 54 | */ 55 | public String getClientSecret() 56 | { 57 | return clientSecret; 58 | } 59 | 60 | 61 | /** 62 | * Set the client secret. 63 | * 64 | *

65 | * Valid characters for a client secret are {@code A-Z}, 66 | * {@code a-z}, {@code 0-9}, {@code -}, and {@code _}. 67 | * The maximum length of a client secret is 86. 68 | *

69 | * 70 | * @param clientSecret 71 | * The new value of the client secret. 72 | * 73 | * @throws IllegalArgumentException 74 | *
    75 | *
  1. {@code clientSecret} is {@code null}.
  2. 76 | *
  3. {@code clientSecret} is an empty string.
  4. 77 | *
  5. The length of {@code clientSecret} exceeds 86.
  6. 78 | *
  7. {@code clientSecret} contains an illegal character.
  8. 79 | *
80 | */ 81 | public ClientSecretUpdateRequest setClientSecret(String clientSecret) 82 | { 83 | // Check if the given client secret complies with the format. 84 | checkClientSecret(clientSecret); 85 | 86 | this.clientSecret = clientSecret; 87 | 88 | return this; 89 | } 90 | 91 | 92 | private void checkClientSecret(String clientSecret) 93 | { 94 | if (clientSecret == null) 95 | { 96 | throw new IllegalArgumentException("clientSecret is null."); 97 | } 98 | 99 | int len = clientSecret.length(); 100 | 101 | if (len == 0) 102 | { 103 | throw new IllegalArgumentException("clientSecret is empty."); 104 | } 105 | 106 | if (86 < len) 107 | { 108 | throw new IllegalArgumentException("clientSecret is too long."); 109 | } 110 | 111 | for (int i = 0; i < len; ++i) 112 | { 113 | char c = clientSecret.charAt(i); 114 | 115 | if (('A' <= c && c <= 'Z') || 116 | ('a' <= c && c <= 'z') || 117 | ('0' <= c && c <= '9') || 118 | ('-' == c || c == '_')) 119 | { 120 | // Valid character. 121 | continue; 122 | } 123 | 124 | // Illegal character. 125 | throw new IllegalArgumentException("clientSecret contains an illegal character."); 126 | } 127 | 128 | // OK. The given client secret complies with the format. 129 | } 130 | } 131 | --------------------------------------------------------------------------------