Skip to content

Commit

Permalink
#87 local copy of xsd files - try 1, posibility to disable XML valida…
Browse files Browse the repository at this point in the history
…tion for AuthRequest
  • Loading branch information
alapierre committed Nov 17, 2023
1 parent 7c960d6 commit 8204542
Show file tree
Hide file tree
Showing 6 changed files with 604 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.val;
import org.jetbrains.annotations.NotNull;
import pl.gov.mf.ksef.schema.gtw.svc.online.auth.request._2021._10._01._0001.InitSessionTokenRequest;

Expand All @@ -29,6 +30,12 @@ public class KsefTokenFacade {

private final InterfejsyInteraktywneSesjaApi api;

private boolean isSchemaValidationEnabled() {
val res = Boolean.parseBoolean(System.getProperty("io.alapierre.ksef.validateAuthRequestXML", "true"));
if (!res) log.info("AuthRequest XML validation is disabled");
return res;
}

public InitSignedResponse authByToken(@NonNull Environment env, @NonNull String identifier, AuthorisationChallengeRequest.IdentifierType identifierType, @NotNull String token) throws ApiException, ParseException {
AuthorisationChallengeResponse challengeResponse = api.authorisationChallengeCall(identifier, identifierType);
log.debug("challengeResponse = {}", challengeResponse);
Expand All @@ -39,7 +46,7 @@ public InitSignedResponse authByToken(@NonNull Environment env, @NonNull String
log.debug("Token request {}", request);
ByteArrayOutputStream os = new ByteArrayOutputStream();
AuthTokenRequestSerializer serializer = new AuthTokenRequestSerializer();
serializer.toStream(request, os);
serializer.toStream(request, os, isSchemaValidationEnabled());
return api.initSessionTokenCall(os.toByteArray());
}

Expand Down
1 change: 1 addition & 0 deletions ksef-xml-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
</execution>
</executions>
<configuration>
<catalog>${basedir}/src/main/resources/catalog.cat</catalog>
</configuration>
<dependencies>
<dependency>
Expand Down
14 changes: 14 additions & 0 deletions ksef-xml-model/src/main/resources/catalog.cat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE catalog
PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN"
"http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">

<public
publicId="http://ksef.mf.gov.pl/schema/gtw/svc/types/2021/10/01/0001"
uri="gtwTypes.xsd"/>

<public
publicId="http://ksef.mf.gov.pl/schema/gtw/svc/online/types/2021/10/01/0001"
uri="onlineTypes.xsd"/>

</catalog>
Loading

0 comments on commit 8204542

Please sign in to comment.