How to Create a STS

SampleSecurityTokenService.java

import javax.jws.Oneway;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;
import javax.jws.soap.SOAPBinding.ParameterStyle;
import javax.xml.ws.Action;
import javax.xml.ws.soap.Addressing;

import org.oasis_open.docs.ws_sx.ws_trust._200512.RequestSecurityTokenResponseCollectionType;
import org.oasis_open.docs.ws_sx.ws_trust._200512.RequestSecurityTokenResponseType;
import org.oasis_open.docs.ws_sx.ws_trust._200512.RequestSecurityTokenType;

@WebService(name = "SampleSecurityTokenPortType_v1_0", portName = "SampleSecurityTokenPort", serviceName = "SampleSecurityTokenService_v1_0", targetNamespace = "http://fernandoribeiro.eti.br/sample/wstrust-v1", wsdlLocation = "WEB-INF/wsdl/SampleSecurityTokenService-1.0.wsdl")
@SOAPBinding(parameterStyle = ParameterStyle.BARE)
@Addressing
public class SampleSecurityTokenService {

  @WebMethod(operationName = "CancelToken")
  @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Cancel", output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/CancelFinal")
  public @WebResult(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") RequestSecurityTokenResponseType cancelToken(@WebParam(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") final RequestSecurityTokenType request) {
    return null;
  }

  @WebMethod(operationName = "IssueToken")
  @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue", output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTRC/IssueFinal")
  public @WebResult(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") RequestSecurityTokenResponseCollectionType issueToken(@WebParam(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") final RequestSecurityTokenType request) {
    return null;
  }

  @WebMethod(operationName = "RenewToken")
  @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Renew", output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/RenewFinal")
  public @WebResult(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") RequestSecurityTokenResponseType renewToken(@WebParam(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") final RequestSecurityTokenType request) {
    return null;
  }

  @WebMethod(operationName = "STSCancelToken")
  @Oneway
  @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/STSCancel")
  public void stsCancelToken(@WebParam(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") final RequestSecurityTokenType request) {
  }

  @WebMethod(operationName = "ValidateToken")
  @Action(input = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Validate", output = "http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Validate")
  public @WebResult(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") RequestSecurityTokenResponseType validateToken(@WebParam(targetNamespace = "http://docs.oasis-open.org/ws-sx/ws-trust/200512") final RequestSecurityTokenType request) {
    return null;
  }

}

SampleSecurityTokenService.wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://fernandoribeiro.eti.br/sample/wstrust-v1" xmlns:tns="http://fernandoribeiro.eti.br/sample/wstrust-v1" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wst="http://docs.oasis-open.org/ws-sx/ws-trust/200512">
  <wsp:Policy xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="SampleSecurityToken_v1_0_SoapBinding_WSAM_Addressing_Policy">
    <wsam:Addressing wsp:Optional="true">
      <wsp:Policy />
    </wsam:Addressing>
  </wsp:Policy>
  <wsdl:types>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
      <xs:import namespace="http://docs.oasis-open.org/ws-sx/ws-trust/200512" schemaLocation="http://docs.oasis-open.org/ws-sx/ws-trust/200512/ws-trust-1.3.xsd" />
    </xs:schema>
  </wsdl:types>
  <wsdl:message name="CancelToken">
    <wsdl:part name="request" element="wst:RequestSecurityToken" />
  </wsdl:message>
  <wsdl:message name="CancelTokenResponse">
    <wsdl:part name="request" element="wst:RequestSecurityTokenResponse" />
  </wsdl:message>
  <wsdl:message name="IssueToken">
    <wsdl:part name="request" element="wst:RequestSecurityToken" />
  </wsdl:message>
  <wsdl:message name="IssueTokenResponseCollection">
    <wsdl:part name="request" element="wst:RequestSecurityTokenResponseCollection" />
  </wsdl:message>
  <wsdl:message name="RenewToken">
    <wsdl:part name="request" element="wst:RequestSecurityToken" />
  </wsdl:message>
  <wsdl:message name="RenewTokenResponse">
    <wsdl:part name="request" element="wst:RequestSecurityTokenResponse" />
  </wsdl:message>
  <wsdl:message name="STSCancelToken">
    <wsdl:part name="request" element="wst:RequestSecurityToken" />
  </wsdl:message>
  <wsdl:message name="ValidateToken">
    <wsdl:part name="request" element="wst:RequestSecurityToken" />
  </wsdl:message>
  <wsdl:message name="ValidateTokenResponse">
    <wsdl:part name="request" element="wst:RequestSecurityTokenResponse" />
  </wsdl:message>
  <wsdl:portType name="SampleSecurityTokenPortType_v1_0">
    <wsdl:operation name="CancelToken">
      <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Cancel" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Cancel" message="tns:CancelToken" />
      <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Cancel" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Cancel" message="tns:CancelTokenResponse" />
    </wsdl:operation>
    <wsdl:operation name="IssueToken">
      <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Issue" message="tns:IssueToken" />
      <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTRC/IssueFinal" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTRC/IssueFinal" message="tns:IssueTokenResponseCollection" />
    </wsdl:operation>
    <wsdl:operation name="RenewToken">
      <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Renew" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Renew" message="tns:RenewToken" />
      <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Renew" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Renew" message="tns:RenewTokenResponse" />
    </wsdl:operation>
    <wsdl:operation name="STSCancelToken">
      <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/STSCancel" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/STSCancel" message="tns:STSCancelToken" />
    </wsdl:operation>
    <wsdl:operation name="ValidateToken">
      <wsdl:input wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Validate" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RST/Validate" message="tns:ValidateToken" />
      <wsdl:output wsam:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Validate" wsaw:Action="http://docs.oasis-open.org/ws-sx/ws-trust/200512/RSTR/Validate" message="tns:ValidateTokenResponse" />
    </wsdl:operation>
  </wsdl:portType>
  <wsdl:binding name="SampleSecurityToken_v1_0_SoapBinding" type="tns:SampleSecurityTokenPortType_v1_0">
    <wsaw:UsingAddressing />
    <wsp:PolicyReference URI="#SampleSecurityToken_v1_0_SoapBinding_WSAM_Addressing_Policy" />
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="CancelToken">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="IssueToken">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="RenewToken">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
    <wsdl:operation name="STSCancelToken">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
    </wsdl:operation>
    <wsdl:operation name="ValidateToken">
      <soap:operation soapAction="" />
      <wsdl:input>
        <soap:body use="literal" />
      </wsdl:input>
      <wsdl:output>
        <soap:body use="literal" />
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="SampleSecurityTokenService_v1_0">
    <wsdl:port name="SampleSecurityTokenPort" binding="tns:SampleSecurityToken_v1_0_SoapBinding">
      <soap:address location="http://localhost/wstrustsample-1.0/SampleSecurityTokenService_v1_0" />
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

A sample is available here.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s