-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-auth-server): added token status list endpoint and status c…
…laim with index. #8562 Signed-off-by: YuriyZ <yzabrovarniy@gmail.com>
- Loading branch information
Showing
13 changed files
with
180 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
jans-auth-server/server/src/main/java/io/jans/as/server/service/token/StatusListService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.jans.as.server.service.token; | ||
|
||
import io.jans.as.model.common.FeatureFlagType; | ||
import io.jans.as.model.error.ErrorResponseFactory; | ||
import io.jans.as.model.token.JsonWebResponse; | ||
import io.jans.as.server.service.DiscoveryService; | ||
import io.jans.orm.PersistenceEntryManager; | ||
import jakarta.inject.Inject; | ||
import jakarta.inject.Named; | ||
import jakarta.ws.rs.core.Response; | ||
import org.json.JSONObject; | ||
import org.slf4j.Logger; | ||
|
||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
@Named | ||
public class StatusListService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Inject | ||
private ErrorResponseFactory errorResponseFactory; | ||
|
||
@Inject | ||
private DiscoveryService discoveryService; | ||
|
||
@Inject | ||
private PersistenceEntryManager persistenceEntryManager; | ||
|
||
private final AtomicInteger localIndex = new AtomicInteger(0); | ||
|
||
public Response requestStatusList(String acceptHeader) { | ||
log.debug("Attempting to request token_status_list, acceptHeader: {} ...", acceptHeader); | ||
|
||
errorResponseFactory.validateFeatureEnabled(FeatureFlagType.TOKEN_STATUS_LIST); | ||
|
||
// todo WIP | ||
throw new UnsupportedOperationException("WIP"); | ||
} | ||
|
||
public void addStatusClaimWithIndex(JsonWebResponse jwr) { | ||
if (!errorResponseFactory.isFeatureFlagEnabled(FeatureFlagType.TOKEN_STATUS_LIST)) { | ||
log.trace("Skipped status claim addition because {} feature flag is disabled.", FeatureFlagType.TOKEN_STATUS_LIST.getValue()); | ||
return; | ||
} | ||
|
||
final JSONObject indexAndUri = new JSONObject(); | ||
indexAndUri.put("idx", nextIndex()); | ||
indexAndUri.put("uri", discoveryService.getTokenStatusListEndpoint()); | ||
|
||
final JSONObject statusList = new JSONObject(); | ||
statusList.put("status_list", indexAndUri); | ||
|
||
jwr.getClaims().setClaim("status", statusList); | ||
} | ||
|
||
private int nextIndex() { | ||
final int nextIndex = localIndex.incrementAndGet(); | ||
// todo | ||
return nextIndex; | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
...-server/server/src/main/java/io/jans/as/server/status/ws/rs/StatusListRestWebService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package io.jans.as.server.status.ws.rs; | ||
|
||
import io.jans.as.server.service.token.StatusListService; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.*; | ||
import jakarta.ws.rs.core.Response; | ||
import org.slf4j.Logger; | ||
|
||
import static io.jans.as.model.config.Constants.CONTENT_TYPE_STATUSLIST_JSON; | ||
import static io.jans.as.model.config.Constants.CONTENT_TYPE_STATUSLIST_JWT; | ||
|
||
/** | ||
* @author Yuriy Z | ||
*/ | ||
@Path("/") | ||
public class StatusListRestWebService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Inject | ||
private StatusListService statusService; | ||
|
||
@GET | ||
@Path("/token_status_list") | ||
@Consumes({CONTENT_TYPE_STATUSLIST_JSON, CONTENT_TYPE_STATUSLIST_JWT}) | ||
@Produces({CONTENT_TYPE_STATUSLIST_JSON, CONTENT_TYPE_STATUSLIST_JWT}) | ||
public Response requestStatusList(@HeaderParam("Accept") String acceptHeader) { | ||
try { | ||
return statusService.requestStatusList(acceptHeader); | ||
} catch (WebApplicationException e) { | ||
throw e; | ||
} catch (Exception e) { | ||
log.error(e.getMessage(), e); | ||
return Response.status(500).build(); | ||
} | ||
} | ||
} |