Skip to content

Commit

Permalink
Moved the SCR to annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
JKAUSHALYA committed Aug 1, 2019
1 parent 54e7925 commit 8daa7b5
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 35 deletions.
21 changes: 5 additions & 16 deletions component/pom.xml
Expand Up @@ -15,16 +15,19 @@
~ limitations under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<parent>
<groupId>org.wso2.carbon.extension.identity.authenticator.outbound.linkedin</groupId>
<artifactId>identity-outbound-auth-linkedIn</artifactId>
<version>1.0.4-SNAPSHOT</version>
</parent>

<modelVersion>4.0.0</modelVersion>
<artifactId>org.wso2.carbon.extension.identity.authenticator.linkedin.connector</artifactId>
<packaging>bundle</packaging>
<name>WSO2 Carbon - Authenticator Library For LinkedIn</name>
<url>http://wso2.org</url>

<build>
<pluginManagement>
<plugins>
Expand All @@ -40,11 +43,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.felix</groupId>
Expand All @@ -58,11 +56,11 @@
<Import-Package>
org.apache.commons.logging.*; version="1.0.4",
org.osgi.framework,
org.osgi.service.component.*,
org.wso2.carbon.identity.application.authentication.framework.*,
javax.servlet,
javax.servlet.http,
org.apache.oltu.oauth2.*;
version="${oltu.package.import.version.range}",
org.apache.oltu.oauth2.*;version="${oltu.package.import.version.range}",
*;resolution:=optional
</Import-Package>
<Export-Package>
Expand All @@ -75,15 +73,6 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
<goals>
<goal>scr</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Expand Up @@ -87,7 +87,7 @@ public boolean canHandle(HttpServletRequest request) {
log.debug(LinkedInAuthenticatorConstants.OAUTH2_PARAM_ERROR + ":" + errorParam);
}

return grantType != null && stateParam != null && loginTypePresent || errorParam != null;
return StringUtils.isNotEmpty(grantType) && stateParam != null && loginTypePresent || errorParam != null;
}

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ protected String getAuthorizationServerEndpoint(Map<String, String> authenticato
authorizationEP = LinkedInAuthenticatorConstants.LINKEDIN_OAUTH_ENDPOINT_V2;
}

return authorizationEP != null ? authorizationEP : LinkedInAuthenticatorConstants.LINKEDIN_OAUTH_ENDPOINT_V2;
return StringUtils.isNotEmpty(authorizationEP) ? authorizationEP : LinkedInAuthenticatorConstants.LINKEDIN_OAUTH_ENDPOINT_V2;
}

/**
Expand All @@ -162,7 +162,7 @@ protected String getTokenEndpoint(Map<String, String> authenticatorProperties) {
tokenEndPoint = LinkedInAuthenticatorConstants.LINKEDIN_TOKEN_ENDPOINT_V2;
}

return tokenEndPoint != null ? tokenEndPoint : LinkedInAuthenticatorConstants.LINKEDIN_TOKEN_ENDPOINT_V2;
return StringUtils.isNotEmpty(tokenEndPoint) ? tokenEndPoint : LinkedInAuthenticatorConstants.LINKEDIN_TOKEN_ENDPOINT_V2;
}

/**
Expand All @@ -178,7 +178,7 @@ protected String getUserInfoEndpoint(OAuthClientResponse token, Map<String, Stri
userinfoEndpoint = LinkedInAuthenticatorConstants.LINKEDIN_USERINFO_ENDPOINT_V2;
}

return userinfoEndpoint != null ? userinfoEndpoint : LinkedInAuthenticatorConstants
return StringUtils.isNotEmpty(userinfoEndpoint) ? userinfoEndpoint : LinkedInAuthenticatorConstants
.LINKEDIN_USERINFO_ENDPOINT_V2;
}

Expand Down Expand Up @@ -498,6 +498,7 @@ public String getEmailEndpointURL(Map<String, String> authenticatorProperties) {
emailEndpoint = LinkedInAuthenticatorConstants.LINKEDIN_EMAIL_ENDPOINT;
}

return emailEndpoint != null ? emailEndpoint : LinkedInAuthenticatorConstants.LINKEDIN_EMAIL_ENDPOINT;
return StringUtils.isNotEmpty(emailEndpoint) ? emailEndpoint : LinkedInAuthenticatorConstants
.LINKEDIN_EMAIL_ENDPOINT;
}
}
}
Expand Up @@ -22,14 +22,18 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.service.component.ComponentContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.wso2.carbon.identity.application.authentication.framework.ApplicationAuthenticator;
import org.wso2.carbon.identity.authenticator.linkedIn.LinkedInAuthenticator;

import java.util.Hashtable;

/**
* @scr.component name="identity.application.authenticator.linkedIn.component" immediate="true"
*/
@Component(
name = "identity.application.authenticator.linkedIn.component",
immediate = true
)
public class LinkedInAuthenticatorServiceComponent {

private static Log log = LogFactory.getLog(LinkedInAuthenticatorServiceComponent.class);
Expand All @@ -39,24 +43,28 @@ public class LinkedInAuthenticatorServiceComponent {
*
* @param componentContext the Component Context
*/
@Activate
protected void activate(ComponentContext componentContext) {
LinkedInAuthenticator authenticator = new LinkedInAuthenticator();
Hashtable<String, String> props = new Hashtable<>();
componentContext.getBundleContext().registerService(ApplicationAuthenticator.class.getName(),
authenticator, props);
if (log.isDebugEnabled()) {
log.debug("linkedIn authenticator is activated");
}

LinkedInAuthenticator authenticator = new LinkedInAuthenticator();
Hashtable<String, String> props = new Hashtable<>();
componentContext.getBundleContext().registerService(ApplicationAuthenticator.class.getName(),
authenticator, props);
if (log.isDebugEnabled()) {
log.debug("linkedIn authenticator is activated.");
}
}

/**
* deactivate custom authenticator.
*
* @param componentContext the Component Context
*/
@Deactivate
protected void deactivate(ComponentContext componentContext) {

if (log.isDebugEnabled()) {
log.debug("linkedIn authenticator is deactivated");
log.debug("linkedIn authenticator is deactivated.");
}
}
}
}
14 changes: 13 additions & 1 deletion pom.xml
Expand Up @@ -17,18 +17,21 @@
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.wso2</groupId>
<artifactId>wso2</artifactId>
<version>1</version>
</parent>

<groupId>org.wso2.carbon.extension.identity.authenticator.outbound.linkedin</groupId>
<artifactId>identity-outbound-auth-linkedIn</artifactId>
<version>1.0.4-SNAPSHOT</version>
<packaging>pom</packaging>
<name>WSO2 Carbon Extension - LinkedIn Pom</name>
<url>http://wso2.org</url>

<profiles>
<profile>
<id>default</id>
Expand All @@ -41,7 +44,13 @@
</modules>
</profile>
</profiles>

<dependencies>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.scr.ds-annotations</artifactId>
<version>${apache.felix.scr.ds.annotations.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.carbon.identity</groupId>
<artifactId>org.wso2.carbon.idp.mgt</artifactId>
Expand Down Expand Up @@ -133,6 +142,7 @@
<version>${wso2.json}</version>
</dependency>
</dependencies>

<scm>
<connection>scm:git:https://github.com/wso2-extensions/identity-outbound-auth-linkedIn.git</connection>
<url>https://github.com/wso2-extensions/identity-outbound-auth-linkedIn.git</url>
Expand All @@ -141,6 +151,7 @@
</developerConnection>
<tag>HEAD</tag>
</scm>

<build>
<extensions>
<extension>
Expand Down Expand Up @@ -190,7 +201,7 @@
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-scr-plugin</artifactId>
<version>1.7.2</version>
<version>1.22.0</version>
<executions>
<execution>
<id>generate-scr-scrdescriptor</id>
Expand Down Expand Up @@ -332,5 +343,6 @@
<encoder.wso2.version>1.2.0.wso2v1</encoder.wso2.version>
<org.apache.oltu.oauth2.client>0.31</org.apache.oltu.oauth2.client>
<org.apache.oltu.oauth2.common>1.0.1</org.apache.oltu.oauth2.common>
<apache.felix.scr.ds.annotations.version>1.2.4</apache.felix.scr.ds.annotations.version>
</properties>
</project>

0 comments on commit 8daa7b5

Please sign in to comment.