-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(jans-config-api): converting fido2 endpoint to plugin (#1304)
* feat(jans-config-api): rectified scope for user fetch request * feat(jans-config-api): converting fido2 endpoint to plugin issue#1224 * feat(jans-config-api): converting fido2 endpoint to plugin issue#1224 * feat(jans-config-api): converting fido2 endpoint to plugin issue#1224 * feat(jans-config-api): converting fido2 endpoint to plugin issue#1224 Co-authored-by: Mustafa Baser <mbaser@mail.com>
- Loading branch information
1 parent
d016682
commit 88c3fff
Showing
36 changed files
with
722 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,222 @@ | ||
<?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"> | ||
<parent> | ||
<artifactId>plugins</artifactId> | ||
<groupId>io.jans.jans-config-api.plugins</groupId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
<groupId>io.jans.jans-config-api.plugins</groupId> | ||
<artifactId>fido2-plugin</artifactId> | ||
<properties> | ||
<httpcore.version>4.4.14</httpcore.version> | ||
<httpclient.version>4.5.13</httpclient.version> | ||
<jans.version>1.0.0-SNAPSHOT</jans.version> | ||
</properties> | ||
|
||
<dependencies> | ||
|
||
<!-- config api --> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-config-api-shared</artifactId> | ||
<version>${jans.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-config-api-server</artifactId> | ||
<version>${jans.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-orm-annotation</artifactId> | ||
<version>${jans.version}</version> | ||
</dependency> | ||
|
||
|
||
<!-- Microprofile --> | ||
<dependency> | ||
<groupId>io.smallrye</groupId> | ||
<artifactId>smallrye-config</artifactId> | ||
<version>1.5.0</version> | ||
</dependency> | ||
|
||
<!-- Others --> | ||
<dependency> | ||
<groupId>commons-collections</groupId> | ||
<artifactId>commons-collections</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpclient</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpcore</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.httpcomponents</groupId> | ||
<artifactId>httpcore-nio</artifactId> | ||
<version>${httpcore.version}</version> | ||
</dependency> | ||
|
||
<!-- CDI --> | ||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>jakarta.enterprise.cdi-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.validation</groupId> | ||
<artifactId>jakarta.validation-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.ws.rs</groupId> | ||
<artifactId>jakarta.ws.rs-api</artifactId> | ||
</dependency> | ||
|
||
|
||
<!-- Testing --> | ||
<dependency> | ||
<groupId>io.rest-assured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.intuit.karate</groupId> | ||
<artifactId>karate-junit5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.intuit.karate</groupId> | ||
<artifactId>karate-apache</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-api</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>net.masterthought</groupId> | ||
<artifactId>cucumber-reporting</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
|
||
<build> | ||
<filters> | ||
<filter>../../profiles/${cfg}/config-build.properties</filter> | ||
<filter>../../profiles/${cfg}/config-api-test.properties</filter> | ||
</filters> | ||
|
||
<testResources> | ||
<testResource> | ||
<directory>src/test/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>karate.properties</include> | ||
<include>karate_jenkins.properties</include> | ||
<include>test.properties</include> | ||
<include>*.*</include> | ||
</includes> | ||
</testResource> | ||
</testResources> | ||
|
||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>**/*.xml</include> | ||
<include>**/*.properties</include> | ||
<include>**/*.json</include> | ||
<include>META-INF/services/*.*</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
|
||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-assembly-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>single</goal> | ||
</goals> | ||
<configuration> | ||
<descriptors> | ||
<descriptor>src/main/assembly/assembly.xml</descriptor> | ||
</descriptors> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<configuration> | ||
<systemPropertyVariables> | ||
</systemPropertyVariables> | ||
<excludedGroups>integration</excludedGroups> | ||
<systemProperties> | ||
<karate.options>--tags ~@ignore</karate.options> | ||
</systemProperties> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<id>integration-tests</id> | ||
<phase>integration-test</phase> | ||
<goals> | ||
<goal>test</goal> | ||
</goals> | ||
<configuration> | ||
<failIfNoTests>false</failIfNoTests> | ||
<excludedGroups>!integration</excludedGroups> | ||
<groups>integration</groups> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<id>deploy-to-local-folder</id> | ||
<phase>package</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>../target/plugins</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>${project.build.directory}</directory> | ||
<include>*-distribution.jar</include> | ||
<filtering>false</filtering> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
19 changes: 19 additions & 0 deletions
19
jans-config-api/plugins/fido2-plugin/src/main/assembly/assembly.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd"> | ||
|
||
<id>distribution</id> | ||
<formats> | ||
<format>jar</format> | ||
</formats> | ||
<includeBaseDirectory>false</includeBaseDirectory> | ||
<fileSets> | ||
<fileSet> | ||
<directory>${project.build.directory}/classes</directory> | ||
<outputDirectory>/</outputDirectory> | ||
<includes> | ||
<include>**/*</include> | ||
</includes> | ||
</fileSet> | ||
</fileSets> | ||
</assembly> |
6 changes: 6 additions & 0 deletions
6
.../fido2-plugin/src/main/java/io/jans/configapi/plugin/fido2/extensions/Fido2Extension.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.jans.configapi.plugin.fido2.extensions; | ||
|
||
import jakarta.enterprise.inject.spi.Extension; | ||
|
||
public class Fido2Extension implements Extension { | ||
} |
81 changes: 81 additions & 0 deletions
81
...2-plugin/src/main/java/io/jans/configapi/plugin/fido2/model/config/Fido2ConfigSource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
package io.jans.configapi.plugin.fido2.model.config; | ||
|
||
import io.jans.exception.ConfigurationException; | ||
import java.io.InputStream; | ||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Properties; | ||
import java.util.Set; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
|
||
import org.eclipse.microprofile.config.spi.ConfigSource; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
@ApplicationScoped | ||
public class Fido2ConfigSource implements ConfigSource { | ||
|
||
private static Logger log = LoggerFactory.getLogger(Fido2ConfigSource.class); | ||
private static final String FILE_CONFIG = "fido2.properties"; | ||
private Properties properties = null; | ||
Map<String, String> propertiesMap = new HashMap<>(); | ||
|
||
public Fido2ConfigSource() { | ||
this.loadProperties(); | ||
} | ||
|
||
@Override | ||
public Map<String, String> getProperties() { | ||
log.debug("Getting properties"); | ||
return propertiesMap; | ||
} | ||
|
||
@Override | ||
public Set<String> getPropertyNames() { | ||
log.debug("Getting Property Names"); | ||
try { | ||
return properties.stringPropertyNames(); | ||
|
||
} catch (Exception e) { | ||
log.error("Unable to read properties from file: " + FILE_CONFIG, e); | ||
} | ||
return Collections.emptySet(); | ||
} | ||
|
||
@Override | ||
public int getOrdinal() { | ||
return 800; | ||
} | ||
|
||
@Override | ||
public String getValue(String name) { | ||
log.debug("Fido2ConfigSource()::getValue() - name:{}", name); | ||
try { | ||
return properties.getProperty(name); | ||
} catch (Exception e) { | ||
log.error("Unable to read properties from file: " + FILE_CONFIG, e); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return FILE_CONFIG; | ||
} | ||
|
||
private Properties loadProperties() { | ||
// Load the properties file | ||
ClassLoader loader = Thread.currentThread().getContextClassLoader(); | ||
try ( InputStream inputStream = loader.getResourceAsStream(FILE_CONFIG)) { | ||
properties = new Properties(); | ||
properties.load(inputStream); | ||
properties.stringPropertyNames().stream().forEach(key -> propertiesMap.put(key, properties.getProperty(key))); | ||
return properties; | ||
} catch (Exception e) { | ||
throw new ConfigurationException("Failed to load configuration from "+ FILE_CONFIG, e); | ||
} | ||
} | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...lugins/fido2-plugin/src/main/java/io/jans/configapi/plugin/fido2/rest/ApiApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.jans.configapi.plugin.fido2.rest; | ||
|
||
import jakarta.ws.rs.ApplicationPath; | ||
import jakarta.ws.rs.core.Application; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
@ApplicationPath("/fido2") | ||
public class ApiApplication extends Application { | ||
|
||
@Override | ||
public Set<Class<?>> getClasses() { | ||
HashSet<Class<?>> classes = new HashSet<>(); | ||
|
||
classes.add(Fido2ConfigResource.class); | ||
|
||
return classes; | ||
} | ||
} |
Oops, something went wrong.