Skip to content

Commit

Permalink
inject server/info and upgrade to 0.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Sep 18, 2016
1 parent 0f3f10b commit 97e0886
Show file tree
Hide file tree
Showing 11 changed files with 25 additions and 23 deletions.
2 changes: 1 addition & 1 deletion audit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion config/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion info/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion mask/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<packaging>pom</packaging>
<name>Parent POM</name>
<description>Java Undertow Framework Components</description>
Expand Down
2 changes: 1 addition & 1 deletion security/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
28 changes: 15 additions & 13 deletions server/src/main/java/com/networknt/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
import com.networknt.security.JwtHelper;
import com.networknt.security.JwtMockHandler;
import com.networknt.security.JwtVerifyHandler;
import com.networknt.security.SwaggerHelper;
import com.networknt.utility.ModuleRegistry;
import com.networknt.validator.ValidatorConfig;
import com.networknt.validator.ValidatorHandler;
import io.swagger.models.Operation;
import io.swagger.models.Path;
import io.swagger.models.Swagger;
import io.undertow.Handlers;
import io.undertow.Undertow;
import io.undertow.UndertowOptions;
Expand All @@ -29,6 +33,7 @@
import org.xnio.Options;

import java.util.EnumSet;
import java.util.Map;
import java.util.ServiceLoader;
import java.util.Set;

Expand Down Expand Up @@ -66,24 +71,21 @@ static public void start() {
}
}

// check if mock jwt handler needs to be installed for testing.
Object object = Config.getInstance().getJsonMapConfig(JwtHelper.SECURITY_CONFIG).get(JwtMockHandler.ENABLE_MOCK_JWT);
if(object != null && (Boolean)object == true) {
JwtMockHandler jwtMockHandler = new JwtMockHandler();
if(handler instanceof RoutingHandler) {
((RoutingHandler) handler).add(Methods.POST, "/oauth/token", jwtMockHandler);
ModuleRegistry.registerModule(JwtMockHandler.class.getName(),
Config.getInstance().getJsonMapConfigNoCache(JwtHelper.SECURITY_CONFIG), null);
}
}

// check if server info handler needs to be installed
// TODO move this into the gnerator so that it can be protected by scope.
ServerInfoConfig serverInfoConfig = (ServerInfoConfig)Config.getInstance().getJsonObjectConfig(ServerInfoHandler.CONFIG_NAME, ServerInfoConfig.class);
if(serverInfoConfig.isEnableServerInfo()) {
ServerInfoHandler serverInfoHandler = new ServerInfoHandler();
if(handler instanceof RoutingHandler) {
((RoutingHandler)handler).add(Methods.GET, "/server/info", serverInfoHandler);
// inject this endpoint to swagger dynamically.
// TODO add security to protect it.
Swagger swagger = SwaggerHelper.swagger;
Path path = new Path();
Operation get = new Operation();
path.set("get", get);
Map<String, Path> paths = swagger.getPaths();
paths.put("/server/info", path);
swagger.setPaths(paths);
ModuleRegistry.registerModule(ServerInfoHandler.class.getName(),
Config.getInstance().getJsonMapConfigNoCache(ServerInfoHandler.CONFIG_NAME), null);
}
Expand All @@ -98,7 +100,7 @@ static public void start() {
}

// check if simple audit log handler needs to be installed.
object = Config.getInstance().getJsonMapConfig(SimpleAuditHandler.CONFIG_NAME).get(SimpleAuditHandler.ENABLE_SIMPLE_AUDIT);
Object object = Config.getInstance().getJsonMapConfig(SimpleAuditHandler.CONFIG_NAME).get(SimpleAuditHandler.ENABLE_SIMPLE_AUDIT);
if(object != null && (Boolean)object == true) {
SimpleAuditHandler simpleAuditHandler = new SimpleAuditHandler(handler);
handler = simpleAuditHandler;
Expand Down
2 changes: 1 addition & 1 deletion utility/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down
2 changes: 1 addition & 1 deletion validator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>com.networknt</groupId>
<artifactId>undertow</artifactId>
<version>0.1.1-SNAPSHOT</version>
<version>0.1.1</version>
<relativePath>..</relativePath>
</parent>

Expand Down

0 comments on commit 97e0886

Please sign in to comment.