Browse Source

Simplified action factory and fixed but in dump code

gremlin 4 years ago
parent
commit
9ad1850f64

+ 3 - 5
src/main/java/riomhaire/lti/JavaLti13ToolApplication.java

@@ -13,14 +13,12 @@ public class JavaLti13ToolApplication {
 
 //	@Bean
 //	public ActionBuilderFactory buildFactory() {
-//		return new ActionBuilderFactory(()-> new LaunchContentBuilder(),
-//				()->new ProcessLtiMessageBuilder(),
-//				()->new ProcessOidcRequestBuilder(),
-//				()->new SelectDeepLinkContentBuilder()) ;
+//		return new ActionBuilderFactory();
 //	}
+
 	@Bean
 	public ActionBuilderFactory customBuildFactory() {
-		return new ActionBuilderFactory(()-> new RiomhaireApplicationContentLauncherBuilder()) ;
+		return new ActionBuilderFactory().setBuilder(Builder.LaunchContentBuilder,()->new RiomhaireApplicationContentLauncherBuilder()) ;
 	}
 
 	public static void main(String[] args) {

+ 1 - 1
src/main/java/riomhaire/lti/core/adapters/token/JWKBasedJwtToMapAdapter.java

@@ -35,7 +35,7 @@ public class JWKBasedJwtToMapAdapter implements Decoder<Map<String, Object>,Stri
 
         try {
             // OK look up jwks and verify
-            log.info("Using key:"+jwt.getKeyId()+" to search: "+jwksUrl);
+            log.trace("Using key:"+jwt.getKeyId()+" to search: "+jwksUrl);
             HttpsJwks httpsJkws = new HttpsJwks(jwksUrl);
             HttpsJwksVerificationKeyResolver httpsJwksKeyResolver = new HttpsJwksVerificationKeyResolver(httpsJkws);
             JwtConsumer jwtConsumer = new JwtConsumerBuilder()

+ 17 - 21
src/main/java/riomhaire/lti/core/business/builder/ActionBuilderFactory.java

@@ -1,32 +1,28 @@
 package riomhaire.lti.core.business.builder;
 
-public class ActionBuilderFactory {
+import lombok.extern.slf4j.Slf4j;
+
+import java.util.HashMap;
+import java.util.Map;
 
-    private ActionBuilderBuilder launchContentBuilder = ()->new NopBuilder();
-    private ActionBuilderBuilder processLTIMessageBuilder = ()->new NopBuilder();
-    private ActionBuilderBuilder processOidcRequestBuilder= ()->new NopBuilder();
-    private ActionBuilderBuilder selectDeepLinkContentBuilder = ()->new NopBuilder();
+@Slf4j
+public class ActionBuilderFactory {
+    private Map<Builder,ActionBuilderBuilder> builders = new HashMap<>();
 
-    public ActionBuilderFactory(ActionBuilderBuilder launchContentBuilder, ActionBuilderBuilder processLTIMessageBuilder, ActionBuilderBuilder processOidcRequestBuilder, ActionBuilderBuilder selectDeepLinkContentBuilder) {
-        this.launchContentBuilder = launchContentBuilder;
-        this.processLTIMessageBuilder = processLTIMessageBuilder;
-        this.processOidcRequestBuilder = processOidcRequestBuilder;
-        this.selectDeepLinkContentBuilder = selectDeepLinkContentBuilder;
+    public ActionBuilderFactory(){
+        log.debug("Initializing ActionBuilderFactory");
+        setBuilder(Builder.ProcessOidcRequestBuilder,()->new ProcessOidcRequestBuilder());
+        setBuilder(Builder.ProcessLTIMessageBuilder,()->new ProcessLtiMessageBuilder());
+        setBuilder(Builder.LaunchContentBuilder,()->new LaunchContentBuilder());
     }
-    public ActionBuilderFactory(ActionBuilderBuilder launchContentBuilder){
-        this.launchContentBuilder = launchContentBuilder;
-        this.processLTIMessageBuilder = ()->new ProcessLtiMessageBuilder();
-        this.processOidcRequestBuilder = ()->new ProcessOidcRequestBuilder();
-        this.selectDeepLinkContentBuilder = ()->new NopBuilder();
 
+    public ActionBuilderFactory setBuilder(Builder builderName, ActionBuilderBuilder actionBuilder) {
+       builders.put(builderName,actionBuilder);
+       return this;
     }
 
     public ActionBuilder getBuilder(Builder name)    {
-        return switch (name) {
-            case LaunchContentBuilder : yield launchContentBuilder.build();
-            case ProcessLTIMessageBuilder: yield processLTIMessageBuilder.build();
-            case ProcessOidcRequestBuilder: yield processOidcRequestBuilder.build();
-            case SelectDeepLinkContentBuilder: yield selectDeepLinkContentBuilder.build();
-        } ;
+       if( !builders.containsKey(name)) return new NopBuilder();
+       return builders.get(name).build();
     }
 }

+ 1 - 1
src/main/resources/templates/dump-launch.html

@@ -3,7 +3,7 @@
 <head>
     <meta charset="utf-8">
     <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=yes">
-    <title>Launch Dump/title>
+    <title>Launch Dump</title>
     <style>
         th {
             min-width: 200px;