diff options
author | Thomas Lenz <tlenz@iaik.tugraz.at> | 2018-06-20 15:11:13 +0200 |
---|---|---|
committer | Thomas Lenz <tlenz@iaik.tugraz.at> | 2018-06-20 15:11:13 +0200 |
commit | 139926faa31ae3ed34dc0083fee503d439112281 (patch) | |
tree | bf69a673df4a222653b47c0b8da88588065e2271 /id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util | |
parent | 1f8f686bee862ae95e32fc79664d82dcc21f708f (diff) | |
download | moa-id-spss-139926faa31ae3ed34dc0083fee503d439112281.tar.gz moa-id-spss-139926faa31ae3ed34dc0083fee503d439112281.tar.bz2 moa-id-spss-139926faa31ae3ed34dc0083fee503d439112281.zip |
refactor PVP2 S-Profile implementation and perform first tests
Diffstat (limited to 'id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util')
-rw-r--r-- | id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/LoALevelMapper.java | 61 | ||||
-rw-r--r-- | id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/QAALevelVerifier.java | 57 |
2 files changed, 46 insertions, 72 deletions
diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/LoALevelMapper.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/LoALevelMapper.java index 3e3d9dafc..10e22c806 100644 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/LoALevelMapper.java +++ b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/LoALevelMapper.java @@ -25,6 +25,9 @@ package at.gv.egovernment.moa.id.util; import java.io.IOException; import java.util.Properties; +import org.springframework.stereotype.Service; + +import at.gv.egiz.eaaf.core.api.data.ILoALevelMapper; import at.gv.egovernment.moa.id.data.AuthenticationRole; import at.gv.egovernment.moa.logging.Logger; import at.gv.egovernment.moa.util.MiscUtil; @@ -33,7 +36,8 @@ import at.gv.egovernment.moa.util.MiscUtil; * @author tlenz * */ -public class LoALevelMapper { +@Service("MOAIDLoALevelMapper") +public class LoALevelMapper implements ILoALevelMapper{ private static final String PVP_SECCLASS_PREFIX = "http://www.ref.gv.at/ns/names/agiz/pvp/"; private static final String STORK_QAA_PREFIX = "http://www.stork.gov.eu/1.0/"; @@ -46,18 +50,8 @@ public class LoALevelMapper { private static final String MAPPING_EIDAS_PREFIX = "eidas_"; private Properties mapping = null; - - private static LoALevelMapper instance = null; - - public static LoALevelMapper getInstance() { - if (instance == null) { - instance = new LoALevelMapper(); - } - - return instance; - } - - private LoALevelMapper() { + + public LoALevelMapper() { try { mapping = new Properties(); mapping.load(this.getClass().getClassLoader().getResourceAsStream(MAPPING_RESOURCE)); @@ -72,6 +66,43 @@ public class LoALevelMapper { } + public String mapToeIDASLoA(String qaa) { + if (qaa.startsWith(STORK_QAA_PREFIX)) + return mapSTORKQAAToeIDASQAA(qaa); + + else if (qaa.startsWith(PVP_SECCLASS_PREFIX)) + return mapSTORKQAAToeIDASQAA(mapSecClassToQAALevel(qaa)); + + else if (qaa.startsWith(MAPPING_EIDAS_PREFIX)) + return qaa; + + else { + Logger.info("QAA: " + qaa + " is NOT supported by LoA level mapper"); + return null; + + } + + } + + public String mapToSecClass(String qaa) { + if (qaa.startsWith(STORK_QAA_PREFIX)) + return mapStorkQAAToSecClass(qaa); + + else if (qaa.startsWith(MAPPING_EIDAS_PREFIX)) + return mapStorkQAAToSecClass(mapeIDASQAAToSTORKQAA(qaa)); + + else if (qaa.startsWith(PVP_SECCLASS_PREFIX)) + return qaa; + + else { + Logger.info("QAA: " + qaa + " is NOT supported by LoA level mapper"); + return null; + + } + + } + + /** * Map STORK QAA level to eIDAS QAA level * @@ -118,7 +149,7 @@ public class LoALevelMapper { * @param STORK-QAA level * @return PVP SecClass pvpQAALevel */ - public String mapToSecClass(String storkQAALevel) { + public String mapStorkQAAToSecClass(String storkQAALevel) { if (mapping != null) { String input = storkQAALevel.substring(STORK_QAA_PREFIX.length()); String mappedQAA = mapping.getProperty(MAPPING_SECCLASS_PREFIX + input); @@ -137,7 +168,7 @@ public class LoALevelMapper { * @param PVP SecClass pvpQAALevel * @return STORK-QAA level */ - public String mapToQAALevel(String pvpQAALevel) { + public String mapSecClassToQAALevel(String pvpQAALevel) { if (mapping != null) { String input = pvpQAALevel.substring(PVP_SECCLASS_PREFIX.length()); String mappedQAA = mapping.getProperty(input); diff --git a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/QAALevelVerifier.java b/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/QAALevelVerifier.java deleted file mode 100644 index ca71ad946..000000000 --- a/id/server/idserverlib/src/main/java/at/gv/egovernment/moa/id/util/QAALevelVerifier.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright 2014 Federal Chancellery Austria - * MOA-ID has been developed in a cooperation between BRZ, the Federal - * Chancellery Austria - ICT staff unit, and Graz University of Technology. - * - * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by - * the European Commission - subsequent versions of the EUPL (the "Licence"); - * You may not use this work except in compliance with the Licence. - * You may obtain a copy of the Licence at: - * http://www.osor.eu/eupl/ - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Licence is distributed on an "AS IS" basis, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Licence for the specific language governing permissions and - * limitations under the Licence. - * - * This product combines work with different licenses. See the "NOTICE" text - * file for details on the various modules and licenses. - * The "NOTICE" text file is part of the distribution. Any derivative works - * that you distribute must include a readable copy of the "NOTICE" text file. - */ -package at.gv.egovernment.moa.id.util; - -import at.gv.egiz.eaaf.core.api.data.EAAFConstants; -import at.gv.egovernment.moa.id.protocols.pvp2x.exceptions.QAANotAllowedException; -import at.gv.egovernment.moa.logging.Logger; - -/** - * @author tlenz - * - */ -public class QAALevelVerifier { - - public static void verifyQAALevel(String qaaAuth, String qaaRequest) throws QAANotAllowedException { - - if (EAAFConstants.EIDAS_QAA_LOW.equals(qaaRequest) && - (EAAFConstants.EIDAS_QAA_LOW.equals(qaaAuth) || - EAAFConstants.EIDAS_QAA_SUBSTANTIAL.equals(qaaAuth) || - EAAFConstants.EIDAS_QAA_HIGH.equals(qaaAuth)) - ) - Logger.debug("Requesed LoA fits LoA from authentication. Continuingauth process ... "); - - else if (EAAFConstants.EIDAS_QAA_SUBSTANTIAL.equals(qaaRequest) && - (EAAFConstants.EIDAS_QAA_SUBSTANTIAL.equals(qaaAuth) || - EAAFConstants.EIDAS_QAA_HIGH.equals(qaaAuth)) - ) - Logger.debug("Requesed LoA fits LoA from authentication. Continuingauth process ... "); - - else if (EAAFConstants.EIDAS_QAA_HIGH.equals(qaaRequest) && EAAFConstants.EIDAS_QAA_HIGH.equals(qaaAuth)) - Logger.debug("Requesed LoA fits LoA from authentication. Continuingauth process ... "); - - else - throw new QAANotAllowedException(qaaAuth, qaaRequest); - - } -} |