Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(jans-fido2) : #10080 fixed dependencies #10412

Merged
merged 5 commits into from
Dec 23, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion jans-fido2/client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
<dependency>
<groupId>io.jans</groupId>
<artifactId>jans-fido2-model</artifactId>
<scope>import</scope>
</dependency>

<!-- commons -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,18 @@
package io.jans.fido2.service.operation;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import com.google.common.base.Strings;

import io.jans.entry.PublicKeyCredentialHints;
import io.jans.entry.Transports;
import io.jans.fido2.ctap.AttestationFormat;
import io.jans.fido2.ctap.AuthenticatorAttachment;
import io.jans.fido2.exception.Fido2CompromisedDevice;
import io.jans.fido2.exception.Fido2RuntimeException;
import io.jans.fido2.model.assertion.AsserOptGenerateResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import io.jans.fido2.model.assertion.AssertionErrorResponseType;
import io.jans.fido2.model.attestation.AttestationErrorResponseType;
import io.jans.fido2.model.error.ErrorResponseFactory;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

import io.jans.as.common.model.common.User;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

import org.apache.commons.codec.binary.Hex;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;

import com.fasterxml.jackson.databind.JsonNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import io.jans.fido2.model.error.ErrorResponseFactory;
import io.jans.fido2.service.DataMapperService;
import io.jans.fido2.service.operation.AssertionService;

import jakarta.validation.constraints.NotNull;
import io.jans.fido2.service.util.CommonUtilService;
import io.jans.fido2.service.verifier.CommonVerifiers;
import jakarta.enterprise.context.ApplicationScoped;
Expand All @@ -22,7 +22,7 @@
import jakarta.ws.rs.core.Response;
import org.slf4j.Logger;

import javax.validation.constraints.NotNull;


/**
* serves request for /assertion endpoint exposed by FIDO2 sever
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

package io.jans.fido2.ws.rs.controller;

import com.fasterxml.jackson.databind.JsonNode;
import org.slf4j.Logger;

import io.jans.fido2.model.attestation.AttestationOptions;
import io.jans.fido2.model.attestation.AttestationResult;
import io.jans.fido2.model.attestation.PublicKeyCredentialCreationOptions;
Expand All @@ -15,17 +16,16 @@
import io.jans.fido2.model.error.ErrorResponseFactory;
import io.jans.fido2.service.DataMapperService;
import io.jans.fido2.service.operation.AttestationService;
import io.jans.fido2.service.util.CommonUtilService;
import io.jans.fido2.service.verifier.CommonVerifiers;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.*;
import jakarta.validation.constraints.NotNull;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.POST;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.WebApplicationException;
import jakarta.ws.rs.core.Response;
import jakarta.ws.rs.core.Response.ResponseBuilder;
import org.slf4j.Logger;

import javax.validation.constraints.NotNull;
import java.io.IOException;

/**
* serves request for /attestation endpoint exposed by FIDO2 sever
Expand All @@ -37,69 +37,65 @@
@Path("/attestation")
public class AttestationController {

@Inject
private Logger log;

@Inject
private AttestationService attestationService;

@Inject
private DataMapperService dataMapperService;

@Inject
private CommonVerifiers commonVerifiers;

@Inject
private AppConfiguration appConfiguration;

@Inject
private ErrorResponseFactory errorResponseFactory;

@POST
@Consumes({"application/json"})
@Produces({"application/json"})
@Path("/options")
public Response register(@NotNull AttestationOptions attestationOptions) {
return processRequest(() -> {
if (appConfiguration.getFido2Configuration() == null) {
throw errorResponseFactory.forbiddenException();
}
PublicKeyCredentialCreationOptions result = attestationService.options(attestationOptions);
return Response.ok().entity(result).build();
});
}

@POST
@Consumes({"application/json"})
@Produces({"application/json"})
@Path("/result")
public Response verify(@NotNull AttestationResult attestationResult) {
return processRequest(() -> {
if (appConfiguration.getFido2Configuration() == null) {
throw errorResponseFactory.forbiddenException();
}
AttestationOrAssertionResponse result = attestationService.verify(attestationResult);
return Response.ok().entity(result).build();
});
}





private Response processRequest(RequestProcessor processor) {
try {
return processor.process();
} catch (WebApplicationException e) {
throw e;
} catch (Exception e) {
log.error("Unknown Error: {}", e.getMessage(), e);
throw errorResponseFactory.unknownError(e.getMessage());
}
}

@FunctionalInterface
private interface RequestProcessor {
Response process() throws Exception;
}
@Inject
private Logger log;

@Inject
private AttestationService attestationService;

@Inject
private DataMapperService dataMapperService;

@Inject
private CommonVerifiers commonVerifiers;

@Inject
private AppConfiguration appConfiguration;

@Inject
private ErrorResponseFactory errorResponseFactory;

@POST
@Consumes({ "application/json" })
@Produces({ "application/json" })
@Path("/options")
public Response register(@NotNull AttestationOptions attestationOptions) {
return processRequest(() -> {
if (appConfiguration.getFido2Configuration() == null) {
throw errorResponseFactory.forbiddenException();
}
PublicKeyCredentialCreationOptions result = attestationService.options(attestationOptions);
return Response.ok().entity(result).build();
});
}

@POST
@Consumes({ "application/json" })
@Produces({ "application/json" })
@Path("/result")
public Response verify(@NotNull AttestationResult attestationResult) {
return processRequest(() -> {
if (appConfiguration.getFido2Configuration() == null) {
throw errorResponseFactory.forbiddenException();
}
AttestationOrAssertionResponse result = attestationService.verify(attestationResult);
return Response.ok().entity(result).build();
});
}

private Response processRequest(RequestProcessor processor) {
try {
return processor.process();
} catch (WebApplicationException e) {
throw e;
} catch (Exception e) {
log.error("Unknown Error: {}", e.getMessage(), e);
throw errorResponseFactory.unknownError(e.getMessage());
}
}

@FunctionalInterface
private interface RequestProcessor {
Response process() throws Exception;
}
}