From 83896588e20d7e532d0e2fdc17512772c29533a8 Mon Sep 17 00:00:00 2001
From: ulrich
Date: Fri, 04 Jun 2021 12:02:52 +0000
Subject: [PATCH] Kommentare um mit JavaDoc inkompatible Inhalte bereinigt

---
 src/de/uhilger/httpserver/auth/handler/LoginHandler.java |   25 +++++++++++--------------
 1 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/de/uhilger/httpserver/auth/handler/LoginHandler.java b/src/de/uhilger/httpserver/auth/handler/LoginHandler.java
index 7158157..0872af1 100644
--- a/src/de/uhilger/httpserver/auth/handler/LoginHandler.java
+++ b/src/de/uhilger/httpserver/auth/handler/LoginHandler.java
@@ -1,5 +1,5 @@
 /*
-  jwtTest - JSON Web Token Testimplementierung 
+  http-auth - Authentication Extensions to jdk.httpserver
   Copyright (C) 2021  Ulrich Hilger
 
   This program is free software: you can redistribute it and/or modify
@@ -24,10 +24,7 @@
 import com.sun.net.httpserver.HttpHandler;
 import de.uhilger.httpserver.auth.TokenAuthenticator;
 import de.uhilger.httpserver.auth.realm.User;
-import java.io.BufferedReader;
 import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
 import java.text.SimpleDateFormat;
 import java.util.Date;
 import java.util.Locale;
@@ -42,7 +39,7 @@
   /* Der Logger fuer diesen JWTLoginHandler */
   //private static final Logger logger = Logger.getLogger(LoginHandler.class.getName());
   
-  public static final String ATTR_JWT_AUTH = "jwtauth";
+  public static final String ATTR_AUTHENTICATOR = "authenticator";
   
   
   //protected String ctx;
@@ -51,7 +48,7 @@
    * Wenn einfach ein HTML-Formular hierhin geschickt wird, das wie
    * bei Java die Formular-Eingabefelder 'j_username' und 'j_password'
    * enthaelt, kommt im Body folgendes an:
-   * j_username=name&j_password=password
+   * j_username=name&j_password=password
    *
    * body koennte auch einen JSON-Ausdruck enthalten wie z.B.
    * {"name": "fred", "password": "secret"}
@@ -65,12 +62,12 @@
   public void handle(HttpExchange exchange) throws IOException {
     User nutzer = getUser(exchange);
     HttpContext context = exchange.getHttpContext();
-    Object o = context.getAttributes().get(ATTR_JWT_AUTH);
+    Object o = context.getAttributes().get(ATTR_AUTHENTICATOR);
     if (o instanceof TokenAuthenticator) {
-      TokenAuthenticator jwtAuth = (TokenAuthenticator) o;
-      String token = jwtAuth.anmelden(nutzer.getName(), nutzer.getPassword());
+      TokenAuthenticator auth = (TokenAuthenticator) o;
+      String token = auth.anmelden(nutzer.getName(), nutzer.getPassword());
       if (token != null) {
-        loginResponse(exchange, jwtAuth, token);
+        loginResponse(exchange, auth, token);
       } else {
         // Nutzer und Kennwort passen nicht
       }
@@ -81,7 +78,7 @@
   
   protected void setAuthenticatedHeader(HttpExchange exchange, Authenticator auth, String token) {
     if(auth instanceof TokenAuthenticator) {
-      TokenAuthenticator jwtAuth = (TokenAuthenticator) auth;
+      TokenAuthenticator tAuth = (TokenAuthenticator) auth;
       // angemeldet, Token als Antwort zurueckgeben
       Headers respHeaders = exchange.getResponseHeaders();
       // JWT=[cookie-inhalt]; Expires=Thu, 21 Oct 2021 07:28:00 GMT; Secure; HttpOnly
@@ -89,7 +86,7 @@
               new SimpleDateFormat(TokenAuthenticator.HEADER_DATE_PATTERN, Locale.US);
       Date exp = Date.from(new Date().toInstant().plusSeconds(TokenAuthenticator.TOKEN_EXPIRATION));
       respHeaders.add(TokenAuthenticator.SET_COOKIE_HEADER, 
-              jwtAuth.cookieBilden(TokenAuthenticator.JWT_INDICATOR, token, exp));
+              tAuth.cookieBilden(TokenAuthenticator.JWT_INDICATOR, token, exp));
     }
   }
   
@@ -97,7 +94,7 @@
   
   protected abstract User getUser(HttpExchange exchange) throws IOException;
 
-  
+  /*
   protected String bodyLesen(HttpExchange exchange) throws IOException {
     StringBuilder sb = new StringBuilder();
     InputStream is = exchange.getRequestBody();
@@ -109,6 +106,6 @@
     }
     return sb.toString();
   }
-  
+  */
   
 }

--
Gitblit v1.9.3