Merge branch 'master' of https://github.com/Kamidu/carbon-device-mgt into Kamidu-master

4.x.x
geethkokila 9 years ago
commit 182e15d632

@ -87,34 +87,16 @@
<instructions> <instructions>
<Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName> <Bundle-SymbolicName>${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>${pom.artifactId}</Bundle-Name> <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> <Private-Package>
org.wso2.sample.authenticator.internal org.wso2.org.wso2.carbon.identity.authenticator.backend.oauth.internal
</Private-Package> </Private-Package>
<Export-Package> <Export-Package>
!org.wso2.sample.authenticator.internal, org.wso2.carbon.identity.authenticator.backend.oauth.*
org.wso2.sample.authenticator.*,
</Export-Package> </Export-Package>
<Import-Package>
javax.servlet.http,
org.apache.commons.logging,
org.wso2.carbon.identity.application.authentication.framework.*,
org.wso2.carbon.identity.oauth2,
org.wso2.carbon.identity.oauth2.dto,
org.wso2.carbon.user.core.service,
org.wso2.carbon.utils.multitenancy,
org.apache.axis2.client,
org.apache.axis2.context,
org.apache.axis2.transport.http,
org.apache.commons.httpclient,
org.osgi.framework,
org.osgi.service.component,
org.wso2.carbon.core.security,
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
</Import-Package>
</instructions> </instructions>
</configuration> </configuration>
</plugin> </plugin>

@ -20,25 +20,27 @@ package org.wso2.carbon.identity.authenticator.backend.oauth.internal;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory; 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.core.services.authentication.CarbonServerAuthenticator;
import org.wso2.carbon.identity.authenticator.backend.oauth.OauthAuthenticator; 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 private static final Log log = LogFactory.getLog(OauthAuthenticatorServiceComponent
.class); .class);
protected void activate(ComponentContext ctxt) { @Override
public void start(BundleContext bundleContext) throws Exception {
log.info("Initiating");
try { try {
OauthAuthenticator oauthAuthenticator = new OauthAuthenticator(); OauthAuthenticator oauthAuthenticator = new OauthAuthenticator();
ctxt.getBundleContext().registerService(CarbonServerAuthenticator.class.getName(), pipServiceRegRef = bundleContext.registerService(CarbonServerAuthenticator.class.getName(),
oauthAuthenticator, null); oauthAuthenticator, null);
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("OAuth Authenticator bundle is activated"); 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()) { if (log.isDebugEnabled()) {
log.debug("OAuth Authenticator bundle is deactivated"); 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 final String RESOURCE_KEY = "resource";
private static APITokenAuthenticator authenticator = new APITokenAuthenticator(); private static APITokenAuthenticator authenticator = new APITokenAuthenticator();
private static final Log log = LogFactory.getLog(OAuthAuthenticator.class); private static final Log log = LogFactory.getLog(OAuthAuthenticator.class);
@Override @Override
@ -81,8 +80,8 @@ public class OAuthAuthenticator implements WebappAuthenticator {
authenticationInfo.setStatus(Status.CONTINUE); authenticationInfo.setStatus(Status.CONTINUE);
} }
String apiVersion = tokenizer.nextToken(); String apiVersion = tokenizer.nextToken();
String authLevel = authenticator.getResourceAuthenticationScheme(context, apiVersion, requestUri, requestMethod); //String authLevel = authenticator.getResourceAuthenticationScheme(context, apiVersion, requestUri, requestMethod);
//String authLevel = "any"; String authLevel = "any";
try { try {
if (Constants.NO_MATCHING_AUTH_SCHEME.equals(authLevel)) { if (Constants.NO_MATCHING_AUTH_SCHEME.equals(authLevel)) {
AuthenticationFrameworkUtil.handleNoMatchAuthScheme(request, response, requestMethod, apiVersion, AuthenticationFrameworkUtil.handleNoMatchAuthScheme(request, response, requestMethod, apiVersion,

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

@ -247,6 +247,11 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </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 --> <!-- Device Management dependencies -->
<!-- Governance dependencies --> <!-- Governance dependencies -->

Loading…
Cancel
Save