use of org.apache.cxf.Bus in project cxf by apache.
the class SAMLRenewUnitTest method testRenewSAML2TokenFail.
@org.junit.Test
public void testRenewSAML2TokenFail() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SAMLRenewUnitTest.class.getResource("cxf-client-unit.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
// Request the token
SecurityToken token = requestSecurityToken(bus, wsdlLocation, WSS4JConstants.WSS_SAML2_TOKEN_TYPE, 2, false);
assertNotNull(token);
// Sleep to expire the token
Thread.sleep(2100);
// Renew the token - this will fail as we didn't send a Renewing @OK attribute
try {
renewSecurityToken(bus, wsdlLocation, token, false);
fail("Failure expected on a different AppliesTo address");
} catch (Exception ex) {
// expected
}
bus.shutdown(true);
}
use of org.apache.cxf.Bus in project cxf by apache.
the class SAMLRenewUnitTest method testRenewSAML2TokenDifferentAppliesTo.
@org.junit.Test
public void testRenewSAML2TokenDifferentAppliesTo() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SAMLRenewUnitTest.class.getResource("cxf-client-unit.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
String wsdlLocation = "https://localhost:" + test.getStsPort() + "/SecurityTokenService/Transport?wsdl";
// Request the token
SecurityToken token = requestSecurityToken(bus, wsdlLocation, WSS4JConstants.WSS_SAML2_TOKEN_TYPE, 2, true);
assertNotNull(token);
// Sleep to expire the token
Thread.sleep(2100);
// Renew the token
token.setIssuerAddress("http://www.apache.org");
try {
renewSecurityToken(bus, wsdlLocation, token, true);
fail("Failure expected on a different AppliesTo address");
} catch (Exception ex) {
// expected
}
bus.shutdown(true);
}
use of org.apache.cxf.Bus in project cxf by apache.
the class AsymmetricEncryptionTest method testEncryptedToken.
@org.junit.Test
public void testEncryptedToken() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = SecurityContextTokenUnitTest.class.getResource("cxf-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
SecurityToken token = requestSecurityToken(bus, test.getStsPort());
assertTrue(token != null);
bus.shutdown(true);
}
use of org.apache.cxf.Bus in project cxf by apache.
the class STSServer method run.
protected void run() {
URL busFile = STSServer.class.getResource("cxf-sts.xml");
Bus busLocal = new SpringBusFactory().createBus(busFile);
BusFactory.setDefaultBus(busLocal);
setBus(busLocal);
try {
new STSServer();
} catch (Exception e) {
e.printStackTrace();
}
}
use of org.apache.cxf.Bus in project cxf by apache.
the class JaxwsBasicAuthTest method testBadBasicAuth.
@org.junit.Test
public void testBadBasicAuth() throws Exception {
SpringBusFactory bf = new SpringBusFactory();
URL busFile = JaxwsBasicAuthTest.class.getResource("cxf-bad-client.xml");
Bus bus = bf.createBus(busFile.toString());
BusFactory.setDefaultBus(bus);
BusFactory.setThreadDefaultBus(bus);
URL wsdl = JaxwsBasicAuthTest.class.getResource("DoubleIt.wsdl");
Service service = Service.create(wsdl, SERVICE_QNAME);
QName portQName = new QName(NAMESPACE, "DoubleItPort");
DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class);
updateAddressPort(port, test.getPort());
if (test.isStreaming()) {
SecurityTestUtil.enableStreaming(port);
}
try {
doubleIt(port, 30);
fail("Expected failure on a bad password");
} catch (javax.xml.ws.soap.SOAPFaultException fault) {
String message = fault.getMessage();
assertTrue(message.contains("STS Authentication failed") || message.contains("Validation of security token failed"));
}
((java.io.Closeable) port).close();
bus.shutdown(true);
}
Aggregations