Как я могу отправить запрос saml, используя jaxws-wsimport, который генерируется из wsdl - PullRequest
1 голос
/ 18 марта 2020
        SecurityTokenService service = new SecurityTokenService();
        SecurityTokenServicePortTypeIssue port = service.getISTSIssue();
        // TODO initialize WS operation arguments here
        RequestSecurityTokenType issueRequest = new RequestSecurityTokenType();

        LifetimeType lifetime = new LifetimeType();

        /*
        * Derive the token creation date and time. Use a GregorianCalendar to establish the current time, then use a DatatypeFactory to map the time data to XML. */
        DatatypeFactory dtFactory = DatatypeFactory.newInstance();
        GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("GMT"));
        XMLGregorianCalendar xmlCalendar = dtFactory.newXMLGregorianCalendar(cal);
        AttributedDateTime created = new AttributedDateTime();
        created.setValue(xmlCalendar.toXMLFormat());
        /*
        * Specify a time interval for token expiration (specified in milliseconds).
         */
        AttributedDateTime expires = new AttributedDateTime();
        xmlCalendar.add(dtFactory.newDuration(30 * 60 * 1000));
        expires.setValue(xmlCalendar.toXMLFormat());

        /*
         * Set the created and expires fields in the lifetime object.
         */
        lifetime.setCreated(created);
        lifetime.setExpires(expires);

        /*
        * Set the token request fields.
         */
        issueRequest.setTokenType("http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0");
        issueRequest.setRequestType("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue");
        issueRequest.setLifetime(lifetime);
        RequestSecurityTokenResponseType result = port.issueRST(issueRequest);
        System.out.println("Result = " + result);
    } catch (Exception ex) {
        System.out.println(ex);
    }

Пожалуйста, скажите мне, что я делаю не так. Вот ошибка, которую я получил после запуска этого кода неудачи.

...