aboutsummaryrefslogtreecommitdiff
path: root/id/server/idserverlib
diff options
context:
space:
mode:
authorThomas Lenz <tlenz@iaik.tugraz.at>2018-06-12 12:08:12 +0200
committerThomas Lenz <tlenz@iaik.tugraz.at>2018-06-12 12:08:12 +0200
commit92982d1ee7f13e5206ea192776b0a042d2ddea2f (patch)
tree699f81d5094afbb885a6258c46b0ceb173bb7606 /id/server/idserverlib
parentc4405efdb0177c6319c0a3a0b9f5d3f4d0967748 (diff)
downloadmoa-id-spss-92982d1ee7f13e5206ea192776b0a042d2ddea2f.tar.gz
moa-id-spss-92982d1ee7f13e5206ea192776b0a042d2ddea2f.tar.bz2
moa-id-spss-92982d1ee7f13e5206ea192776b0a042d2ddea2f.zip
fix wrong encoding in EncryptedBPKAttributeBuilder
Diffstat (limited to 'id/server/idserverlib')
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java3
-rw-r--r--id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/builder/attributes/EncryptedBPKAttributeBuilder.java19
2 files changed, 15 insertions, 7 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
index 14de65e36..865f7e6b4 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/auth/builder/BPKBuilder.java
@@ -171,7 +171,8 @@ public class BPKBuilder {
try {
byte[] inputBytes = input.getBytes("ISO-8859-1");
result = encrypt(inputBytes, publicKey);
- return new String(Base64Utils.encode(result, "ISO-8859-1")).replaceAll("\r\n", "");
+
+ return new String(java.util.Base64.getEncoder().encode(result), "ISO-8859-1").replaceAll("\r\n", "");
} catch (Exception e) {
throw new BuildException("bPK encryption FAILED", null, e);
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/builder/attributes/EncryptedBPKAttributeBuilder.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/builder/attributes/EncryptedBPKAttributeBuilder.java
index f5c48b826..d15f545ae 100644
--- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/builder/attributes/EncryptedBPKAttributeBuilder.java
+++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/protocols/builder/attributes/EncryptedBPKAttributeBuilder.java
@@ -23,12 +23,9 @@
package at.gv.egovernment.moa.id.protocols.builder.attributes;
import at.gv.egovernment.moa.id.commons.api.IOAAuthParameters;
-import at.gv.egovernment.moa.id.config.auth.OAAuthParameter;
import at.gv.egovernment.moa.id.data.IAuthData;
import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.AttributeException;
import at.gv.egovernment.moa.id.protocols.pvp2x.builder.attributes.exceptions.UnavailableAttributeException;
-import at.gv.egovernment.moa.logging.Logger;
-import at.gv.egovernment.moa.util.Constants;
public class EncryptedBPKAttributeBuilder implements IPVPAttributeBuilder {
@@ -40,10 +37,10 @@ public class EncryptedBPKAttributeBuilder implements IPVPAttributeBuilder {
IAttributeGenerator<ATT> g) throws AttributeException {
if (authData.getEncbPKList() != null &&
- authData.getEncbPKList().size() > 0) {
- String value = "(" + authData.getEncbPKList().get(0) + ")";
+ authData.getEncbPKList().size() > 0) {
+ String value = addPreAndSufix(authData.getEncbPKList().get(0));
for (int i=1; i<authData.getEncbPKList().size(); i++)
- value += ";"+authData.getEncbPKList().get(i);
+ value += ";"+addPreAndSufix(authData.getEncbPKList().get(i));
return g.buildStringAttribute(ENC_BPK_LIST_FRIENDLY_NAME, ENC_BPK_LIST_NAME,
value);
@@ -68,4 +65,14 @@ public class EncryptedBPKAttributeBuilder implements IPVPAttributeBuilder {
return g.buildEmptyAttribute(ENC_BPK_LIST_FRIENDLY_NAME, ENC_BPK_LIST_NAME);
}
+ private String addPreAndSufix(String value) {
+ if (!value.startsWith("("))
+ value = "(" + value;
+
+ if (!value.endsWith(""))
+ value = value + ")";
+
+ return value;
+ }
+
}