use of org.talend.esb.security.saml.STSRESTOutInterceptor in project tesb-rt-se by Talend.
the class STSRESTOutInterceptorTest method handleMessageNotRequestor.
@Test
public void handleMessageNotRequestor() throws Exception {
STSRESTOutInterceptor i = new STSRESTOutInterceptor();
Message message = createMock(Message.class);
message.get(Message.REQUESTOR_ROLE);
expectLastCall().andReturn(false).anyTimes();
STSClient stsClient = createMock(STSClient.class);
i.setStsClient(stsClient);
assertSame(stsClient, i.getStsClient());
replay(message);
i.handleMessage(message);
verify(message);
}
use of org.talend.esb.security.saml.STSRESTOutInterceptor in project tesb-rt-se by Talend.
the class STSRESTOutInterceptorTest method handleMessageNoStsClient.
@Test
public void handleMessageNoStsClient() throws Exception {
STSRESTOutInterceptor i = new STSRESTOutInterceptor();
Message message = createMock(Message.class);
message.get(Message.REQUESTOR_ROLE);
expectLastCall().andReturn(true).anyTimes();
i.setStsClient(null);
assertSame(null, i.getStsClient());
replay(message);
i.handleMessage(message);
verify(message);
}
use of org.talend.esb.security.saml.STSRESTOutInterceptor in project tesb-rt-se by Talend.
the class SAMLRESTUtilsTest method configureClientTest.
@Test
public void configureClientTest() throws Exception {
AbstractJAXRSFactoryBean clientFactory = createMock(AbstractJAXRSFactoryBean.class);
STSClient stsClient = createMock(STSClient.class);
List<Interceptor<? extends Message>> interceptors = new ArrayList<Interceptor<? extends Message>>();
expect(clientFactory.getOutInterceptors()).andReturn(interceptors).anyTimes();
replay(clientFactory);
SAMLRESTUtils.configureClient(clientFactory, stsClient);
assertFalse(interceptors.isEmpty());
for (Interceptor<? extends Message> i : interceptors) {
if (i instanceof STSRESTOutInterceptor) {
assertSame(((STSRESTOutInterceptor) i).getStsClient(), stsClient);
}
}
EasyMock.verify(clientFactory);
}
use of org.talend.esb.security.saml.STSRESTOutInterceptor in project tesb-rt-se by Talend.
the class STSRESTOutInterceptorTest method handleMessage.
@Test
public void handleMessage() throws Exception {
STSRESTOutInterceptor i = new STSRESTOutInterceptor();
Message message = createMock(Message.class);
STSClient stsClient = createMock(STSClient.class);
stsClient.requestSecurityToken(EasyMock.<String>anyObject());
EasyMock.expectLastCall().andReturn(null).anyTimes();
stsClient.setActAs(EasyMock.<String>anyObject());
EasyMock.expectLastCall().atLeastOnce();
stsClient.setOnBehalfOf(EasyMock.<Object>anyObject());
EasyMock.expectLastCall().atLeastOnce();
stsClient.setMessage(EasyMock.<Message>anyObject());
EasyMock.expectLastCall().atLeastOnce();
replay(stsClient);
i.setStsClient(stsClient);
assertSame(stsClient, i.getStsClient());
message.get(Message.REQUESTOR_ROLE);
expectLastCall().andReturn(true).anyTimes();
message.getContextualProperty(SecurityConstants.STS_TOKEN_ACT_AS);
expectLastCall().andReturn(new Object()).anyTimes();
message.getContextualProperty(SecurityConstants.STS_APPLIES_TO);
expectLastCall().andReturn(new Object()).anyTimes();
message.getContextualProperty(SecurityConstants.STS_TOKEN_ON_BEHALF_OF);
expectLastCall().andReturn(new Object()).anyTimes();
replay(message);
i.handleMessage(message);
verify(message);
}
use of org.talend.esb.security.saml.STSRESTOutInterceptor in project tesb-rt-se by Talend.
the class AuxiliaryStorageRestClientSecurityProvider method getClientFactory.
protected JAXRSClientFactoryBean getClientFactory() {
if (null == cachedClientFactory) {
JAXRSClientFactoryBean factoryBean = new JAXRSClientFactoryBean();
factoryBean.setThreadSafe(true);
factoryBean.setAddress(getServerURL());
if (Authentication.BASIC == auxiliaryStorageAuthentication) {
factoryBean.setUsername(authenticationUser);
factoryBean.setPassword(authenticationPassword);
}
if (Authentication.SAML == auxiliaryStorageAuthentication) {
STSClient stsClient = STSClientCreator.create(factoryBean.getBus(), stsProps);
STSRESTOutInterceptor outInterceptor = new STSRESTOutInterceptor();
outInterceptor.setStsClient(stsClient);
factoryBean.getOutInterceptors().add(outInterceptor);
factoryBean.getOutInterceptors().add(new SamlHeaderOutInterceptor());
}
cachedClientFactory = factoryBean;
}
return cachedClientFactory;
}
Aggregations