Skip to content

Commit

Permalink
code cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
IsurangaPerera committed Aug 13, 2017
1 parent 4059d86 commit e27977d
Show file tree
Hide file tree
Showing 8 changed files with 43 additions and 565 deletions.
6 changes: 6 additions & 0 deletions org.wso2.carbon.sts.provider/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.wso2.carbon.sts</groupId>
<artifactId>org.wso2.carbon.sts.provider2</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.neethi</groupId>
<artifactId>neethi</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,15 @@
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.wso2.carbon.sts.resource.provider.DefaultSecurityTokenServiceProvider;
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;
Expand Down Expand Up @@ -44,7 +49,7 @@ public class STSResource extends AbstractResource {
public void processRequest(@Context Request request, @Context Response response) {

try {
DefaultSecurityTokenServiceProvider provider = new DefaultSecurityTokenServiceProvider();
DefaultSecurityTokenServiceProvider provider = DataHolder.getInstance().getServiceProvider();
provider.setWebServiceContext(WSContext.getInstance()
.getWSContext());
Source resp = provider.invoke((Source) request
Expand All @@ -64,6 +69,23 @@ public void processRequest(@Context Request request, @Context Response response)
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
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.provider.PasswordCallbackHandler;
import org.wso2.carbon.sts.resource.utils.SOAPUtils;
import org.wso2.carbon.sts.resource.utils.WSContext;
import org.wso2.msf4j.Interceptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@

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();

Expand All @@ -30,4 +32,12 @@ public void setExchange(Exchange exchange) {
public Exchange getExchange() {
return exchange;
}

public void setServiceProvider(DefaultSecurityTokenServiceProvider provider) {
this.provider = provider;
}

public DefaultSecurityTokenServiceProvider getServiceProvider() {
return provider;
}
}
Loading

0 comments on commit e27977d

Please sign in to comment.