Skip to content

Commit d1298bd

Browse files
Merge pull request #12 from bcgov/add-bceid-starter
Adding bceid lib
2 parents d9d1027 + 4b82ebc commit d1298bd

23 files changed

+2319
-3
lines changed

src/pom.xml

+23-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@
55

66
<groupId>ca.bc.gov.open</groupId>
77
<artifactId>spring-starters</artifactId>
8-
<version>0.1.1</version>
8+
<version>0.1.2</version>
9+
<modules>
10+
11+
</modules>
912

1013
<name>spring-starters</name>
1114
<packaging>pom</packaging>
@@ -20,8 +23,27 @@
2023
<id>all</id>
2124
<modules>
2225
<module>spring-sftp-starter</module>
26+
<module>spring-bceid-starter</module>
27+
<module>spring-starters-bom</module>
28+
</modules>
29+
</profile>
30+
31+
<profile>
32+
<id>spring-sftp-starter</id>
33+
<modules>
34+
<module>spring-starters-bom</module>
35+
<module>spring-sftp-starter</module>
2336
</modules>
2437
</profile>
38+
39+
<profile>
40+
<id>spring-bceid-starter</id>
41+
<modules>
42+
<module>spring-starters-bom</module>
43+
<module>spring-bceid-starter</module>
44+
</modules>
45+
</profile>
46+
2547
</profiles>
2648

2749
</project>

src/spring-bceid-starter/README.md

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# spring-bceid-starter
2+
3+
A stater to facilitate usage of bceid service.
4+
5+
## Usage
6+
7+
Add spring-bceid-starter as a maven dependency
8+
9+
```xml
10+
<dependencies>
11+
<dependency>
12+
<groupId>ca.bc.gov.open</groupId>
13+
<artifactId>spring-bceid-starter</artifactId>
14+
<version>0.1.2</version>
15+
</dependency>
16+
</dependencies>
17+
```
18+
19+
## Configuration
20+
21+
| name | definition | required |
22+
| --- | --- | --- |
23+
| [bcgov.bceid.service.uri](#cgovbceidserviceuri) | String | Yes |
24+
| [bcgov.bceid.service.username](#bcgovbceidserviceusername) | String | Yes |
25+
| [bcgov.bceid.service.password](#bcgovbceidservicepassword) | String | Yes |
26+
| [bcgov.bceid.service.onlineServiceId](#bcgovbceidserviceonlineServiceId) | String | Yes |
27+
28+
#### bcgov.bceid.service.uri
29+
30+
* Value type is String
31+
32+
Sets the BCeID service URI
33+
34+
#### bcgov.bceid.service.username
35+
36+
* Value type is String
37+
38+
Sets the username used to set basic authentication on the BCeID service
39+
40+
#### bcgov.bceid.service.password
41+
42+
* Value type is String
43+
44+
Sets the password used to set basic authentication on the BCeID service
45+
46+
#### bcgov.bceid.service.onlineServiceId
47+
48+
* Value type is String
49+
50+
Sets the onlineServiceId

src/spring-bceid-starter/pom.xml

+148
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>ca.bc.gov.open</groupId>
8+
<artifactId>spring-bceid-starter</artifactId>
9+
<version>0.1.2</version>
10+
11+
<properties>
12+
<java.version>1.8</java.version>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.source>1.8</maven.compiler.source>
15+
<maven.compiler.target>1.8</maven.compiler.target>
16+
<spring-boot.version>2.2.4.RELEASE</spring-boot.version>
17+
<org.mapstruct.version>1.3.1.Final</org.mapstruct.version>
18+
</properties>
19+
20+
<dependencies>
21+
22+
<dependency>
23+
<groupId>org.springframework.boot</groupId>
24+
<artifactId>spring-boot-starter-web-services</artifactId>
25+
<exclusions>
26+
<exclusion>
27+
<groupId>org.springframework.boot</groupId>
28+
<artifactId>spring-boot-starter-tomcat</artifactId>
29+
</exclusion>
30+
</exclusions>
31+
</dependency>
32+
33+
<dependency>
34+
<groupId>org.springframework.boot</groupId>
35+
<artifactId>spring-boot-starter-test</artifactId>
36+
<scope>test</scope>
37+
<exclusions>
38+
<exclusion>
39+
<groupId>org.junit.vintage</groupId>
40+
<artifactId>junit-vintage-engine</artifactId>
41+
</exclusion>
42+
</exclusions>
43+
</dependency>
44+
45+
<dependency>
46+
<groupId>org.apache.cxf</groupId>
47+
<artifactId>cxf-rt-frontend-jaxws</artifactId>
48+
</dependency>
49+
50+
<dependency>
51+
<groupId>org.apache.cxf</groupId>
52+
<artifactId>cxf-rt-transports-http</artifactId>
53+
</dependency>
54+
55+
<dependency>
56+
<groupId>org.apache.cxf</groupId>
57+
<artifactId>cxf-rt-transports-http-jetty</artifactId>
58+
</dependency>
59+
60+
<dependency>
61+
<groupId>org.apache.commons</groupId>
62+
<artifactId>commons-lang3</artifactId>
63+
</dependency>
64+
65+
<dependency>
66+
<groupId>joda-time</groupId>
67+
<artifactId>joda-time</artifactId>
68+
</dependency>
69+
70+
<dependency>
71+
<groupId>org.mapstruct</groupId>
72+
<artifactId>mapstruct</artifactId>
73+
</dependency>
74+
75+
</dependencies>
76+
77+
<dependencyManagement>
78+
<dependencies>
79+
<dependency>
80+
<groupId>org.springframework.boot</groupId>
81+
<artifactId>spring-boot-dependencies</artifactId>
82+
<version>${spring-boot.version}</version>
83+
<type>pom</type>
84+
<scope>import</scope>
85+
</dependency>
86+
<dependency>
87+
<groupId>ca.bc.gov.open</groupId>
88+
<artifactId>spring-starters-bom</artifactId>
89+
<version>0.1.2</version>
90+
<type>pom</type>
91+
<scope>import</scope>
92+
</dependency>
93+
</dependencies>
94+
</dependencyManagement>
95+
96+
<build>
97+
<plugins>
98+
99+
<plugin>
100+
<groupId>org.apache.maven.plugins</groupId>
101+
<artifactId>maven-compiler-plugin</artifactId>
102+
<version>3.5.1</version>
103+
<configuration>
104+
<source>${java.version}</source>
105+
<target>${java.version}</target>
106+
<annotationProcessorPaths>
107+
<path>
108+
<groupId>org.mapstruct</groupId>
109+
<artifactId>mapstruct-processor</artifactId>
110+
<version>${org.mapstruct.version}</version>
111+
</path>
112+
</annotationProcessorPaths>
113+
</configuration>
114+
</plugin>
115+
116+
<!-- WSDL to Java generator -->
117+
<plugin>
118+
<groupId>org.apache.cxf</groupId>
119+
<artifactId>cxf-codegen-plugin</artifactId>
120+
<version>3.3.7</version>
121+
<executions>
122+
<execution>
123+
<id>generate-sources</id>
124+
<phase>generate-sources</phase>
125+
<configuration>
126+
<sourceRoot>${project.build.directory}/generated-sources/cxf</sourceRoot>
127+
<wsdlOptions>
128+
<wsdlOption>
129+
<wsdl>${project.basedir}/src/main/resources/wsdl/BCeIDService.wsdl</wsdl>
130+
<extraargs>
131+
<extraarg>-client</extraarg>
132+
<extraarg>-autoNameResolution</extraarg>
133+
</extraargs>
134+
</wsdlOption>
135+
</wsdlOptions>
136+
</configuration>
137+
<goals>
138+
<goal>wsdl2java</goal>
139+
</goals>
140+
</execution>
141+
</executions>
142+
</plugin>
143+
144+
</plugins>
145+
146+
</build>
147+
148+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
package ca.bc.gov.open.bceid.starter;
2+
3+
import ca.bc.gov.open.bceid.starter.account.BCeIDAccountService;
4+
import ca.bc.gov.open.bceid.starter.account.BCeIDAccountServiceImpl;
5+
import ca.bc.gov.open.bceid.starter.account.mappers.AccountDetailRequestMapper;
6+
import ca.bc.gov.open.bceid.starter.account.mappers.AccountDetailRequestMapperImpl;
7+
import ca.bc.gov.open.bceid.starter.account.mappers.IndividualIdentityMapper;
8+
import ca.bc.gov.open.bceid.starter.account.mappers.IndividualIdentityMapperImpl;
9+
import ca.bceid.webservices.client.v9.BCeIDServiceSoap;
10+
import org.apache.commons.lang3.StringUtils;
11+
import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
12+
import org.springframework.boot.context.properties.EnableConfigurationProperties;
13+
import org.springframework.context.annotation.Bean;
14+
import org.springframework.context.annotation.Configuration;
15+
16+
@Configuration
17+
@EnableConfigurationProperties(BCeIdProperties.class)
18+
public class AutoConfiguration {
19+
20+
private final BCeIdProperties bCeIdProperties;
21+
22+
public AutoConfiguration(BCeIdProperties bCeIdProperties) {
23+
this.bCeIdProperties = bCeIdProperties;
24+
}
25+
26+
@Bean
27+
public AccountDetailRequestMapper accountDetailRequestMapper() {
28+
return new AccountDetailRequestMapperImpl();
29+
}
30+
31+
@Bean
32+
public IndividualIdentityMapper individualIdentityMapper() {
33+
return new IndividualIdentityMapperImpl();
34+
}
35+
36+
@Bean
37+
public BCeIDServiceSoap bCeIDServiceSoap() {
38+
39+
JaxWsProxyFactoryBean jaxWsProxyFactoryBean = new JaxWsProxyFactoryBean();
40+
jaxWsProxyFactoryBean.setServiceClass(BCeIDServiceSoap.class);
41+
jaxWsProxyFactoryBean.setAddress(bCeIdProperties.getUri());
42+
if(StringUtils.isNotBlank(bCeIdProperties.getUsername()))
43+
jaxWsProxyFactoryBean.setUsername(bCeIdProperties.getUsername());
44+
if(StringUtils.isNotBlank(bCeIdProperties.getPassword()))
45+
jaxWsProxyFactoryBean.setPassword(bCeIdProperties.getPassword());
46+
return (BCeIDServiceSoap) jaxWsProxyFactoryBean.create();
47+
48+
}
49+
50+
@Bean
51+
public BCeIDAccountService bCeIDUserService(BCeIDServiceSoap bCeIDServiceSoap, AccountDetailRequestMapper accountDetailRequestMapper, IndividualIdentityMapper individualIdentityMapper) {
52+
return new BCeIDAccountServiceImpl(bCeIDServiceSoap, bCeIdProperties, accountDetailRequestMapper, individualIdentityMapper);
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package ca.bc.gov.open.bceid.starter;
2+
3+
import org.springframework.boot.context.properties.ConfigurationProperties;
4+
5+
@ConfigurationProperties(prefix = "bcgov.bceid.service")
6+
public class BCeIdProperties {
7+
8+
private String uri;
9+
private String username;
10+
private String password;
11+
private String onlineServiceId;
12+
13+
public String getUri() {
14+
return uri;
15+
}
16+
17+
public void setUri(String uri) {
18+
this.uri = uri;
19+
}
20+
21+
public String getUsername() {
22+
return username;
23+
}
24+
25+
public void setUsername(String username) {
26+
this.username = username;
27+
}
28+
29+
public String getPassword() {
30+
return password;
31+
}
32+
33+
public void setPassword(String password) {
34+
this.password = password;
35+
}
36+
37+
public String getOnlineServiceId() {
38+
return onlineServiceId;
39+
}
40+
41+
public void setOnlineServiceId(String onlineServiceId) {
42+
this.onlineServiceId = onlineServiceId;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package ca.bc.gov.open.bceid.starter.account;
2+
3+
import ca.bc.gov.open.bceid.starter.account.models.IndividualIdentity;
4+
5+
import java.util.Optional;
6+
7+
public interface BCeIDAccountService {
8+
9+
Optional<IndividualIdentity> getIndividualIdentity(GetAccountRequest request);
10+
11+
}

0 commit comments

Comments
 (0)