Change the service registration

4.x.x
Kamidu Sachith 9 years ago
parent d52df2474e
commit d5dcf44f27

@ -87,12 +87,14 @@
<instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pom.artifactId}</Bundle-Name>
<Bundle-Version>${carbon.device.mgt.version}</Bundle-Version>
<Bundle-Description>Identity backend Bundle</Bundle-Description>
<Bundle-Activator>org.wso2.carbon.identity.authenticator.backend.oauth.internal.OauthAuthenticatorServiceComponent</Bundle-Activator>
<Private-Package>
org.wso2.sample.authenticator.internal
org.wso2.org.wso2.carbon.identity.authenticator.backend.oauth.internal
</Private-Package>
<Export-Package>
!org.wso2.sample.authenticator.internal,
org.wso2.sample.authenticator.*,
org.wso2.carbon.identity.authenticator.backend.oauth.*
</Export-Package>
<Import-Package>
javax.servlet.http,
@ -112,8 +114,8 @@
org.wso2.carbon.core.services.authentication,
org.wso2.carbon.identity.oauth2.stub,
org.wso2.carbon.identity.oauth2.stub.dto,
org.wso2.carbon.base,
org.wso2.carbon.utils
org.wso2.carbon.base,
org.wso2.carbon.utils
</Import-Package>
</instructions>
</configuration>

@ -20,25 +20,27 @@ package org.wso2.carbon.identity.authenticator.backend.oauth.internal;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
import org.wso2.carbon.core.services.authentication.CarbonServerAuthenticator;
import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator;
/**
* @scr.component component.name="org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator" immediate="true"
*/
@SuppressWarnings("unused")
public class OauthAuthenticatorServiceComponent {
public class OauthAuthenticatorServiceComponent implements BundleActivator {
private ServiceRegistration pipServiceRegRef;
private static final Log log = LogFactory.getLog(OauthAuthenticatorServiceComponent
.class);
protected void activate(ComponentContext ctxt) {
@Override
public void start(BundleContext bundleContext) throws Exception {
log.info("Initiating");
try {
OauthAuthenticator oauthAuthenticator = new OauthAuthenticator();
ctxt.getBundleContext().registerService(CarbonServerAuthenticator.class.getName(),
oauthAuthenticator, null);
pipServiceRegRef = bundleContext.registerService(CarbonServerAuthenticator.class.getName(),
oauthAuthenticator, null);
if (log.isDebugEnabled()) {
log.debug("OAuth Authenticator bundle is activated");
}
@ -47,10 +49,12 @@ public class OauthAuthenticatorServiceComponent {
}
}
protected void deactivate(ComponentContext ctxt) {
@Override
public void stop(BundleContext bundleContext) throws Exception {
if (log.isDebugEnabled()) {
log.debug("OAuth Authenticator bundle is deactivated");
}
pipServiceRegRef.unregister();
}
}

@ -45,7 +45,6 @@ public class OAuthAuthenticator implements WebappAuthenticator {
private static final String RESOURCE_KEY = "resource";
private static APITokenAuthenticator authenticator = new APITokenAuthenticator();
private static final Log log = LogFactory.getLog(OAuthAuthenticator.class);
@Override
@ -81,8 +80,8 @@ public class OAuthAuthenticator implements WebappAuthenticator {
authenticationInfo.setStatus(Status.CONTINUE);
}
String apiVersion = tokenizer.nextToken();
String authLevel = authenticator.getResourceAuthenticationScheme(context, apiVersion, requestUri, requestMethod);
//String authLevel = "any";
//String authLevel = authenticator.getResourceAuthenticationScheme(context, apiVersion, requestUri, requestMethod);
String authLevel = "any";
try {
if (Constants.NO_MATCHING_AUTH_SCHEME.equals(authLevel)) {
AuthenticationFrameworkUtil.handleNoMatchAuthScheme(request, response, requestMethod, apiVersion,

@ -45,6 +45,10 @@
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.device.mgt.oauth.extensions</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.authenticator.backend.oauth</artifactId>
</dependency>
</dependencies>
<build>
@ -73,6 +77,9 @@
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.device.mgt.oauth.extensions:${carbon.device.mgt.version}
</bundleDef>
<bundleDef>
org.wso2.carbon.devicemgt:org.wso2.carbon.identity.authenticator.backend.oauth:${carbon.device.mgt.version}
</bundleDef>
</bundles>
<importFeatures>
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}

@ -247,6 +247,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>org.wso2.carbon.identity.authenticator.backend.oauth</artifactId>
<version>${carbon.device.mgt.version}</version>
</dependency>
<!-- Device Management dependencies -->
<!-- Governance dependencies -->

Loading…
Cancel
Save