// Path: webapp/src/test/java/org/apache/coheigea/cxf/sts/xacml/common/STSServer.java
// public class STSServer extends AbstractBusTestServerBase {
// 
//     public STSServer() {
// 
//     }
// 
//     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();
//         }
//     }
// }
// 
// Path: webapp/src/test/java/org/apache/coheigea/cxf/sts/xacml/common/TokenTestUtils.java
// public final class TokenTestUtils {
//     
//     private TokenTestUtils() {
//         // complete
//     }
//     
//     public static void updateSTSPort(BindingProvider p, String port) {
//         STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
//         if (stsClient != null) {
//             String location = stsClient.getWsdlLocation();
//             if (location != null && location.contains("8080")) {
//                 stsClient.setWsdlLocation(location.replace("8080", port));
//             } else if (location != null && location.contains("8443")) {
//                 stsClient.setWsdlLocation(location.replace("8443", port));
//             }
//         }
//         stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT + ".sct");
//         if (stsClient != null) {
//             String location = stsClient.getWsdlLocation();
//             if (location.contains("8080")) {
//                 stsClient.setWsdlLocation(location.replace("8080", port));
//             } else if (location.contains("8443")) {
//                 stsClient.setWsdlLocation(location.replace("8443", port));
//             }
//         }
//     }
// 
// }


import org.apache.coheigea.cxf.sts.xacml.common.TokenTestUtils;
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.example.contract.doubleit.DoubleItPortType;
import org.junit.Before;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URL;
import java.net.URLClassLoader;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import org.apache.coheigea.cxf.sts.xacml.common.STSServer;
/*
 * Copyright (C) 2012-2021 THALES.
 *
 * This file is part of AuthzForce CE.
 *
 * AuthzForce CE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * AuthzForce CE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with AuthzForce CE.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.ow2.authzforce.webapp.test.pep.cxf;





/**
 * The client authenticates to the STS using a username/password, and gets a signed holder-of-key SAML Assertion in return. This is presented to the service, who verifies proof-of-possession + the
 * signature of the STS on the assertion. The CXF endpoint extracts roles from the Assertion + populates the security context. Note that the CXF endpoint requires a "role" Claim via the security
 * policy.
 *
 * The CXF Endpoint has configured the XACMLAuthorizingInterceptor, which creates a XACML 3.0 request for dispatch to the PDP, and then enforces the PDP's decision. The PDP is a REST service, that
 * requires that a user must have role "boss" to access the "doubleIt" operation ("alice" has this role, "bob" does not).
 */
public class RESTfulPdpBasedAuthzInterceptorTest extends AbstractBusClientServerTestBase
{

	// public static final String PDP_PORT = allocatePort(PdpServer.class);
	static
	{
		allocatePort(PdpServer.class);
	}

	private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
	private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");

	private static final String PORT = allocatePort(Server.class);
// Path: webapp/src/test/java/org/apache/coheigea/cxf/sts/xacml/common/STSServer.java
// public class STSServer extends AbstractBusTestServerBase {
// 
//     public STSServer() {
// 
//     }
// 
//     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();
//         }
//     }
// }
// 
// Path: webapp/src/test/java/org/apache/coheigea/cxf/sts/xacml/common/TokenTestUtils.java
// public final class TokenTestUtils {
//     
//     private TokenTestUtils() {
//         // complete
//     }
//     
//     public static void updateSTSPort(BindingProvider p, String port) {
//         STSClient stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT);
//         if (stsClient != null) {
//             String location = stsClient.getWsdlLocation();
//             if (location != null && location.contains("8080")) {
//                 stsClient.setWsdlLocation(location.replace("8080", port));
//             } else if (location != null && location.contains("8443")) {
//                 stsClient.setWsdlLocation(location.replace("8443", port));
//             }
//         }
//         stsClient = (STSClient)p.getRequestContext().get(SecurityConstants.STS_CLIENT + ".sct");
//         if (stsClient != null) {
//             String location = stsClient.getWsdlLocation();
//             if (location.contains("8080")) {
//                 stsClient.setWsdlLocation(location.replace("8080", port));
//             } else if (location.contains("8443")) {
//                 stsClient.setWsdlLocation(location.replace("8443", port));
//             }
//         }
//     }
// 
// }


// Path: webapp/src/test/java/org/ow2/authzforce/webapp/test/pep/cxf/RESTfulPdpBasedAuthzInterceptorTest.java
import org.apache.coheigea.cxf.sts.xacml.common.TokenTestUtils;
import org.apache.cxf.BusFactory;
import org.apache.cxf.endpoint.Client;
import org.apache.cxf.frontend.ClientProxy;
import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase;
import org.example.contract.doubleit.DoubleItPortType;
import org.junit.Before;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.net.URL;
import java.net.URLClassLoader;
import javax.xml.namespace.QName;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.Service;
import org.apache.coheigea.cxf.sts.xacml.common.STSServer;

/*
 * Copyright (C) 2012-2021 THALES.
 *
 * This file is part of AuthzForce CE.
 *
 * AuthzForce CE is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * AuthzForce CE is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with AuthzForce CE.  If not, see <http://www.gnu.org/licenses/>.
 */
package org.ow2.authzforce.webapp.test.pep.cxf;





/**
 * The client authenticates to the STS using a username/password, and gets a signed holder-of-key SAML Assertion in return. This is presented to the service, who verifies proof-of-possession + the
 * signature of the STS on the assertion. The CXF endpoint extracts roles from the Assertion + populates the security context. Note that the CXF endpoint requires a "role" Claim via the security
 * policy.
 *
 * The CXF Endpoint has configured the XACMLAuthorizingInterceptor, which creates a XACML 3.0 request for dispatch to the PDP, and then enforces the PDP's decision. The PDP is a REST service, that
 * requires that a user must have role "boss" to access the "doubleIt" operation ("alice" has this role, "bob" does not).
 */
public class RESTfulPdpBasedAuthzInterceptorTest extends AbstractBusClientServerTestBase
{

	// public static final String PDP_PORT = allocatePort(PdpServer.class);
	static
	{
		allocatePort(PdpServer.class);
	}

	private static final String NAMESPACE = "http://www.example.org/contract/DoubleIt";
	private static final QName SERVICE_QNAME = new QName(NAMESPACE, "DoubleItService");

	private static final String PORT = allocatePort(Server.class);
	private static final String STS_PORT = allocatePort(STSServer.class);