From 19c3c55e8120312c41fd008da799a7e47f53a5bb Mon Sep 17 00:00:00 2001
From: ulrich
Date: Sat, 26 Oct 2024 12:08:49 +0000
Subject: [PATCH] fixFileName hinzugefuegt

---
 src/de/uhilger/neon/Factory.java |   31 ++++++++++++++++++++++++++++---
 1 files changed, 28 insertions(+), 3 deletions(-)

diff --git a/src/de/uhilger/neon/Factory.java b/src/de/uhilger/neon/Factory.java
index b6550ba..14015d5 100644
--- a/src/de/uhilger/neon/Factory.java
+++ b/src/de/uhilger/neon/Factory.java
@@ -19,6 +19,7 @@
 
 import com.google.gson.Gson;
 import com.sun.net.httpserver.Authenticator;
+import com.sun.net.httpserver.Filter;
 import com.sun.net.httpserver.HttpContext;
 import com.sun.net.httpserver.HttpHandler;
 import com.sun.net.httpserver.HttpServer;
@@ -161,6 +162,7 @@
           IllegalAccessException, IllegalArgumentException, InvocationTargetException, IOException {
     Map<String, HttpHandler> sharedHandlers = new HashMap();
     Iterator<ContextDescriptor> contextIterator = contextList.iterator();
+    Authenticator auth = null;
     while (contextIterator.hasNext()) {
       ContextDescriptor cd = contextIterator.next();
       HttpHandler h = buildHandler(cd, sharedHandlers);
@@ -180,11 +182,34 @@
               ctx.getAttributes().put("serverDataProviderList", sdp);
           }
         }        
-        Authenticator auth = createAuthenticator(d);
-        if (auth instanceof Authenticator && cd.authenticator instanceof String) {
+        if(cd.authenticator instanceof String) {
+          if(!(auth instanceof Authenticator)) {
+            auth = createAuthenticator(d);
+          }
+          if(auth instanceof Authenticator) {
             ctx.setAuthenticator(auth);      
             ctx.getAttributes().putAll(d.authenticator.attributes);
-            fireAuthenticatorCreated(ctx, auth);
+            fireAuthenticatorCreated(ctx, auth); // event umbenennen in etwas wie authAdded oder so
+          }
+          
+        }
+        
+        //Authenticator auth = createAuthenticator(d);
+        //if (auth instanceof Authenticator && cd.authenticator instanceof String) {
+        //    ctx.setAuthenticator(auth);      
+        //    ctx.getAttributes().putAll(d.authenticator.attributes);
+        //    fireAuthenticatorCreated(ctx, auth);
+        //}
+        if(cd.filter != null) {
+          for(String filterClassName : cd.filter) {
+            //
+            Object filterObj = Class.forName(filterClassName)
+                  .getDeclaredConstructor().newInstance();
+            if(filterObj instanceof Filter) {
+              Filter filter = (Filter) filterObj;
+              ctx.getFilters().add(filter);
+            }
+          }
         }
         fireHandlerCreated(ctx, h);
         fireContextCreated(ctx);

--
Gitblit v1.9.3