diff --git a/org.wso2.carbon.sts.claim.mgt/.classpath b/org.wso2.carbon.sts.claim.mgt/.classpath deleted file mode 100644 index 83dd2f4..0000000 --- a/org.wso2.carbon.sts.claim.mgt/.classpath +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.carbon.sts.claim.mgt/pom.xml b/org.wso2.carbon.sts.claim.mgt/pom.xml deleted file mode 100644 index 6abed53..0000000 --- a/org.wso2.carbon.sts.claim.mgt/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - org.wso2.carbon.sts - identity-inbound-auth-sts - 1.0.0 - - 4.0.0 - org.wso2.carbon.sts.claim.mgt - bundle - org.wso2.carbon.sts.claim.mgt - - - - org.wso2.msf4j - msf4j-core - 2.1.0 - - - org.apache.cxf - cxf-core - 3.1.11 - - - org.apache.cxf.services.sts - cxf-services-sts-core - 3.1.11 - - - - - org.wso2.carbon.sts.claim.mgt.internal - - !org.wso2.carbon.sts.claim.mgt.internal, - org.wso2.carbon.sts.claim.mgt.*, - - - org.osgi.framework.*;version="${osgi.framework.import.version.range}", - - - - diff --git a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/ClaimsManagerFactory.java b/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/ClaimsManagerFactory.java deleted file mode 100644 index b4fd184..0000000 --- a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/ClaimsManagerFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.wso2.carbon.sts.claim.mgt; - -import org.apache.cxf.sts.claims.ClaimsHandler; -import org.apache.cxf.sts.claims.ClaimsManager; - -public class ClaimsManagerFactory { - - private static ClaimsManager claimsManager; - - private ClaimsManagerFactory () { - - } - - public static ClaimsManager getInstance() { - if(claimsManager != null) { - return claimsManager; - } else { - claimsManager = new ClaimsManager(); - claimsManager.getClaimHandlers().add(new STSClaimsHandler()); - - return claimsManager; - } - } - - public static void setClaimsHandler(ClaimsHandler handler) { - claimsManager.getClaimHandlers().add(handler); - } - - public static void removeAllClaimsHandlers() { - claimsManager.getClaimHandlers().clear(); - } -} diff --git a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/STSClaimsHandler.java b/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/STSClaimsHandler.java deleted file mode 100644 index 0c576ab..0000000 --- a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/STSClaimsHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -package org.wso2.carbon.sts.claim.mgt; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import org.apache.cxf.rt.security.claims.Claim; -import org.apache.cxf.rt.security.claims.ClaimCollection; -import org.apache.cxf.sts.claims.ClaimsHandler; -import org.apache.cxf.sts.claims.ClaimsParameters; -import org.apache.cxf.sts.claims.ProcessedClaim; -import org.apache.cxf.sts.claims.ProcessedClaimCollection; - -// Dummy Class. -// Need to be replaced with an actual implementation -public class STSClaimsHandler implements ClaimsHandler { - - public static final URI ROLE = URI - .create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/role"); - public static final URI GIVEN_NAME = URI - .create("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname"); - public static final URI LANGUAGE = URI - .create("http://schemas.mycompany.com/claims/language"); - - public ProcessedClaimCollection retrieveClaimValues(ClaimCollection claims, - ClaimsParameters parameters) { - - if (claims != null && !claims.isEmpty()) { - ProcessedClaimCollection claimCollection = new ProcessedClaimCollection(); - for (Claim requestClaim : claims) { - ProcessedClaim claim = new ProcessedClaim(); - claim.setClaimType(requestClaim.getClaimType()); - claim.setIssuer("Test Issuer"); - claim.setOriginalIssuer("Original Issuer"); - if (ROLE.equals(requestClaim.getClaimType())) { - if ("alice".equals(parameters.getPrincipal().getName())) { - claim.addValue("admin-user"); - } else { - claim.addValue("ordinary-user"); - } - } else if (GIVEN_NAME.equals(requestClaim.getClaimType())) { - claim.addValue(parameters.getPrincipal().getName()); - } else if (LANGUAGE.equals(requestClaim.getClaimType())) { - claim.addValue(parameters.getPrincipal().getName()); - } - claimCollection.add(claim); - } - return claimCollection; - } - return null; - } - - public List getSupportedClaimTypes() { - List list = new ArrayList<>(); - list.add(ROLE); - list.add(GIVEN_NAME); - list.add(LANGUAGE); - return list; - } -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/internal/STSServiceDataHolder.java b/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/internal/STSServiceDataHolder.java deleted file mode 100644 index 3c81031..0000000 --- a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/internal/STSServiceDataHolder.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.wso2.carbon.sts.claim.mgt.internal; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class STSServiceDataHolder { - Logger logger = LoggerFactory.getLogger(STSServiceDataHolder.class.getName()); - - private static STSServiceDataHolder instance = new STSServiceDataHolder(); - - private STSServiceDataHolder() { - - } - - public static STSServiceDataHolder getInstance() { - return instance; - } -} diff --git a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/internal/ServiceComponent.java b/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/internal/ServiceComponent.java deleted file mode 100644 index bb30e21..0000000 --- a/org.wso2.carbon.sts.claim.mgt/src/main/java/org/wso2/carbon/sts/claim/mgt/internal/ServiceComponent.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.wso2.carbon.sts.claim.mgt.internal; - -import org.apache.cxf.sts.claims.ClaimsHandler; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wso2.carbon.sts.claim.mgt.ClaimsManagerFactory; -import org.wso2.carbon.sts.claim.mgt.STSClaimsHandler; - -@Component(name = "org.wso2.carbon.sts.claim.mgt.internal.ServiceComponent", immediate = true) -public class ServiceComponent { - - Logger logger = LoggerFactory.getLogger(ServiceComponent.class.getName()); - private ServiceRegistration serviceRegistration; - - @Activate - protected void start(BundleContext bundleContext) throws Exception { - logger.info("Service Component is activated"); - - bundleContext.registerService( - ClaimsHandler.class.getName(), new STSClaimsHandler(), null); - - serviceRegistration = bundleContext.registerService(ClaimsManagerFactory.class.getName(), - ClaimsManagerFactory.getInstance(), null); - } - - @Deactivate - protected void stop() throws Exception { - logger.info("Service Component is deactivated"); - serviceRegistration.unregister(); - } - - // @Reference(name = "carbon.runtime.service", service = - // CarbonRuntime.class, cardinality = ReferenceCardinality.MANDATORY, policy - // = ReferencePolicy.DYNAMIC, unbind = "unsetCarbonRuntime") - // protected void deactivate(ComponentContext ctxt) { - // if (logger.isDebugEnabled()) { - // logger.debug("Carbon STS bundle is deactivated"); - // } - // } -} diff --git a/org.wso2.carbon.sts.provider/.classpath b/org.wso2.carbon.sts.provider/.classpath old mode 100755 new mode 100644 index 85a6e58..6d7587a --- a/org.wso2.carbon.sts.provider/.classpath +++ b/org.wso2.carbon.sts.provider/.classpath @@ -6,7 +6,7 @@ - + @@ -22,7 +22,7 @@ - + diff --git a/org.wso2.carbon.sts.provider/pom.xml b/org.wso2.carbon.sts.provider/pom.xml old mode 100755 new mode 100644 index f4874a9..191bd38 --- a/org.wso2.carbon.sts.provider/pom.xml +++ b/org.wso2.carbon.sts.provider/pom.xml @@ -1,141 +1,86 @@ - - - - 4.0.0 - - org.wso2.carbon.sts - identity-inbound-auth-sts - 1.0.0 - - - org.wso2.carbon.sts.provider - bundle - org.wso2.carbon.sts.provider - - - - org.wso2.msf4j - msf4j-core - provided - - - org.wso2.msf4j - msf4j-swagger - provided - - - org.wso2.carbon.sts - org.wso2.carbon.sts.security.provider - 1.0.0 - provided - - - org.wso2.carbon.sts - org.wso2.carbon.sts.provider2 - 1.0.0 - provided - - - org.apache.neethi - neethi - 3.0.3 - provided - - - javax.xml.stream - stax-api - 1.0-2 - provided - - - org.apache.cxf - cxf-bundle-compatible - 3.1.12 - - - org.apache.cxf.services.sts - cxf-services-sts-core - 3.1.11 - - - org.apache.servicemix.bundles - org.apache.servicemix.bundles.wsdl4j - 1.6.3_1 - - - org.apache.wss4j - wss4j-ws-security-dom - 2.1.10 - - - org.slf4j - slf4j-api - 1.7.25 - - - com.google.guava - guava - 22.0 - - - commons-codec - commons-codec - 1.10 - - - org.codehaus.woodstox - woodstox-core-asl - 4.4.1 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.felix - maven-bundle-plugin - 3.3.0 - true - - - - - - - org.wso2.carbon.sts.resource.*;version="${project.version}" - - - org.osgi.framework.*;version="${osgi.framework.import.version.range}", - org.wso2.msf4j.*, - javax.ws.rs.*, - io.swagger.annotations.*, - org.wso2.carbon.messaging.*, - org.apache.log4j.*, - org.wso2.carbon.sts.security.provider.*, - org.apache.neethi.*, - - * - - osgi.service;objectClass="org.wso2.msf4j.Interceptor";serviceCount="1", - osgi.service;objectClass="org.wso2.msf4j.Microservice";serviceCount="1" - - *;scope=!provided|!test;inline=false - target/dependency - true - - + + + 4.0.0 + + org.wso2.carbon.sts + identity-inbound-auth-sts + 1.0.0 + + + org.wso2.carbon.sts.provider + bundle + org.wso2.carbon.sts.provider + + + + org.wso2.carbon.sts + org.wso2.carbon.sts.cxf + 1.0.0 + + + org.wso2.eclipse.osgi + org.eclipse.osgi.services + provided + + + org.wso2.eclipse.osgi + org.eclipse.osgi + 3.10.2.v20150203-1939 + provided + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.8 + 1.8 + + + + org.apache.maven.plugins + maven-surefire-plugin + + + org.apache.felix + maven-bundle-plugin + 3.3.0 + true + + + + + + + org.wso2.carbon.sts.provider.*, + + + org.osgi.framework.*;version="${osgi.framework.import.version.range}", + org.apache.log4j.*, + org.apache.cxf.ws.security.tokenstore.*, + org.apache.cxf.sts.token.validator.*, + org.apache.wss4j.common.ext.*, + org.apache.cxf.sts.token.renewer.*, + org.apache.cxf.sts.token.provider.*, + org.apache.cxf.sts.service.*, + org.apache.cxf.sts.operation.*, + org.apache.cxf.sts.event.*, + org.apache.cxf.sts.claims.*, + org.apache.cxf.sts.*, + org.apache.cxf.ws.security.sts.provider.model.*, + org.apache.cxf.ws.security.sts.provider.*, + org.apache.cxf.staxutils.*, + org.apache.cxf.binding.soap.*, + org.apache.cxf.common.jaxb.*, + org.apache.cxf.common.jaxb.*, + org.apache.cxf.common.util.*, + org.apache.cxf.helpers.*, + + + \ No newline at end of file diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/AbstractResource.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/AbstractResource.java deleted file mode 100755 index 7cedec7..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/AbstractResource.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.wso2.carbon.sts.resource; - -import javax.ws.rs.core.Context; - -import org.wso2.msf4j.Microservice; -import org.wso2.msf4j.Request; -import org.wso2.msf4j.Response; - -public abstract class AbstractResource implements Microservice { - - public abstract void processRequest(@Context Request request, - @Context Response response); -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/STSResource.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/STSResource.java deleted file mode 100755 index 607cf43..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/STSResource.java +++ /dev/null @@ -1,105 +0,0 @@ -package org.wso2.carbon.sts.resource; - -import io.swagger.annotations.Info; -import io.swagger.annotations.License; -import io.swagger.annotations.SwaggerDefinition; - -import javax.ws.rs.Consumes; -import javax.ws.rs.POST; -import javax.ws.rs.Path; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MediaType; -import javax.xml.transform.Source; -import javax.xml.ws.Provider; - -import org.apache.cxf.binding.soap.SoapFault; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Reference; -import org.osgi.service.component.annotations.ReferenceCardinality; -import org.osgi.service.component.annotations.ReferencePolicy; -import org.wso2.carbon.sts.provider2.provider.DefaultSecurityTokenServiceProvider; -import org.wso2.carbon.sts.resource.internal.DataHolder; -import org.wso2.carbon.sts.resource.utils.SOAPUtils; -import org.wso2.carbon.sts.resource.utils.WSContext; -import org.wso2.msf4j.Microservice; -import org.wso2.msf4j.Request; -import org.wso2.msf4j.Response; - -@Component( - name = "org.wso2.carbon.sts.resources.STSResource", - service = Microservice.class, - immediate = true -) - -@SwaggerDefinition( - info = @Info( - title = "/SecurityTokenService Endpoint Swagger Definition", version = "1.0", - description = "STS /SecurityTokenService endpoint", - license = @License(name = "Apache 2.0", url = "http://www.apache.org/licenses/LICENSE-2.0")) -) -@Path("/services") -public class STSResource extends AbstractResource { - - private SOAPUtils instance = SOAPUtils.getInstance(); - - @POST - @Path("/wso2carbon-sts") - @Consumes(MediaType.TEXT_XML) - - public void processRequest(@Context Request request, @Context Response response) { - - try { - DefaultSecurityTokenServiceProvider provider = DataHolder.getInstance().getServiceProvider(); - provider.setWebServiceContext(WSContext.getInstance() - .getWSContext()); - Source resp = provider.invoke((Source) request - .getProperty(Source.class.getName())); - - String m = instance.soapToString(instance.buildSoapResponse(resp)); - - response.setEntity(m); - - } catch (SoapFault fault) { - response.setEntity(instance.soapToString(instance - .createSoapFault(fault))); - } catch (Exception e) { - //log here - } - - response.send(); - } - - @Reference( - name = "provider", - service = Provider.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "removePolicy" - ) - public void addServiceProvider(Provider provider) { - - DataHolder.getInstance().setServiceProvider(((DefaultSecurityTokenServiceProvider)provider)); - } - - public void removePolicy(Provider provider) { - - DataHolder.getInstance().setServiceProvider(null); - } - - /*@Reference( - name = "policy", - service = SecurityPolicyService.class, - cardinality = ReferenceCardinality.MANDATORY, - policy = ReferencePolicy.DYNAMIC, - unbind = "removePolicy" - ) - public void addPolicy(SecurityPolicyService provider) { - - DataHolder.getInstance().setPolicy(((SecurityPolicyServiceImpl)provider).getEffectivePolicy()); - } - - public void removePolicy(SecurityPolicyService provider) { - - DataHolder.getInstance().setPolicy(null); - }*/ -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/MSF4JMessageInInterceptor.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/MSF4JMessageInInterceptor.java deleted file mode 100644 index a090895..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/MSF4JMessageInInterceptor.java +++ /dev/null @@ -1,175 +0,0 @@ -package org.wso2.carbon.sts.resource.interceptor; - -import java.io.ByteArrayInputStream; -import java.nio.ByteBuffer; -import java.util.List; - -import javax.xml.namespace.QName; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPMessage; -import javax.xml.stream.XMLStreamReader; -import javax.xml.transform.Source; -import javax.xml.transform.dom.DOMSource; - -import org.apache.cxf.binding.soap.SoapFault; -import org.apache.cxf.binding.soap.SoapMessage; -import org.apache.cxf.binding.soap.interceptor.CheckFaultInterceptor; -import org.apache.cxf.binding.soap.interceptor.MustUnderstandInterceptor; -import org.apache.cxf.binding.soap.interceptor.ReadHeadersInterceptor; -import org.apache.cxf.binding.soap.interceptor.SoapActionInInterceptor; -import org.apache.cxf.binding.soap.interceptor.StartBodyInterceptor; -import org.apache.cxf.binding.soap.saaj.SAAJInInterceptor; -import org.apache.cxf.bus.managers.PhaseManagerImpl; -import org.apache.cxf.interceptor.InterceptorChain; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageImpl; -import org.apache.cxf.staxutils.StaxUtils; -import org.apache.cxf.ws.policy.PolicyConstants; -import org.apache.cxf.ws.policy.PolicyInInterceptor; -import org.osgi.service.component.annotations.Component; -import org.wso2.carbon.sts.resource.internal.DataHolder; -import org.wso2.carbon.sts.resource.utils.SOAPUtils; -import org.wso2.carbon.sts.resource.utils.WSContext; -import org.wso2.msf4j.Interceptor; -import org.wso2.msf4j.Request; -import org.wso2.msf4j.Response; -import org.wso2.msf4j.ServiceMethodInfo; -import org.wso2.msf4j.util.BufferUtil; - -@Component( - name = "org.wso2.carbon.sts.resource.interceptor.MSF4JMessageInInterceptor", - service = Interceptor.class, - immediate = true -) -public class MSF4JMessageInInterceptor implements Interceptor { - - public static final String METHOD = "org.wso2.carbon.sts.resource.STSResource"; - - public static final String WST_NS_05_12 = "http://docs.oasis-open.org/ws-sx/ws-trust/200512"; - public static final QName FAILED_AUTH = new QName(WST_NS_05_12, - "FailedAuthentication"); - public static final QName INVALID_REQUEST = new QName(WST_NS_05_12, - "InvalidRequest"); - - @Override - public void postCall(Request request, int status, - ServiceMethodInfo serviceMethodInfo) throws Exception { - - /* - * SoapHeaderOutFilterInterceptor(); SoapPreProtocolOutInterceptor(); - * SoapOutInterceptor(); - */ - - } - - @Override - public boolean preCall(Request request, Response response, - ServiceMethodInfo smi) throws SoapFault { - - if (METHOD.equals(smi.getMethodName())) { - - SAAJInInterceptor saajIn = new SAAJInInterceptor(); - boolean faultExist = false; - DOMSource source = null; - - SoapMessage message = processMessage(request); - WSContext.getInstance().buildWebServiceContext(request, message); - - message.put(Message.REQUESTOR_ROLE, Boolean.FALSE); - message.put(Message.INBOUND_MESSAGE, Boolean.TRUE); - message.put(SoapMessage.HTTP_REQUEST_METHOD, - request.getHttpMethod()); - message.put(Message.CONTENT_TYPE, request.getContentType()); - message.put("endpoint-processes-headers", - "{http://cxf.apache.org/outofband/Header}outofbandHeader"); - - InterceptorChain chain = message.getInterceptorChain(); - - chain.add((org.apache.cxf.interceptor.Interceptor) saajIn - .getAdditionalInterceptors().iterator().next()); - chain.add(new ReadHeadersInterceptor(message.getExchange().getBus())); - chain.add(new MustUnderstandInterceptor()); - chain.add(new SoapActionInInterceptor()); - chain.add(new CheckFaultInterceptor()); - chain.add(new StartBodyInterceptor()); - chain.add(new PolicyInInterceptor()); - chain.add(saajIn); - - chain.doIntercept(message); - - if (message.getContent(Exception.class) != null) { - SoapFault fault = new SoapFault(message.getContent( - Exception.class).getMessage(), FAILED_AUTH); - - response.setEntity(SOAPUtils.getInstance().soapToString( - SOAPUtils.getInstance().createSoapFault(fault))); - - faultExist = true; - } - - if (!faultExist) { - - try { - source = new DOMSource(message - .getContent(SOAPMessage.class).getSOAPBody() - .extractContentAsDocument()); - request.setProperty(Source.class.getName(), source); - } catch (SOAPException e) { - faultExist = true; - // log here - } - } - - if (faultExist) { - response.send(); - return false; - } - } - return true; - } - - private SoapMessage processMessage(Request request) { - List fullMessageBody = request.getFullMessageBody(); - ByteBuffer buffer = BufferUtil.merge(fullMessageBody); - - byte[] bytes = new byte[buffer.remaining()]; - buffer.get(bytes, 0, bytes.length); - buffer.clear(); - bytes = new byte[buffer.capacity()]; - buffer.get(bytes, 0, bytes.length); - - Message m = new MessageImpl(); - m.setContent(XMLStreamReader.class, StaxUtils - .createXMLStreamReader(new ByteArrayInputStream(bytes))); - setExtensions(m); - - return new SoapMessage(m); - } - - private void setExtensions(Message m) { - - Exchange ex = DataHolder.getInstance().getExchange(); - ex.getEndpoint() - .getEndpointInfo() - .setProperty("security.callback-handler", - new PasswordCallbackHandler()); - ex.getEndpoint() - .getEndpointInfo() - .setProperty(PolicyConstants.POLICY_OVERRIDE, - DataHolder.getInstance().getPolicy()); - /* - * ex.getEndpoint() .getEndpointInfo() - * .setProperty(SecurityConstants.ENABLE_STREAMING_SECURITY, - * Boolean.TRUE); - */ - - PhaseInterceptorChain chain = new PhaseInterceptorChain( - new PhaseManagerImpl().getInPhases()); - - m.setInterceptorChain(chain); - ex.setInMessage(m); - m.setExchange(ex); - } - -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/MessageBuilderComponent.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/MessageBuilderComponent.java deleted file mode 100644 index ed575d1..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/MessageBuilderComponent.java +++ /dev/null @@ -1,95 +0,0 @@ -package org.wso2.carbon.sts.resource.interceptor; - -import java.util.Collection; -import java.util.List; - -import javax.wsdl.Definition; - -import org.apache.cxf.Bus; -import org.apache.cxf.bus.extension.ExtensionManagerBus; -import org.apache.cxf.endpoint.Endpoint; -import org.apache.cxf.endpoint.EndpointImpl; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.ExchangeImpl; -import org.apache.cxf.service.Service; -import org.apache.cxf.service.ServiceImpl; -import org.apache.cxf.service.model.EndpointInfo; -import org.apache.cxf.service.model.ServiceInfo; -import org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder; -import org.apache.cxf.ws.policy.AssertionBuilderRegistry; -import org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl; -import org.apache.cxf.ws.policy.PolicyBuilderImpl; -import org.apache.cxf.ws.policy.PolicyEngine; -import org.apache.cxf.ws.policy.PolicyEngineImpl; -import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry; -import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistryImpl; -import org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader; -import org.apache.cxf.wsdl11.WSDLServiceBuilder; -import org.osgi.framework.BundleContext; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.wso2.carbon.sts.resource.internal.DataHolder; -import org.wso2.carbon.sts.resource.security.SecurityComponent; -import org.wso2.carbon.sts.resource.security.SecurityPolicyServiceImpl; - -@Component( - name = "org.wso2.carbon.sts.resource.interceptor.MessageBuilderComponent", - immediate = true -) -public class MessageBuilderComponent { - - @Activate - public void start(BundleContext c) { - - try { - Bus bus = new ExtensionManagerBus(); - bus.setExtension(new AssertionBuilderRegistryImpl(), - AssertionBuilderRegistry.class); - bus.setExtension(new PolicyInterceptorProviderRegistryImpl(), - PolicyInterceptorProviderRegistry.class); - - bus.setExtension(new PolicyEngineImpl(bus), PolicyEngine.class); - - @SuppressWarnings("unused") - PolicyBuilderImpl pb = new PolicyBuilderImpl(bus); - - AssertionBuilderRegistryImpl reg = (AssertionBuilderRegistryImpl) bus - .getExtension(AssertionBuilderRegistry.class); - reg.setBus(bus); - - pb = new PolicyBuilderImpl(bus); - - @SuppressWarnings("unused") - WSSecurityPolicyLoader loader = new WSSecurityPolicyLoader(bus); - - // / ??? - new SecurityComponent().processPolicies(c, bus); - DataHolder.getInstance().setPolicy( - new SecurityPolicyServiceImpl().getEffectivePolicy()); - - WSDLDefinitionBuilder builder = new WSDLDefinitionBuilder(bus); - Definition definition = builder.build("ws-trust-1.4-service.wsdl"); - WSDLServiceBuilder wsb = new WSDLServiceBuilder(bus); - - List serviceInfo = wsb.buildServices(definition); - ServiceInfo si = serviceInfo.get(0); - Service service = new ServiceImpl(si); - - Collection endpointInfo = si.getEndpoints(); - EndpointInfo ei = endpointInfo.iterator().next(); - - Endpoint endpoint = new EndpointImpl(bus, service, ei); - - Exchange exchange = new ExchangeImpl(); - exchange.put(Bus.class, bus); - exchange.put(Service.class, service); - exchange.put(Endpoint.class, endpoint); - - DataHolder.getInstance().setExchange(exchange); - - } catch (Exception e) { - // log here - } - } - -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/PhaseInterceptorChain.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/PhaseInterceptorChain.java deleted file mode 100644 index fdc6105..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/interceptor/PhaseInterceptorChain.java +++ /dev/null @@ -1,842 +0,0 @@ -package org.wso2.carbon.sts.resource.interceptor; - -import java.lang.ref.WeakReference; -import java.util.Collection; -import java.util.HashMap; -import java.util.Iterator; -import java.util.ListIterator; -import java.util.Map; -import java.util.NoSuchElementException; -import java.util.Set; -import java.util.SortedSet; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.apache.cxf.common.logging.LogUtils; -import org.apache.cxf.common.util.StringUtils; -import org.apache.cxf.continuations.SuspendedInvocationException; -import org.apache.cxf.interceptor.Fault; -import org.apache.cxf.interceptor.Interceptor; -import org.apache.cxf.interceptor.InterceptorChain; -import org.apache.cxf.interceptor.ServiceInvokerInterceptor; -import org.apache.cxf.logging.FaultListener; -import org.apache.cxf.message.Exchange; -import org.apache.cxf.message.FaultMode; -import org.apache.cxf.message.Message; -import org.apache.cxf.message.MessageUtils; -import org.apache.cxf.phase.Phase; -import org.apache.cxf.phase.PhaseInterceptor; -import org.apache.cxf.service.Service; -import org.apache.cxf.service.model.BindingOperationInfo; -import org.apache.cxf.service.model.OperationInfo; -import org.apache.cxf.transport.MessageObserver; -import org.apache.cxf.ws.security.wss4j.WSS4JStaxInInterceptor; - -/** - * A PhaseInterceptorChain orders Interceptors according to the phase they - * participate in and also according to the before & after properties on an - * Interceptor. - *

- * A List of phases is supplied to the PhaseInterceptorChain in the constructor. - * This class is typically instantiated from the PhaseChainCache class in this - * package. Interceptors that are added to the chain are ordered by phase. - * Within a phase, interceptors can order themselves. Each PhaseInterceptor - * has an ID. PhaseInterceptors can supply a Collection of IDs which they - * should run before or after, supplying fine grained ordering. - *

- * - */ -public class PhaseInterceptorChain implements InterceptorChain { - public static final String PREVIOUS_MESSAGE = PhaseInterceptorChain.class.getName() + ".PREVIOUS_MESSAGE"; - - private static final Logger LOG = LogUtils.getL7dLogger(PhaseInterceptorChain.class); - - private static final ThreadLocal CURRENT_MESSAGE = new ThreadLocal(); - - private final Map nameMap; - private final Phase phases[]; - - // heads[phase] refers to the first interceptor of the given phase - private InterceptorHolder heads[]; - // tails[phase] refers to the last interceptor of the given phase - private InterceptorHolder tails[]; - // hasAfters[phase] indicates that the given phase has already inserted - // interceptors that may need to be placed after future to-be-inserted - // interceptors. This flag is used to activate ordering of interceptors - // when new ones are added to the list for this phase. - // Note no hasBefores[] is needed because implementation adds subsequent - // interceptors to the end of the list by default. - private boolean hasAfters[]; - - - private State state; - private Message pausedMessage; - private MessageObserver faultObserver; - private PhaseInterceptorIterator iterator; - private final boolean isFineLogging; - - // currently one chain for one request/response, use below as signal - // to avoid duplicate fault processing on nested calling of - // doIntercept(), which will throw same fault multi-times - private boolean faultOccurred; - private boolean chainReleased; - - - private PhaseInterceptorChain(PhaseInterceptorChain src) { - isFineLogging = LOG.isLoggable(Level.FINE); - - //only used for clone - state = State.EXECUTING; - - //immutable, just repoint - nameMap = src.nameMap; - phases = src.phases; - - int length = phases.length; - hasAfters = new boolean[length]; - System.arraycopy(src.hasAfters, 0, hasAfters, 0, length); - - heads = new InterceptorHolder[length]; - tails = new InterceptorHolder[length]; - - InterceptorHolder last = null; - for (int x = 0; x < length; x++) { - InterceptorHolder ih = src.heads[x]; - while (ih != null - && ih.phaseIdx == x) { - InterceptorHolder ih2 = new InterceptorHolder(ih); - ih2.prev = last; - if (last != null) { - last.next = ih2; - } - if (heads[x] == null) { - heads[x] = ih2; - } - tails[x] = ih2; - last = ih2; - ih = ih.next; - } - } - } - - public PhaseInterceptorChain(SortedSet ps) { - state = State.EXECUTING; - isFineLogging = LOG.isLoggable(Level.FINE); - - int numPhases = ps.size(); - phases = new Phase[numPhases]; - nameMap = new HashMap(); - - heads = new InterceptorHolder[numPhases]; - tails = new InterceptorHolder[numPhases]; - hasAfters = new boolean[numPhases]; - - int idx = 0; - for (Phase phase : ps) { - phases[idx] = phase; - nameMap.put(phase.getName(), idx); - ++idx; - } - } - - public static Message getCurrentMessage() { - return CURRENT_MESSAGE.get(); - } - - public static boolean setCurrentMessage(PhaseInterceptorChain chain, Message m) { - if (getCurrentMessage() == m) { - return false; - } - if (chain.iterator.hasPrevious()) { - chain.iterator.previous(); - if (chain.iterator.next() instanceof ServiceInvokerInterceptor) { - CURRENT_MESSAGE.set(m); - return true; - } else { - String error = "Only ServiceInvokerInterceptor can update the current chain message"; - LOG.warning(error); - throw new IllegalStateException(error); - } - } - return false; - - } - - public synchronized State getState() { - return state; - } - - public synchronized void releaseAndAcquireChain() { - while (!chainReleased) { - try { - this.wait(); - } catch (InterruptedException ex) { - // ignore - } - } - chainReleased = false; - } - - public synchronized void releaseChain() { - this.chainReleased = true; - this.notifyAll(); - } - - public PhaseInterceptorChain cloneChain() { - return new PhaseInterceptorChain(this); - } - - private void updateIterator() { - if (iterator == null) { - iterator = new PhaseInterceptorIterator(heads); - outputChainToLog(false); - //System.out.println(toString()); - } - } - - public void add(Collection> newhandlers) { - add(newhandlers, false); - } - - public void add(Collection> newhandlers, boolean force) { - if (newhandlers == null) { - return; - } - - for (Interceptor handler : newhandlers) { - add(handler, force); - } - } - - public void add(Interceptor i) { - add(i, false); - } - - public void add(Interceptor i, boolean force) { - PhaseInterceptor pi = (PhaseInterceptor)i; - - String phaseName = pi.getPhase(); - Integer phase = nameMap.get(phaseName); - - if (phase == null) { - LOG.warning("Skipping interceptor " + i.getClass().getName() - + ((phaseName == null) ? ": Phase declaration is missing." - : ": Phase " + phaseName + " specified does not exist.")); - } else { - if (isFineLogging) { - LOG.fine("Adding interceptor " + i + " to phase " + phaseName); - } - - insertInterceptor(phase, pi, force); - } - Collection> extras - = pi.getAdditionalInterceptors(); - if (extras != null) { - for (PhaseInterceptor p : extras) { - add(p, force); - } - } - } - - public synchronized void pause() { - state = State.PAUSED; - pausedMessage = CURRENT_MESSAGE.get(); - } - public synchronized void unpause() { - if (state == State.PAUSED || state == State.SUSPENDED) { - state = State.EXECUTING; - pausedMessage = null; - } - } - - public synchronized void suspend() { - state = State.SUSPENDED; - pausedMessage = CURRENT_MESSAGE.get(); - } - - public synchronized void resume() { - if (state == State.PAUSED || state == State.SUSPENDED) { - state = State.EXECUTING; - Message m = pausedMessage; - pausedMessage = null; - doIntercept(m); - } - } - - /** - * Intercept a message, invoking each phase's handlers in turn. - * - * @param message the message - * @throws Exception - */ - @SuppressWarnings("unchecked") - public synchronized boolean doIntercept(Message message) { - updateIterator(); - - Message oldMessage = CURRENT_MESSAGE.get(); - try { - CURRENT_MESSAGE.set(message); - if (oldMessage != null - && !message.containsKey(PREVIOUS_MESSAGE) - && message != oldMessage - && message.getExchange() != oldMessage.getExchange()) { - message.put(PREVIOUS_MESSAGE, new WeakReference(oldMessage)); - } - while (state == State.EXECUTING && iterator.hasNext()) { - try { - Interceptor currentInterceptor = (Interceptor)iterator.next(); - if (isFineLogging) { - LOG.fine("Invoking handleMessage on interceptor " + currentInterceptor); - } - - System.out.println(message.get(WSS4JStaxInInterceptor.SECURITY_PROCESSED)); - System.out.println("-----------" + currentInterceptor); - currentInterceptor.handleMessage(message); - if (state == State.SUSPENDED) { - // throw the exception to make sure thread exit without interrupt - throw new SuspendedInvocationException(); - } - - } catch (SuspendedInvocationException ex) { - System.out.println("IOP"); - ex.printStackTrace(); - // we need to resume from the same interceptor the exception got originated from - if (iterator.hasPrevious()) { - iterator.previous(); - } - pause(); - throw ex; - } catch (RuntimeException ex) { - ex.printStackTrace(); - if (!faultOccurred) { - faultOccurred = true; - wrapExceptionAsFault(message, ex); - } - state = State.ABORTED; - } - } - if (state == State.EXECUTING) { - state = State.COMPLETE; - } - return state == State.COMPLETE; - } finally { - CURRENT_MESSAGE.set(oldMessage); - } - } - - private void wrapExceptionAsFault(Message message, RuntimeException ex) { - String description = getServiceInfo(message); - - message.setContent(Exception.class, ex); - unwind(message); - Exception ex2 = message.getContent(Exception.class); - if (ex2 == null) { - ex2 = ex; - } - - FaultListener flogger = (FaultListener) - message.getContextualProperty(FaultListener.class.getName()); - boolean useDefaultLogging = true; - if (flogger != null) { - useDefaultLogging = flogger.faultOccurred(ex2, description, message); - } - if (useDefaultLogging) { - doDefaultLogging(message, ex2, description); - } - - if (message.getExchange() != null && message.getContent(Exception.class) != null) { - message.getExchange().put(Exception.class, ex2); - } - - if (faultObserver != null && !isOneWay(message)) { - // CXF-5629. when exchange is one way and robust, it becomes req-resp in order to - // send the fault - message.getExchange().setOneWay(false); - faultObserver.onMessage(message); - } - } - - private String getServiceInfo(Message message) { - StringBuilder description = new StringBuilder(); - if (message.getExchange() != null) { - Exchange exchange = message.getExchange(); - Service service = exchange.getService(); - if (service != null) { - description.append('\''); - description.append(service.getName()); - BindingOperationInfo boi = exchange.getBindingOperationInfo(); - OperationInfo opInfo = boi != null ? boi.getOperationInfo() : null; - if (opInfo != null) { - description.append("#").append(opInfo.getName()); - } - description.append("\' "); - } - } - return description.toString(); - } - - private void doDefaultLogging(Message message, Exception ex, String description) { - FaultMode mode = message.get(FaultMode.class); - if (mode == FaultMode.CHECKED_APPLICATION_FAULT) { - if (isFineLogging) { - LogUtils.log(LOG, Level.FINE, - "Application " + description - + "has thrown exception, unwinding now", ex); - } else if (LOG.isLoggable(Level.INFO)) { - Throwable t = ex; - if (ex instanceof Fault - && ex.getCause() != null) { - t = ex.getCause(); - } - - LogUtils.log(LOG, Level.INFO, - "Application " + description - + "has thrown exception, unwinding now: " - + t.getClass().getName() - + ": " + ex.getMessage()); - } - } else if (LOG.isLoggable(Level.WARNING)) { - if (mode == FaultMode.UNCHECKED_APPLICATION_FAULT) { - LogUtils.log(LOG, Level.WARNING, - "Application " + description - + "has thrown exception, unwinding now", ex); - } else { - LogUtils.log(LOG, Level.WARNING, - "Interceptor for " + description - + "has thrown exception, unwinding now", ex); - } - } - } - - private boolean isOneWay(Message message) { - return (message.getExchange() != null) ? message.getExchange().isOneWay() && !isRobustOneWay(message) : false; - } - - private boolean isRobustOneWay(Message message) { - return MessageUtils.isTrue(message.getContextualProperty(Message.ROBUST_ONEWAY)); - } - - /** - * Intercept a message, invoking each phase's handlers in turn, - * starting after the specified interceptor. - * - * @param message the message - * @param startingAfterInterceptorID the id of the interceptor - * @throws Exception - */ - public synchronized boolean doInterceptStartingAfter(Message message, - String startingAfterInterceptorID) { - updateIterator(); - while (state == State.EXECUTING && iterator.hasNext()) { - PhaseInterceptor currentInterceptor - = (PhaseInterceptor)iterator.next(); - if (currentInterceptor.getId().equals(startingAfterInterceptorID)) { - break; - } - } - return doIntercept(message); - } - - /** - * Intercept a message, invoking each phase's handlers in turn, - * starting at the specified interceptor. - * - * @param message the message - * @param startingAtInterceptorID the id of the interceptor - * @throws Exception - */ - public synchronized boolean doInterceptStartingAt(Message message, - String startingAtInterceptorID) { - updateIterator(); - while (state == State.EXECUTING && iterator.hasNext()) { - PhaseInterceptor currentInterceptor - = (PhaseInterceptor)iterator.next(); - if (currentInterceptor.getId().equals(startingAtInterceptorID)) { - iterator.previous(); - break; - } - } - return doIntercept(message); - } - - public synchronized void reset() { - updateIterator(); - if (state == State.COMPLETE) { - state = State.EXECUTING; - iterator.reset(); - } else { - iterator.reset(); - } - } - - @SuppressWarnings("unchecked") - public void unwind(Message message) { - while (iterator.hasPrevious()) { - Interceptor currentInterceptor = (Interceptor)iterator.previous(); - if (isFineLogging) { - LOG.fine("Invoking handleFault on interceptor " + currentInterceptor); - } - try { - currentInterceptor.handleFault(message); - } catch (RuntimeException e) { - LOG.log(Level.WARNING, "Exception in handleFault on interceptor " + currentInterceptor, e); - throw e; - } catch (Exception e) { - LOG.log(Level.WARNING, "Exception in handleFault on interceptor " + currentInterceptor, e); - throw new RuntimeException(e); - } - } - } - - public void remove(Interceptor i) { - PhaseInterceptorIterator it = new PhaseInterceptorIterator(heads); - while (it.hasNext()) { - InterceptorHolder holder = it.nextInterceptorHolder(); - if (holder.interceptor == i) { - remove(holder); - return; - } - } - } - - public synchronized void abort() { - this.state = InterceptorChain.State.ABORTED; - } - - public Iterator> iterator() { - return getIterator(); - } - public ListIterator> getIterator() { - return new PhaseInterceptorIterator(heads); - } - - private void remove(InterceptorHolder i) { - if (i.prev != null) { - i.prev.next = i.next; - } - if (i.next != null) { - i.next.prev = i.prev; - } - int ph = i.phaseIdx; - if (heads[ph] == i) { - if (i.next != null - && i.next.phaseIdx == ph) { - heads[ph] = i.next; - } else { - heads[ph] = null; - tails[ph] = null; - } - } - if (tails[ph] == i) { - if (i.prev != null - && i.prev.phaseIdx == ph) { - tails[ph] = i.prev; - } else { - heads[ph] = null; - tails[ph] = null; - } - } - } - - private void insertInterceptor(int phase, PhaseInterceptor interc, boolean force) { - InterceptorHolder ih = new InterceptorHolder(interc, phase); - if (heads[phase] == null) { - // no interceptors yet in this phase - heads[phase] = ih; - tails[phase] = ih; - hasAfters[phase] = !interc.getAfter().isEmpty(); - - int idx = phase - 1; - while (idx >= 0) { - if (tails[idx] != null) { - break; - } - --idx; - } - if (idx >= 0) { - //found something before us, in an earlier phase - ih.prev = tails[idx]; - ih.next = tails[idx].next; - if (ih.next != null) { - ih.next.prev = ih; - } - tails[idx].next = ih; - } else { - //did not find something before us, try after - idx = phase + 1; - while (idx < heads.length) { - if (heads[idx] != null) { - break; - } - ++idx; - } - - if (idx != heads.length) { - //found something after us - ih.next = heads[idx]; - heads[idx].prev = ih; - } - } - } else { // this phase already has interceptors attached - - // list of interceptors that the new interceptor should precede - Set beforeList = interc.getBefore(); - - // list of interceptors that the new interceptor should be after - Set afterList = interc.getAfter(); - - // firstBefore will hold the first interceptor of a given phase - // that the interceptor to be added must precede - InterceptorHolder firstBefore = null; - - // lastAfter will hold the last interceptor of a given phase - // that the interceptor to be added must come after - InterceptorHolder lastAfter = null; - - String id = interc.getId(); - if (hasAfters[phase] || !beforeList.isEmpty()) { - - InterceptorHolder ih2 = heads[phase]; - while (ih2 != tails[phase].next) { - PhaseInterceptor cmp = ih2.interceptor; - String cmpId = cmp.getId(); - if (cmpId != null && firstBefore == null - && (beforeList.contains(cmpId) - || cmp.getAfter().contains(id))) { - firstBefore = ih2; - } - if (cmp.getBefore().contains(id) - || (cmpId != null && afterList.contains(cmpId))) { - lastAfter = ih2; - } - if (!force && cmpId.equals(id)) { - // interceptor is already in chain - return; - } - ih2 = ih2.next; - } - if (lastAfter == null && beforeList.contains("*")) { - firstBefore = heads[phase]; - } - //System.out.print("Didn't skip: " + phase.toString()); - //System.out.println(" " + interc.getId()); - } else if (!force) { - // skip interceptor if already in chain - InterceptorHolder ih2 = heads[phase]; - while (ih2 != tails[phase].next) { - if (ih2.interceptor.getId().equals(id)) { - return; - } - ih2 = ih2.next; - } - - //System.out.print("Skipped: " + phase.toString()); - //System.out.println(" " + interc.getId()); - } - hasAfters[phase] |= !afterList.isEmpty(); - - if (firstBefore == null - && lastAfter == null - && !beforeList.isEmpty() - && afterList.isEmpty()) { - //if this interceptor has stuff it MUST be before, - //but nothing it must be after, just - //stick it at the beginning - firstBefore = heads[phase]; - } - - if (firstBefore == null) { - //just add new interceptor at the end - ih.prev = tails[phase]; - ih.next = tails[phase].next; - tails[phase].next = ih; - - if (ih.next != null) { - ih.next.prev = ih; - } - tails[phase] = ih; - } else { - ih.prev = firstBefore.prev; - if (ih.prev != null) { - ih.prev.next = ih; - } - ih.next = firstBefore; - firstBefore.prev = ih; - - if (heads[phase] == firstBefore) { - heads[phase] = ih; - } - } - } - if (iterator != null) { - outputChainToLog(true); - } - } - - public String toString() { - return toString(""); - } - private String toString(String message) { - StringBuilder chain = new StringBuilder(); - - chain.append("Chain ") - .append(super.toString()) - .append(message) - .append(". Current flow:\n"); - - for (int x = 0; x < phases.length; x++) { - if (heads[x] != null) { - chain.append(" "); - printPhase(x, chain); - } - } - return chain.toString(); - } - private void printPhase(int ph, StringBuilder chain) { - - chain.append(phases[ph].getName()) - .append(" ["); - InterceptorHolder i = heads[ph]; - boolean first = true; - while (i != tails[ph].next) { - if (first) { - first = false; - } else { - chain.append(", "); - } - String nm = i.interceptor.getClass().getSimpleName(); - if (StringUtils.isEmpty(nm)) { - nm = i.interceptor.getId(); - } - chain.append(nm); - i = i.next; - } - chain.append("]\n"); - } - - private void outputChainToLog(boolean modified) { - if (isFineLogging) { - if (modified) { - LOG.fine(toString(" was modified")); - } else { - LOG.fine(toString(" was created")); - } - } - } - - public MessageObserver getFaultObserver() { - return faultObserver; - } - - public void setFaultObserver(MessageObserver faultObserver) { - this.faultObserver = faultObserver; - } - - static final class PhaseInterceptorIterator implements ListIterator> { - InterceptorHolder heads[]; - InterceptorHolder prev; - InterceptorHolder first; - - PhaseInterceptorIterator(InterceptorHolder h[]) { - heads = h; - first = findFirst(); - } - - public void reset() { - prev = null; - first = findFirst(); - } - - private InterceptorHolder findFirst() { - for (int x = 0; x < heads.length; x++) { - if (heads[x] != null) { - return heads[x]; - } - } - return null; - } - - - public boolean hasNext() { - if (prev == null) { - return first != null; - } - return prev.next != null; - } - - public Interceptor next() { - if (prev == null) { - if (first == null) { - throw new NoSuchElementException(); - } - prev = first; - } else { - if (prev.next == null) { - throw new NoSuchElementException(); - } - prev = prev.next; - } - return prev.interceptor; - } - public InterceptorHolder nextInterceptorHolder() { - if (prev == null) { - if (first == null) { - throw new NoSuchElementException(); - } - prev = first; - } else { - if (prev.next == null) { - throw new NoSuchElementException(); - } - prev = prev.next; - } - return prev; - } - - public boolean hasPrevious() { - return prev != null; - } - public Interceptor previous() { - if (prev == null) { - throw new NoSuchElementException(); - } - InterceptorHolder tmp = prev; - prev = prev.prev; - return tmp.interceptor; - } - - public int nextIndex() { - throw new UnsupportedOperationException(); - } - public int previousIndex() { - throw new UnsupportedOperationException(); - } - public void add(Interceptor o) { - throw new UnsupportedOperationException(); - } - public void set(Interceptor o) { - throw new UnsupportedOperationException(); - } - public void remove() { - throw new UnsupportedOperationException(); - } - } - - - static final class InterceptorHolder { - PhaseInterceptor interceptor; - InterceptorHolder next; - InterceptorHolder prev; - int phaseIdx; - - InterceptorHolder(PhaseInterceptor i, int p) { - interceptor = i; - phaseIdx = p; - } - InterceptorHolder(InterceptorHolder p) { - interceptor = p.interceptor; - phaseIdx = p.phaseIdx; - } - } - -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/internal/DataHolder.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/internal/DataHolder.java deleted file mode 100755 index 6dd6014..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/internal/DataHolder.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.wso2.carbon.sts.resource.internal; - -import org.apache.cxf.message.Exchange; -import org.apache.neethi.Policy; -import org.wso2.carbon.sts.provider2.provider.DefaultSecurityTokenServiceProvider; - -public class DataHolder { - private Policy policy; - private Exchange exchange; - private DefaultSecurityTokenServiceProvider provider; - - private static DataHolder instance = new DataHolder(); - - private DataHolder() {} - - public static DataHolder getInstance() { - return instance; - } - - public Policy getPolicy() { - return policy; - } - - public void setPolicy(Policy policy) { - this.policy = policy; - } - - public void setExchange(Exchange exchange) { - this.exchange = exchange; - } - - public Exchange getExchange() { - return exchange; - } - - public void setServiceProvider(DefaultSecurityTokenServiceProvider provider) { - this.provider = provider; - } - - public DefaultSecurityTokenServiceProvider getServiceProvider() { - return provider; - } -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityComponent.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityComponent.java deleted file mode 100644 index 14503a9..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityComponent.java +++ /dev/null @@ -1,83 +0,0 @@ -package org.wso2.carbon.sts.resource.security; - -import java.io.FileNotFoundException; -import java.net.URL; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.cxf.Bus; -import org.apache.cxf.ws.policy.PolicyBuilder; -import org.osgi.framework.BundleContext; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class SecurityComponent { - - XMLInputFactory factory = XMLInputFactory.newInstance(); - - public void processPolicies(BundleContext bundleContext, Bus bus) throws Exception { - - PolicyBuilder builder = bus.getExtension(PolicyBuilder.class); - XMLStreamReader streamReader = null; - - URL resource = bundleContext.getBundle().getResource( - "/scenarios/scenario-config.xml"); - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(resource.openStream()); - doc.getDocumentElement().normalize(); - - NodeList nList = doc.getElementsByTagName("Scenario"); - - for (int temp = 0; temp < nList.getLength(); temp++) { - Node nNode = nList.item(temp); - if (nNode.getNodeType() == Node.ELEMENT_NODE) { - - Element eElement = (Element) nNode; - String id = eElement.getAttribute("id"); - - // Need to clarify what to do with this case - if (id.equalsIgnoreCase("policyFromRegistry")) - continue; - - SecurityScenario scenario = new SecurityScenario(); - - URL policyPath = bundleContext.getBundle().getResource( - "/scenarios/" + id + "-policy.xml"); - - try { - streamReader = factory.createXMLStreamReader(policyPath - .openStream()); - } catch (FileNotFoundException | XMLStreamException e) { - - } - - try { - scenario.setPolicy(builder.getPolicy(streamReader)); - } catch(Exception e) { - e.printStackTrace(); - } - scenario.setCategory(eElement.getElementsByTagName("Category") - .item(0).getTextContent()); - scenario.setScenarioId(id); - scenario.setDescription(eElement - .getElementsByTagName("Description").item(0) - .getTextContent()); - scenario.setSummary(eElement.getElementsByTagName("Summary") - .item(0).getTextContent()); - scenario.setType(eElement.getElementsByTagName("Type").item(0) - .getTextContent()); - scenario.setWsuId(eElement.getElementsByTagName("WsuId") - .item(0).getTextContent()); - - SecurityScenarioDatabase.put(id, scenario); - } - } - } -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityPolicyServiceImpl.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityPolicyServiceImpl.java deleted file mode 100644 index 1d8485e..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityPolicyServiceImpl.java +++ /dev/null @@ -1,20 +0,0 @@ -package org.wso2.carbon.sts.resource.security; - - -import org.apache.neethi.Policy; - -public class SecurityPolicyServiceImpl { - - public void updateEffectivePolicy(String scenario) { - - //Update the security policy used by current tenant - } - - public Policy getEffectivePolicy() { - - //Need to get policy using tenant information - /*String scenario = DataHolder.getInstance().getScenario();*/ - String scenario = "UTOverTransport"; - return SecurityScenarioDatabase.getByWsuId(scenario).getPolicy(); - } -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityScenario.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityScenario.java deleted file mode 100644 index 7571685..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityScenario.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.wso2.carbon.sts.resource.security; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.neethi.Policy; - -/** - * - */ -public class SecurityScenario { - - /** - * Modules that need to be engaged for this security scenario - */ - private List modules = new ArrayList<>(); - private List services = new ArrayList<>(); - - private String scenarioId; - private String summary; - private String category; - private String description; - private boolean isCurrentScenario; - private String wsuId; - private String type; - private boolean isGeneralPolicy; - private Policy policy; - - /** - * Constructs a new SecurityScenarioDO. - */ - public SecurityScenario() { - isGeneralPolicy = true; - } - - /** - * Getter for property 'summary'. - * - * @return Value for property 'summary'. - * @see #setSummary - */ - public String getSummary() { - return summary; - } - - /** - * Setter for property 'summary'. - * - * @param summary Value to set for property 'summary'. - * @see #getSummary - */ - public void setSummary(String summary) { - this.summary = summary; - } - - /** - * Getter for property 'description'. - * - * @return Value for property 'description'. - * @see #setDescription - */ - public String getDescription() { - return description; - } - - /** - * Setter for property 'description'. - * - * @param description Value to set for property 'description'. - * @see #getDescription - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Getter for property 'scenarioId'. - * - * @return Value for property 'scenarioId'. - * @see #setScenarioId - */ - public String getScenarioId() { - return scenarioId; - } - - /** - * Setter for property 'scenarioId'. - * - * @param scenarioId Value to set for property 'scenarioId'. - * @see #getScenarioId - */ - public void setScenarioId(String scenarioId) { - this.scenarioId = scenarioId; - } - - - public void addModule(String module) { - modules.add(module); - } - - public void addService(String service) { - services.add(service); - } - - /** - * Getter for property 'currentScenario'. - * - * @return Value for property 'currentScenario'. - * @see #setIsCurrentScenario - */ - public boolean getIsCurrentScenario() { - return isCurrentScenario; - } - - /** - * Setter for property 'currentScenario'. - * - * @param currentScenario Value to set for property 'currentScenario'. - * @see #isCurrentScenario - */ - public void setIsCurrentScenario(boolean currentScenario) { - isCurrentScenario = currentScenario; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public List getModules() { - return modules; - } - - public List getServices() { - return services; - } - - public String getWsuId() { - return wsuId; - } - - public void setWsuId(String wsuId) { - this.wsuId = wsuId; - } - - public Policy getPolicy() { - return policy; - } - - public void setPolicy(Policy policy) { - this.policy = policy; - } - - public boolean isCurrentScenario() { - return isCurrentScenario; - } - - public void setCurrentScenario(boolean currentScenario) { - isCurrentScenario = currentScenario; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public boolean getGeneralPolicy() { - return isGeneralPolicy; - } - - public void setGeneralPolicy(boolean isGeneralPolicy) { - this.isGeneralPolicy = isGeneralPolicy; - } -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityScenarioDatabase.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityScenarioDatabase.java deleted file mode 100644 index db46dcf..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/security/SecurityScenarioDatabase.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.wso2.carbon.sts.resource.security; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * An in-memory DB which maintains all the security scenarios - */ -public class SecurityScenarioDatabase { - private static Map scenarios = new LinkedHashMap<>(); - private static SecurityScenarioDatabase instance = new SecurityScenarioDatabase(); - - private SecurityScenarioDatabase() { - } - - public static SecurityScenarioDatabase getInstance() { - return instance; - } - - public static void put(String scenarioId, SecurityScenario scenario) { - scenarios.put(scenarioId, scenario); - } - - public static SecurityScenario get(String scenarioId) { - return scenarios.get(scenarioId); - } - - public static Collection getAllScenarios() { - return scenarios.values(); - } - - public static SecurityScenario getByWsuId(String wsuIdValue) { - SecurityScenario scenario = null; - Iterator ite = scenarios.values().iterator(); - while (ite.hasNext()) { - SecurityScenario temp = ite.next(); - if (wsuIdValue.equals(temp.getWsuId())) { - scenario = temp; - break; - } - } - return scenario; - } -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/utils/SOAPUtils.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/utils/SOAPUtils.java deleted file mode 100644 index f807c7b..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/utils/SOAPUtils.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.wso2.carbon.sts.resource.utils; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.StringReader; -import java.io.StringWriter; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.soap.MessageFactory; -import javax.xml.soap.SOAPBody; -import javax.xml.soap.SOAPEnvelope; -import javax.xml.soap.SOAPException; -import javax.xml.soap.SOAPFault; -import javax.xml.soap.SOAPMessage; -import javax.xml.soap.SOAPPart; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.stream.StreamResult; - -import org.apache.cxf.binding.soap.SoapFault; -import org.w3c.dom.Document; -import org.xml.sax.InputSource; - -public class SOAPUtils { - - private SOAPUtils() {} - - private static SOAPUtils instance = new SOAPUtils(); - - public static SOAPUtils getInstance() { - return instance; - } - - public synchronized SOAPMessage createSoapFault(SoapFault fault) { - - SOAPMessage soapMsg = null; - - try { - MessageFactory factory = MessageFactory.newInstance(); - soapMsg = factory.createMessage(); - SOAPPart part = soapMsg.getSOAPPart(); - - SOAPEnvelope envelope = part.getEnvelope(); - SOAPBody body = envelope.getBody(); - - SOAPFault soapFault = body.addFault(); - soapFault.setFaultString(fault.getMessage()); - soapFault.setFaultCode(fault.getCode()); - - }catch(SOAPException e) { - //log here - } - - return soapMsg; - } - - public synchronized String soapToString(SOAPMessage msg) { - ByteArrayOutputStream stream = new ByteArrayOutputStream(); - String soap = null; - try { - msg.writeTo(stream); - soap = new String(stream.toByteArray(), "utf-8"); - } catch (IOException | SOAPException e) { - //log here - } - return soap; - } - - public SOAPMessage buildSoapResponse(Source response) { - - SOAPMessage soapMsg = null; - - try { - MessageFactory factory = MessageFactory.newInstance(); - soapMsg = factory.createMessage(); - SOAPPart part = soapMsg.getSOAPPart(); - - SOAPEnvelope envelope = part.getEnvelope(); - SOAPBody body = envelope.getBody(); - - StringWriter writer = new StringWriter(); - StreamResult result = new StreamResult(writer); - TransformerFactory tf = TransformerFactory.newInstance(); - Transformer transformer = tf.newTransformer(); - transformer.transform(response, result); - - DocumentBuilderFactory dFact = DocumentBuilderFactory.newInstance(); - dFact.setNamespaceAware(true); - dFact.setValidating(false); - dFact.setIgnoringComments(false); - dFact.setIgnoringElementContentWhitespace(true); - - DocumentBuilder db = dFact.newDocumentBuilder(); - - InputSource is = new InputSource(); - is.setCharacterStream(new StringReader(writer.toString())); - Document doc = db.parse(is); - - body.addDocument(doc); - } catch (Exception e) { - // log here - } - - return soapMsg; - } - -} diff --git a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/utils/WSContext.java b/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/utils/WSContext.java deleted file mode 100644 index f90b28d..0000000 --- a/org.wso2.carbon.sts.provider/src/main/java/org/wso2/carbon/sts/resource/utils/WSContext.java +++ /dev/null @@ -1,74 +0,0 @@ -package org.wso2.carbon.sts.resource.utils; - -import java.security.Principal; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import javax.xml.ws.WebServiceContext; -import javax.xml.ws.handler.MessageContext; -import javax.xml.ws.handler.MessageContext.Scope; - -import org.apache.cxf.binding.soap.Soap12; -import org.apache.cxf.binding.soap.SoapVersion; -import org.apache.cxf.jaxws.context.WebServiceContextImpl; -import org.apache.cxf.jaxws.context.WrappedMessageContext; -import org.apache.cxf.message.Message; -import org.apache.cxf.security.SecurityContext; -import org.apache.wss4j.common.principal.CustomTokenPrincipal; -import org.wso2.carbon.messaging.Header; -import org.wso2.carbon.messaging.Headers; -import org.wso2.msf4j.Request; - -public class WSContext { - - private static WSContext context = new WSContext(); - private WebServiceContext wsContext; - - private WSContext() {} - - public static WSContext getInstance() { - return context; - } - - public WebServiceContext getWSContext() { - return wsContext; - } - - public void buildWebServiceContext(Request request, - Message soap) { - MessageContext msgCtx = new WrappedMessageContext(soap); - Principal principal = new CustomTokenPrincipal("alice"); - Map> headerMap = new HashMap<>(); - Headers headers = request.getHeaders(); - for (Header h : headers.getAll()) { - List values = new ArrayList<>(); - values.add(h.getValue()); - headerMap.put(h.getName(), values); - } - msgCtx.put(SecurityContext.class.getName(), - createSecurityContext(principal)); - msgCtx.put(MessageContext.HTTP_REQUEST_HEADERS, headerMap); - msgCtx.put(MessageContext.HTTP_REQUEST_METHOD, request.getHttpMethod()); - msgCtx.put(SoapVersion.class.getName(), Soap12.getInstance()); - msgCtx.setScope(MessageContext.HTTP_REQUEST_HEADERS, Scope.APPLICATION); - - WebServiceContext context = new WebServiceContextImpl(msgCtx); - - wsContext = context; - } - - private SecurityContext createSecurityContext(final Principal p) { - return new SecurityContext() { - public Principal getUserPrincipal() { - return p; - } - - public boolean isUserInRole(String role) { - return false; - } - }; - } - -} diff --git a/org.wso2.carbon.sts.store/.classpath b/org.wso2.carbon.sts.store/.classpath deleted file mode 100644 index d2043c7..0000000 --- a/org.wso2.carbon.sts.store/.classpath +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.carbon.sts.store/pom.xml b/org.wso2.carbon.sts.store/pom.xml deleted file mode 100644 index 0c69ba5..0000000 --- a/org.wso2.carbon.sts.store/pom.xml +++ /dev/null @@ -1,46 +0,0 @@ - - - 4.0.0 - - org.wso2.carbon.sts - identity-inbound-auth-sts - 1.0.0 - - - org.wso2.carbon.sts.store - bundle - org.wso2.carbon.sts.store - - - - org.apache.commons - commons-lang3 - 3.5 - - - org.wso2.msf4j - msf4j-core - 2.1.0 - - - org.apache.cxf.services.sts - cxf-services-sts-core - 3.1.11 - - - - - - - - org.osgi.framework.*;version="${osgi.framework.import.version.range}", - org.slf4j.*, - - - !org.wso2.carbon.sts.store.internal, - org.wso2.carbon.sts.store.*;version="1.0.0" - - - diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/CacheEntry.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/CacheEntry.java deleted file mode 100644 index fb4e0cb..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/CacheEntry.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.wso2.carbon.sts.store; - -import java.time.Instant; - -import org.apache.cxf.ws.security.tokenstore.SecurityToken; - -public class CacheEntry { - - private final SecurityToken securityToken; - private final Instant expires; - - CacheEntry(SecurityToken securityToken, Instant expires) { - this.securityToken = securityToken; - this.expires = expires; - } - - /** - * Get the SecurityToken - * @return the SecurityToken - */ - public SecurityToken getSecurityToken() { - return securityToken; - } - - /** - * Get when this CacheEntry is to be removed from the cache - * @return when this CacheEntry is to be removed from the cache - */ - public Instant getExpiry() { - return expires; - } - -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/DBQueries.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/DBQueries.java deleted file mode 100644 index 052ebdd..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/DBQueries.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.wso2.carbon.sts.store; - -public class DBQueries { - - public static final String ADD_TOKEN = "INSERT INTO IDN_STS_STORE (TOKEN_ID, TOKEN_CONTENT,CREATE_DATE," + - " EXPIRE_DATE) VALUES (?,?,?,?)"; - - public static final String UPDATE_TOKEN = "UPDATE IDN_STS_STORE SET TOKEN_CONTENT = ? ,CREATE_DATE = ?," + - "EXPIRE_DATE = ? WHERE TOKEN_ID = ?"; - - public static final String REMOVE_TOKEN = "DELETE FROM IDN_STS_STORE WHERE TOKEN_ID = ?"; - - public static final String REMOVE_EXPIRED_TOKENS = "DELETE FROM IDN_STS_STORE WHERE EXPIRE_DATE < ?"; - - public static final String ALL_TOKEN_KEYS = "SELECT TOKEN_ID FROM IDN_STS_STORE"; - - public static final String GET_TOKEN = "SELECT TOKEN_CONTENT FROM IDN_STS_STORE WHERE TOKEN_ID = ?"; - - public static final String GET_ALL_TOKENS = "SELECT * FROM IDN_STS_STORE"; - - public static final String VALID_TOKENS = "SELECT * FROM IDN_STS_STORE WHERE STATE =? OR STATE =?"; - - public static final String GET_TOKENS_BY_STATE = "SELECT * FROM IDN_STS_STORE WHERE STATE = ?"; - - public static final String TOKENS_EXISTS = "SELECT 1 FROM IDN_STS_STORE"; - - private DBQueries() { - } -} diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/JDBCTokenStore.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/JDBCTokenStore.java deleted file mode 100644 index 223fde9..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/JDBCTokenStore.java +++ /dev/null @@ -1,214 +0,0 @@ -package org.wso2.carbon.sts.store; - -import java.time.Instant; -import java.util.Collection; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; - -import org.apache.commons.lang3.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.cxf.ws.security.tokenstore.SecurityToken; -import org.apache.cxf.ws.security.tokenstore.TokenStore; -import org.wso2.carbon.sts.store.dao.DBStsDAO; - -public class JDBCTokenStore implements TokenStore { - - private static final Logger log = LoggerFactory.getLogger(JDBCTokenStore.class); - private static int poolSize = 100; - private static ExecutorService executorService = Executors - .newFixedThreadPool(poolSize); - public static final long DEFAULT_TTL = 60L * 5L; - public static final long MAX_TTL = DEFAULT_TTL * 12L; - private Map tokenCache = new ConcurrentHashMap<>(); - private long ttl = DEFAULT_TTL; - private DBStsDAO dbStsDAO; - - public static ExecutorService getExecutorService() { - return executorService; - } - - /** - * "#" are used for internal references. If a token-id comes with that we - * need to remove. - * - * @param token - * @return - */ - private String getTokenId(SecurityToken token) { - if (token == null) { - return ""; - } - String tokenId = token.getId(); - if (tokenId != null && tokenId.startsWith("#")) { - tokenId = tokenId.substring(1); - } - return tokenId; - } - - /** - * "#" are used for internal references. If a token-id comes with that we - * need to remove - * - * @param tokenId - * @return - */ - private String getTokenId(String tokenId) { - String tokenIdVal = tokenId; - if (tokenId != null && tokenId.startsWith("#")) { - tokenIdVal = tokenIdVal.substring(1); - } - return tokenIdVal; - } - - @Override - public void add(SecurityToken token) { - String identifier = getTokenId(token); - if (token != null && !StringUtils.isEmpty(identifier)) { - CacheEntry cacheEntry = createCacheEntry(token); - if (cacheEntry != null) { - tokenCache.put(identifier, cacheEntry); - executorService.submit(new TokenPersisterTask(token)); - } - } - } - - @Override - public void add(String identifier, SecurityToken token) { - if (token != null && !StringUtils.isEmpty(identifier)) { - CacheEntry cacheEntry = createCacheEntry(token); - if (cacheEntry != null) { - tokenCache.put(identifier, cacheEntry); - executorService.submit(new TokenPersisterTask(token)); - } - } - } - - @Override - public SecurityToken getToken(String id) { - processTokenExpiry(); - String tokenId = getTokenId(id); - - if (tokenCache.containsKey(tokenId)) { - CacheEntry cacheEntry = tokenCache.get(tokenId); - return cacheEntry.getSecurityToken(); - } - initDao(); - - SecurityToken token = null; - try { - token = dbStsDAO.getToken(tokenId); - } catch (Exception e) { - log.debug("Failed to get token from database"); - } - - if (token == null) { - log.debug("Token is not present in cache or database"); - } - - if (token != null) { - CacheEntry cacheEntry = createCacheEntry(token); - tokenCache.put(tokenId, cacheEntry); - } - return token; - } - - @Override - public Collection getTokenIdentifiers() { - processTokenExpiry(); - return tokenCache.keySet(); - } - - /** - * Set a new (default) TTL value in seconds - * - * @param newTtl - * a new (default) TTL value in seconds - */ - public void setTTL(long newTtl) { - ttl = newTtl; - } - - @Override - public void remove(String identifier) { - if (!StringUtils.isEmpty(identifier) && tokenCache.containsKey(identifier)) { - tokenCache.remove(identifier); - executorService.submit(new TokenRemoverTask(identifier)); - } - } - - private void initDao() { - if (dbStsDAO == null) { - this.dbStsDAO = new DBStsDAO(); - } - } - - protected void processTokenExpiry() { - Instant current = Instant.now(); - synchronized (tokenCache) { - for (Map.Entry entry : tokenCache.entrySet()) { - if (entry.getValue().getExpiry().isBefore(current)) { - tokenCache.remove(entry.getKey()); - } - } - } - } - - private CacheEntry createCacheEntry(SecurityToken token) { - Instant expires = Instant.now().plusSeconds(ttl); - return new CacheEntry(token, expires); - } - - protected static class TokenPersisterTask implements Runnable { - - private SecurityToken token; - - public TokenPersisterTask(SecurityToken token) { - this.token = token; - } - - @Override - public void run() { - try { - persist(); - } catch (Exception e) { - log.error("Failed to persist token", e); - } - } - - private synchronized void persist() throws Exception { - try { - new DBStsDAO().addToken(token); - } catch (Exception e) { - throw new Exception("Failed to persist token", e); - } - } - } - - protected static class TokenRemoverTask implements Runnable { - - private String identifier; - - public TokenRemoverTask(String identifier){ - this.identifier = identifier; - } - @Override - public void run() { - try { - remove(identifier); - } catch (Exception e) { - log.error("Failed to remove token", e); - } - } - - private synchronized void remove(String identifier) throws Exception { - try { - new DBStsDAO().removeToken(identifier); - } catch (Exception e) { - throw new Exception("Failed to remove token", e); - } - } - } -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/STSMgtConstants.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/STSMgtConstants.java deleted file mode 100644 index b84c42e..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/STSMgtConstants.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.wso2.carbon.sts.store; - -public class STSMgtConstants { - - public static final String TOKEN_CACHE_MANAGER = "STS_TOKEN_CACHE_MANAGER"; - public static final String TOKEN_CACHE_ID = "STS_TOKEN_CACHE"; - - public static final String TOKEN_CONTENT = "TOKEN_CONTENT"; - public static final String TOKEN_ID = "TOKEN_ID"; - - private STSMgtConstants() { - } -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/dao/DBStsDAO.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/dao/DBStsDAO.java deleted file mode 100644 index 29dcb5d..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/dao/DBStsDAO.java +++ /dev/null @@ -1,350 +0,0 @@ -package org.wso2.carbon.sts.store.dao; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.apache.cxf.ws.security.tokenstore.SecurityToken; -import org.apache.cxf.ws.security.trust.TrustException; - -import org.wso2.carbon.sts.store.DBQueries; -import org.wso2.carbon.sts.store.STSMgtConstants; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.sql.Blob; -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; -import java.sql.Timestamp; -import java.util.ArrayList; -import java.util.List; - -/** - * This utility used to manage the DB operations for token store. - */ -public class DBStsDAO { - - private static final Logger log = LoggerFactory.getLogger(DBStsDAO.class); - - /** - * This is for adding token to DB. - * - * @param token Token - * @throws Exception - */ - public void addToken(SecurityToken token) throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - - String query = DBQueries.ADD_TOKEN; - - try { - prepStmt = connection.prepareStatement(query); - prepStmt.setString(1, token.getId()); - byte[] tokenByteContainer = getTokenContent(token); - InputStream tokenInputStream = new ByteArrayInputStream(tokenByteContainer); - prepStmt.setBinaryStream(2, tokenInputStream, tokenByteContainer.length); - prepStmt.setTimestamp(3, new Timestamp(token.getCreated().getTime())); - prepStmt.setTimestamp(4, new Timestamp(token.getExpires().getTime())); - prepStmt.execute(); - connection.commit(); - - } catch (Exception e) { - IdentityDatabaseUtil.rollBack(connection); - String msg = "Failed to add token"; - throw new Exception(msg, e); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - - } - - /** - * This is for updating the token in DB - * - * @param token Token - * @throws Exception - */ - public void updateToken(SecurityToken token) throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - String query = DBQueries.UPDATE_TOKEN; - - try { - prepStmt = connection.prepareStatement(query); - byte[] tokenByteContainer = getTokenContent(token); - InputStream tokenInputStream = new ByteArrayInputStream(tokenByteContainer); - prepStmt.setBinaryStream(1, tokenInputStream, tokenByteContainer.length); - prepStmt.setTimestamp(2, new Timestamp(token.getCreated().getTime())); - prepStmt.setTimestamp(3, new Timestamp(token.getExpires().getTime())); - - prepStmt.setString(4, token.getId()); - prepStmt.executeUpdate(); - connection.commit(); - - } catch (Exception e) { - IdentityDatabaseUtil.rollBack(connection); - String msg = "Failed to update token "; - throw new Exception(msg, e); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - - } - - /** - * This is for removing token - * - * @param tokenId tokenId - * @throws Exception - */ - public void removeToken(String tokenId) throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - - String query = DBQueries.REMOVE_TOKEN; - try { - prepStmt = connection.prepareStatement(query); - prepStmt.setString(1, tokenId); - prepStmt.executeUpdate(); - - } catch (Exception e) { - String msg = "Failed to remove token"; - throw new Exception(msg, e); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - - } - - /** - * This is for get all the token keys - * - * @return arrays of keys - * @throws Exception - */ - public String[] getAllTokenKeys() throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - List keyList; - String[] keys = new String[0]; - String query = DBQueries.ALL_TOKEN_KEYS; - try { - prepStmt = connection.prepareStatement(query); - rs = prepStmt.executeQuery(); - - keyList = new ArrayList<>(); - if (rs != null) { - while (rs.next()) { - keyList.add(rs.getString(STSMgtConstants.TOKEN_ID)); - } - } - if (!keyList.isEmpty()) { - keys = keyList.toArray(new String[keyList.size()]); - } - } catch (Exception e) { - String msg = "Failed to get all tokens"; - throw new Exception(msg, e); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - return keys; - } - - /** - * This is to get Token from token id - * - * @param tokenId tokenId - * @return Token - */ - public SecurityToken getToken(String tokenId) throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - SecurityToken token = null; - - String query = DBQueries.GET_TOKEN; - try { - prepStmt = connection.prepareStatement(query); - prepStmt.setString(1, tokenId); - rs = prepStmt.executeQuery(); - - if (rs != null) { - while (rs.next()) { - Blob tokenContent = rs.getBlob(STSMgtConstants.TOKEN_CONTENT); - byte[] tokenContentBytes = tokenContent.getBytes(1, (int) tokenContent.length()); - token = getToken(tokenContentBytes); - } - } - } catch (Exception e) { - String msg = "Failed to get token"; - throw new Exception(msg, e); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - return token; - } - - private SecurityToken getToken(byte[] tokenContentBytes) throws Exception { - SecurityToken token; - try { - ByteArrayInputStream tokenContentByteArray = new ByteArrayInputStream(tokenContentBytes); - ObjectInputStream tokenContentObject = new ObjectInputStream(tokenContentByteArray); - Object tokenObj = tokenContentObject.readObject(); - token = (SecurityToken) tokenObj; - } catch (Exception e) { - String msg = "Failed to convert blob content to Token object "; - throw new Exception(msg, e); - } - return token; - } - - /** - * This is to get all tokens from token store - * - * @return List of Tokens - */ - public List getTokens() throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - List tokens = new ArrayList(); - - String query = DBQueries.GET_ALL_TOKENS; - try { - prepStmt = connection.prepareStatement(query); - rs = prepStmt.executeQuery(); - - if (rs != null) { - while (rs.next()) { - tokens.add(getToken((byte[]) rs.getObject(STSMgtConstants.TOKEN_CONTENT))); - } - } - return tokens; - } catch (Exception e) { - String msg = "Failed to get all tokens"; - throw new Exception(msg, e); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - } - - - - /** - * This is to get expired tokens from token store - * - * @param status state id of expired tokens - * @return Token[] - * @throws TrustException if failed to get expired tokens - */ - public SecurityToken[] getExpiredTokens(int status) throws Exception { - return getTokens(status); - } - - /** - * This is to get the renewed tokens from token store - * - * @param status state id of the renewed token - * @return Token[] - * @throws TrustException if failed to get renewed tokens - */ - public SecurityToken[] getRenewedTokens(int status) throws Exception { - return getTokens(status); - } - - /** - * This is to get canceled tokens from token store - * - * @param status state id of cancel token - * @return Token[] - * @throws Exception - */ - public SecurityToken[] getCancelledTokens(int status) throws Exception { - return getTokens(status); - } - - private SecurityToken[] getTokens(int status) throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - List tokens = new ArrayList(); - - String query = DBQueries.GET_TOKENS_BY_STATE; - try { - prepStmt = connection.prepareStatement(query); - prepStmt.setInt(1, status); - rs = prepStmt.executeQuery(); - - if (rs != null) { - while (rs.next()) { - SecurityToken token = getToken((byte[]) rs.getObject(STSMgtConstants.TOKEN_CONTENT)); - tokens.add(token); - } - } - return tokens.toArray(new SecurityToken[tokens.size()]); - } catch (Exception e) { - String msg = "Failed to get token"; - log.error(msg, e); - throw new Exception(msg); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - } - - /** - * This is to check token store empty or not - * - * @return boolean - * @throws TrustException if failed to check the tokens availability - */ - public boolean isTokensExist() throws Exception { - Connection connection = IdentityDatabaseUtil.getDBConnection(); - PreparedStatement prepStmt = null; - ResultSet rs = null; - boolean tokenExist = false; - - String query = DBQueries.TOKENS_EXISTS; - try { - prepStmt = connection.prepareStatement(query); - rs = prepStmt.executeQuery(); - - if (rs != null && rs.next()) { - return true; - } - - } catch (Exception e) { - String msg = "Failed to check token exist"; - log.error(msg, e); - throw new Exception(msg); - } finally { - IdentityDatabaseUtil.closeAllConnections(connection, rs, prepStmt); - } - return tokenExist; - } - - private byte[] getTokenContent(SecurityToken token) throws IOException { - ByteArrayOutputStream tokenArrayStream = new ByteArrayOutputStream(); - ObjectOutputStream tokenObjectStream = null; - byte[] tokenBytes = null; - try { - tokenObjectStream = new ObjectOutputStream(tokenArrayStream); - tokenObjectStream.writeObject(token); - tokenObjectStream.flush(); - tokenBytes = tokenArrayStream.toByteArray(); - } finally { - if (tokenObjectStream != null) { - tokenObjectStream.close(); - } - } - return tokenBytes; - } - -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/dao/IdentityDatabaseUtil.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/dao/IdentityDatabaseUtil.java deleted file mode 100644 index 2eabbe6..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/dao/IdentityDatabaseUtil.java +++ /dev/null @@ -1,26 +0,0 @@ -package org.wso2.carbon.sts.store.dao; - -import java.sql.Connection; -import java.sql.PreparedStatement; -import java.sql.ResultSet; - -// Dummy implementation. May need to replace with utility class for database operations -// provided by IS6 -public class IdentityDatabaseUtil { - - public static void closeAllConnections(Connection connection, ResultSet rs, - PreparedStatement prepStmt) { - // TODO Auto-generated method stub - - } - - public static Connection getDBConnection() { - // TODO Auto-generated method stub - return null; - } - - public static void rollBack(Connection connection) { - // TODO Auto-generated method stub - - } -} diff --git a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/internal/STSStoreComponent.java b/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/internal/STSStoreComponent.java deleted file mode 100644 index 7a73356..0000000 --- a/org.wso2.carbon.sts.store/src/main/java/org/wso2/carbon/sts/store/internal/STSStoreComponent.java +++ /dev/null @@ -1,19 +0,0 @@ -package org.wso2.carbon.sts.store.internal; - -import org.osgi.framework.BundleContext; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -@Component(name = "org.wso2.carbon.sts.store.internal.STSStoreComponent", immediate = true) -public class STSStoreComponent { - - private static final Logger logger = LoggerFactory - .getLogger(STSStoreComponent.class); - - @Activate - protected void activate(BundleContext context) { - logger.info("Identity STS Mgt bundle is activated"); - } -} diff --git a/org.wso2.carbon.sts.token.provider/.classpath b/org.wso2.carbon.sts.token.provider/.classpath deleted file mode 100644 index d2043c7..0000000 --- a/org.wso2.carbon.sts.token.provider/.classpath +++ /dev/null @@ -1,26 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.carbon.sts.token.provider/pom.xml b/org.wso2.carbon.sts.token.provider/pom.xml deleted file mode 100644 index e21953b..0000000 --- a/org.wso2.carbon.sts.token.provider/pom.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - 4.0.0 - - identity-inbound-auth-sts - org.wso2.carbon.sts - 1.0.0 - - - org.wso2.carbon.sts.token.provider - bundle - org.wso2.carbon.sts.token.provider - - - - org.wso2.eclipse.osgi - org.eclipse.osgi.services - - - org.apache.cxf - cxf-core - 3.1.11 - - - org.apache.cxf.services.sts - cxf-services-sts-core - 3.1.11 - - - - - - - org.apache.felix - maven-bundle-plugin - 3.0.1 - true - - - org.wso2.carbon.sts.token.provider.internal.TokenProviderComponent - ${project.artifactId} - ${project.artifactId} - org.wso2.carbon.sts.token.provider.internal - !org.wso2.carbon.sts.token.provider.internal, - org.wso2.carbon.sts.token.provider.*;version="${project.version}" - org.osgi.framework.*;version="[1.8.0, 2.0.0)" - - - - - - - diff --git a/org.wso2.carbon.sts.token.provider/src/main/java/org/wso2/carbon/sts/token/provider/CustomAttributeStatementProvider.java b/org.wso2.carbon.sts.token.provider/src/main/java/org/wso2/carbon/sts/token/provider/CustomAttributeStatementProvider.java deleted file mode 100644 index c8ef471..0000000 --- a/org.wso2.carbon.sts.token.provider/src/main/java/org/wso2/carbon/sts/token/provider/CustomAttributeStatementProvider.java +++ /dev/null @@ -1,99 +0,0 @@ -package org.wso2.carbon.sts.token.provider; - -import java.net.URI; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.cxf.sts.claims.ClaimsManager; -import org.apache.cxf.sts.claims.ClaimsParameters; -import org.apache.cxf.sts.claims.ProcessedClaim; -import org.apache.cxf.sts.claims.ProcessedClaimCollection; -import org.apache.cxf.sts.token.provider.AttributeStatementProvider; -import org.apache.cxf.sts.token.provider.TokenProviderParameters; -import org.apache.wss4j.common.saml.bean.AttributeBean; -import org.apache.wss4j.common.saml.bean.AttributeStatementBean; -import org.apache.wss4j.common.saml.builder.SAML2Constants; -import org.apache.wss4j.dom.WSConstants; - -public class CustomAttributeStatementProvider implements AttributeStatementProvider { - - private String nameFormat = SAML2Constants.ATTRNAME_FORMAT_UNSPECIFIED; - - public AttributeStatementBean getStatement(TokenProviderParameters providerParameters) { - - // Handle Claims - ClaimsManager claimsManager = providerParameters.getClaimsManager(); - ProcessedClaimCollection retrievedClaims = new ProcessedClaimCollection(); - if (claimsManager != null) { - ClaimsParameters params = new ClaimsParameters(); - params.setAdditionalProperties(providerParameters.getAdditionalProperties()); - params.setAppliesToAddress(providerParameters.getAppliesToAddress()); - params.setEncryptionProperties(providerParameters.getEncryptionProperties()); - params.setKeyRequirements(providerParameters.getKeyRequirements()); - params.setPrincipal(providerParameters.getPrincipal()); - params.setRealm(providerParameters.getRealm()); - params.setStsProperties(providerParameters.getStsProperties()); - params.setTokenRequirements(providerParameters.getTokenRequirements()); - params.setTokenStore(providerParameters.getTokenStore()); - params.setMessageContext(providerParameters.getMessageContext()); - retrievedClaims = - claimsManager.retrieveClaimValues( - providerParameters.getRequestedPrimaryClaims(), - providerParameters.getRequestedSecondaryClaims(), - params - ); - } - if (retrievedClaims == null) { - return null; - } - - Iterator claimIterator = retrievedClaims.iterator(); - if (!claimIterator.hasNext()) { - return null; - } - - List attributeList = new ArrayList<>(); - String tokenType = providerParameters.getTokenRequirements().getTokenType(); - - AttributeStatementBean attrBean = new AttributeStatementBean(); - while (claimIterator.hasNext()) { - ProcessedClaim claim = claimIterator.next(); - AttributeBean attributeBean = new AttributeBean(); - - URI claimType = claim.getClaimType(); - if (WSConstants.WSS_SAML2_TOKEN_TYPE.equals(tokenType) - || WSConstants.SAML2_NS.equals(tokenType)) { - attributeBean.setQualifiedName(claimType.toString()); - attributeBean.setNameFormat(nameFormat); - } else { - String uri = claimType.toString(); - int lastSlash = uri.lastIndexOf("/"); - if (lastSlash == (uri.length() - 1)) { - uri = uri.substring(0, lastSlash); - lastSlash = uri.lastIndexOf("/"); - } - - String namespace = uri.substring(0, lastSlash); - String name = uri.substring(lastSlash + 1, uri.length()); - - attributeBean.setSimpleName(name); - attributeBean.setQualifiedName(namespace); - } - attributeBean.setAttributeValues(claim.getValues()); - attributeList.add(attributeBean); - } - attrBean.setSamlAttributes(attributeList); - - return attrBean; - } - - public String getNameFormat() { - return nameFormat; - } - - public void setNameFormat(String nameFormat) { - this.nameFormat = nameFormat; - } - -} \ No newline at end of file diff --git a/org.wso2.carbon.sts.token.provider/src/main/java/org/wso2/carbon/sts/token/provider/internal/TokenProviderComponent.java b/org.wso2.carbon.sts.token.provider/src/main/java/org/wso2/carbon/sts/token/provider/internal/TokenProviderComponent.java deleted file mode 100644 index f861c3f..0000000 --- a/org.wso2.carbon.sts.token.provider/src/main/java/org/wso2/carbon/sts/token/provider/internal/TokenProviderComponent.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.wso2.carbon.sts.token.provider.internal; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.cxf.sts.token.provider.AttributeStatementProvider; -import org.apache.cxf.sts.token.provider.DefaultAttributeStatementProvider; -import org.apache.cxf.sts.token.provider.SAMLTokenProvider; -import org.apache.cxf.sts.token.provider.TokenProvider; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.wso2.carbon.sts.token.provider.STSAttributeStatementProvider; - -@Component(name = "org.wso2.carbon.sts.token.provider.internal.TokenProviderComponent", immediate = true) -public class TokenProviderComponent { - - Logger logger = LoggerFactory.getLogger(TokenProviderComponent.class - .getName()); - - @Activate - public void start(BundleContext bundleContext) throws Exception { - logger.info("Token Service Provider Component is activated"); - - bundleContext.registerService( - AttributeStatementProvider.class.getName(), - new STSAttributeStatementProvider(), null); - - SAMLTokenProvider tokenProvider = new SAMLTokenProvider(); - List attributeStatementProviders = new ArrayList(); - attributeStatementProviders - .add(new DefaultAttributeStatementProvider()); - tokenProvider - .setAttributeStatementProviders(attributeStatementProviders); - bundleContext.registerService(TokenProvider.class.getName(), - tokenProvider, null); - } - - @Deactivate - public void stop(BundleContext bundleContext) throws Exception { - - } -} diff --git a/org.wso2.sts.security.provider/.classpath b/org.wso2.sts.security.provider/.classpath deleted file mode 100644 index 85b766f..0000000 --- a/org.wso2.sts.security.provider/.classpath +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/pom.xml b/org.wso2.sts.security.provider/pom.xml deleted file mode 100644 index 2cceb46..0000000 --- a/org.wso2.sts.security.provider/pom.xml +++ /dev/null @@ -1,87 +0,0 @@ - - - 4.0.0 - - org.wso2.carbon.sts - identity-inbound-auth-sts - 1.0.0 - - - org.wso2.carbon.sts.security.provider - org.wso2.carbon.sts.security.provider - bundle - - - - org.apache.neethi - neethi - 3.0.3 - provided - - - org.wso2.eclipse.osgi - org.eclipse.osgi - 3.10.2.v20150203-1939 - provided - - - org.apache.cxf - cxf-rt-ws-policy - 3.1.12 - - - org.apache.cxf - cxf-rt-ws-security - 3.1.12 - - - org.wso2.eclipse.osgi - org.eclipse.osgi.services - provided - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.8 - 1.8 - - - - org.apache.maven.plugins - maven-surefire-plugin - - - org.apache.felix - maven-bundle-plugin - 3.3.0 - true - - - - - - - org.wso2.carbon.sts.security.internal - - - !org.wso2.carbon.sts.security.internal, - org.wso2.carbon.sts.security.provider.*, - org.wso2.carbon.sts.security.provider.util.*, - - - org.osgi.framework.*;version="${osgi.framework.import.version.range}", - org.apache.neethi.*, - - *;scope=!provided|!test;inline=true - target/dependency - true - - - diff --git a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/internal/DataHolder.java b/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/internal/DataHolder.java deleted file mode 100644 index 571f040..0000000 --- a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/internal/DataHolder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.wso2.carbon.sts.security.internal; - -public class DataHolder { - private String scenario; - - private static DataHolder instance = new DataHolder(); - - private DataHolder() {} - - public static DataHolder getInstance() { - return instance; - } - - public String getScenario() { - return scenario; - } - - public void setScenario(String scenario) { - this.scenario = scenario; - } -} \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/internal/SecurityComponent.java b/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/internal/SecurityComponent.java deleted file mode 100644 index cea7d3a..0000000 --- a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/internal/SecurityComponent.java +++ /dev/null @@ -1,131 +0,0 @@ -package org.wso2.carbon.sts.security.internal; - -import java.io.FileNotFoundException; -import java.net.URL; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; - -import org.apache.cxf.Bus; -import org.apache.cxf.bus.extension.ExtensionManagerBus; -import org.apache.cxf.ws.policy.AssertionBuilderRegistry; -import org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl; -import org.apache.cxf.ws.policy.PolicyBuilder; -import org.apache.cxf.ws.policy.PolicyBuilderImpl; -import org.apache.cxf.ws.policy.PolicyEngine; -import org.apache.cxf.ws.policy.PolicyEngineImpl; -import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistry; -import org.apache.cxf.ws.policy.PolicyInterceptorProviderRegistryImpl; -import org.apache.cxf.ws.security.policy.WSSecurityPolicyLoader; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; -import org.osgi.service.component.annotations.Activate; -import org.osgi.service.component.annotations.Component; -import org.osgi.service.component.annotations.Deactivate; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.wso2.carbon.sts.security.provider.SecurityPolicyService; -import org.wso2.carbon.sts.security.provider.SecurityPolicyServiceImpl; -import org.wso2.carbon.sts.security.provider.util.SecurityScenario; -import org.wso2.carbon.sts.security.provider.util.SecurityScenarioDatabase; - -@Component(name = "org.wso2.carbon.sts.security.provider", immediate = true) -public class SecurityComponent { - - private ServiceRegistration serviceRegistration; - XMLInputFactory factory = XMLInputFactory.newInstance(); - - @Activate - protected void start(BundleContext bundleContext) throws Exception { - - Bus bus = new ExtensionManagerBus(); - bus.setExtension(new AssertionBuilderRegistryImpl(), - AssertionBuilderRegistry.class); - bus.setExtension(new PolicyInterceptorProviderRegistryImpl(), - PolicyInterceptorProviderRegistry.class); - - bus.setExtension(new PolicyEngineImpl(bus), PolicyEngine.class); - - @SuppressWarnings("unused") - PolicyBuilderImpl pb = new PolicyBuilderImpl(bus); - - AssertionBuilderRegistryImpl reg = (AssertionBuilderRegistryImpl) bus - .getExtension(AssertionBuilderRegistry.class); - reg.setBus(bus); - - pb = new PolicyBuilderImpl(bus); - - @SuppressWarnings("unused") - WSSecurityPolicyLoader loader = new WSSecurityPolicyLoader(bus); - - PolicyBuilder builder = bus.getExtension(PolicyBuilder.class); - XMLStreamReader streamReader = null; - - URL resource = bundleContext.getBundle().getResource( - "/scenarios/scenario-config.xml"); - DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); - Document doc = dBuilder.parse(resource.openStream()); - doc.getDocumentElement().normalize(); - - NodeList nList = doc.getElementsByTagName("Scenario"); - - for (int temp = 0; temp < nList.getLength(); temp++) { - Node nNode = nList.item(temp); - if (nNode.getNodeType() == Node.ELEMENT_NODE) { - - Element eElement = (Element) nNode; - String id = eElement.getAttribute("id"); - - // Need to clarify what to do with this case - if (id.equalsIgnoreCase("policyFromRegistry")) - continue; - - SecurityScenario scenario = new SecurityScenario(); - - URL policyPath = bundleContext.getBundle().getResource( - "/scenarios/" + id + "-policy.xml"); - - try { - streamReader = factory.createXMLStreamReader(policyPath - .openStream()); - } catch (FileNotFoundException | XMLStreamException e) { - - } - - scenario.setPolicy(builder.getPolicy(streamReader)); - scenario.setCategory(eElement.getElementsByTagName("Category") - .item(0).getTextContent()); - scenario.setScenarioId(id); - scenario.setDescription(eElement - .getElementsByTagName("Description").item(0) - .getTextContent()); - scenario.setSummary(eElement.getElementsByTagName("Summary") - .item(0).getTextContent()); - scenario.setType(eElement.getElementsByTagName("Type").item(0) - .getTextContent()); - scenario.setWsuId(eElement.getElementsByTagName("WsuId") - .item(0).getTextContent()); - - SecurityScenarioDatabase.put(id, scenario); - - } - } - - serviceRegistration = bundleContext.registerService( - SecurityPolicyService.class.getName(), - new SecurityPolicyServiceImpl(), null); - - } - - @Deactivate - protected void stop() throws Exception { - - serviceRegistration.unregister(); - } -} \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/SecurityPolicyService.java b/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/SecurityPolicyService.java deleted file mode 100644 index c276d49..0000000 --- a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/SecurityPolicyService.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.wso2.carbon.sts.security.provider; - -import org.apache.neethi.Policy; - -public interface SecurityPolicyService { - - public void updateEffectivePolicy(String scenario); - public Policy getEffectivePolicy(); -} diff --git a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/SecurityPolicyServiceImpl.java b/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/SecurityPolicyServiceImpl.java deleted file mode 100644 index 79021e7..0000000 --- a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/SecurityPolicyServiceImpl.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.wso2.carbon.sts.security.provider; - -import org.apache.neethi.Policy; -import org.wso2.carbon.sts.security.provider.util.SecurityScenarioDatabase; - -public class SecurityPolicyServiceImpl implements SecurityPolicyService { - - @Override - public void updateEffectivePolicy(String scenario) { - - //Update the security policy used by current tenant - } - - @Override - public Policy getEffectivePolicy() { - - //Need to get policy using tenant information - /*String scenario = DataHolder.getInstance().getScenario();*/ - String scenario = "UTOverTransport"; - return SecurityScenarioDatabase.getByWsuId(scenario).getPolicy(); - } -} \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/util/SecurityScenario.java b/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/util/SecurityScenario.java deleted file mode 100644 index 21ae838..0000000 --- a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/util/SecurityScenario.java +++ /dev/null @@ -1,180 +0,0 @@ -package org.wso2.carbon.sts.security.provider.util; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.neethi.Policy; - -/** - * - */ -public class SecurityScenario { - - /** - * Modules that need to be engaged for this security scenario - */ - private List modules = new ArrayList<>(); - private List services = new ArrayList<>(); - - private String scenarioId; - private String summary; - private String category; - private String description; - private boolean isCurrentScenario; - private String wsuId; - private String type; - private boolean isGeneralPolicy; - private Policy policy; - - /** - * Constructs a new SecurityScenarioDO. - */ - public SecurityScenario() { - isGeneralPolicy = true; - } - - /** - * Getter for property 'summary'. - * - * @return Value for property 'summary'. - * @see #setSummary - */ - public String getSummary() { - return summary; - } - - /** - * Setter for property 'summary'. - * - * @param summary Value to set for property 'summary'. - * @see #getSummary - */ - public void setSummary(String summary) { - this.summary = summary; - } - - /** - * Getter for property 'description'. - * - * @return Value for property 'description'. - * @see #setDescription - */ - public String getDescription() { - return description; - } - - /** - * Setter for property 'description'. - * - * @param description Value to set for property 'description'. - * @see #getDescription - */ - public void setDescription(String description) { - this.description = description; - } - - /** - * Getter for property 'scenarioId'. - * - * @return Value for property 'scenarioId'. - * @see #setScenarioId - */ - public String getScenarioId() { - return scenarioId; - } - - /** - * Setter for property 'scenarioId'. - * - * @param scenarioId Value to set for property 'scenarioId'. - * @see #getScenarioId - */ - public void setScenarioId(String scenarioId) { - this.scenarioId = scenarioId; - } - - - public void addModule(String module) { - modules.add(module); - } - - public void addService(String service) { - services.add(service); - } - - /** - * Getter for property 'currentScenario'. - * - * @return Value for property 'currentScenario'. - * @see #setIsCurrentScenario - */ - public boolean getIsCurrentScenario() { - return isCurrentScenario; - } - - /** - * Setter for property 'currentScenario'. - * - * @param currentScenario Value to set for property 'currentScenario'. - * @see #isCurrentScenario - */ - public void setIsCurrentScenario(boolean currentScenario) { - isCurrentScenario = currentScenario; - } - - public String getCategory() { - return category; - } - - public void setCategory(String category) { - this.category = category; - } - - public List getModules() { - return modules; - } - - public List getServices() { - return services; - } - - public String getWsuId() { - return wsuId; - } - - public void setWsuId(String wsuId) { - this.wsuId = wsuId; - } - - public Policy getPolicy() { - return policy; - } - - public void setPolicy(Policy policy) { - this.policy = policy; - } - - public boolean isCurrentScenario() { - return isCurrentScenario; - } - - public void setCurrentScenario(boolean currentScenario) { - isCurrentScenario = currentScenario; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public boolean getGeneralPolicy() { - return isGeneralPolicy; - } - - public void setGeneralPolicy(boolean isGeneralPolicy) { - this.isGeneralPolicy = isGeneralPolicy; - } -} \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/util/SecurityScenarioDatabase.java b/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/util/SecurityScenarioDatabase.java deleted file mode 100644 index f24ec4e..0000000 --- a/org.wso2.sts.security.provider/src/main/java/org/wso2/carbon/sts/security/provider/util/SecurityScenarioDatabase.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.wso2.carbon.sts.security.provider.util; - -import java.util.Collection; -import java.util.Iterator; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * An in-memory DB which maintains all the security scenarios - */ -public class SecurityScenarioDatabase { - private static Map scenarios = new LinkedHashMap<>(); - private static SecurityScenarioDatabase instance = new SecurityScenarioDatabase(); - - private SecurityScenarioDatabase() { - } - - public static SecurityScenarioDatabase getInstance() { - return instance; - } - - public static void put(String scenarioId, SecurityScenario scenario) { - scenarios.put(scenarioId, scenario); - } - - public static SecurityScenario get(String scenarioId) { - return scenarios.get(scenarioId); - } - - public static Collection getAllScenarios() { - return scenarios.values(); - } - - public static SecurityScenario getByWsuId(String wsuIdValue) { - SecurityScenario scenario = null; - Iterator ite = scenarios.values().iterator(); - while (ite.hasNext()) { - SecurityScenario temp = ite.next(); - if (wsuIdValue.equals(temp.getWsuId())) { - scenario = temp; - break; - } - } - return scenario; - } -} diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario-config.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario-config.xml deleted file mode 100755 index 7b8cf3a..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario-config.xml +++ /dev/null @@ -1,154 +0,0 @@ - - - - -

UsernameToken - Provides Authentication. Clients have Username Tokens - ut - UTOverTransport - basic - - - Non-repudiation - Provides Authentication and Integrity. Clients have X509 certificates - keystore - SigOnly - basic - - - Integrity - Provides Integrity. Clients do not have X509 certificates - keystore - SgnOnlyAnonymous - basic - - - Confidentiality - Provides Confidentiality. Clients do not have X509 certificates - keystore - EncrOnlyAnonymous - basic - - - - - Sign and Encrypt - X509 Authentication - Provides Authentication, Integrity and Confidentiality. Clients have X509 certificates - keystore - SigEncr - advanced - - - Sign and Encrypt - Anonymous clients - Provides Integrity and Confidentiality. - keystore - SgnEncrAnonymous - advanced - - - Encrypt only - Username Token Authentication - Provides Authentication and Confidentiality. Clients have Username Tokens - ut-keystore - EncrOnlyUsername - advanced - - - Sign and Encrypt - Username Token Authentication - Provides Authentication, Integrity and Confidentiality. Clients have Username Tokens - ut-keystore - SgnEncrUsername - advanced - - - SecureConversation - Sign only - Service as STS - Bootstrap policy - Sign and Encrypt , X509 Authentication - Provides Authentication and Integrity. Multiple message exchange.Clients have X509 certificates. - keystore - SecConSignOnly - advanced - - - SecureConversation - Encrypt only - Service as STS - Bootstrap policy - - Sign and Encrypt , X509 Authentication - Provides Confidentiality. Multiple message exchange.Clients have X509 certificates. - keystore - SecConEncrOnly - advanced - - - SecureConversation - Sign and Encrypt - Service as STS - Bootstrap policy - Sign and Encrypt , X509 Authentication - Provides Authentication, Integrity and Confidentiality. Multiple message exchange.Clients have X509 certificates. - keystore - SecConSgnEncr - advanced - - - SecureConversation - Sign Only - Service as STS - Bootstrap policy - Sign and Encrypt , Anonymous clients - Provides Integrity. Multiple message exchange. - keystore - SecConSignOnlyAnonymous - advanced - - - SecureConversation - Sign and Encrypt - Service as STS - Bootstrap policy - Sign and Encrypt , Anonymous clients - Provides Integrity and Confidentiality. Multiple message exchange. - keystore - SecConEncrOnlyAnonymous - advanced - - - SecureConversation - Encrypt Only - Service as STS - Bootstrap policy - Sign and Encrypt , Username Token Authentication - Provides Authentication and Confidentiality. Multiple message exchange. Clients have Username Tokens. - ut-keystore - SecConEncrUsername - advanced - - - SecureConversation - Sign and Encrypt - Service as STS - Bootstrap policy - Sign and Encrypt , Username Token Authentication - Provides Authentication Integrity and Confidentiality. Multiple message exchange. Clients have Username Tokens. - ut-keystore - SecConSgnEncrUsername - advanced - - - Kerberos Authentication - Sign - Sign based on a Kerberos Token. - Provides Authentication, Integrity. Multiple message exchange. Clients has to obtain a Kerberos token from a KDC. - kerberos - kerberossignandencrypt - advanced - - - Client authenticates with SAML 2.0 protection token. Symmetric Key. X509 Certificate by the Service. - Client authenticates with SAML 2.0 protection token. Symmetric Key. X509 Certificate by the Service. - keystore - SAML2HoKProtection31 - advanced - - - Client authenticates with SAML 1.1 protection token. Symmetric Key. X509 Certificate by the Service. - Client authenticates with SAML 1.1 protection token. Symmetric Key. X509 Certificate by the Service. - keystore - SAML11HoKProtection32 - advanced - - - Sign and Encrypt - X509 Authentication - SAML 2.0 Token Required as Supporting. - Sign and Encrypt - X509 Authentication - SAML 2.0 Token Required as Supporting - keystore - SigEncrSAML20Supporting33 - advanced - - - Sign and Encrypt - X509 Authentication - SAML 1.1 Token Required as Supporting. - Sign and Encrypt - X509 Authentication - SAML 1.1 Token Required as Supporting - keystore - SigEncrSAML11Supporting34 - advanced - - - Security Policy is in Registry - User specifies a Security Policy which is stored either in Configuration Registry or in Governance Registry - ut-keystore - policyFromRegistry - registryPolicy - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario1-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario1-policy.xml deleted file mode 100755 index 0a52815..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario1-policy.xml +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario10-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario10-policy.xml deleted file mode 100755 index d9ad493..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario10-policy.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario11-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario11-policy.xml deleted file mode 100755 index f3b87d0..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario11-policy.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario12-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario12-policy.xml deleted file mode 100755 index f52fbc4..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario12-policy.xml +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario13-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario13-policy.xml deleted file mode 100755 index 9d37acf..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario13-policy.xml +++ /dev/null @@ -1,125 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario14-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario14-policy.xml deleted file mode 100755 index c99004e..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario14-policy.xml +++ /dev/null @@ -1,131 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario15-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario15-policy.xml deleted file mode 100755 index a1acc22..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario15-policy.xml +++ /dev/null @@ -1,134 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario16-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario16-policy.xml deleted file mode 100755 index 9949ab9..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario16-policy.xml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- https://kirillgdev04/Security_Federation_SecurityTokenService_Indigo/Symmetric.svc/Scenario_1_IssuedTokenOverTransport_UsernameOverTransport
-
- - - urn:oasis:names:tc:SAML:1.0:assertion - - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - - 256 - - - - -
- - - -
-
- - - - - - - - - - - - - -
-
-
\ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario17-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario17-policy.xml deleted file mode 100755 index f558321..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario17-policy.xml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - -
http://foo.bar/we/don/t/process/this/yet
-
- - urn:oasis:names:tc:SAML:1.0:assertion - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - 256 - - - - -
-
-
- - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario2-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario2-policy.xml deleted file mode 100755 index 0c61700..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario2-policy.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario20-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario20-policy.xml deleted file mode 100755 index 315f89e..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario20-policy.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario21-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario21-policy.xml deleted file mode 100755 index f46bbb4..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario21-policy.xml +++ /dev/null @@ -1,107 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
https://localhost:9443/services/wso2carbon-sts
-
- - urn:oasis:names:tc:SAML:2.0:assertion - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - 256 - - - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
-
- diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario22-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario22-policy.xml deleted file mode 100755 index 78a1988..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario22-policy.xml +++ /dev/null @@ -1,98 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
https://localhost:9443/services/wso2carbon-sts
-
- - urn:oasis:names:tc:SAML:2.0:assertion - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - 256 - - - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - -
-
-
\ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario3-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario3-policy.xml deleted file mode 100755 index 997bbcc..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario3-policy.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario31-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario31-policy.xml deleted file mode 100755 index 778d3ab..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario31-policy.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - -
https://localhost:9443/services/wso2carbon-sts -
-
- - urn:oasis:names:tc:SAML:2.0:assertion - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - - 256 - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
-
\ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario32-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario32-policy.xml deleted file mode 100755 index 3f9cfbc..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario32-policy.xml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - -
https://localhost:9443/services/wso2carbon-sts -
-
- - http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1 - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - - 256 - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
-
\ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario33-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario33-policy.xml deleted file mode 100755 index 7e020bb..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario33-policy.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
https://localhost:9443/services/wso2carbon-sts
-
- - urn:oasis:names:tc:SAML:2.0:assertion - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - 256 - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
-
- diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario34-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario34-policy.xml deleted file mode 100755 index 19f188a..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario34-policy.xml +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
https://localhost:9443/services/wso2carbon-sts
-
- - http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1 - http://schemas.xmlsoap.org/ws/2005/02/trust/SymmetricKey - 256 - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - -
-
-
- diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario4-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario4-policy.xml deleted file mode 100755 index bf24b1e..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario4-policy.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario5-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario5-policy.xml deleted file mode 100755 index a41998c..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario5-policy.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario6-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario6-policy.xml deleted file mode 100755 index b35b8a0..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario6-policy.xml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario7-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario7-policy.xml deleted file mode 100755 index 454c911..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario7-policy.xml +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario8-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario8-policy.xml deleted file mode 100755 index bb1804e..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario8-policy.xml +++ /dev/null @@ -1,84 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario9-policy.xml b/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario9-policy.xml deleted file mode 100755 index c7e14cd..0000000 --- a/org.wso2.sts.security.provider/src/main/resources/scenarios/scenario9-policy.xml +++ /dev/null @@ -1,123 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/pom.xml b/pom.xml index 5b0df2d..6bb8f6b 100644 --- a/pom.xml +++ b/pom.xml @@ -15,12 +15,12 @@ pom - org.wso2.carbon.sts.store - org.wso2.carbon.sts.claim.mgt org.wso2.carbon.sts.provider - org.wso2.sts.security.provider - org.wso2.carbon.sts.provider2 - + org.wso2.carbon.sts.resource + org.wso2.carbon.sts.security.provider + org.wso2.carbon.sts.samples + org.wso2.carbon.sts.cxf +