Package com.networknt.basicauth
Class BasicAuthHandler
- java.lang.Object
-
- com.networknt.basicauth.BasicAuthHandler
-
- All Implemented Interfaces:
LightHttpHandler,MiddlewareHandler,io.undertow.server.HttpHandler
public class BasicAuthHandler extends Object implements MiddlewareHandler
This is a middleware handler that handles basic authentication in restful APIs. It is not used in most situations as OAuth 2.0 is the standard. In certain cases for example, the server is deployed to IoT devices, basic authentication can be used to replace OAuth 2.0 handlers. There are multiple users that can be defined in basic.yml config file. Password can be stored in plain or encrypted format in basic.yml. In case of password encryption, please remember to add corresponding com.networknt.utility.Decryptor in service.yml. And access is logged into audit.log if audit middleware is used.- Author:
- Steve Hu
-
-
Field Summary
-
Fields inherited from interface com.networknt.handler.LightHttpHandler
AUDIT_CONFIG_NAME, AUDIT_ON_ERROR, AUDIT_STACK_TRACE, auditConfig, auditOnError, auditStackTrace, ERROR_NOT_DEFINED
-
-
Constructor Summary
Constructors Constructor Description BasicAuthHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description io.undertow.server.HttpHandlergetNext()voidhandleRequest(io.undertow.server.HttpServerExchange exchange)booleanisEnabled()voidregister()MiddlewareHandlersetNext(io.undertow.server.HttpHandler next)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.networknt.handler.LightHttpHandler
setExchangeStatus, setExchangeStatus, setExchangeStatus
-
-
-
-
Method Detail
-
handleRequest
public void handleRequest(io.undertow.server.HttpServerExchange exchange) throws Exception- Specified by:
handleRequestin interfaceio.undertow.server.HttpHandler- Throws:
Exception
-
getNext
public io.undertow.server.HttpHandler getNext()
- Specified by:
getNextin interfaceMiddlewareHandler
-
setNext
public MiddlewareHandler setNext(io.undertow.server.HttpHandler next)
- Specified by:
setNextin interfaceMiddlewareHandler
-
isEnabled
public boolean isEnabled()
- Specified by:
isEnabledin interfaceMiddlewareHandler
-
register
public void register()
- Specified by:
registerin interfaceMiddlewareHandler
-
-