Программно изменить сервер STS в клиенте METRO SOAP

Можно ли изменить Secure Token Server, который мой клиент использует во время выполнения?

У меня есть рабочий клиент METRO 2.3 для службы .NET, которая защищена с помощью службы токенов безопасности служб федерации Active Directory. Все настраивается с использованием файлов xml. Сервис предлагает два одинаковых сервера. Один для тестирования и один для производства.

Можно ли переключить сервер во время выполнения?

Мой сокращенный wsit-client.xml:

<definitions xmlns="http://schemas.xmlsoap.org/wsdl/">
    <import location="mex.xml" namespace="http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice"/>
    <import location="myservice.svc.xml" namespace="http://namespace.org/"/>
</definitions>

И важная часть моего mex.xml:

<wsdl:definitions name="SecurityTokenService" 
                  targetNamespace="http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice" 
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
                  xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" 
                  xmlns:wsa10="http://www.w3.org/2005/08/addressing" 
                  xmlns:wsp1="http://www.w3.org/ns/ws-policy" 
                  xmlns:tc="http://schemas.sun.com/ws/2006/05/trust/client">
    <wsdl:service name="SecurityTokenService">
        <wsdl:port name="IssuedTokenWSTrustBinding_IWSTrust13Async" binding="tns:IssuedTokenWSTrustBinding_IWSTrust13Async">
            <soap12:address location="http://login.test.miljoeportal.dk/adfs/services/trust/13/issuedtokensymmetricbasic256sha256"/>
            <wsa10:EndpointReference>
                <wsa10:Address>http://login.test.theserver.com/adfs/services/trust/13/issuedtokensymmetricbasic256sha256</wsa10:Address>
                <Identity xmlns="http://schemas.xmlsoap.org/ws/2006/02/addressingidentity">
                    <KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
                        <X509Data>
                            <X509Certificate>THECERTIFICATE</X509Certificate>
                        </X509Data>
                    </KeyInfo>
                </Identity>
            </wsa10:EndpointReference>
        </wsdl:port>
    </wsdl:service>
    <wsp1:Policy wsu:Id="IssuedTokenWSTrustBinding_IWSTrust13AsyncPolicy">
        <wsp1:ExactlyOne>
            <wsp1:All>
                <tc:PreconfiguredSTS wspp:visibility="private" 
                                     endpoint=    "http://login.test.theserver.com/adfs/services/trust/13/username" 
                                     wsdlLocation="https://login.test.theserver.com/adfs/services/trust/mex" 
                                     metadata=    "https://login.test.theserver.com/adfs/services/trust/mex" 
                                     serviceName="SecurityTokenService" 
                                     portName="UserNameWSTrustBinding_IWSTrust_13Async" 
                                     wstVersion="http://docs.oasis-open.org/ws-sx/ws-trust/200512"/>
            </wsp1:All>
        </wsp1:ExactlyOne>
    </wsp1:Policy>
</wsdl:definitions>

Можно ли изменить URL-адреса http://login.test.theserver.com на http://login.prod.theserver.com во время выполнения?


person Jan    schedule 18.11.2014    source источник
comment
Изменить конечную точку службы легко: metro.java.net/guide/, но я не нахожу информации об изменении sts   -  person Jan    schedule 19.11.2014


Ответы (1)


Эти параметры можно установить так:

MyServices s = new MyService();
myserviceinterface = s.getMyService();

Map<String, Object> context = ((BindingProvider) myserviceinterface ).getRequestContext();
context.put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, "http://service.theserver.com/wsdl");

String stsEndpoint     = "http://login.theserver.com/adfs/services/trust/13/username";
String stsWSDLLocation = "https://login.theserver.com/adfs/services/trust/mex";
String stsServiceName  = "SecurityTokenService";
String stsPortName     = "UserNameWSTrustBinding_IWSTrust13Async";
String stsNamespace    = "http://schemas.microsoft.com/ws/2008/06/identity/securitytokenservice";

context.put(STSIssuedTokenConfiguration.STS_ENDPOINT, stsEndpoint);
context.put(STSIssuedTokenConfiguration.STS_NAMESPACE, stsNamespace);
context.put(STSIssuedTokenConfiguration.STS_WSDL_LOCATION, stsWSDLLocation);
context.put(STSIssuedTokenConfiguration.STS_SERVICE_NAME, stsServiceName);
context.put(STSIssuedTokenConfiguration.STS_PORT_NAME, stsPortName);

Я не нашел способа изменить настройки хранилища ключей во время выполнения.

person Jan    schedule 10.02.2015