Search in sources :

Example 1 with EsbSecurity

use of org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity in project tesb-rt-se by Talend.

the class RuntimeESBConsumerTest method noPropertiesSetProvidesEmptyArgumentList.

@Test
public void noPropertiesSetProvidesEmptyArgumentList() throws Exception {
    QName serviceName = new QName("http://services.talend.org/test/Library/1.0", "LibraryProvider");
    QName portName = new QName("http://services.talend.org/test/Library/1.0", "LibraryHttpPort");
    QName operationName = new QName("http://services.talend.org/test/Library/1.0", "seekBook");
    String publishedEndpointUrl = "local://LibraryHttpPort";
    String wsdlURL = "classpath:/conf/libraryService/Library.wsdl";
    boolean useServiceLocator = false;
    LocatorFeature locatorFeature = null;
    Map<String, String> locatorProps = new HashMap<String, String>();
    EventFeature samFeature = null;
    Map<String, String> samProps = new HashMap<String, String>();
    boolean useServiceRegistry = false;
    EsbSecurity esbSecurity = null;
    Policy policy = null;
    String username = "";
    String password = "";
    String alias = "";
    Map<String, String> clientProperties = new HashMap<String, String>();
    String roleName = "";
    Object securityToken = null;
    Crypto cryptoProvider = null;
    SecurityArguments securityArguments = new SecurityArguments(esbSecurity, policy, username, password, alias, clientProperties, roleName, securityToken, cryptoProvider);
    Bus bus = null;
    boolean logging = false;
    List<Header> soapHeaders = new ArrayList<Header>();
    Feature httpHeadersFeature = null;
    boolean enhancedResponse = false;
    Object correlationIDCallbackHandler = null;
    final boolean useGZipCompression = false;
    RuntimeESBConsumer consumer = new RuntimeESBConsumer(serviceName, portName, operationName, publishedEndpointUrl, wsdlURL, useServiceLocator, locatorFeature, locatorProps, samFeature, samProps, useServiceRegistry, securityArguments, bus, logging, soapHeaders, httpHeadersFeature, enhancedResponse, correlationIDCallbackHandler, useGZipCompression);
    String requestString = "<ns2:SearchFor xmlns:ns2=\"http://types.talend.org/test/Library/Common/1.0\" " + "xmlns:ns3=\"http://types.talend.org/test/GeneralObjects/ErrorHandling/1.0\">" + "<AuthorLastName>Icebear</AuthorLastName><ISBNNumber>123</ISBNNumber></ns2:SearchFor>";
    consumer.invoke(getDocumentFromString(requestString));
}
Also used : Policy(org.apache.neethi.Policy) Bus(org.apache.cxf.Bus) HashMap(java.util.HashMap) QName(javax.xml.namespace.QName) ArrayList(java.util.ArrayList) EventFeature(org.talend.esb.sam.agent.feature.EventFeature) EventFeature(org.talend.esb.sam.agent.feature.EventFeature) LocatorFeature(org.talend.esb.servicelocator.cxf.LocatorFeature) Feature(org.apache.cxf.feature.Feature) Crypto(org.apache.wss4j.common.crypto.Crypto) Header(org.apache.cxf.headers.Header) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) LocatorFeature(org.talend.esb.servicelocator.cxf.LocatorFeature) Test(org.junit.Test)

Example 2 with EsbSecurity

use of org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity in project tesb-rt-se by Talend.

the class SecurityArgumentsTest method buildClientConfigWithoutAlias.

@Test
public void buildClientConfigWithoutAlias() throws Exception {
    initSTSClientUtils();
    EsbSecurity esbSecurity = EsbSecurity.fromString("DIGEST");
    Policy policy = createNiceMock(Policy.class);
    String username = "username";
    String password = "password";
    String alias = null;
    Map<String, String> clientProperties = new HashMap<String, String>();
    String actor = "ws-security.actor";
    clientProperties.put("ws-security.actor", actor);
    String roleName = "roleName";
    Object securityToken = new Object();
    Crypto cryptoProvider = createNiceMock(Crypto.class);
    SecurityArguments sa = new SecurityArguments(esbSecurity, policy, username, password, alias, clientProperties, roleName, securityToken, cryptoProvider);
    Bus bus = createNiceMock(Bus.class);
    boolean useServiceRegistry = true;
    String encryptionUsername = "encryptionUsername";
    Map<String, Object> config = sa.buildClientConfig(bus, useServiceRegistry, encryptionUsername);
    assertSame(config.get("security.username"), username);
    assertSame(config.get("security.encryption.username"), encryptionUsername);
    assertSame(config.get("security.password"), password);
    assertSame(config.get("security.signature.username"), alias);
    assertSame(config.get("security.encryption.crypto"), cryptoProvider);
}
Also used : Policy(org.apache.neethi.Policy) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Bus(org.apache.cxf.Bus) Crypto(org.apache.wss4j.common.crypto.Crypto) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 3 with EsbSecurity

use of org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity in project tesb-rt-se by Talend.

the class SecurityArgumentsTest method buildClientConfig.

@Test
public void buildClientConfig() throws Exception {
    initSTSClientUtils();
    EsbSecurity esbSecurity = EsbSecurity.fromString("DIGEST");
    Policy policy = createNiceMock(Policy.class);
    String username = "username";
    String password = "password";
    String alias = "alias";
    Map<String, String> clientProperties = new HashMap<String, String>();
    String actor = "actor";
    String cacheConfiFile = "file:123";
    clientProperties.put(SecurityConstants.ACTOR, actor);
    clientProperties.put(SecurityConstants.CACHE_CONFIG_FILE, cacheConfiFile);
    String roleName = "roleName";
    Object securityToken = new Object();
    Crypto cryptoProvider = createNiceMock(Crypto.class);
    SecurityArguments sa = new SecurityArguments(esbSecurity, policy, username, password, alias, clientProperties, roleName, securityToken, cryptoProvider);
    Bus bus = createNiceMock(Bus.class);
    boolean useServiceRegistry = true;
    String encryptionUsername = "encryptionUsername";
    Map<String, Object> config = sa.buildClientConfig(bus, useServiceRegistry, encryptionUsername);
    assertSame(config.get("security.username"), username);
    assertSame(config.get("security.encryption.username"), encryptionUsername);
    assertSame(config.get("security.password"), password);
    assertSame(config.get("security.signature.username"), alias);
    assertSame(config.get("security.encryption.crypto"), cryptoProvider);
}
Also used : Policy(org.apache.neethi.Policy) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Bus(org.apache.cxf.Bus) Crypto(org.apache.wss4j.common.crypto.Crypto) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 4 with EsbSecurity

use of org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity in project tesb-rt-se by Talend.

the class SecurityArgumentsTest method buildDigestAuthorizationPolicy.

@Test
public void buildDigestAuthorizationPolicy() throws Exception {
    EsbSecurity esbSecurity = EsbSecurity.fromString("DIGEST");
    String username = "username";
    String password = "password";
    String alias = "alias";
    SecurityArguments sa = new SecurityArguments(esbSecurity, null, username, password, alias, null, null, null, null);
    AuthorizationPolicy p = sa.buildAuthorizationPolicy();
    assertSame(p.getPassword(), password);
    assertSame(p.getUserName(), username);
    assertSame(p.getAuthorizationType(), "Digest");
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) Test(org.junit.Test)

Example 5 with EsbSecurity

use of org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity in project tesb-rt-se by Talend.

the class RuntimeESBEndpointRegistry method createConsumer.

@Override
public ESBConsumer createConsumer(ESBEndpointInfo endpoint) {
    final Map<String, Object> props = endpoint.getEndpointProperties();
    boolean useServiceRegistry = getBoolean(props, ESBEndpointConstants.USE_SERVICE_REGISTRY);
    final String authorizationRole = (String) props.get(ESBEndpointConstants.AUTHZ_ROLE);
    boolean useCrypto = getBoolean(props, ESBEndpointConstants.USE_CRYPTO);
    final EsbSecurity esbSecurity = EsbSecurity.fromString((String) props.get(ESBEndpointConstants.ESB_SECURITY));
    Policy policy = buildSecurePolicy(authorizationRole, useCrypto, esbSecurity);
    final SecurityArguments securityArguments = new SecurityArguments(esbSecurity, policy, (String) props.get(ESBEndpointConstants.USERNAME), (String) props.get(ESBEndpointConstants.PASSWORD), (String) props.get(ESBEndpointConstants.ALIAS), clientProperties, authorizationRole, props.get(ESBEndpointConstants.SECURITY_TOKEN), (useCrypto || useServiceRegistry) ? cryptoProvider : null);
    List<Header> soapHeaders = listSoapHeaders(props.get(ESBEndpointConstants.SOAP_HEADERS));
    if (useServiceRegistry) {
        ensureServiceRegistryAvailable(bus);
    }
    final QName serviceName = QName.valueOf((String) props.get(ESBEndpointConstants.SERVICE_NAME));
    String operationNamespace = (String) props.get(ESBEndpointConstants.OPERATION_NAMESPACE);
    final QName operationName = new QName((null == operationNamespace) ? serviceName.getNamespaceURI() : operationNamespace, (String) props.get(ESBEndpointConstants.DEFAULT_OPERATION_NAME));
    return new RuntimeESBConsumer(serviceName, QName.valueOf((String) props.get(ESBEndpointConstants.PORT_NAME)), operationName, (String) props.get(ESBEndpointConstants.PUBLISHED_ENDPOINT_URL), (String) props.get(ESBEndpointConstants.WSDL_URL), getBoolean(props, ESBEndpointConstants.USE_SERVICE_LOCATOR), locatorFeature, (Map<String, String>) props.get(ESBEndpointConstants.REQUEST_SL_PROPS), getBoolean(props, ESBEndpointConstants.USE_SERVICE_ACTIVITY_MONITOR) ? samFeature : null, (Map<String, String>) props.get(ESBEndpointConstants.REQUEST_SAM_PROPS), useServiceRegistry, securityArguments, bus, getBoolean(props, ESBEndpointConstants.LOG_MESSAGES), soapHeaders, (Feature) props.get("httpHeadersFeature"), getBoolean(props, ESBEndpointConstants.ENHANCED_RESPONSE), props.get(CorrelationIDFeature.CORRELATION_ID_CALLBACK_HANDLER), getBoolean(props, ESBEndpointConstants.USE_GZIP_COMPRESSION));
}
Also used : Policy(org.apache.neethi.Policy) Header(org.apache.cxf.headers.Header) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) QName(javax.xml.namespace.QName)

Aggregations

EsbSecurity (org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity)7 Test (org.junit.Test)6 AuthorizationPolicy (org.apache.cxf.configuration.security.AuthorizationPolicy)5 Policy (org.apache.neethi.Policy)5 HashMap (java.util.HashMap)4 Crypto (org.apache.wss4j.common.crypto.Crypto)4 Bus (org.apache.cxf.Bus)3 QName (javax.xml.namespace.QName)2 Header (org.apache.cxf.headers.Header)2 ArrayList (java.util.ArrayList)1 Feature (org.apache.cxf.feature.Feature)1 EventFeature (org.talend.esb.sam.agent.feature.EventFeature)1 LocatorFeature (org.talend.esb.servicelocator.cxf.LocatorFeature)1