-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lock Endpoint Scaffolding #8672
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
jans-linux-setup/jans_setup/templates/jans-lock/dynamic-conf.json
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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
{ | ||
"baseEndpoint" : "https://%(hostname)s/jans-lock/v1", | ||
|
||
"tokenChannels":[ | ||
"jans_token" | ||
], | ||
|
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
37 changes: 37 additions & 0 deletions
37
...lock/lock-master/service/src/main/java/io/jans/lock/service/util/ResteasyInitializer.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,37 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2024, Janssen Project | ||
*/ | ||
|
||
package io.jans.lock.service.util; | ||
|
||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
import io.jans.lock.service.ws.rs.ConfigurationRestWebService; | ||
import io.jans.lock.service.ws.rs.audit.AuditRestWebServiceImpl; | ||
import io.jans.lock.service.ws.rs.sse.SseRestWebServiceImpl; | ||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
|
||
|
||
/** | ||
* Integration with Resteasy | ||
* | ||
* @author Yuriy Movchan Date: 06/06/2024 | ||
*/ | ||
@ApplicationPath("/v1") | ||
public class ResteasyInitializer extends Application { | ||
|
||
@Override | ||
public Set<Class<?>> getClasses() { | ||
HashSet<Class<?>> classes = new HashSet<Class<?>>(); | ||
classes.add(AuditRestWebServiceImpl.class); | ||
classes.add(ConfigurationRestWebService.class); | ||
classes.add(SseRestWebServiceImpl.class); | ||
|
||
return classes; | ||
} | ||
|
||
} |
46 changes: 46 additions & 0 deletions
46
jans-lock/lock-master/service/src/main/java/io/jans/lock/service/util/ServerUtil.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,46 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2024, Janssen Project | ||
*/ | ||
|
||
package io.jans.lock.service.util; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import jakarta.ws.rs.core.CacheControl; | ||
|
||
/** | ||
* @author Yuriy Zabrovarnyy | ||
* @author Yuriy Movchan | ||
* @version 0.9, 26/12/2012 | ||
*/ | ||
|
||
public class ServerUtil { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(ServerUtil.class); | ||
|
||
public static final String PRAGMA = "Pragma"; | ||
public static final String NO_CACHE = "no-cache"; | ||
|
||
public static CacheControl cacheControl(boolean noStore) { | ||
final CacheControl cacheControl = new CacheControl(); | ||
cacheControl.setNoStore(noStore); | ||
return cacheControl; | ||
} | ||
|
||
public static CacheControl cacheControl(boolean noStore, boolean noTransform) { | ||
final CacheControl cacheControl = new CacheControl(); | ||
cacheControl.setNoStore(noStore); | ||
cacheControl.setNoTransform(noTransform); | ||
return cacheControl; | ||
} | ||
|
||
public static CacheControl cacheControlWithNoStoreTransformAndPrivate() { | ||
final CacheControl cacheControl = cacheControl(true, false); | ||
cacheControl.setPrivate(true); | ||
return cacheControl; | ||
} | ||
|
||
} |
74 changes: 74 additions & 0 deletions
74
...-master/service/src/main/java/io/jans/lock/service/ws/rs/ConfigurationRestWebService.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,74 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2024, Janssen Project | ||
*/ | ||
|
||
package io.jans.lock.service.ws.rs; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.core.Response.ResponseBuilder; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.node.ObjectNode; | ||
|
||
import io.jans.lock.model.config.AppConfiguration; | ||
import io.jans.service.net.NetworkService; | ||
|
||
/** | ||
* Lock metadata configuration | ||
* | ||
* @author Yuriy Movchan Date: 12/19/2018 | ||
*/ | ||
@ApplicationScoped | ||
@Path("/configuration") | ||
public class ConfigurationRestWebService { | ||
|
||
@Inject | ||
private AppConfiguration appConfiguration; | ||
|
||
@Inject | ||
private NetworkService networkService; | ||
|
||
private ObjectMapper objectMapper; | ||
|
||
@PostConstruct | ||
public void init() { | ||
this.objectMapper = new ObjectMapper(); | ||
} | ||
|
||
@GET | ||
@Produces({ "application/json" }) | ||
public Response getConfiguration() { | ||
final String baseEndpointUri = appConfiguration.getBaseEndpoint(); | ||
ObjectNode response = objectMapper.createObjectNode(); | ||
|
||
response.put("version", "1.0"); | ||
response.put("issuer", networkService.getHost(baseEndpointUri)); | ||
|
||
ObjectNode audit = objectMapper.createObjectNode(); | ||
response.set("audit", audit); | ||
audit.put("health_endpoint", baseEndpointUri + "/audit/health"); | ||
audit.put("log_endpoint", baseEndpointUri + "/audit/log"); | ||
audit.put("telemetry_endpoint", baseEndpointUri + "/audit/telemetry"); | ||
|
||
ObjectNode config = objectMapper.createObjectNode(); | ||
response.set("config", config); | ||
config.put("config_endpoint", baseEndpointUri + "/config"); | ||
config.put("issuers_endpoint", baseEndpointUri + "/config/issuers"); | ||
config.put("policy_endpoint", baseEndpointUri + "/config/policy"); | ||
config.put("schema_endpoint", baseEndpointUri + "/config/schema"); | ||
|
||
config.put("sse_endpoint", baseEndpointUri + "/sse"); | ||
|
||
ResponseBuilder builder = Response.ok().entity(response.toString()); | ||
return builder.build(); | ||
} | ||
|
||
} |
42 changes: 42 additions & 0 deletions
42
...ck-master/service/src/main/java/io/jans/lock/service/ws/rs/audit/AuditRestWebService.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,42 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2024, Janssen Project | ||
*/ | ||
|
||
package io.jans.lock.service.ws.rs.audit; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.ws.rs.POST; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.core.SecurityContext; | ||
|
||
/** | ||
* Provides interface for audit REST web services | ||
* | ||
* @author Yuriy Movchan Date: 05/24/2024 | ||
*/ | ||
public interface AuditRestWebService { | ||
|
||
@POST | ||
@Path("/audit/health") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processHealthRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, @Context SecurityContext sec); | ||
|
||
@POST | ||
@Path("/audit//log") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processLogRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, @Context SecurityContext sec); | ||
|
||
@POST | ||
@Path("/audit//telemetry") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processTelemetryRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, | ||
@Context SecurityContext sec); | ||
|
||
} |
64 changes: 64 additions & 0 deletions
64
...aster/service/src/main/java/io/jans/lock/service/ws/rs/audit/AuditRestWebServiceImpl.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,64 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2024, Janssen Project | ||
*/ | ||
|
||
package io.jans.lock.service.ws.rs.audit; | ||
|
||
import org.slf4j.Logger; | ||
|
||
import io.jans.lock.service.util.ServerUtil; | ||
import jakarta.inject.Inject; | ||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.core.SecurityContext; | ||
|
||
/** | ||
* Provides interface for audit REST web services | ||
* | ||
* @author Yuriy Movchan Date: 06/06/2024 | ||
*/ | ||
public class AuditRestWebServiceImpl implements AuditRestWebService { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
@Override | ||
public Response processHealthRequest(HttpServletRequest request, HttpServletResponse response, SecurityContext sec) { | ||
log.debug("Processing Health request"); | ||
Response.ResponseBuilder builder = Response.ok(); | ||
|
||
builder.cacheControl(ServerUtil.cacheControlWithNoStoreTransformAndPrivate()); | ||
builder.header(ServerUtil.PRAGMA, ServerUtil.NO_CACHE); | ||
builder.entity("{\"res\" : \"ok\"}"); | ||
|
||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public Response processLogRequest(HttpServletRequest request, HttpServletResponse response, SecurityContext sec) { | ||
log.debug("Processing Log request"); | ||
Response.ResponseBuilder builder = Response.ok(); | ||
|
||
builder.cacheControl(ServerUtil.cacheControlWithNoStoreTransformAndPrivate()); | ||
builder.header(ServerUtil.PRAGMA, ServerUtil.NO_CACHE); | ||
builder.entity("{\"res\" : \"ok\"}"); | ||
|
||
return builder.build(); | ||
} | ||
|
||
@Override | ||
public Response processTelemetryRequest(HttpServletRequest request, HttpServletResponse response, SecurityContext sec) { | ||
log.debug("Processing Telemetry request"); | ||
Response.ResponseBuilder builder = Response.ok(); | ||
|
||
builder.cacheControl(ServerUtil.cacheControlWithNoStoreTransformAndPrivate()); | ||
builder.header(ServerUtil.PRAGMA, ServerUtil.NO_CACHE); | ||
builder.entity("{\"res\" : \"ok\"}"); | ||
|
||
return builder.build(); | ||
} | ||
|
||
} |
47 changes: 47 additions & 0 deletions
47
...-master/service/src/main/java/io/jans/lock/service/ws/rs/config/ConfigRestWebService.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,47 @@ | ||
/* | ||
* Janssen Project software is available under the Apache License (2004). See http://www.apache.org/licenses/ for full text. | ||
* | ||
* Copyright (c) 2024, Janssen Project | ||
*/ | ||
|
||
package io.jans.lock.service.ws.rs.config; | ||
|
||
import jakarta.servlet.http.HttpServletRequest; | ||
import jakarta.servlet.http.HttpServletResponse; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.Produces; | ||
import jakarta.ws.rs.core.Context; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.core.Response; | ||
import jakarta.ws.rs.core.SecurityContext; | ||
|
||
/** | ||
* Provides interface for configuration REST web services | ||
* | ||
* @author Yuriy Movchan Date: 06/06/2024 | ||
*/ | ||
public interface ConfigRestWebService { | ||
|
||
@GET | ||
@Path("/config") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processConfigRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, @Context SecurityContext sec); | ||
|
||
@GET | ||
@Path("/config/issuers") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processIssuersRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, | ||
@Context SecurityContext sec); | ||
|
||
@GET | ||
@Path("/config/policy") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processPolicyRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, @Context SecurityContext sec); | ||
|
||
@GET | ||
@Path("/config/schema") | ||
@Produces({ MediaType.APPLICATION_JSON }) | ||
Response processSchemaRequest(@Context HttpServletRequest request, @Context HttpServletResponse response, @Context SecurityContext sec); | ||
|
||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align with this format: https://www.apache.org/licenses/LICENSE-2.0#apply