Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

decodeAndValidateSamlResponse NULL response #143

Open
smarttang opened this issue Apr 26, 2024 · 0 comments
Open

decodeAndValidateSamlResponse NULL response #143

smarttang opened this issue Apr 26, 2024 · 0 comments

Comments

@smarttang
Copy link

I don't know why?
i try to check, but can't find bug...


   @PostMapping("/samlReply")
    public RedirectView login(HttpServletRequest request, HttpServletResponse response) {
        Reader reader = null;
        InputStream inputStream = getClass().getClassLoader().getResourceAsStream("sso.xml");
        reader = new InputStreamReader(inputStream, StandardCharsets.UTF_8);

        SamlResponse samlResponse = null;
        try {
            assert reader != null;
            SamlClient samlClient = SamlClient.fromMetadata("https://tes1111.authing.cn",
                    "http://authus.findbuer.com/report/samlReply", reader);

            String encodedResponse = request.getParameter("SAMLResponse");
            log.info("encodedResponse:{}", encodedResponse);
            log.info("request.getMethod():{}", request.getMethod());

            samlResponse = samlClient.decodeAndValidateSamlResponse(encodedResponse, request.getMethod());
            log.info("email:{}", samlResponse.getNameID());
        } catch (SamlException e) {
            e.printStackTrace();
        }
        return new RedirectView("/error");
    }
2024-04-26 13:32:53.693  INFO 1 --- [nio-8080-exec-3] c.e.l.r.s.controller.ReportController    : request.getMethod():POST
2024-04-26 13:32:53.792 ERROR 1 --- [nio-8080-exec-3] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is java.lang.NullPointerException] with root cause

java.lang.NullPointerException: null
        at com.coveo.saml.ValidatorUtils.enforceConditions(ValidatorUtils.java:125) ~[saml-client-4.0.0.jar!/:na]
        at com.coveo.saml.ValidatorUtils.validateAssertion(ValidatorUtils.java:110) ~[saml-client-4.0.0.jar!/:na]
        at com.coveo.saml.ValidatorUtils.validate(ValidatorUtils.java:215) ~[saml-client-4.0.0.jar!/:na]
        at com.coveo.saml.SamlClient.decodeAndValidateSamlResponse(SamlClient.java:281) ~[saml-client-4.0.0.jar!/:na]
        at com.example.latrust.report.service.controller.ReportController.login(ReportController.java:125) ~[classes!/:0.0.1-SNAPSHOT]
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_312]
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_312]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_312]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_312]
        at org.springframework.web.method.support.InvocableHandlerMethod.doInvoke(InvocableHandlerMethod.java:190) ~[spring-web-5.2.11.RELEASE.jar!/:5.2.11.RELEASE]
        at org.springframework.web.method.support.InvocableHandlerMethod.invokeForRequest(InvocableHandlerMethod.java:138) ~[spring-web-5.2.11.RELEASE.jar!/:5.2.11.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.ServletInvocableHandlerMethod.invokeAndHandle(ServletInvocableHandlerMethod.java:105) ~[spring-webmvc-5.2.11.RELEASE.jar!/:5.2.11.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.invokeHandlerMethod(RequestMappingHandlerAdapter.java:878) ~[spring-webmvc-5.2.11.RELEASE.jar!/:5.2.11.RELEASE]
        at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter.handleInternal(RequestMappingHandlerAdapter.java:792) ~[spring-webmvc-5.2.11.RELEASE.jar!/:5.2.11.RELEASE]
        at org.springframework.web.servlet.mvc.method.AbstractHandlerMethodAdapter.handle(AbstractHandlerMethodAdapter.java:87) ~[spring-webmvc-5.2.11.RELEASE.jar!/:5.2.11.RELEASE]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant