use of org.apache.neethi.Policy in project tesb-rt-se by Talend.
the class AbstractPolicyTest method customPolicyTest.
public void customPolicyTest(SchemaValidationPolicy assertion, String customerName) throws Exception {
clientCtxt = new ClassPathXmlApplicationContext("classpath:spring/client/policy/client-defaultApplicationContext.xml");
ClientProxyFactoryBean clientFactory = (ClientProxyFactoryBean) clientCtxt.getBean(ClientProxyFactoryBean.class);
Policy policy = new Policy();
policy.addAssertion(assertion);
clientFactory.getProperties().put(PolicyConstants.POLICY_OVERRIDE, policy);
CustomerServiceTester tester = new CustomerServiceTester();
tester.setCustomerService(clientFactory.create(CustomerService.class));
tester.testCustomerService(customerName);
clientCtxt.close();
}
use of org.apache.neethi.Policy 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));
}
use of org.apache.neethi.Policy 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);
}
use of org.apache.neethi.Policy 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);
}
use of org.apache.neethi.Policy in project cxf by apache.
the class SpnegoContextTokenInInterceptor method handleMessage.
public void handleMessage(SoapMessage message) throws Fault {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
// extract Assertion information
if (aim != null) {
Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.SPNEGO_CONTEXT_TOKEN);
if (ais.isEmpty()) {
return;
}
if (isRequestor(message)) {
// client side should be checked on the way out
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
return;
}
String s = (String) message.get(SoapBindingConstants.SOAP_ACTION);
if (s == null) {
s = SoapActionInInterceptor.getSoapAction(message);
}
AddressingProperties inProps = (AddressingProperties) message.getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
if (inProps != null && s == null) {
// MS/WCF doesn't put a soap action out for this, must check the headers
s = inProps.getAction().getValue();
}
if (s != null && s.contains("/RST/Issue") && (s.startsWith(STSUtils.WST_NS_05_02) || s.startsWith(STSUtils.WST_NS_05_12))) {
Policy p = new Policy();
ExactlyOne ea = new ExactlyOne();
p.addPolicyComponent(ea);
All all = new All();
Assertion ass = NegotiationUtils.getAddressingPolicy(aim, false);
all.addPolicyComponent(ass);
ea.addPolicyComponent(all);
// setup endpoint and forward to it.
unmapSecurityProps(message);
String ns = STSUtils.WST_NS_05_12;
if (s.startsWith(STSUtils.WST_NS_05_02)) {
ns = STSUtils.WST_NS_05_02;
}
NegotiationUtils.recalcEffectivePolicy(message, ns, p, new SpnegoSTSInvoker(), false);
} else {
message.getInterceptorChain().add(SpnegoContextTokenFinderInterceptor.INSTANCE);
}
}
}
Aggregations