Skip to content

Commit

Permalink
Merge pull request #278 from wultra/develop
Browse files Browse the repository at this point in the history
Merge develop to master
  • Loading branch information
banterCZ authored Dec 22, 2022
2 parents d991346 + 9405f09 commit eea17fb
Show file tree
Hide file tree
Showing 15 changed files with 592 additions and 55 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/coverity-scan.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: Run Coverity scan and upload results

on:
workflow_dispatch:
schedule:
- cron: '0 10 1 * *' # monthly


jobs:
coverity-scan:
uses: wultra/wultra-infrastructure/.github/workflows/coverity-scan.yml@develop
secrets: inherit
with:
project-name: ${{ github.event.repository.name }}
version: ${{ github.sha }}
description: ${{ github.ref }}
52 changes: 52 additions & 0 deletions .github/workflows/maven-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Deploy with Maven

on:
workflow_dispatch:
branches:
- 'develop'
- 'master'
- 'releases/**'
- 'test/ci'
inputs:
release_type:
type: choice
description: releasing to snapshot or release
default: snapshot
options:
- snapshot
- release
environment:
type: environment
default: internal-publish
description: internal or external repository
push:
branches:
- 'develop'
- 'test/ci'



jobs:
maven-deploy-jfrog:
if: ${{ github.event_name == 'push' }}
name: Deploy to jfrog
uses: wultra/wultra-infrastructure/.github/workflows/maven-deploy.yml@develop
with:
environment: internal-publish
release_type: snapshot
secrets:
username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}

maven-deploy-manual:
if: ${{ github.event_name == 'workflow_dispatch' }}
name: Deploy by parameter
uses: wultra/wultra-infrastructure/.github/workflows/maven-deploy.yml@develop
with:
environment: ${{ inputs.environment }}
release_type: ${{ inputs.release_type }}
secrets:
username: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
password: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
gpg_passphrase: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
gpg_key: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
20 changes: 20 additions & 0 deletions .github/workflows/maven-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Test with Maven

on:
workflow_dispatch:
push:
branches:
- 'develop'
- 'master'
- 'releases/**'
- 'test/ci'
pull_request:
branches:
- 'develop'
- 'master'
- 'releases/**'

jobs:
maven-tests:
uses: wultra/wultra-infrastructure/.github/workflows/maven-test.yml@develop
secrets: inherit
12 changes: 12 additions & 0 deletions .github/workflows/owas-dependecy-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
name: Run OWASP Dependency Check
on:
workflow_dispatch:

push:
branches:
- 'develop'

jobs:
owasp-check:
uses: wultra/wultra-infrastructure/.github/workflows/owasp-dependency-check.yml@develop
secrets: inherit
17 changes: 17 additions & 0 deletions docs/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,23 @@ java -jar powerauth-java-cmd.jar \

The commit upgrade request is sent to the server including a version `3.0` signature. The server verifies the request signature and commits the upgrade of activation to version `3`.

## Compute Offline Signature

Use this method to compute offline PowerAuth signature.

```bash
java -jar powerauth-java-cmd.jar \
--status-file "/tmp/pa_status.json" \
--config-file "/tmp/pamk.json" \
--method "compute-offline-signature" \
--qr-code-data "c68dc57f-ee5f-497c-8c92-338439426e76\nApprove Login\nPlease confirm the login request.\nA2\nB\nETIK4iFz1E9u6vABKSbytg==\n1MEYCIQCnQqFFzS589auwdMRZ9Aq5qFxso21oxd2sng9Vp7gCUgIhAITaJ9L3fP2tov63mcIgU2e/37h9EXyAMhzrCXXDNJZE" \
--password "1234"
```

The `qr-code-data` parameter is taken from QR code generated by PowerAuth RESTful services. Note that the QR code is signed, the signature is verified during offline signature computation. The method unlocks the knowledge related signing key using `1234` as a password.

The method does not execute any server calls due to its offline nature. The computed offline signature is used as an OTP and it is available from the output of the command in decimal format, e.g.: `"offlineSignature" : "99961544-80193814"`.

## Basic Usage

PowerAuth Reference Client is called as any Java application that is packaged as a JAR file and it uses following command-line arguments.
Expand Down
112 changes: 91 additions & 21 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

<groupId>io.getlime.security</groupId>
<artifactId>powerauth-cmd-parent</artifactId>
<version>1.3.0</version>
<version>1.4.0</version>
<packaging>pom</packaging>

<inceptionYear>2016</inceptionYear>
Expand Down Expand Up @@ -76,21 +76,42 @@
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven-source-plugin.version>3.2.1</maven-source-plugin.version>
<maven-deploy-plugin.version>3.0.0-M2</maven-deploy-plugin.version>
<maven-javadoc-plugin.version>3.4.0</maven-javadoc-plugin.version>
<spring-boot.version>2.6.8</spring-boot.version>
<bc.version>1.70</bc.version>
<jackson.version>2.13.3</jackson.version>
<maven-deploy-plugin.version>3.0.0</maven-deploy-plugin.version>
<maven-javadoc-plugin.version>3.4.1</maven-javadoc-plugin.version>
<spring-boot.version>2.6.14</spring-boot.version>
<bc.version>1.72</bc.version>
<commons-cli.version>1.5.0</commons-cli.version>
<commons-io.version>2.11.0</commons-io.version>
<json-simple.version>1.1.1</json-simple.version>
<powerauth.version>1.3.0</powerauth.version>
<wultra-java-core.version>1.5.0</wultra-java-core.version>
<lombok.version>1.18.24</lombok.version>
<junit.version>5.8.2</junit.version>
<powerauth.version>1.4.0</powerauth.version>
<wultra-java-core.version>1.6.0</wultra-java-core.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>io.getlime.security</groupId>
<artifactId>powerauth-java-cmd-lib</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk18on</artifactId>
<version>${bc.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -157,6 +178,66 @@
</plugins>
</build>
</profile>
<profile>
<id>internal-repository</id>
<activation>
<property>
<name>useInternalRepo</name>
<value>true</value>
</property>
</activation>
<properties>
</properties>
<distributionManagement>
<repository>
<id>jfrog-central</id>
<name>Wultra Artifactory-releases</name>
<url>https://wultra.jfrog.io/artifactory/internal-maven-repository</url>
</repository>
<snapshotRepository>
<id>jfrog-central</id>
<name>Wultra Artifactory-snapshots</name>
<url>https://wultra.jfrog.io/artifactory/internal-maven-repository</url>
</snapshotRepository>
</distributionManagement>
<repositories>
<repository>
<id>jfrog-central</id>
<name>Wultra Artifactory-releases</name>
<url>https://wultra.jfrog.io/artifactory/internal-maven-repository</url>
</repository>
<repository>
<id>ossrh-snapshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
<profile>
<id>public-repository</id>
<activation>
<property>
<name>!useInternalRepo</name>
</property>
</activation>
<properties>
</properties>
<distributionManagement>
<snapshotRepository>
<id>ossrh-snapshots-distribution</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>ossrh-staging-distribution</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
</profile>
</profiles>

<repositories>
Expand All @@ -172,15 +253,4 @@
</repository>
</repositories>

<distributionManagement>
<snapshotRepository>
<id>ossrh-snapshots-distribution</id>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</snapshotRepository>
<repository>
<id>ossrh-staging-distribution</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>

</project>
11 changes: 2 additions & 9 deletions powerauth-java-cmd-lib/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,17 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>powerauth-java-cmd-lib</artifactId>
<description>PowerAuth Command-line Utility - Java Library</description>
<version>1.3.0</version>

<parent>
<artifactId>powerauth-cmd-parent</artifactId>
<groupId>io.getlime.security</groupId>
<version>1.3.0</version>
<relativePath>../pom.xml</relativePath>
<version>1.4.0</version>
</parent>

<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
Expand Down Expand Up @@ -60,15 +57,13 @@

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>${bc.version}</version>
<artifactId>bcprov-jdk18on</artifactId>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<version>${spring-boot.version}</version>
<exclusions>
<exclusion>
<artifactId>log4j-to-slf4j</artifactId>
Expand All @@ -79,7 +74,6 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<version>${spring-boot.version}</version>
<optional>true</optional>
</dependency>
<dependency>
Expand All @@ -91,7 +85,6 @@
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>

</dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public enum PowerAuthStep {
*/
SIGN_ENCRYPT("sign-encrypt", "Sign and Encrypt Request", "sign-encrypt"),

/**
* Compute an offline signature
*/
SIGNATURE_OFFLINE_COMPUTE("signature-offline-compute", "Compute Offline Signature", "compute-offline-signature"),

/**
* Verifying a signed request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ public final JSONObject execute(StepLogger stepLogger, Map<String, Object> conte
null
);

StepContext<M, R> stepContext = prepareStepContext(stepLogger, context);
final StepContext<M, R> stepContext = prepareStepContext(stepLogger, context);
if (stepContext == null) {
return null;
}

try {
ResponseContext<R> responseContext = callServer(stepContext);
Expand Down Expand Up @@ -295,6 +298,15 @@ protected void logDryRun(StepLogger stepLogger) {
* Calls the server and prepares response context with the response data
*/
private @Nullable ResponseContext<R> callServer(StepContext<M, R> stepContext) throws Exception {
if (stepContext == null) {
return null;
}

final ParameterizedTypeReference<R> responseTypeReference = getResponseTypeReference();
if (responseTypeReference == null) {
return null;
}

M model = stepContext.getModel();
RequestContext requestContext = stepContext.getRequestContext();

Expand Down Expand Up @@ -328,9 +340,9 @@ protected void logDryRun(StepLogger stepLogger) {
try {
// Call the right method with the REST client
if (HttpMethod.GET.equals(requestContext.getHttpMethod())) {
responseEntity = restClient.get(requestContext.getUri(), null, MapUtil.toMultiValueMap(headers), ParameterizedTypeReference.forType(getResponseTypeReference().getType()));
responseEntity = restClient.get(requestContext.getUri(), null, MapUtil.toMultiValueMap(headers), responseTypeReference);
} else {
responseEntity = restClient.post(requestContext.getUri(), requestBytes, null, MapUtil.toMultiValueMap(headers), ParameterizedTypeReference.forType(getResponseTypeReference().getType()));
responseEntity = restClient.post(requestContext.getUri(), requestBytes, null, MapUtil.toMultiValueMap(headers), responseTypeReference);
}
} catch (RestClientException ex) {
stepContext.getStepLogger().writeServerCallError(step.id() + "-error-server-call", ex.getStatusCode().value(), ex.getResponse(), HttpUtil.flattenHttpHeaders(ex.getResponseHeaders()));
Expand Down
Loading

0 comments on commit eea17fb

Please sign in to comment.