Search in sources :

Example 6 with EsbSecurity

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

the class SecurityArgumentsTest method buildBasicAuthorizationPolicy.

@Test
public void buildBasicAuthorizationPolicy() throws Exception {
    EsbSecurity esbSecurity = EsbSecurity.fromString("BASIC");
    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(), "Basic");
}
Also used : AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) Test(org.junit.Test)

Example 7 with EsbSecurity

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

the class SecurityArgumentsTest method constructorTest.

@Test
public void constructorTest() throws Exception {
    EsbSecurity esbSecurity = EsbSecurity.fromString(null);
    Policy policy = createNiceMock(Policy.class);
    String username = "username";
    String password = "password";
    String alias = "alias";
    Map<String, String> clientProperties = new HashMap<String, String>();
    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);
    assertSame(sa.getEsbSecurity(), esbSecurity);
    assertSame(sa.getPolicy(), policy);
    assertSame(sa.getUsername(), username);
    assertSame(sa.getPassword(), password);
    assertSame(sa.getAlias(), alias);
    assertSame(sa.getClientProperties(), clientProperties);
    assertSame(sa.getRoleName(), roleName);
    assertSame(sa.getSecurityToken(), securityToken);
    assertSame(sa.getCryptoProvider(), cryptoProvider);
}
Also used : Policy(org.apache.neethi.Policy) AuthorizationPolicy(org.apache.cxf.configuration.security.AuthorizationPolicy) Crypto(org.apache.wss4j.common.crypto.Crypto) EsbSecurity(org.talend.esb.job.controller.ESBEndpointConstants.EsbSecurity) HashMap(java.util.HashMap) Test(org.junit.Test)

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