-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f40b042
commit c3ea6b5
Showing
26 changed files
with
1,963 additions
and
1,007 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
server/src/main/java/com/bankid/codefront/config/AppConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
BSD 3-Clause License | ||
Copyright (c) 2022, Finansiell ID-Teknik BID AB | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package com.bankid.codefront.config; | ||
|
||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
|
||
/** | ||
* Represents the general configuration settings. | ||
*/ | ||
@ConfigurationProperties("app.bankid") | ||
public class AppConfig { | ||
|
||
private String domain; | ||
|
||
/** | ||
* Set the page domain. | ||
* @param domain of the page. | ||
*/ | ||
public void setDomain(String domain) { | ||
this.domain = domain; | ||
} | ||
|
||
/** | ||
* Returns the domain. | ||
* @return the domain. | ||
*/ | ||
public String getDomain() { | ||
return this.domain; | ||
} | ||
} |
126 changes: 126 additions & 0 deletions
126
server/src/main/java/com/bankid/codefront/models/bankid/relyingparty/AdditionalWebData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
/* | ||
BSD 3-Clause License | ||
Copyright (c) 2022, Finansiell ID-Teknik BID AB | ||
All rights reserved. | ||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
*/ | ||
|
||
package com.bankid.codefront.models.bankid.relyingparty; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
|
||
/** | ||
* Represents additional web page data from relying party. | ||
*/ | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class AdditionalWebData { | ||
private static final int REFERRING_DOMAIN_MIN_LENGTH = 3; | ||
private static final int USER_AGENT_MAX_LENGTH = 256; | ||
private static final int DEVICE_IDENTIFIER_MAX_LENGTH = 64; | ||
|
||
/** | ||
* The domain that start the BankID app. | ||
* | ||
* <p>Example: www.testbank.bankid.com</p> | ||
* | ||
* <p>String. 3 - 253 characters</p> | ||
*/ | ||
private final String referringDomain; | ||
/** | ||
* The user agent of the RP web page. | ||
* String. 1 - 256 characters | ||
*/ | ||
private final String userAgent; | ||
/** | ||
* The identifier of the device running the RP client. Use a web cookie or a hash of it. | ||
* String. 1 - 64 characters | ||
*/ | ||
private final String deviceIdentifier; | ||
|
||
/** | ||
* Initialize the object. | ||
* | ||
* @param referringDomain - The domain that start the BankID app. | ||
* @param userAgent - The user agent of the RP web page. | ||
* @param deviceIdentifier - The identifier of the device running the RP client. | ||
*/ | ||
public AdditionalWebData(String referringDomain, String userAgent, String deviceIdentifier) { | ||
if (referringDomain == null || referringDomain.length() < REFERRING_DOMAIN_MIN_LENGTH) { | ||
throw new IllegalArgumentException( | ||
"referringDomain cannot be null or smaller than " + REFERRING_DOMAIN_MIN_LENGTH | ||
); | ||
} | ||
if (userAgent == null || userAgent.isBlank()) { | ||
throw new IllegalArgumentException("userAgent cannot be null or empty"); | ||
} | ||
if (deviceIdentifier == null || deviceIdentifier.isBlank()) { | ||
throw new IllegalArgumentException("deviceIdentifier cannot be null or empty"); | ||
} | ||
|
||
this.referringDomain = referringDomain; | ||
|
||
// Trim user agent | ||
if (userAgent.length() > USER_AGENT_MAX_LENGTH) { | ||
userAgent = userAgent.substring(0, USER_AGENT_MAX_LENGTH); | ||
} | ||
|
||
this.userAgent = userAgent; | ||
|
||
// Trim device identifier | ||
if (deviceIdentifier.length() > DEVICE_IDENTIFIER_MAX_LENGTH) { | ||
deviceIdentifier = deviceIdentifier.substring(0, DEVICE_IDENTIFIER_MAX_LENGTH); | ||
} | ||
|
||
this.deviceIdentifier = deviceIdentifier; | ||
} | ||
|
||
/** | ||
* Returns the referring domain. | ||
* @return the referring domain. | ||
*/ | ||
public String getReferringDomain() { | ||
return this.referringDomain; | ||
} | ||
|
||
/** | ||
* Returns the user agent. | ||
* @return the user agent. | ||
*/ | ||
public String getUserAgent() { | ||
return this.userAgent; | ||
} | ||
|
||
/** | ||
* Returns the device identifier. | ||
* @return the device identifier. | ||
*/ | ||
public String getDeviceIdentifier() { | ||
return this.deviceIdentifier; | ||
} | ||
} |
Oops, something went wrong.