Skip to content

Commit

Permalink
Merge pull request #12 from bcgov/add-bceid-starter
Browse files Browse the repository at this point in the history
Adding bceid lib
  • Loading branch information
sdevalapurkar-bcgov authored Aug 17, 2020
2 parents d9d1027 + 4b82ebc commit d1298bd
Show file tree
Hide file tree
Showing 23 changed files with 2,319 additions and 3 deletions.
24 changes: 23 additions & 1 deletion src/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

<groupId>ca.bc.gov.open</groupId>
<artifactId>spring-starters</artifactId>
<version>0.1.1</version>
<version>0.1.2</version>
<modules>

</modules>

<name>spring-starters</name>
<packaging>pom</packaging>
Expand All @@ -20,8 +23,27 @@
<id>all</id>
<modules>
<module>spring-sftp-starter</module>
<module>spring-bceid-starter</module>
<module>spring-starters-bom</module>
</modules>
</profile>

<profile>
<id>spring-sftp-starter</id>
<modules>
<module>spring-starters-bom</module>
<module>spring-sftp-starter</module>
</modules>
</profile>

<profile>
<id>spring-bceid-starter</id>
<modules>
<module>spring-starters-bom</module>
<module>spring-bceid-starter</module>
</modules>
</profile>

</profiles>

</project>
50 changes: 50 additions & 0 deletions src/spring-bceid-starter/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# spring-bceid-starter

A stater to facilitate usage of bceid service.

## Usage

Add spring-bceid-starter as a maven dependency

```xml
<dependencies>
<dependency>
<groupId>ca.bc.gov.open</groupId>
<artifactId>spring-bceid-starter</artifactId>
<version>0.1.2</version>
</dependency>
</dependencies>
```

## Configuration

| name | definition | required |
| --- | --- | --- |
| [bcgov.bceid.service.uri](#cgovbceidserviceuri) | String | Yes |
| [bcgov.bceid.service.username](#bcgovbceidserviceusername) | String | Yes |
| [bcgov.bceid.service.password](#bcgovbceidservicepassword) | String | Yes |
| [bcgov.bceid.service.onlineServiceId](#bcgovbceidserviceonlineServiceId) | String | Yes |

#### bcgov.bceid.service.uri

* Value type is String

Sets the BCeID service URI

#### bcgov.bceid.service.username

* Value type is String

Sets the username used to set basic authentication on the BCeID service

#### bcgov.bceid.service.password

* Value type is String

Sets the password used to set basic authentication on the BCeID service

#### bcgov.bceid.service.onlineServiceId

* Value type is String

Sets the onlineServiceId
148 changes: 148 additions & 0 deletions src/spring-bceid-starter/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<modelVersion>4.0.0</modelVersion>

<groupId>ca.bc.gov.open</groupId>
<artifactId>spring-bceid-starter</artifactId>
<version>0.1.2</version>

<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<spring-boot.version>2.2.4.RELEASE</spring-boot.version>
<org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
</properties>

<dependencies>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web-services</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
</dependency>

<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http-jetty</artifactId>
</dependency>

<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>

</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>ca.bc.gov.open</groupId>
<artifactId>spring-starters-bom</artifactId>
<version>0.1.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${org.mapstruct.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>

<!-- WSDL to Java generator -->
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>3.3.7</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${project.basedir}/src/main/resources/wsdl/BCeIDService.wsdl</wsdl>
<extraargs>
<extraarg>-client</extraarg>
<extraarg>-autoNameResolution</extraarg>
</extraargs>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>

</plugins>

</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package ca.bc.gov.open.bceid.starter;

import ca.bc.gov.open.bceid.starter.account.BCeIDAccountService;
import ca.bc.gov.open.bceid.starter.account.BCeIDAccountServiceImpl;
import ca.bc.gov.open.bceid.starter.account.mappers.AccountDetailRequestMapper;
import ca.bc.gov.open.bceid.starter.account.mappers.AccountDetailRequestMapperImpl;
import ca.bc.gov.open.bceid.starter.account.mappers.IndividualIdentityMapper;
import ca.bc.gov.open.bceid.starter.account.mappers.IndividualIdentityMapperImpl;
import ca.bceid.webservices.client.v9.BCeIDServiceSoap;
import org.apache.commons.lang3.StringUtils;
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties(BCeIdProperties.class)
public class AutoConfiguration {

private final BCeIdProperties bCeIdProperties;

public AutoConfiguration(BCeIdProperties bCeIdProperties) {
this.bCeIdProperties = bCeIdProperties;
}

@Bean
public AccountDetailRequestMapper accountDetailRequestMapper() {
return new AccountDetailRequestMapperImpl();
}

@Bean
public IndividualIdentityMapper individualIdentityMapper() {
return new IndividualIdentityMapperImpl();
}

@Bean
public BCeIDServiceSoap bCeIDServiceSoap() {

JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
jaxWsProxyFactoryBean.setServiceClass(BCeIDServiceSoap.class);
jaxWsProxyFactoryBean.setAddress(bCeIdProperties.getUri());
if(StringUtils.isNotBlank(bCeIdProperties.getUsername()))
jaxWsProxyFactoryBean.setUsername(bCeIdProperties.getUsername());
if(StringUtils.isNotBlank(bCeIdProperties.getPassword()))
jaxWsProxyFactoryBean.setPassword(bCeIdProperties.getPassword());
return (BCeIDServiceSoap) jaxWsProxyFactoryBean.create();

}

@Bean
public BCeIDAccountService bCeIDUserService(BCeIDServiceSoap bCeIDServiceSoap, AccountDetailRequestMapper accountDetailRequestMapper, IndividualIdentityMapper individualIdentityMapper) {
return new BCeIDAccountServiceImpl(bCeIDServiceSoap, bCeIdProperties, accountDetailRequestMapper, individualIdentityMapper);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package ca.bc.gov.open.bceid.starter;

import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "bcgov.bceid.service")
public class BCeIdProperties {

private String uri;
private String username;
private String password;
private String onlineServiceId;

public String getUri() {
return uri;
}

public void setUri(String uri) {
this.uri = uri;
}

public String getUsername() {
return username;
}

public void setUsername(String username) {
this.username = username;
}

public String getPassword() {
return password;
}

public void setPassword(String password) {
this.password = password;
}

public String getOnlineServiceId() {
return onlineServiceId;
}

public void setOnlineServiceId(String onlineServiceId) {
this.onlineServiceId = onlineServiceId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package ca.bc.gov.open.bceid.starter.account;

import ca.bc.gov.open.bceid.starter.account.models.IndividualIdentity;

import java.util.Optional;

public interface BCeIDAccountService {

Optional<IndividualIdentity> getIndividualIdentity(GetAccountRequest request);

}
Loading

0 comments on commit d1298bd

Please sign in to comment.