Skip to content

Commit

Permalink
Merge pull request #3 from SK-EID/master
Browse files Browse the repository at this point in the history
Sync with upstream
  • Loading branch information
andrevka authored Sep 13, 2019
2 parents ba95d0e + a26cd14 commit 1aafd20
Show file tree
Hide file tree
Showing 23 changed files with 500 additions and 25 deletions.
21 changes: 9 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

## [1.2] - 2019-08-26
## [1.3] - 2019-09-13
### Added
- added maven dependency check plugin for continuous security [#11][i11]
- added spotbugs plugin for continuous bug detection [#1][i1]
- added support for new rp api endpoints [#13][i13]

### Fixed
- Add document number to authentication responses [#2][i2]
- Capabilities parameter ([#25](https://github.com/SK-EID/smart-id-java-client/pull/25))
- [Request properties](https://github.com/SK-EID/smart-id-documentation#416-request-properties) (vcChoice) for authentication and signing ([#21](https://github.com/SK-EID/smart-id-java-client/pull/21))

[i1]: https://github.com/SK-EID/smart-id-java-client/issues/1
[i2]: https://github.com/SK-EID/smart-id-java-client/issues/2
[i11]: https://github.com/SK-EID/smart-id-java-client/pull/11
[i13]: https://github.com/SK-EID/smart-id-java-client/issues/13
## [1.2] - 2019-08-21
### Added
- Support for [Semantics Identifier](https://github.com/SK-EID/smart-id-documentation#412-rest-object-references) ([#17](https://github.com/SK-EID/smart-id-java-client/pull/17))
- Document number to authentication responses ([#14](https://github.com/SK-EID/smart-id-java-client/issues/14))
- Maven dependency check plugin for continuous security
- SpotBugs plugin for continuous bug detection

## [1.1] - 2018-12-10

Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

The Smart-ID Java client can be used for easy integration of the [Smart-ID](https://www.smart-id.com) solution to information systems or e-services.


## Features

* Simple interface for user authentication
Expand All @@ -23,15 +22,26 @@ The Smart-ID Java client can be used for easy integration of the [Smart-ID](http

## How to use it

Take a look at the [examples](https://github.com/SK-EID/smart-id-java-client/wiki/Examples-of-using-it)
Take a look at the [examples](https://github.com/SK-EID/smart-id-java-client/wiki/Examples-of-using-it)

## Getting the library

## Maven
You can use the library as a Maven dependency from the [Maven Central](https://search.maven.org/search?q=g:ee.sk.smartid%20AND%20a:smart-id-java-client&core=gav)
### Maven
You can use the library as a Maven dependency from the [Maven Central](https://search.maven.org/search?q=a:smart-id-java-client).

```xml
<dependency>
<groupId>ee.sk.smartid</groupId>
<artifactId>smart-id-java-client</artifactId>
<version>1.2</version>
<version>INSERT_VERSION_HERE</version>
</dependency>
```
```

### Gradle

`implementation 'ee.sk.smartid:smart-id-java-client:INSERT_VERSION_HERE'`

### Changes

* Listed in [changelog](CHANGELOG.md)

2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>ee.sk.smartid</groupId>
<artifactId>smart-id-java-client</artifactId>
<packaging>jar</packaging>
<version>1.2</version>
<version>1.1</version>

<name>Smart-ID Java client</name>
<description>Smart-ID Java client is a Java library that can be used for easy integration of the Smart-ID solution to information systems or e-services</description>
Expand Down
2 changes: 1 addition & 1 deletion publish.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

project="smart-id-java-client"
version="1.2"
version="1.1"
staging_url="https://oss.sonatype.org/service/local/staging/deploy/maven2/"
repositoryId="ossrh"

Expand Down
48 changes: 48 additions & 0 deletions src/main/java/ee/sk/smartid/AuthenticationRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,52 @@ public AuthenticationRequestBuilder withNonce(String nonce) {
return this;
}

/**
* Specifies capabilities of the user
* <p>
* By default there are no specified capabilities.
* The capabilities need to be specified in case of
* a restricted Smart ID user
* {@link #withCapabilities(String...)}
* @param capabilities are specified capabilities for a restricted Smart ID user
* and is one of [QUALIFIED, ADVANCED]
* @return this builder
*/
public AuthenticationRequestBuilder withCapabilities(Capability... capabilities) {
super.withCapabilities(capabilities);
return this;
}

/**
* Specifies capabilities of the user
* <p>
*
* By default there are no specified capabilities.
* The capabilities need to be specified in case of
* a restricted Smart ID user
* {@link #withCapabilities(Capability...)}
* @param capabilities are specified capabilities for a restricted Smart ID user
* and is one of ["QUALIFIED", "ADVANCED"]
* @return this builder
*/
public AuthenticationRequestBuilder withCapabilities(String... capabilities) {
super.withCapabilities(capabilities);
return this;
}

/**
* Sets the request's request properties
* <p>
* Optional. Additional request properties
*
* @param requestProperties request properties of the request
* @return this builder
*/
protected AuthenticationRequestBuilder withRequestProperties(RequestProperties requestProperties) {
super.withRequestProperties(requestProperties);
return this;
}

/**
* Send the authentication request and get the response
* <p>
Expand Down Expand Up @@ -393,6 +439,8 @@ private AuthenticationSessionRequest createAuthenticationSessionRequest() {
request.setHash(getHashInBase64());
request.setDisplayText(getDisplayText());
request.setNonce(getNonce());
request.setCapabilities(getCapabilities());
request.setRequestProperties(getRequestProperties());
return request;
}

Expand Down
34 changes: 34 additions & 0 deletions src/main/java/ee/sk/smartid/CertificateRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,39 @@ public CertificateRequestBuilder withNonce(String nonce) {
return this;
}

/**
* Specifies capabilities of the user
* <p>
* By default there are no specified capabilities.
* The capabilities need to be specified in case of
* a restricted Smart ID user
* {@link #withCapabilities(String...)}
* @param capabilities are specified capabilities for a restricted Smart ID user
* and is one of [QUALIFIED, ADVANCED]
* @return this builder
*/
public CertificateRequestBuilder withCapabilities(Capability... capabilities) {
super.withCapabilities(capabilities);
return this;
}

/**
* Specifies capabilities of the user
* <p>
*
* By default there are no specified capabilities.
* The capabilities need to be specified in case of
* a restricted Smart ID user
* {@link #withCapabilities(Capability...)}
* @param capabilities are specified capabilities for a restricted Smart ID user
* and is one of ["QUALIFIED", "ADVANCED"]
* @return this builder
*/
public CertificateRequestBuilder withCapabilities(String... capabilities) {
super.withCapabilities(capabilities);
return this;
}

/**
* Sets the request's personal semantics identifier
* <p>
Expand Down Expand Up @@ -324,6 +357,7 @@ private CertificateRequest createCertificateRequest() {
request.setRelyingPartyName(getRelyingPartyName());
request.setCertificateLevel(getCertificateLevel());
request.setNonce(getNonce());
request.setCapabilities(getCapabilities());
return request;
}

Expand Down
48 changes: 48 additions & 0 deletions src/main/java/ee/sk/smartid/SignatureRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,52 @@ public SignatureRequestBuilder withNonce(String nonce) {
return this;
}

/**
* Specifies capabilities of the user
* <p>
* By default there are no specified capabilities.
* The capabilities need to be specified in case of
* a restricted Smart ID user
* {@link #withCapabilities(String...)}
* @param capabilities are specified capabilities for a restricted Smart ID user
* and is one of [QUALIFIED, ADVANCED]
* @return this builder
*/
public SignatureRequestBuilder withCapabilities(Capability... capabilities) {
super.withCapabilities(capabilities);
return this;
}

/**
* Specifies capabilities of the user
* <p>
*
* By default there are no specified capabilities.
* The capabilities need to be specified in case of
* a restricted Smart ID user
* {@link #withCapabilities(Capability...)}
* @param capabilities are specified capabilities for a restricted Smart ID user
* and is one of ["QUALIFIED", "ADVANCED"]
* @return this builder
*/
public SignatureRequestBuilder withCapabilities(String... capabilities) {
super.withCapabilities(capabilities);
return this;
}

/**
* Sets the request's request properties
* <p>
* Optional. Additional request properties
*
* @param requestProperties request properties of the request
* @return this builder
*/
public SignatureRequestBuilder withRequestProperties(RequestProperties requestProperties) {
super.withRequestProperties(requestProperties);
return this;
}

/**
* Send the signature request and get the response
* <p>
Expand Down Expand Up @@ -339,6 +385,8 @@ private SignatureSessionRequest createSignatureSessionRequest() {
request.setHash(getHashInBase64());
request.setDisplayText(getDisplayText());
request.setNonce(getNonce());
request.setCapabilities(getCapabilities());
request.setRequestProperties(getRequestProperties());
return request;
}
}
33 changes: 33 additions & 0 deletions src/main/java/ee/sk/smartid/SmartIdRequestBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,18 @@
import ee.sk.smartid.exception.*;
import ee.sk.smartid.rest.SessionStatusPoller;
import ee.sk.smartid.rest.SmartIdConnector;
import ee.sk.smartid.rest.dao.Capability;
import ee.sk.smartid.rest.dao.NationalIdentity;
import ee.sk.smartid.rest.dao.RequestProperties;
import ee.sk.smartid.rest.dao.SemanticsIdentifier;
import ee.sk.smartid.rest.dao.SessionResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import static org.apache.commons.lang3.StringUtils.*;

public abstract class SmartIdRequestBuilder {
Expand All @@ -54,6 +60,8 @@ public abstract class SmartIdRequestBuilder {
private SignableHash hashToSign;
private String nonce;
private String displayText;
private Set<String> capabilities;
private RequestProperties requestProperties;

protected SmartIdRequestBuilder(SmartIdConnector connector, SessionStatusPoller sessionStatusPoller) {
this.connector = connector;
Expand Down Expand Up @@ -117,6 +125,20 @@ protected SmartIdRequestBuilder withCertificateLevel(String certificateLevel) {
return this;
}

protected SmartIdRequestBuilder withCapabilities(Capability... capabilities) {
HashSet<String> capabilitySet = new HashSet<>();
for (Capability capability : capabilities) {
capabilitySet.add(capability.toString());
}
this.capabilities = capabilitySet;
return this;
}

protected SmartIdRequestBuilder withCapabilities(String... capabilities) {
this.capabilities = new HashSet<>(Arrays.asList(capabilities));
return this;
}

protected SmartIdRequestBuilder withNonce(String nonce) {
this.nonce = nonce;
return this;
Expand All @@ -127,6 +149,11 @@ protected SmartIdRequestBuilder withDisplayText(String displayText) {
return this;
}

protected SmartIdRequestBuilder withRequestProperties(RequestProperties requestProperties) {
this.requestProperties = requestProperties;
return this;
}

protected void validateParameters() {
if (isBlank(relyingPartyUUID)) {
logger.error("Relying Party UUID parameter must be set");
Expand Down Expand Up @@ -236,4 +263,10 @@ protected String getDisplayText() {
}

public SemanticsIdentifier getSemanticsIdentifier() { return semanticsIdentifier; }

public Set<String> getCapabilities() { return capabilities; }

public RequestProperties getRequestProperties() {
return requestProperties;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import com.fasterxml.jackson.annotation.JsonInclude;

import java.io.Serializable;
import java.util.Set;

public class AuthenticationSessionRequest implements Serializable {

Expand All @@ -42,6 +43,10 @@ public class AuthenticationSessionRequest implements Serializable {
private String displayText;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private String nonce;
@JsonInclude(JsonInclude.Include.NON_NULL)
private Set capabilities;
@JsonInclude(JsonInclude.Include.NON_EMPTY)
private RequestProperties requestProperties;

public String getCertificateLevel() {
return certificateLevel;
Expand Down Expand Up @@ -98,4 +103,20 @@ public String getNonce() {
public void setNonce(String nonce) {
this.nonce = nonce;
}

public Set getCapabilities() {
return capabilities;
}

public void setCapabilities(Set capabilities) {
this.capabilities = capabilities;
}

public RequestProperties getRequestProperties() {
return requestProperties;
}

public void setRequestProperties(RequestProperties requestProperties) {
this.requestProperties = requestProperties;
}
}
5 changes: 5 additions & 0 deletions src/main/java/ee/sk/smartid/rest/dao/Capability.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package ee.sk.smartid.rest.dao;

public enum Capability {
QUALIFIED, ADVANCED
}
Loading

0 comments on commit 1aafd20

Please # to comment.