我正在尝试使用基本身份验证自动登录。如果用户来自具有编码字符串的特定位置,我的代码将解码该字符串。如果用户没有编码字符串或没有有效的编码字符串,那么我想使用基本身份验证。我已经看到了针对特定Ip绕过基本身份验证的示例。我试图运行应用程序并尝试通过request.getParameter获取变量值,以通过HTTP请求获取我的值。 但这让我无效。
import java.io.IOException;
import javax.servlet.ServletException;
import org.apache.catalina.connector.Request;
import org.apache.catalina.connector.Response;
import org.apache.catalina.valves.ValveBase;
public class AutoLoginValve extends ValveBase {
private String token;
public AutoLoginValve() {
}
@Override
public void invoke(final Request request, final Response response) throws IOException, ServletException {
// I am trying to get HTTP Request Parameter here but its returning me null If i have correct username and password i do not want to invoke tomcat basic authentication popup
getNext().invoke(request, response);
}
}