将用户属性从 CAS 传递到 Web 应用程序

Passing User Attrinbutes from CAS to web app

我有一个受 CAS 保护的网络应用程序。现在我想打印当前登录的用户但是。我得到

javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException:No name matching localhost found

这是我的代码

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.getServletContext().log("T1");
    System.out.println("T2");

    PrintWriter writer = response.getWriter();

    String userID = request.getRemoteUser();

    HttpSession session = request.getSession(true);

    writer.println("<html>");
    writer.println("<head><title>Hello World Servlet</title></head>");
    writer.println("<body>");
    writer.println("<h1>Congratulations! You are logged in " + userID + "</h1>");if(request.getUserPrincipal() != null) {
        AttributePrincipal principal = (AttributePrincipal) request.getUserPrincipal();

        writer.println("<h1>P: " +  principal.getName() + "</h1>");


        Map<String, Object> attributes = principal.getAttributes();

        Iterator<String> attributeNames = attributes.keySet().iterator();

        writer.print("<p>");
        writer.println();

        while(attributeNames.hasNext()) {
            String attributeName = attributeNames.next();

            writer.print(attributeName + ": ");
            writer.print(attributes.get(attributeName));
            writer.println();
        }

        writer.print("<p>");
    }

    writer.println("<body>");
    writer.println("</html>");

    writer.close();         
}

在我的 web.xml 中,我正确使用了 SAMLValidationFilter 和 SAMLAuthentication 过滤器。有谁知道我在做什么是错误的。或者有一个工作示例?

问题不在于示例代码。这是你的环境。您正在尝试访问不受您的运行时 java 环境信任的 HTTPS 端点。使用 https://github.com/UniconLabs/java-keystore-ssl-test

测试该端点