Class SecureTheWorldValve
- java.lang.Object
-
- org.apache.catalina.util.LifecycleBase
-
- org.apache.catalina.util.LifecycleMBeanBase
-
- org.apache.catalina.valves.ValveBase
-
- org.wso2.carbon.tomcat.ext.valves.SecureTheWorldValve
-
- All Implemented Interfaces:
MBeanRegistration,org.apache.catalina.Contained,org.apache.catalina.JmxEnabled,org.apache.catalina.Lifecycle,org.apache.catalina.Valve
public class SecureTheWorldValve extends org.apache.catalina.valves.ValveBaseThis valves forces HTTP basic auth for all incoming requests Add this valve to catalina-server.xml as follows if you want to secure the world
-
-
Field Summary
-
Fields inherited from class org.apache.catalina.valves.ValveBase
asyncSupported, container, containerLog, next, sm
-
Fields inherited from interface org.apache.catalina.Lifecycle
AFTER_DESTROY_EVENT, AFTER_INIT_EVENT, AFTER_START_EVENT, AFTER_STOP_EVENT, BEFORE_DESTROY_EVENT, BEFORE_INIT_EVENT, BEFORE_START_EVENT, BEFORE_STOP_EVENT, CONFIGURE_START_EVENT, CONFIGURE_STOP_EVENT, PERIODIC_EVENT, START_EVENT, STOP_EVENT
-
-
Constructor Summary
Constructors Constructor Description SecureTheWorldValve()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static Stringdecode(String encoded)decode a Base 64 encoded String.voidinvoke(org.apache.catalina.connector.Request req, org.apache.catalina.connector.Response res)-
Methods inherited from class org.apache.catalina.valves.ValveBase
backgroundProcess, getContainer, getDomainInternal, getNext, getObjectNameKeyProperties, initInternal, isAsyncSupported, setAsyncSupported, setContainer, setNext, startInternal, stopInternal, toString
-
Methods inherited from class org.apache.catalina.util.LifecycleMBeanBase
destroyInternal, getDomain, getObjectName, postDeregister, postRegister, preDeregister, preRegister, register, setDomain, unregister, unregister
-
-
-
-
Method Detail
-
invoke
public void invoke(org.apache.catalina.connector.Request req, org.apache.catalina.connector.Response res) throws IOException, javax.servlet.ServletException- Throws:
IOExceptionjavax.servlet.ServletException
-
decode
public static String decode(String encoded)
decode a Base 64 encoded String.String to byte conversion
This method uses a naive String to byte interpretation, it simply gets each char of the String and calls it a byte.Since we should be dealing with Base64 encoded Strings that is a reasonable assumption.
End of data
We don't try to stop the conversion when we find the "=" end of data padding char. We simply add zero bytes to the unencode buffer.- Parameters:
encoded- The encoded String- Returns:
- the decoded String
-
-