Skip to content
This repository was archived by the owner on Jul 31, 2022. It is now read-only.

Commit 31dec99

Browse files
committed
Reimplemented Authenticator
1 parent 5007b80 commit 31dec99

File tree

3 files changed

+90
-31
lines changed

3 files changed

+90
-31
lines changed

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpExchangeAuthenticator.java

Lines changed: 0 additions & 28 deletions
This file was deleted.

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpServer.java

Lines changed: 67 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
package com.kttdevelopment.simplehttpserver;
22

3-
import com.sun.net.httpserver.HttpHandler;
4-
import com.sun.net.httpserver.HttpServer;
5-
import com.sun.net.httpserver.HttpContext;
3+
import com.sun.net.httpserver.*;
64

75
import java.io.IOException;
86
import java.net.InetSocketAddress;
@@ -271,6 +269,72 @@ public static SimpleHttpServer create(final int port, final int backlog) throws
271269
*/
272270
public abstract HttpContext createContext(final String context, final SimpleHttpHandler handler);
273271

272+
//
273+
274+
/**
275+
* Creates a context mapped to a specific {@link HttpContext} with an {@link Authenticator}.
276+
*
277+
* @param context the context
278+
* @param authenticator authenticator
279+
* @return the http context associated with the context
280+
* @throws IllegalArgumentException if the context is invalid or taken
281+
* @throws NullPointerException if the context is null
282+
*
283+
* @see HttpContext
284+
* @see Authenticator
285+
* @see #createContext(String, HttpHandler, Authenticator)
286+
* @see #createContext(String, SimpleHttpHandler, Authenticator)
287+
* @see #removeContext(String)
288+
* @see #removeContext(HttpContext)
289+
* @since 03.03.00
290+
* @author Ktt Development
291+
*/
292+
public abstract HttpContext createContext(final String context, final Authenticator authenticator);
293+
294+
/**
295+
* Creates a context mapped to a specific {@link HttpContext} with an {@link Authenticator}.
296+
*
297+
* @param context the context
298+
* @param handler the handler
299+
* @param authenticator authenticator
300+
* @return the http context associated with the context
301+
* @throws IllegalArgumentException if the context is invalid or taken
302+
* @throws NullPointerException if the context is null
303+
*
304+
* @see HttpContext
305+
* @see HttpHandler
306+
* @see Authenticator
307+
* @see #createContext(String, Authenticator)
308+
* @see #createContext(String, SimpleHttpHandler, Authenticator)
309+
* @see #removeContext(String)
310+
* @see #removeContext(HttpContext)
311+
* @since 03.03.00
312+
* @author Ktt Development
313+
*/
314+
public abstract HttpContext createContext(final String context, final HttpHandler handler, final Authenticator authenticator);
315+
316+
/**
317+
* Creates a context mapped to a specific {@link HttpContext} with an {@link Authenticator}.
318+
*
319+
* @param context the context
320+
* @param handler the handler
321+
* @param authenticator authenticator
322+
* @return the http context associated with the context
323+
* @throws IllegalArgumentException if the context is invalid or taken
324+
* @throws NullPointerException if the context is null
325+
*
326+
* @see HttpContext
327+
* @see SimpleHttpHandler
328+
* @see Authenticator
329+
* @see #createContext(String, Authenticator)
330+
* @see #createContext(String, HttpHandler, Authenticator)
331+
* @see #removeContext(String)
332+
* @see #removeContext(HttpContext)
333+
* @since 03.03.00
334+
* @author Ktt Development
335+
*/
336+
public abstract HttpContext createContext(final String context, final SimpleHttpHandler handler, final Authenticator authenticator);
337+
274338
//
275339

276340
/**

src/main/java/com/kttdevelopment/simplehttpserver/SimpleHttpServerImpl.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,29 @@ public synchronized final HttpContext createContext(final String path, final Sim
125125
return context;
126126
}
127127

128+
//
129+
130+
@Override
131+
public synchronized final HttpContext createContext(final String path, final Authenticator authenticator){
132+
final HttpContext context = createContext(path);
133+
context.setAuthenticator(authenticator);
134+
return context;
135+
}
136+
137+
@Override
138+
public synchronized final HttpContext createContext(final String path, final HttpHandler handler, final Authenticator authenticator){
139+
final HttpContext context = createContext(path,handler);
140+
context.setAuthenticator(authenticator);
141+
return context;
142+
}
143+
144+
@Override
145+
public synchronized final HttpContext createContext(final String path, final SimpleHttpHandler handler, final Authenticator authenticator){
146+
final HttpContext context = createContext(path,handler);
147+
context.setAuthenticator(authenticator);
148+
return context;
149+
}
150+
128151

129152
//
130153

0 commit comments

Comments
 (0)