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/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
+ * 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: + *
+ * + *+ * 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