-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
1,233 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,170 @@ | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" 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> | ||
<artifactId>jans-fido2-common</artifactId> | ||
<packaging>jar</packaging> | ||
<name>FIDO2 Common</name> | ||
|
||
<parent> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-fido2-parent</artifactId> | ||
<version>1.0.7-SNAPSHOT</version> | ||
</parent> | ||
|
||
<build> | ||
<resources> | ||
<resource> | ||
<directory>src/main/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>**/*.xml</include> | ||
<include>**/services/*</include> | ||
<include>**/*.properties</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
|
||
<testResources> | ||
<testResource> | ||
<directory>src/test/resources</directory> | ||
<filtering>true</filtering> | ||
<includes> | ||
<include>**/*.xml</include> | ||
<include>**/services/*</include> | ||
<include>**/*.properties</include> | ||
</includes> | ||
</testResource> | ||
</testResources> | ||
|
||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-javadoc-plugin</artifactId> | ||
<configuration> | ||
<failOnError>false</failOnError> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<dependencies> | ||
<!-- Jans --> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-fido2-model</artifactId> | ||
<version>${janssen.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-orm-model</artifactId> | ||
<version>${janssen.version}</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-core-model</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-orm-ldap</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-orm-couchbase</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-orm-sql</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>${project.groupId}</groupId> | ||
<artifactId>jans-orm-hybrid</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-core-util</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-core-service</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-core-cache</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-auth-client</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.jans</groupId> | ||
<artifactId>jans-auth-common</artifactId> | ||
</dependency> | ||
|
||
<!-- Weld --> | ||
<dependency> | ||
<groupId>jakarta.enterprise</groupId> | ||
<artifactId>jakarta.enterprise.cdi-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.servlet</groupId> | ||
<artifactId>jakarta.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jboss.weld</groupId> | ||
<artifactId>weld-core-impl</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.inject</groupId> | ||
<artifactId>jakarta.inject-api</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.glassfish</groupId> | ||
<artifactId>jakarta.faces</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>jakarta.validation</groupId> | ||
<artifactId>jakarta.validation-api</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>jakarta.ejb</groupId> | ||
<artifactId>jakarta.ejb-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.fasterxml.jackson.dataformat</groupId> | ||
<artifactId>jackson-dataformat-cbor</artifactId> | ||
</dependency> | ||
|
||
|
||
|
||
<!-- Quartz --> | ||
<dependency> | ||
<groupId>org.quartz-scheduler</groupId> | ||
<artifactId>quartz</artifactId> | ||
</dependency> | ||
|
||
<!-- Tests --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
</dependency> | ||
|
||
|
||
|
||
<!-- RestEasy --> | ||
<dependency> | ||
<groupId>org.jboss.resteasy</groupId> | ||
<artifactId>resteasy-client</artifactId> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
</project> |
49 changes: 49 additions & 0 deletions
49
jans-fido2/common/src/main/java/io/jans/fido2/exception/Fido2RuntimeException.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,49 @@ | ||
/* | ||
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.fido2.exception; | ||
|
||
import io.jans.fido2.model.error.Fido2RPError; | ||
|
||
/** | ||
* Parent class of all FIDO2 RuntimeExceptions | ||
* | ||
*/ | ||
public class Fido2RuntimeException extends RuntimeException { | ||
|
||
private static final long serialVersionUID = -118563205092295773L; | ||
|
||
private final String status; | ||
private final String errorMessage; | ||
|
||
public Fido2RuntimeException(String errorMessage) { | ||
super(errorMessage); | ||
this.status = "failed"; | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
public Fido2RuntimeException(String errorMessage, Throwable cause) { | ||
super(errorMessage, cause); | ||
this.status = "failed"; | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
public Fido2RuntimeException(String status, String errorMessage) { | ||
super(errorMessage); | ||
this.status = status; | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
public Fido2RuntimeException(String status, String errorMessage, Throwable cause) { | ||
super(errorMessage, cause); | ||
this.status = status; | ||
this.errorMessage = errorMessage; | ||
} | ||
|
||
public Fido2RPError getFormattedMessage() { | ||
return new Fido2RPError(status, errorMessage); | ||
} | ||
} |
77 changes: 77 additions & 0 deletions
77
jans-fido2/common/src/main/java/io/jans/fido2/service/Base64Service.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,77 @@ | ||
/* | ||
* Janssen Project software is available under the MIT License (2008). See http://opensource.org/licenses/MIT for full text. | ||
* | ||
* Copyright (c) 2020, Janssen Project | ||
*/ | ||
|
||
package io.jans.fido2.service; | ||
|
||
import java.util.Base64; | ||
import java.util.Base64.Decoder; | ||
import java.util.Base64.Encoder; | ||
|
||
import jakarta.annotation.PostConstruct; | ||
import jakarta.enterprise.context.ApplicationScoped; | ||
import jakarta.inject.Inject; | ||
|
||
import org.slf4j.Logger; | ||
|
||
/** | ||
* Utility methods for base64 encoding / decoding | ||
* @author Yuriy Movchan | ||
* @version May 08, 2020 | ||
*/ | ||
|
||
@ApplicationScoped | ||
public class Base64Service { | ||
|
||
@Inject | ||
private Logger log; | ||
|
||
private Encoder base64Encoder; | ||
private Decoder base64Decoder; | ||
|
||
private Encoder base64UrlEncoder; | ||
private Decoder base64UrlDecoder; | ||
|
||
@PostConstruct | ||
public void init() { | ||
this.base64Encoder = Base64.getEncoder().withoutPadding(); | ||
this.base64Decoder = Base64.getDecoder(); | ||
|
||
this.base64UrlEncoder = Base64.getUrlEncoder().withoutPadding(); | ||
this.base64UrlDecoder = Base64.getUrlDecoder(); | ||
} | ||
|
||
public String encodeToString(byte[] src) { | ||
return base64Encoder.encodeToString(src); | ||
} | ||
|
||
public byte[] encode(byte[] src) { | ||
return base64Encoder.encode(src); | ||
} | ||
|
||
public byte[] decode(byte[] src) { | ||
return base64Decoder.decode(src); | ||
} | ||
|
||
public byte[] decode(String src) { | ||
return base64Decoder.decode(src); | ||
} | ||
|
||
public String urlEncodeToString(byte[] src) { | ||
return base64UrlEncoder.encodeToString(src); | ||
} | ||
|
||
public String urlEncodeToStringWithoutPadding(byte[] src) { | ||
return base64UrlEncoder.withoutPadding().encodeToString(src); | ||
} | ||
|
||
public byte[] urlDecode(byte[] src) { | ||
return base64UrlDecoder.decode(src); | ||
} | ||
|
||
public byte[] urlDecode(String src) { | ||
return base64UrlDecoder.decode(src); | ||
} | ||
} |
Oops, something went wrong.