From fcb54273541d454837ce4d14fd69bb21248d92ac Mon Sep 17 00:00:00 2001 From: bilalashraf123 Date: Tue, 17 Feb 2026 13:53:19 +0500 Subject: [PATCH 1/3] tsl_support --- .idea/compiler.xml | 13 ++ .idea/encodings.xml | 7 + .idea/jarRepositories.xml | 20 ++ .idea/misc.xml | 12 + .idea/vcs.xml | 6 + .idea/workspace.xml | 84 +++++++ .../java/com/authlete/common/dto/Service.java | 91 ++++++++ .../authlete/common/dto/TslConfigData.java | 213 ++++++++++++++++++ .../com/authlete/common/dto/TslEntry.java | 150 ++++++++++++ .../common/dto/TslPublishConfigInfo.java | 127 +++++++++++ .../dto/TslPublishConfigsListResponse.java | 130 +++++++++++ .../common/dto/TslPublishRequest.java | 75 ++++++ .../common/dto/TslPublishResponse.java | 116 ++++++++++ .../com/authlete/common/dto/TslRequest.java | 76 +++++++ .../com/authlete/common/dto/TslResponse.java | 126 +++++++++++ .../dto/TslTokenStatusUpdateRequest.java | 147 ++++++++++++ .../dto/TslTokenStatusUpdateResponse.java | 83 +++++++ .../common/dto/TslUnusedIndexesRequest.java | 102 +++++++++ .../common/dto/TslUnusedIndexesResponse.java | 85 +++++++ .../com/authlete/common/types/TslFormat.java | 114 ++++++++++ .../authlete/common/types/TslTokenStatus.java | 113 ++++++++++ 21 files changed, 1890 insertions(+) create mode 100644 .idea/compiler.xml create mode 100644 .idea/encodings.xml create mode 100644 .idea/jarRepositories.xml create mode 100644 .idea/misc.xml create mode 100644 .idea/vcs.xml create mode 100644 .idea/workspace.xml create mode 100644 src/main/java/com/authlete/common/dto/TslConfigData.java create mode 100644 src/main/java/com/authlete/common/dto/TslEntry.java create mode 100644 src/main/java/com/authlete/common/dto/TslPublishConfigInfo.java create mode 100644 src/main/java/com/authlete/common/dto/TslPublishConfigsListResponse.java create mode 100644 src/main/java/com/authlete/common/dto/TslPublishRequest.java create mode 100644 src/main/java/com/authlete/common/dto/TslPublishResponse.java create mode 100644 src/main/java/com/authlete/common/dto/TslRequest.java create mode 100644 src/main/java/com/authlete/common/dto/TslResponse.java create mode 100644 src/main/java/com/authlete/common/dto/TslTokenStatusUpdateRequest.java create mode 100644 src/main/java/com/authlete/common/dto/TslTokenStatusUpdateResponse.java create mode 100644 src/main/java/com/authlete/common/dto/TslUnusedIndexesRequest.java create mode 100644 src/main/java/com/authlete/common/dto/TslUnusedIndexesResponse.java create mode 100644 src/main/java/com/authlete/common/types/TslFormat.java create mode 100644 src/main/java/com/authlete/common/types/TslTokenStatus.java diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 000000000..cca833500 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 000000000..aa00ffab7 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml new file mode 100644 index 000000000..712ab9d98 --- /dev/null +++ b/.idea/jarRepositories.xml @@ -0,0 +1,20 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 000000000..9e0563eb9 --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,12 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 000000000..35eb1ddfb --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/workspace.xml b/.idea/workspace.xml new file mode 100644 index 000000000..aa7f340e2 --- /dev/null +++ b/.idea/workspace.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + { + "associatedIndex": 5 +} + + + + { + "keyToString": { + "Maven.authlete-java-common [clean].executor": "Run", + "Maven.authlete-java-common [compile].executor": "Run", + "Maven.authlete-java-common [deploy].executor": "Run", + "Maven.authlete-java-common [install].executor": "Run", + "ModuleVcsDetector.initialDetectionPerformed": "true", + "RunOnceActivity.MCP Project settings loaded": "true", + "RunOnceActivity.ShowReadmeOnStart": "true", + "RunOnceActivity.git.unshallow": "true", + "git-widget-placeholder": "feature/tsl__support", + "kotlin-language-version-configured": "true", + "last_opened_file_path": "C:/data/authlete/development/authlete-java-common" + } +} + + + + + + + + + + + + + + + + + + 1767021603385 + + + + \ No newline at end of file diff --git a/src/main/java/com/authlete/common/dto/Service.java b/src/main/java/com/authlete/common/dto/Service.java index 9bd957527..4c6e76371 100644 --- a/src/main/java/com/authlete/common/dto/Service.java +++ b/src/main/java/com/authlete/common/dto/Service.java @@ -1980,6 +1980,26 @@ public class Service implements Serializable */ private boolean httpAliasProhibited; + /** + * The flag indicating whether the feature of TSL publishing for + * this service is enabled or not. + * + * @since 4.33 + * @since Authlete 3.0.22 + */ + private boolean tslPublishingEnabled; + + + /** + * TSL configuration data. + * + * @since 4.33 + * @since Authlete 3.0.22 + * + * @see + * Trust Status List + */ + private TslConfigData tslConfigData; /** * Get the service number. @@ -13021,4 +13041,75 @@ public Service setHttpAliasProhibited(boolean prohibited) return this; } + + /* + * Sets whether TSL publishing is enabled for this service. + * + * @param tslPublishingEnabled + * {@code true} to enable TSL publishing. {@code false} to disable it. + * + * @return + * this {@link Service} instance for method chaining + * + * @since 4.33 + * @since Authlete 3.0.22 + */ + public Service setTslPublishingEnabled(boolean tslPublishingEnabled) + { + this.tslPublishingEnabled = tslPublishingEnabled; + + return this; + } + + /** + * Get the flag indicating whether the feature of TSL publishing + * for this service is enabled or not. + * + * @return + * {@code true} if the feature of TSL publishing is enabled. + * + * @since 4.33 + * @since Authlete 3.0.22 + */ + public boolean isTslPublishingEnabled() + { + return tslPublishingEnabled; + } + + /** + * Sets the {@link TslConfigData} for this service. + * + * @param tslConfigData + * the configuration data to be applied + * + * @return + * this {@code Service} instance for method chaining + * + * @since 4.33 + * @since Authlete 3.0.22 + * + * @see + * Trust Status List + */ + public Service setTslConfigData(TslConfigData tslConfigData) + { + this.tslConfigData = tslConfigData; + + return this; + } + + /** + * Retrieves the {@link TslConfigData} associated with this service. + * + * @return + * the current {@link TslConfigData} + * + * @since 4.33 + * @since Authlete 3.0.22 + */ + public TslConfigData getTslConfigData() + { + return tslConfigData; + + } } diff --git a/src/main/java/com/authlete/common/dto/TslConfigData.java b/src/main/java/com/authlete/common/dto/TslConfigData.java new file mode 100644 index 000000000..393c23533 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslConfigData.java @@ -0,0 +1,213 @@ +package com.authlete.common.dto; + +import com.authlete.common.types.TslFormat; + +import java.io.Serializable; +import java.net.URI; + +/** + * A class that represents TSL configurations data + * The set consists of the following. + * + * + * + * @since 4.33 + * @since Authlete 3.0.22 + * + * @see Token Status List (TSL) + */ +public class TslConfigData implements Serializable +{ + + private static final long serialVersionUID = 1L; + + /** + * The format of the TSL. Possible values are jwt and cwt. Currently only jwt is supported + */ + private TslFormat format; + + /** + * The validity of the TSL in hours. + */ + private long validity; + + /** + * Publish TSL after every X hours. + */ + private long publishFrequency; + + /** + * Time to live in hours which provides indication to verifiers to cache this TSL + */ + private long timeToLive; + + /** + * Endpoint where to publish this TSL + */ + private URI publishEndpoint; + + /** + * The default constructor. + */ + public TslConfigData() + { + } + + /** + * Copy constructor. + */ + public TslConfigData(TslConfigData tslConfigData) + { + if (tslConfigData == null) + { + return; + } + format = tslConfigData.getFormat(); + validity = tslConfigData.getValidity(); + publishFrequency = tslConfigData.getPublishFrequency(); + timeToLive = tslConfigData.getTimeToLive(); + publishEndpoint = tslConfigData.getPublishEndpoint(); + } + + /** + * Sets the publishing format for the TSL configuration. + * + * @param format + * the {@link TslFormat} value to set + * + * @return + * this {@code TslConfigData} instance for method chaining + */ + public TslConfigData setFormat(TslFormat format) + { + this.format = format; + + return this; + } + + /** + * Returns the publishing format of the TSL configuration. + * + * @return + * the {@link TslFormat} value currently configured + */ + public TslFormat getFormat() + { + return format; + } + + /** + * Sets the TSL validity in hours. + * + * @param validity + * validity in hours + * + * @return + * this {@code TslConfigData} instance for method chaining + */ + public TslConfigData setValidity(long validity) + { + this.validity = validity; + + return this; + } + + /** + * Returns the TSL validity in hours. + * + * @return + * TSL validity + */ + public long getValidity() + { + return validity; + } + + /** + * Sets the TSL publishing frequency in every X hours. + * + * @param publishFrequency + * TSL publish frequency + * + * @return + * this {@code TslConfigData} instance for method chaining + */ + public TslConfigData setPublishFrequency(long publishFrequency) + { + this.publishFrequency = publishFrequency; + + return this; + } + + /** + * Returns the TSL publishing frequency. + * + * @return + * TSL publishing frequency + */ + public long getPublishFrequency() + { + return publishFrequency; + } + + /** + * Sets the ttl value of TSL in hours. + * + * @param timeToLive + * the ttl value + * + * @return + * this {@code TslConfigData} instance for method chaining + */ + public TslConfigData setTimeToLive(long timeToLive) + { + this.timeToLive = timeToLive; + + return this; + } + + /** + * Returns the ttl value. + * + * @return + * ttl value + */ + public long getTimeToLive() + { + return timeToLive; + } + + /** + * Sets the TSL publishing endpoint. + * + * @param publishEndpoint + * TSL publish endpoint + * + * @return + * this {@code TslConfigData} instance for method chaining + */ + public TslConfigData setPublishEndpoint(URI publishEndpoint) + { + this.publishEndpoint = publishEndpoint; + + return this; + } + + /** + * Returns the TSL publishing endpoint. + * + * @return + * TSL publishing endpoint + */ + public URI getPublishEndpoint() + { + return publishEndpoint; + } +} \ No newline at end of file diff --git a/src/main/java/com/authlete/common/dto/TslEntry.java b/src/main/java/com/authlete/common/dto/TslEntry.java new file mode 100644 index 000000000..8c037c895 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslEntry.java @@ -0,0 +1,150 @@ +package com.authlete.common.dto; + +import com.authlete.common.types.TslTokenStatus; + +/** + * Represents a single token entry used in constructing a Token Status List (TSL). + * + *

+ * Each entry corresponds to an issued VC/token and includes its index, unique + * token ID, current status, and usage flag. These objects are typically returned + * as part of a list in {@code /tsl/entries/list} responses. + *

+ * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslEntry +{ + private static final long serialVersionUID = 1L; + + /** + * The token index associated with the issued VC/token. + * This index helps uniquely identify the token within a service. + */ + private int tokenIndex; + + /** + * The unique token ID assigned at issuance time. + * This value is globally unique per token/VC. + */ + private String tokenId; + + /** + * The current status of the issued VC/token. + */ + private TslTokenStatus tokenStatus; + + /** + * Indicates whether this token entry has been marked as used. + */ + private boolean used; + + /** + * Set the token index associated with this entry. + * + * @param tokenIndex + * The token index. + * + * @return + * {@code this} object for method chaining. + */ + public TslEntry setTokenIndex(int tokenIndex) + { + this.tokenIndex = tokenIndex; + + return this; + } + + /** + * Get the token index associated with this entry. + * + * @return + * The token index. + */ + public int getTokenIndex() + { + return tokenIndex; + } + + /** + * Set the unique token ID for this entry. + * + * @param tokenId + * The unique token identifier. + * + * @return + * {@code this} object for method chaining. + */ + public TslEntry setTokenId(String tokenId) + { + this.tokenId = tokenId; + + return this; + } + + /** + * Get the unique token ID associated with this entry. + * + * @return + * The token ID. + */ + public String getTokenId() + { + return tokenId; + } + + /** + * Set the current token status. + * + * @param tokenStatus + * The status of the token. + * + * @return + * {@code this} object for method chaining. + */ + public TslEntry setTokenStatus(TslTokenStatus tokenStatus) + { + this.tokenStatus = tokenStatus; + + return this; + } + + /** + * Get the current status of the issued token. + * + * @return + * The token status. + */ + public TslTokenStatus getTokenStatus() + { + return tokenStatus; + } + + /** + * Set the usage flag for this token entry. + * + * @param used + * {@code true} if the entry is already used; {@code false} otherwise. + * + * @return + * {@code this} object for method chaining. + */ + public TslEntry setUsed(boolean used) + { + this.used = used; + + return this; + } + + /** + * Check whether this token entry has been marked as used. + * + * @return + * {@code true} if the entry is used; {@code false} otherwise. + */ + public boolean getUsed() + { + return used; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslPublishConfigInfo.java b/src/main/java/com/authlete/common/dto/TslPublishConfigInfo.java new file mode 100644 index 000000000..c52f3f753 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslPublishConfigInfo.java @@ -0,0 +1,127 @@ +package com.authlete.common.dto; + +import com.authlete.common.types.TslFormat; + +/** + * Represents the Token Status List (TSL) publish configurations for a service. + * + *

+ * This class contains per-service settings related to TSL publication, including + * the service ID, format and the Unix timestamp (in seconds) indicating when the + * next TSL will be published. + *

+ * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslPublishConfigInfo +{ + + private static final long serialVersionUID = 1L; + + /** + * The service ID for which the TSL publication schedule applies. + * + *

+ * This uniquely identifies the service whose TSL will be published at + * the configured next publish time. + *

+ */ + private long serviceId; + + /** + * The Unix timestamp (in seconds) indicating when the next TSL + * will be published for this service. + * + *

+ * This value allows services to schedule periodic TSL publication. + *

+ */ + private long nextTslPublishTime; + + /** + * The TSL format of the TSL for this service. + */ + private TslFormat format; + + /** + * Set the service ID associated with this TSL publish configurations. + * + * @param serviceId + * The service ID. + * + * @return + * {@code this} object. + */ + public TslPublishConfigInfo setServiceId(long serviceId) + { + this.serviceId = serviceId; + + return this; + } + + /** + * Get the service ID associated with this TSL publish configurations. + * + * @return + * The service ID. + */ + public long getServiceId() + { + return serviceId; + } + + /** + * Set the Unix timestamp (in seconds) for the next TSL publication time. + * + * @param nextTslPublishTime + * The next publish time, in seconds. + * + * @return + * {@code this} object. + */ + public TslPublishConfigInfo setNextTslPublishTime(long nextTslPublishTime) + { + this.nextTslPublishTime = nextTslPublishTime; + + return this; + } + + /** + * Get the Unix timestamp (in seconds) for the next TSL publication time. + * + * @return The next publish time, in seconds. + */ + public long getNextTslPublishTime() + { + return nextTslPublishTime; + } + + /** + * Sets the format of the TSL + * + * @param format + * The TSL format. + * + * @return + * {@code this} object. + */ + public TslPublishConfigInfo setTslFormat(TslFormat format) + { + this.format = format; + + return this; + } + + /** + * Gets the format of the TSL. + * + * @return + * The TSL format. + */ + public TslFormat getTslFormat() + { + return format; + } + +} diff --git a/src/main/java/com/authlete/common/dto/TslPublishConfigsListResponse.java b/src/main/java/com/authlete/common/dto/TslPublishConfigsListResponse.java new file mode 100644 index 000000000..4d6098898 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslPublishConfigsListResponse.java @@ -0,0 +1,130 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +/** + * Response from Authlete's {@code /tsl/publish/configs/list} API. + * + *

+ * This class represents the response containing Token Status List (TSL) + * publish configurations for one or more services. Each entry + * indicates when the next TSL will be published for the corresponding service. + *

+ * + *

+ * The response includes an array of {@link TslPublishConfigInfo} objects, each + * describing: + *

+ * + * + * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslPublishConfigsListResponse extends ApiResponse +{ + private static final long serialVersionUID = 1L; + + /** + * The next action that the implementation of the publish TSL endpoint + * should take after getting a response from Authlete's + * {@code /tsl/publish/configs/list} API. + */ + public enum Action + { + /** + * Information about the TSL publish configs has been obtained + * successfully. + */ + OK, + } + + /** + * The result of the {@code /tsl/publish/configs/list} API call. + */ + private Action action; + + /** + * The list of TSL publish configurations. + * + *

+ * Each element in the array contains the publishing schedule for a service, + * including the service ID, format and the next TSL scheduled publish time. + *

+ */ + private TslPublishConfigInfo[] info; + + + /** + * Get the next action that the implementation of the TSL publish endpoint should + * take after getting a response from Authlete's {@code /tsl/publish/configs/list} API. + * + * @return + * The next action. + */ + public Action getAction() + { + return action; + } + + /** + * Set the next action that the implementation of the TSL endpoint should + * take after getting a response from Authlete's {@code /tsl/publish/configs/list} API. + * + * @param action + * The next action. + * + * @return + * {@code this} object. + */ + public TslPublishConfigsListResponse setAction(Action action) + { + this.action = action; + + return this; + } + + /** + * Set the list of TSL publish configurations. + * + * @param info + * An array of {@link TslPublishConfigInfo} objects. + * + * @return + * {@code this} object. + */ + public TslPublishConfigsListResponse setInfo(TslPublishConfigInfo[] info) + { + this.info = info; + + return this; + } + + /** + * Get the list of TSL publish configurations. + * + * @return + * An array of {@link TslPublishConfigInfo} objects. + */ + public TslPublishConfigInfo[] getInfo() + { + return info; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslPublishRequest.java b/src/main/java/com/authlete/common/dto/TslPublishRequest.java new file mode 100644 index 000000000..d11954d7c --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslPublishRequest.java @@ -0,0 +1,75 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +import com.authlete.common.types.TslFormat; + +import java.io.Serializable; + +/** + * Request to Authlete's {@code /tsl/publish} API. + * + *

+ * This class represents a request to publish a Token Status List (TSL) for + * a specific service. + *

+ * + *

+ * For more details about Token Status Lists (TSL), see: + *

+ * + * @see + * Token Status List (TSL) Specification + * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslPublishRequest implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * The format of the to be published TSL. + */ + private TslFormat format; + + /** + * Set the to be published TSL format + * + * @param format + * The TSL format. + * + * @return + * {@code this} object. + */ + public TslPublishRequest setTslFormat(TslFormat format) + { + this.format = format; + + return this; + } + + /** + * Get the to be published TSL format. + * + * @return + * The TSL format. + */ + public TslFormat getTslFormat() + { + return format; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslPublishResponse.java b/src/main/java/com/authlete/common/dto/TslPublishResponse.java new file mode 100644 index 000000000..01cd959a0 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslPublishResponse.java @@ -0,0 +1,116 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +/** + * Response from Authlete's {@code /tsl/publish} API. + * + *

+ * This class represents the response returned when publishing a Token Status + * List (TSL) from Authlete API. + *

+ * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslPublishResponse extends ApiResponse +{ + private static final long serialVersionUID = 1L; + + /** + * The next action that the implementation of the publish TSL endpoint + * should take after getting a response from Authlete's + * {@code /tsl/publish} API. + */ + public enum Action + { + /** + * A TSL publish response has been prepared successfully. + */ + OK, + + /** + * The feature of TSL publish not enabled in the service + * configuration. + */ + FORBIDDEN, + + /** + * Invalid TSL format + */ + INVALID_TSL_FORMAT, + } + + private Action action; + + private String tsl; + + /** + * Get the next action that the implementation of the TSL publish endpoint should + * take after getting a response from Authlete's {@code /tsl/publish} API. + * + * @return + * The next action. + */ + public Action getAction() + { + return action; + } + + /** + * Set the next action that the implementation of the TSL endpoint should + * take after getting a response from Authlete's {@code /tsl/publish} API. + * + * @param action + * The next action. + * + * @return + * {@code this} object. + */ + public TslPublishResponse setAction(Action action) + { + this.action = action; + + return this; + } + + /** + * Get the published TSL + * + * @return + * The published TSL. + */ + public String getTsl() + { + return tsl; + } + + /** + * Set the published TSL. + * + * @param tsl + * The published TSL. + * + * @return + * {@code this} object. + */ + public TslPublishResponse setTsl(String tsl) + { + this.tsl = tsl; + + return this; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslRequest.java b/src/main/java/com/authlete/common/dto/TslRequest.java new file mode 100644 index 000000000..17f570956 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslRequest.java @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +import com.authlete.common.types.TslFormat; + +import java.io.Serializable; + +/** + * Request to Authlete's {@code /tsl} API. + * + *

+ * This class represents a request to retrieve a published Token Status List (TSL) + * for a specific service. The request requires the caller to specify the + * {@code tslFormat} for the requested TSL. + *

+ * + *

+ * For more details about Token Status Lists (TSL), see: + *

+ * + * @see + * Token Status List (TSL) Specification + * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslRequest implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * The requested TSL format. Currently only JWT format is supported. + */ + private TslFormat format; + + /** + * Set the requested TSL format + * + * @param format + * The TSL format. + * + * @return + * {@code this} object. + */ + public TslRequest setTslFormat(TslFormat format) + { + this.format = format; + + return this; + } + + /** + * Get the requested TSL format. + * + * @return + * The TSL format. + */ + public TslFormat getTslFormat() + { + return format; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslResponse.java b/src/main/java/com/authlete/common/dto/TslResponse.java new file mode 100644 index 000000000..c715f9e06 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslResponse.java @@ -0,0 +1,126 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +/** + * Response from Authlete's {@code /tsl} API. + * + *

+ * This class represents the response returned when retrieving a Token Status + * List (TSL) from Authlete API. + *

+ * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslResponse extends ApiResponse +{ + private static final long serialVersionUID = 1L; + + /** + * The next action that the implementation of the TSL endpoint + * should take after getting a response from Authlete's + * {@code /tsl} API. + */ + public enum Action + { + /** + * A get TSL response has been prepared successfully. + */ + OK, + + /** + * The feature of TSL is not enabled in the service + * configuration. + */ + FORBIDDEN, + + /** + * Invalid TSL format + */ + INVALID_TSL_FORMAT, + + /** + * TSL not found + */ + NO_TSL_FOUND + } + + private Action action; + + private String responseContent; + + /** + * Get the next action that the implementation of the TSL endpoint should + * take after getting a response from Authlete's {@code /tsl} API. + * + * @return + * The next action. + */ + public Action getAction() + { + return action; + } + + /** + * Set the next action that the implementation of the TSL endpoint should + * take after getting a response from Authlete's {@code /tsl} API. + * + * @param action + * The next action. + * + * @return + * {@code this} object. + */ + public TslResponse setAction(Action action) + { + this.action = action; + + return this; + } + + + /** + * Get the content that the implementation of the TSL endpoint should use + * when it constructs a response. + * + * @return + * The response content in the JSON format. + */ + public String getResponseContent() + { + return responseContent; + } + + + /** + * Set the content that the implementation of the TSL endpoint should use + * when it constructs a response. + * + * @param content + * The response content in the JSON format. + * + * @return + * {@code this} object. + */ + public TslResponse setResponseContent(String content) + { + this.responseContent = content; + + return this; + } + +} diff --git a/src/main/java/com/authlete/common/dto/TslTokenStatusUpdateRequest.java b/src/main/java/com/authlete/common/dto/TslTokenStatusUpdateRequest.java new file mode 100644 index 000000000..9d1174e60 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslTokenStatusUpdateRequest.java @@ -0,0 +1,147 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +import com.authlete.common.types.TslTokenStatus; + +import java.io.Serializable; + +/** + * Request to Authlete's {@code /tsl/token/status} API. + * + *

+ * This class represents a request to update the status of an issued + * Verifiable Credential (VC) or token. The updated status will later + * be included in the issued Token Status List (TSL). The request contains + * the following information: + *

+ * + * + * + *

+ * For more details about Token Status Lists (TSL), see: + *

+ * + * @see + * Token Status List (TSL) Specification + * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslTokenStatusUpdateRequest implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * The token ID used to identify the issued VC/token whose status is to be changed. + */ + private String tokenId; + + /** + * The token status to be set. + */ + private TslTokenStatus tokenStatus; + + /** + * The index of the token in the issued TSL. + */ + private int tokenIndex; + + /** + * Set the token ID of the issued VC/token whose status is to be updated. + * + * @param tokenId + * The unique token identifier. + * + * @return + * {@code this} object. + */ + public TslTokenStatusUpdateRequest setTokenId(String tokenId) + { + this.tokenId = tokenId; + + return this; + } + + /** + * Get the token ID of the issued VC/token whose status is being updated. + * + * @return + * The token ID. + */ + public String getTokenId() + { + return tokenId; + } + + /** + * Set the token status to assign to the issued token/VC. + * + * @param tokenStatus + * The new token status. + * + * @return + * {@code this} object. + */ + public TslTokenStatusUpdateRequest setTokenStatus(TslTokenStatus tokenStatus) + { + this.tokenStatus = tokenStatus; + + return this; + } + + /** + * Get the token status currently set for this update request. + * + * @return + * The token status. + */ + public TslTokenStatus getTokenStatus() + { + return tokenStatus; + } + + /** + * Set the token index in the issued TSL. + * + * @param tokenIndex + * The index of the token. + * + * @return + * {@code this} object. + */ + public TslTokenStatusUpdateRequest setTokenIndex(int tokenIndex) + { + this.tokenIndex = tokenIndex; + + return this; + } + + /** + * Get the token index in the issued TSL. + * + * @return + * The token index. + */ + public int getIndex() + { + return tokenIndex; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslTokenStatusUpdateResponse.java b/src/main/java/com/authlete/common/dto/TslTokenStatusUpdateResponse.java new file mode 100644 index 000000000..4eb10cbd1 --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslTokenStatusUpdateResponse.java @@ -0,0 +1,83 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +/** + * Response to Authlete's {@code /tsl/token/status} API. + * + *

+ * This class represents a response to update the status of an issued + * Verifiable Credential (VC) or token. The updated status will later + * be included in the issued Token Status List (TSL). + * + * @since 4.33 + * @since Authlete 3.0.22 + * + */ +public class TslTokenStatusUpdateResponse extends ApiResponse { + + private static final long serialVersionUID = 1L; + + /** + * The next action that the implementation of the token status update endpoint + * should take after getting a response from Authlete's + * {@code /tsl/token/status} API. + */ + public enum Action + { + /** + * A token status update performed successfully. + */ + OK, + + /** + * The feature of TSL publish not enabled in the service + * configuration. + */ + FORBIDDEN, + } + + private TslTokenStatusUpdateResponse.Action action; + + /** + * Get the next action that the implementation of the token status update endpoint should + * take after getting a response from Authlete's {@code /tsl/token/status} API. + * + * @return + * The next action. + */ + public TslTokenStatusUpdateResponse.Action getAction() + { + return action; + } + + /** + * Set the next action that the implementation of the token status update endpoint should + * take after getting a response from Authlete's {@code /tsl/token/status} API. + * + * @param action + * The next action. + * + * @return + * {@code this} object. + */ + public TslTokenStatusUpdateResponse setAction(TslTokenStatusUpdateResponse.Action action) + { + this.action = action; + + return this; + } +} diff --git a/src/main/java/com/authlete/common/dto/TslUnusedIndexesRequest.java b/src/main/java/com/authlete/common/dto/TslUnusedIndexesRequest.java new file mode 100644 index 000000000..a345e9b1a --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslUnusedIndexesRequest.java @@ -0,0 +1,102 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +import java.io.Serializable; + +/** + * Request to Authlete's {@code /tsl/unused/indexes} API. + * + *

+ * This class represents a request to pre-populate unused token indexes for a + * particular service. These unused indexes are later consumed when issuing + * Verifiable Credentials (VCs) or access tokens, allowing efficient allocation + * of token indexes within a Token Status List (TSL) environment. + *

+ * + * @since 4.33 + * @since Authlete 3.0.22 + */ +public class TslUnusedIndexesRequest implements Serializable +{ + private static final long serialVersionUID = 1L; + + /** + * If less than this number of unused VC/token indexes left then populate new unused indexes + * specified in {@code unusedTokenIndexesAdd}. + */ + private long unusedTokenIndexesLeft; + + /** + * Add this number of new unused VC/token indexes. + */ + private long unusedTokenIndexesAdd; + + /** + * Set the unused token indexes left value. + * + * @param unusedTokenIndexesLeft + * The unused token indexes left value. + * + * @return + * {@code this} object. + */ + public TslUnusedIndexesRequest setUnusedTokenIndexesLeft(long unusedTokenIndexesLeft) + { + this.unusedTokenIndexesLeft = unusedTokenIndexesLeft; + + return this; + } + + /** + * Get the unused token indexes left value. + * + * @return + * The unused token indexes left value. + */ + public long getUnusedTokenIndexesLeft() + { + return unusedTokenIndexesLeft; + } + + /** + * Set the unused token indexes add value. + * + * @param unusedTokenIndexesAdd + * The unused token indexes add value. + * + * @return + * {@code this} object. + */ + public TslUnusedIndexesRequest setUnusedTokenIndexesAdd(long unusedTokenIndexesAdd) + { + this.unusedTokenIndexesAdd = unusedTokenIndexesAdd; + + return this; + } + + /** + * Get the unused token indexes add value. + * + * @return + * The unused token indexes add value. + */ + public long getUnusedTokenIndexesAdd() + { + return unusedTokenIndexesAdd; + } + +} diff --git a/src/main/java/com/authlete/common/dto/TslUnusedIndexesResponse.java b/src/main/java/com/authlete/common/dto/TslUnusedIndexesResponse.java new file mode 100644 index 000000000..ce38b5bae --- /dev/null +++ b/src/main/java/com/authlete/common/dto/TslUnusedIndexesResponse.java @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2025 Authlete, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.authlete.common.dto; + +/** + * Response to Authlete's {@code /tsl/unused/indexes} API. + * + *

+ * This class represents a response to pre-populate unused token indexes for a + * particular service. These unused indexes are later consumed when issuing + * Verifiable Credentials (VCs) or access tokens, allowing efficient allocation + * of token indexes within a Token Status List (TSL) environment. + *

+ * + * @since 4.33 + * @since Authlete 3.0.22 + */ + +public class TslUnusedIndexesResponse extends ApiResponse { + + private static final long serialVersionUID = 1L; + + /** + * The next action that the implementation of the TSL unused indexes endpoint + * should take after getting a response from Authlete's + * {@code /tsl/unused/indexes} API. + */ + public enum Action + { + /** + * A TSL unused indexes has been populated successfully. + */ + OK, + + /** + * The feature of TSL publish not enabled in the service + * configuration. + */ + FORBIDDEN, + } + + private TslUnusedIndexesResponse.Action action; + + /** + * Get the next action that the implementation of the TSL unused indexes endpoint should + * take after getting a response from Authlete's {@code /tsl/unused/indexes} API. + * + * @return + * The next action. + */ + public TslUnusedIndexesResponse.Action getAction() + { + return action; + } + + /** + * Set the next action that the implementation of the TSL unused indexes endpoint should + * take after getting a response from Authlete's {@code /tsl/unused/indexes} API. + * + * @param action + * The next action. + * + * @return + * {@code this} object. + */ + public TslUnusedIndexesResponse setAction(TslUnusedIndexesResponse.Action action) + { + this.action = action; + + return this; + } +} diff --git a/src/main/java/com/authlete/common/types/TslFormat.java b/src/main/java/com/authlete/common/types/TslFormat.java new file mode 100644 index 000000000..dabb11e96 --- /dev/null +++ b/src/main/java/com/authlete/common/types/TslFormat.java @@ -0,0 +1,114 @@ +package com.authlete.common.types; + +import java.util.EnumSet; + +public enum TslFormat +{ + + /** + * Currently jwt is supported. TSL publishing cwt format will be supported in the next iteration + */ + JWT((short)1, "jwt"); + + + private static final TslFormat[] sValues = values(); + private static final TslFormat.Helper sHelper = new TslFormat.Helper(sValues); + private final short mValue; + private final String mString; + + + private TslFormat(short value, String string) + { + mValue = value; + mString = string; + } + + + /** + * Get the integer representation of this enum instance. + */ + public short getValue() + { + return mValue; + } + + + /** + * Find an instance of this enum by a value. + * + * @param value + * The integer representation of the instance to find. + * + * @return + * An instance of this enum, or {@code null} if not found. + */ + public static TslFormat getByValue(short value) + { + if (value < 1 || sValues.length < value) + { + // Not found. + return null; + } + + return sValues[value - 1]; + } + + + /** + * Get the string value of TSL publish format. + * + * @return + * A string that contains TSL publish format. + */ + public String getString() + { + return mString; + } + + + public static int toBits(EnumSet set) + { + return sHelper.toBits(set); + } + + + public static TslFormat[] toArray(int bits) + { + return sHelper.toArray(bits); + } + + + public static EnumSet toSet(int bits) + { + return sHelper.toSet(bits); + } + + + public static EnumSet toSet(TslFormat[] array) + { + return sHelper.toSet(array); + } + + + private static class Helper extends EnumHelper + { + public Helper(TslFormat[] values) + { + super(TslFormat.class, values); + } + + + @Override + protected short getValue(TslFormat entry) + { + return entry.getValue(); + } + + + @Override + protected TslFormat[] newArray(int size) + { + return new TslFormat[size]; + } + } +} diff --git a/src/main/java/com/authlete/common/types/TslTokenStatus.java b/src/main/java/com/authlete/common/types/TslTokenStatus.java new file mode 100644 index 000000000..c102ea913 --- /dev/null +++ b/src/main/java/com/authlete/common/types/TslTokenStatus.java @@ -0,0 +1,113 @@ +package com.authlete.common.types; + +import java.util.EnumSet; + +public enum TslTokenStatus +{ + + VALID((short)0, "valid"), + INVALID((short)1, "invalid"), + SUSPENDED((short)2, "suspended"); + + + private static final TslTokenStatus[] sValues = values(); + private static final TslTokenStatus.Helper sHelper = new TslTokenStatus.Helper(sValues); + private final short mValue; + private final String mString; + + + private TslTokenStatus(short value, String string) + { + mValue = value; + mString = string; + } + + + /** + * Get the integer representation of this enum instance. + */ + public short getValue() + { + return mValue; + } + + + /** + * Find an instance of this enum by a value. + * + * @param value + * The integer representation of the instance to find. + * + * @return + * An instance of this enum, or {@code null} if not found. + */ + public static TslTokenStatus getByValue(short value) + { + if (value < 1 || sValues.length < value) + { + // Not found. + return null; + } + + return sValues[value - 1]; + } + + + /** + * Get the string value of TSL token status. + * + * @return + * A string that contains TSL token status. + */ + public String getString() + { + return mString; + } + + + public static int toBits(EnumSet set) + { + return sHelper.toBits(set); + } + + + public static TslTokenStatus[] toArray(int bits) + { + return sHelper.toArray(bits); + } + + + public static EnumSet toSet(int bits) + { + return sHelper.toSet(bits); + } + + + public static EnumSet toSet(TslTokenStatus[] array) + { + return sHelper.toSet(array); + } + + + private static class Helper extends EnumHelper + { + public Helper(TslTokenStatus[] values) + { + super(TslTokenStatus.class, values); + } + + + @Override + protected short getValue(TslTokenStatus entry) + { + return entry.getValue(); + } + + + @Override + protected TslTokenStatus[] newArray(int size) + { + return new TslTokenStatus[size]; + } + } +} From 2a008bb47641fa485acedf1cba7de91809887abf Mon Sep 17 00:00:00 2001 From: bilalashraf123 Date: Tue, 17 Feb 2026 14:00:48 +0500 Subject: [PATCH 2/3] tsl_support --- .gitignore | 2 ++ .idea/workspace.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9c65be456..1e776d6a0 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ authlete.properties .project .classpath .DS_Store +.idea/ +*.iml diff --git a/.idea/workspace.xml b/.idea/workspace.xml index aa7f340e2..770b6234c 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,7 +5,7 @@ - +