Skip to content

Commit

Permalink
remove walt
Browse files Browse the repository at this point in the history
  • Loading branch information
wistefan committed Nov 13, 2023
1 parent 1f2ec66 commit c0234bc
Show file tree
Hide file tree
Showing 23 changed files with 601 additions and 920 deletions.
95 changes: 54 additions & 41 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,23 @@
<groupId>com.danubetech</groupId>
<artifactId>verifiable-credentials-java</artifactId>
<version>${version.com.danubetech.verifiable-credentials-java}</version>
<exclusions>
<exclusion>
<groupId>org.glassfish</groupId>
<artifactId>jakarta.json</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jakarta.json</groupId>
<artifactId>jakarta.json-api</artifactId>
<version>2.1.3</version>
</dependency>
<dependency>
<groupId>org.eclipse.parsson</groupId>
<artifactId>parsson</artifactId>
<version>1.1.5</version>
</dependency>


<!-- Testing -->
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down Expand Up @@ -290,7 +304,6 @@
</dependency>



<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-common</artifactId>
Expand Down Expand Up @@ -486,44 +499,44 @@
</execution>
</executions>
</plugin>
<!-- <plugin>-->
<!-- <groupId>com.github.eirslett</groupId>-->
<!-- <artifactId>frontend-maven-plugin</artifactId>-->
<!-- <version>${version.com.github.eirslett.frontend-maven-plugin}</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>generate-sources</phase>-->
<!-- <goals>-->
<!-- <goal>install-node-and-npm</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>npm install</id>-->
<!-- <phase>generate-sources</phase>-->
<!-- <goals>-->
<!-- <goal>npm</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <arguments>install</arguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>npm run build</id>-->
<!-- <phase>generate-resources</phase>-->
<!-- <goals>-->
<!-- <goal>npm</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <arguments>run build</arguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- <configuration>-->
<!-- <nodeVersion>${version.frontend.node}</nodeVersion>-->
<!-- <workingDirectory>${project.build.directory}/theme/siop-2/account/src</workingDirectory>-->
<!-- <installDirectory>${project.build.directory}/theme/siop-2/account/src</installDirectory>-->
<!-- </configuration>-->
<!-- </plugin>-->
<!-- <plugin>-->
<!-- <groupId>com.github.eirslett</groupId>-->
<!-- <artifactId>frontend-maven-plugin</artifactId>-->
<!-- <version>${version.com.github.eirslett.frontend-maven-plugin}</version>-->
<!-- <executions>-->
<!-- <execution>-->
<!-- <phase>generate-sources</phase>-->
<!-- <goals>-->
<!-- <goal>install-node-and-npm</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>npm install</id>-->
<!-- <phase>generate-sources</phase>-->
<!-- <goals>-->
<!-- <goal>npm</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <arguments>install</arguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- <execution>-->
<!-- <id>npm run build</id>-->
<!-- <phase>generate-resources</phase>-->
<!-- <goals>-->
<!-- <goal>npm</goal>-->
<!-- </goals>-->
<!-- <configuration>-->
<!-- <arguments>run build</arguments>-->
<!-- </configuration>-->
<!-- </execution>-->
<!-- </executions>-->
<!-- <configuration>-->
<!-- <nodeVersion>${version.frontend.node}</nodeVersion>-->
<!-- <workingDirectory>${project.build.directory}/theme/siop-2/account/src</workingDirectory>-->
<!-- <installDirectory>${project.build.directory}/theme/siop-2/account/src</installDirectory>-->
<!-- </configuration>-->
<!-- </plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
Expand Down
19 changes: 11 additions & 8 deletions src/main/java/org/fiware/keycloak/JWTSigningService.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,18 @@
import com.danubetech.verifiablecredentials.jwt.ToJwtConverter;
import com.nimbusds.jose.JOSEException;
import org.bitcoinj.core.ECKey;
import org.jboss.logging.Logger;

public class JWTSigningService extends SigningService<String> {

private static final Logger LOGGER = Logger.getLogger(JWTSigningService.class);
private final AlgorithmType algorithmType;

public JWTSigningService(String keyPath,
AlgorithmType algorithmType) {
super(keyPath, algorithmType);
public JWTSigningService(String keyPath){
super(keyPath);
algorithmType = getAlgorithmType();
}

private AlgorithmType getAlgorithmType() {
return AlgorithmType.getByValue(signingKey.getPrivate().getAlgorithm());
}

@Override
Expand All @@ -25,10 +28,10 @@ public String signCredential(VerifiableCredential verifiableCredential) {
return switch (algorithmType) {
case RSA -> {
String concreteAlgorithm = signingKey.getPrivate().getAlgorithm();
if (concreteAlgorithm.equalsIgnoreCase("rs256")) {
yield jwtVerifiableCredential.sign_RSA_RS256(signingKey);
} else {
if (concreteAlgorithm.equalsIgnoreCase("ps256")) {
yield jwtVerifiableCredential.sign_RSA_PS256(signingKey);
} else {
yield jwtVerifiableCredential.sign_RSA_RS256(signingKey);
}
}
case ECDSA_Secp256k1 -> jwtVerifiableCredential.sign_secp256k1_ES256K(
Expand Down
11 changes: 3 additions & 8 deletions src/main/java/org/fiware/keycloak/LDSigningService.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,22 @@
import java.security.GeneralSecurityException;
import java.time.Clock;
import java.util.Date;
import java.util.List;
import java.util.Optional;

public class LDSigningService extends SigningService<VerifiableCredential> {
private static final Logger LOGGER = Logger.getLogger(LDSigningService.class);

private static final List<AlgorithmType> SUPPORTED_ALGORITHMS = List.of(
AlgorithmType.EdDSA_Ed25519, AlgorithmType.ECDSA_Secp256k1, AlgorithmType.ECDSA_Secp256k1,
AlgorithmType.RSA);

private final Clock clock;

public LDSigningService(String keyPath,
AlgorithmType algorithmType, Clock clock) {
super(keyPath, algorithmType);

Clock clock) {
super(keyPath);
this.clock = clock;
}

@Override
public VerifiableCredential signCredential(VerifiableCredential verifiableCredential) {
LOGGER.debug("Sign credential with an ld-proof.");
String proofType = Optional.ofNullable(verifiableCredential.getLdProof()).map(LdProof::getType)
// use a default
.orElse(LDSignatureType.RSA_SIGNATURE_2018.getValue());
Expand Down
4 changes: 1 addition & 3 deletions src/main/java/org/fiware/keycloak/SigningService.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ public abstract class SigningService<T> implements VCSigningService<T> {

private static final Logger LOGGER = Logger.getLogger(SigningService.class);

protected final AlgorithmType algorithmType;
protected final KeyPair signingKey;

protected SigningService(String keyPath, AlgorithmType algorithmType) {
protected SigningService(String keyPath) {

this.algorithmType = algorithmType;
this.signingKey = parsePem(loadPrivateKeyString(keyPath));
}

Expand Down
Loading

0 comments on commit c0234bc

Please sign in to comment.