From 6c7a6f8e222e4fb39a11c220b63e785f2037d428 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Thu, 16 Jan 2014 08:55:06 +0100 Subject: fix added real source of stork modules --- .../src/main/java/eu/.svn/all-wcprops | 5 + .../stork2-commons/src/main/java/eu/.svn/entries | 31 + .../src/main/java/eu/stork/.svn/all-wcprops | 5 + .../src/main/java/eu/stork/.svn/entries | 31 + .../src/main/java/eu/stork/peps/.svn/all-wcprops | 5 + .../src/main/java/eu/stork/peps/.svn/entries | 31 + .../main/java/eu/stork/peps/auth/.svn/all-wcprops | 5 + .../src/main/java/eu/stork/peps/auth/.svn/entries | 34 + .../eu/stork/peps/auth/commons/.svn/all-wcprops | 167 ++++ .../java/eu/stork/peps/auth/commons/.svn/entries | 949 +++++++++++++++++++++ .../text-base/AttributeConstants.java.svn-base | 72 ++ .../.svn/text-base/AttributeProvider.java.svn-base | 74 ++ .../text-base/AttributeProvidersMap.java.svn-base | 94 ++ .../.svn/text-base/AttributeSource.java.svn-base | 119 +++ .../.svn/text-base/AttributeUtil.java.svn-base | 231 +++++ .../.svn/text-base/CitizenConsent.java.svn-base | 123 +++ .../commons/.svn/text-base/Country.java.svn-base | 95 +++ .../.svn/text-base/CountryCodes.java.svn-base | 79 ++ .../commons/.svn/text-base/DateUtil.java.svn-base | 169 ++++ .../text-base/IAttributeProvidersMap.java.svn-base | 82 ++ .../text-base/IPersonalAttributeList.java.svn-base | 140 +++ .../.svn/text-base/IStorkLogger.java.svn-base | 239 ++++++ .../.svn/text-base/IStorkSession.java.svn-base | 85 ++ .../commons/.svn/text-base/Linker.java.svn-base | 173 ++++ .../.svn/text-base/PEPSErrors.java.svn-base | 348 ++++++++ .../.svn/text-base/PEPSParameters.java.svn-base | 511 +++++++++++ .../commons/.svn/text-base/PEPSUtil.java.svn-base | 353 ++++++++ .../.svn/text-base/PEPSValues.java.svn-base | 325 +++++++ .../.svn/text-base/PersonalAttribute.java.svn-base | 323 +++++++ .../text-base/PersonalAttributeList.java.svn-base | 305 +++++++ .../text-base/STORKAttrQueryRequest.java.svn-base | 426 +++++++++ .../text-base/STORKAttrQueryResponse.java.svn-base | 301 +++++++ .../.svn/text-base/STORKAuthnRequest.java.svn-base | 495 +++++++++++ .../text-base/STORKAuthnResponse.java.svn-base | 309 +++++++ .../.svn/text-base/STORKStatusCode.java.svn-base | 68 ++ .../text-base/STORKSubStatusCode.java.svn-base | 71 ++ .../.svn/text-base/package-info.java.svn-base | 9 + .../peps/auth/commons/AttributeConstants.java | 72 ++ .../stork/peps/auth/commons/AttributeProvider.java | 74 ++ .../peps/auth/commons/AttributeProvidersMap.java | 94 ++ .../stork/peps/auth/commons/AttributeSource.java | 119 +++ .../eu/stork/peps/auth/commons/AttributeUtil.java | 231 +++++ .../eu/stork/peps/auth/commons/CitizenConsent.java | 123 +++ .../java/eu/stork/peps/auth/commons/Country.java | 95 +++ .../eu/stork/peps/auth/commons/CountryCodes.java | 79 ++ .../java/eu/stork/peps/auth/commons/DateUtil.java | 169 ++++ .../peps/auth/commons/IAttributeProvidersMap.java | 82 ++ .../peps/auth/commons/IPersonalAttributeList.java | 140 +++ .../eu/stork/peps/auth/commons/IStorkLogger.java | 239 ++++++ .../eu/stork/peps/auth/commons/IStorkSession.java | 85 ++ .../java/eu/stork/peps/auth/commons/Linker.java | 173 ++++ .../eu/stork/peps/auth/commons/PEPSErrors.java | 348 ++++++++ .../eu/stork/peps/auth/commons/PEPSParameters.java | 511 +++++++++++ .../java/eu/stork/peps/auth/commons/PEPSUtil.java | 353 ++++++++ .../eu/stork/peps/auth/commons/PEPSValues.java | 325 +++++++ .../stork/peps/auth/commons/PersonalAttribute.java | 323 +++++++ .../peps/auth/commons/PersonalAttributeList.java | 305 +++++++ .../peps/auth/commons/STORKAttrQueryRequest.java | 426 +++++++++ .../peps/auth/commons/STORKAttrQueryResponse.java | 301 +++++++ .../stork/peps/auth/commons/STORKAuthnRequest.java | 495 +++++++++++ .../peps/auth/commons/STORKAuthnResponse.java | 309 +++++++ .../stork/peps/auth/commons/STORKStatusCode.java | 68 ++ .../peps/auth/commons/STORKSubStatusCode.java | 71 ++ .../peps/auth/commons/exceptions/.svn/all-wcprops | 53 ++ .../peps/auth/commons/exceptions/.svn/entries | 300 +++++++ .../text-base/AbstractPEPSException.java.svn-base | 173 ++++ .../.svn/text-base/CPEPSException.java.svn-base | 143 ++++ .../InternalErrorPEPSException.java.svn-base | 74 ++ .../InvalidParameterPEPSException.java.svn-base | 54 ++ .../InvalidSessionPEPSException.java.svn-base | 46 + .../text-base/SecurityPEPSException.java.svn-base | 67 ++ .../text-base/StorkPEPSException.java.svn-base | 53 ++ .../.svn/text-base/package-info.java.svn-base | 7 + .../commons/exceptions/AbstractPEPSException.java | 173 ++++ .../auth/commons/exceptions/CPEPSException.java | 143 ++++ .../exceptions/InternalErrorPEPSException.java | 74 ++ .../exceptions/InvalidParameterPEPSException.java | 54 ++ .../exceptions/InvalidSessionPEPSException.java | 46 + .../commons/exceptions/SecurityPEPSException.java | 67 ++ .../commons/exceptions/StorkPEPSException.java | 53 ++ .../peps/auth/commons/exceptions/package-info.java | 7 + .../eu/stork/peps/auth/commons/package-info.java | 9 + .../eu/stork/peps/auth/specific/.svn/all-wcprops | 41 + .../java/eu/stork/peps/auth/specific/.svn/entries | 232 +++++ .../.svn/text-base/IAUService.java.svn-base | 183 ++++ .../text-base/ICheckAttributeValue.java.svn-base | 37 + .../.svn/text-base/IDeriveAttribute.java.svn-base | 40 + .../.svn/text-base/INormaliseValue.java.svn-base | 35 + .../text-base/ITranslatorService.java.svn-base | 100 +++ .../.svn/text-base/package-info.java.svn-base | 8 + .../eu/stork/peps/auth/specific/IAUService.java | 183 ++++ .../peps/auth/specific/ICheckAttributeValue.java | 37 + .../stork/peps/auth/specific/IDeriveAttribute.java | 40 + .../stork/peps/auth/specific/INormaliseValue.java | 35 + .../peps/auth/specific/ITranslatorService.java | 100 +++ .../eu/stork/peps/auth/specific/package-info.java | 8 + 96 files changed, 15167 insertions(+) create mode 100644 id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeConstants.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Country.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CountryCodes.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/DateUtil.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeProvidersMap.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkLogger.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkSession.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnRequest.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKStatusCode.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKSubStatusCode.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/AbstractPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/CPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InternalErrorPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidParameterPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidSessionPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/SecurityPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/StorkPEPSException.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/package-info.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/package-info.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ICheckAttributeValue.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IDeriveAttribute.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/INormaliseValue.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/package-info.java (limited to 'id/server/stork2-commons/src/main/java/eu') diff --git a/id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops new file mode 100644 index 000000000..b792be687 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 61 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu +END diff --git a/id/server/stork2-commons/src/main/java/eu/.svn/entries b/id/server/stork2-commons/src/main/java/eu/.svn/entries new file mode 100644 index 000000000..d746a275b --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +stork +dir + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops new file mode 100644 index 000000000..bfb5156c8 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 67 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork +END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/.svn/entries new file mode 100644 index 000000000..081cc291c --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +peps +dir + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops new file mode 100644 index 000000000..10f18802a --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 72 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps +END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries new file mode 100644 index 000000000..d8fcce9b6 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries @@ -0,0 +1,31 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +auth +dir + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops new file mode 100644 index 000000000..479002e28 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops @@ -0,0 +1,5 @@ +K 25 +svn:wc:ra_dav:version-url +V 77 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth +END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries new file mode 100644 index 000000000..c90333736 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries @@ -0,0 +1,34 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +commons +dir + +specific +dir + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops new file mode 100644 index 000000000..5c34d72e7 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops @@ -0,0 +1,167 @@ +K 25 +svn:wc:ra_dav:version-url +V 85 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons +END +CitizenConsent.java +K 25 +svn:wc:ra_dav:version-url +V 105 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java +END +AttributeProvidersMap.java +K 25 +svn:wc:ra_dav:version-url +V 112 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java +END +AttributeConstants.java +K 25 +svn:wc:ra_dav:version-url +V 109 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeConstants.java +END +AttributeUtil.java +K 25 +svn:wc:ra_dav:version-url +V 104 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java +END +STORKStatusCode.java +K 25 +svn:wc:ra_dav:version-url +V 106 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKStatusCode.java +END +STORKAttrQueryResponse.java +K 25 +svn:wc:ra_dav:version-url +V 113 +/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java +END +PersonalAttributeList.java +K 25 +svn:wc:ra_dav:version-url +V 112 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java +END +Country.java +K 25 +svn:wc:ra_dav:version-url +V 98 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/Country.java +END +PEPSErrors.java +K 25 +svn:wc:ra_dav:version-url +V 101 +/CITnet/svn/STORK2/!svn/ver/73/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java +END +PEPSUtil.java +K 25 +svn:wc:ra_dav:version-url +V 99 +/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java +END +PersonalAttribute.java +K 25 +svn:wc:ra_dav:version-url +V 108 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java +END +IAttributeProvidersMap.java +K 25 +svn:wc:ra_dav:version-url +V 113 +/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IAttributeProvidersMap.java +END +IStorkLogger.java +K 25 +svn:wc:ra_dav:version-url +V 103 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IStorkLogger.java +END +DateUtil.java +K 25 +svn:wc:ra_dav:version-url +V 99 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/DateUtil.java +END +STORKAuthnRequest.java +K 25 +svn:wc:ra_dav:version-url +V 108 +/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnRequest.java +END +STORKSubStatusCode.java +K 25 +svn:wc:ra_dav:version-url +V 109 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKSubStatusCode.java +END +IPersonalAttributeList.java +K 25 +svn:wc:ra_dav:version-url +V 113 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java +END +AttributeProvider.java +K 25 +svn:wc:ra_dav:version-url +V 108 +/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java +END +IStorkSession.java +K 25 +svn:wc:ra_dav:version-url +V 104 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IStorkSession.java +END +CountryCodes.java +K 25 +svn:wc:ra_dav:version-url +V 103 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/CountryCodes.java +END +STORKAuthnResponse.java +K 25 +svn:wc:ra_dav:version-url +V 109 +/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java +END +package-info.java +K 25 +svn:wc:ra_dav:version-url +V 103 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/package-info.java +END +AttributeSource.java +K 25 +svn:wc:ra_dav:version-url +V 106 +/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java +END +Linker.java +K 25 +svn:wc:ra_dav:version-url +V 97 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/Linker.java +END +PEPSValues.java +K 25 +svn:wc:ra_dav:version-url +V 101 +/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java +END +PEPSParameters.java +K 25 +svn:wc:ra_dav:version-url +V 105 +/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java +END +STORKAttrQueryRequest.java +K 25 +svn:wc:ra_dav:version-url +V 112 +/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java +END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries new file mode 100644 index 000000000..78c1138bc --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries @@ -0,0 +1,949 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth/commons +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +AttributeSource.java +file + + + + +2013-12-20T12:27:56.638475Z +0f5436915d275475d2e30e1ac8aa9916 +2013-10-10T17:38:31.956327Z +31 +emlelisst + + + + + + + + + + + + + + + + + + + + + +2576 + +Linker.java +file + + + + +2013-12-20T12:27:56.638475Z +7e2de1580308d3fa7c91f95eed36fcff +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +4707 + +package-info.java +file + + + + +2013-12-20T12:27:56.638475Z +8d8068e217f10425f76a8d37192ccd80 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +277 + +PEPSValues.java +file + + + + +2013-12-20T12:27:56.638475Z +95c122e156ff030f46dd02bacaef7b2a +2013-10-10T17:38:31.956327Z +31 +emlelisst + + + + + + + + + + + + + + + + + + + + + +7515 + +PEPSParameters.java +file + + + + +2013-12-20T12:27:56.638475Z +3bbae3c0d36d323b2551d8735becbbf3 +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +12811 + +STORKAttrQueryRequest.java +file + + + + +2013-12-20T12:27:56.638475Z +f24b34d7b7778b050000759b8e51e135 +2013-10-24T15:44:04.704923Z +56 +emgrtargr + + + + + + + + + + + + + + + + + + + + + +10086 + +CitizenConsent.java +file + + + + +2013-12-20T12:27:56.638475Z +65152dd2df078e7d9ba767293ee3089e +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +3419 + +AttributeProvidersMap.java +file + + + + +2013-12-20T12:27:56.638475Z +dd0a71bc5e428238622d01103d1ff592 +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +2570 + +AttributeConstants.java +file + + + + +2013-12-20T12:27:56.638475Z +940dcb9e93ede62e221f4b25abd6576b +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1831 + +exceptions +dir + +AttributeUtil.java +file + + + + +2013-12-20T12:27:56.638475Z +fa7359e18bb73f5e6a40a10602334001 +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +7921 + +STORKStatusCode.java +file + + + + +2013-12-20T12:27:56.638475Z +771689c75a8263c7e3966e820d59025e +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1906 + +STORKAttrQueryResponse.java +file + + + + +2013-12-20T12:27:56.638475Z +7f38f84cce71009e69f5b122cc56b9a4 +2013-10-24T15:44:04.704923Z +56 +emgrtargr + + + + + + + + + + + + + + + + + + + + + +6750 + +PersonalAttributeList.java +file + + + + +2013-12-20T12:27:56.638475Z +6d50cc23699503bb7a1444c9a16cff8c +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +9413 + +Country.java +file + + + + +2013-12-20T12:27:56.638475Z +9cbde5f25b646d02dae7ccf424906b4a +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +2208 + +PEPSErrors.java +file + + + + +2013-12-20T12:27:56.638475Z +8cd32a1d957e59b567eeb14ac9d989b6 +2013-10-28T11:11:01.095477Z +73 +emlelisst + + + + + + + + + + + + + + + + + + + + + +10810 + +PEPSUtil.java +file + + + + +2013-12-20T12:27:56.634475Z +54dfabdb89ec6069a2ec2e33c8d925d6 +2013-10-24T15:44:04.704923Z +56 +emgrtargr + + + + + + + + + + + + + + + + + + + + + +11507 + +PersonalAttribute.java +file + + + + +2013-12-20T12:27:56.634475Z +76a8ff69fd13e5f67f1404249ca1d8a1 +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +8471 + +IAttributeProvidersMap.java +file + + + + +2013-12-20T12:27:56.634475Z +225257e8d6d7b9e6bcc4bea2463c33be +2013-10-10T17:38:31.956327Z +31 +emlelisst + + + + + + + + + + + + + + + + + + + + + +2534 + +IStorkLogger.java +file + + + + +2013-12-20T12:27:56.634475Z +f15979b29f52d1674103528aed914ae7 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +4766 + +DateUtil.java +file + + + + +2013-12-20T12:27:56.634475Z +59f9cd2a3d1169a0f1a797b28719921a +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +5702 + +STORKAuthnRequest.java +file + + + + +2013-12-20T12:27:56.634475Z +3f36e65f0c4f1c7df753784b2e64f00b +2013-10-24T15:44:04.704923Z +56 +emgrtargr + + + + + + + + + + + + + + + + + + + + + +11269 + +STORKSubStatusCode.java +file + + + + +2013-12-20T12:27:56.634475Z +65e615e0119d4125d5f4f58af8bcd18b +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +2181 + +IPersonalAttributeList.java +file + + + + +2013-12-20T12:27:56.634475Z +8a39da025b26fd5782611eeadeb69e03 +2013-11-01T20:35:30.927048Z +96 +emferreri + + + + + + + + + + + + + + + + + + + + + +4664 + +AttributeProvider.java +file + + + + +2013-12-20T12:27:56.634475Z +a16d3c5a83ced423ccc22f1d841c3575 +2013-10-10T17:38:31.956327Z +31 +emlelisst + + + + + + + + + + + + + + + + + + + + + +1525 + +IStorkSession.java +file + + + + +2013-12-20T12:27:56.634475Z +5a8701b1fd27998d5cf3280a5c99bcb0 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +2745 + +CountryCodes.java +file + + + + +2013-12-20T12:27:56.638475Z +f91b0f8df0b2a68fe1b900d425257c23 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +3527 + +STORKAuthnResponse.java +file + + + + +2013-12-20T12:27:56.638475Z +413495295761fd9c49a0b1e50befc68f +2013-10-24T15:44:04.704923Z +56 +emgrtargr + + + + + + + + + + + + + + + + + + + + + +6797 + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base new file mode 100644 index 000000000..09769641c --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base @@ -0,0 +1,72 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the STORK PEPS, Commons and Specific errors + * constant identifiers. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.2 $, $Date: 2010-11-17 05:15:28 $ + */ +public enum AttributeConstants { + + /** + * Represents the attribute's name index. + */ + ATTR_NAME_INDEX(0), + /** + * Represents the attribute's type index. + */ + ATTR_TYPE_INDEX(1), + /** + * Represents the attribute's value index. + */ + ATTR_VALUE_INDEX(2), + /** + * Represents the attribute's status index. + */ + ATTR_STATUS_INDEX(3), + /** + * Represents the number of allowed tuples. + */ + NUMBER_TUPLES(4); + + /** + * Represents the constant's value. + */ + private int attribute; + + /** + * Solo Constructor. + * + * @param attr The Attribute Constant value. + */ + AttributeConstants(final int attr) { + + this.attribute = attr; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public int intValue() { + + return attribute; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base new file mode 100644 index 000000000..013f4caf3 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base @@ -0,0 +1,74 @@ +package eu.stork.peps.auth.commons; + +/** + * This class is a bean used to store the information relative to the Attribute Provider. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-09-17 $ + */ +public final class AttributeProvider { + + /** + * Provider Id. + */ + private String providerId; + + /** + * Provider Name. + */ + private String providerName; + + /** + * Attribute Provider Constructor. + * + * @param pId Id of the Attribute Provider. + * @param pName Name of the Attribute Provider. + */ + public AttributeProvider(final String pId, final String pName) { + + this.providerId = pId; + this.providerName = pName; + } + + /** + * Getter for the providerId value. + * + * @return The providerId value. + */ + public String getProviderId() { + + return providerId; + } + + /** + * Setter for the providerId value. + * + * @param pId Id of the Attribute Provider. + */ + public void setProviderId(final String pId) { + + this.providerId = pId; + } + + /** + * Getter for the providerName value. + * + * @return The providerName value. + */ + public String getProviderName() { + + return providerName; + } + + /** + * Setter for the providerName value. + * + * @param name Name of the Attribute Provider. + */ + public void setProviderName(final String name) { + + this.providerName = name; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base new file mode 100644 index 000000000..8806ba866 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base @@ -0,0 +1,94 @@ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; +import java.util.LinkedHashMap; + +import org.apache.log4j.Logger; + +/** + * Implementation of the AttributeProviderMap using a LinkedHashMap. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.01 $, $Date: 2013-09-20 $ + * + * @see LinkedHashMap + */ +public class AttributeProvidersMap extends LinkedHashMap + implements IAttributeProvidersMap { + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(AttributeProvidersMap.class.getName()); + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 8949081185106296122L; + + /** + * {@inheritDoc} + */ + @Override + public IPersonalAttributeList get(AttributeSource key) { + return this.get((Object) key); + } + + /** + * {@inheritDoc} + */ + @Override + public IPersonalAttributeList remove(AttributeSource key) { + return this.remove((Object) key); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean containsKey(AttributeSource key) { + return this.containsKey((Object) key); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator keyIterator() { + return this.keySet().iterator(); + } + + public void trace() { + Iterator iterator; + Iterator iterator2; + AttributeSource source; + IPersonalAttributeList pal; + PersonalAttribute pa; + + iterator = this.keyIterator(); + LOG.trace("Start dumping of AttributeProvidersMap\n======================="); + while (iterator.hasNext()) { + source = iterator.next(); + + LOG.trace("Source details: type [" + source.getSourceType() + "], URL [" + source.getProviderURL() + "]"); + + if(source.getSourceType() == AttributeSource.SOURCE_LOCAL_APROVIDER) + LOG.trace("-> Attribute Provider: ID [" + source.getProvider().getProviderId() + "], name [" + source.getProvider().getProviderName() + "]"); + else + LOG.trace("-> Country: ID [" + source.getCountry().getCountryId() + "], name [" + source.getCountry().getCountryName() + "]"); + + pal = this.get(source); + LOG.trace("++++++++=>"); + iterator2 = pal.iterator(); + while (iterator2.hasNext()) { + pa = iterator2.next(); + + LOG.trace("-> Citizen Attribute: name [" + pa.getName() + "], name [" + pa.isRequired() + "]"); + } + LOG.trace("<=++++++++"); + + LOG.trace("-----------------------"); + } + LOG.trace("END\n======================="); + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base new file mode 100644 index 000000000..4b9dc33e9 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base @@ -0,0 +1,119 @@ +package eu.stork.peps.auth.commons; + +/** + * This class is a bean used to store the information relative to the Attribute Source (either AttributeProvider or Country). + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-09-19 $ + */ +public final class AttributeSource { + public static final int SOURCE_LOCAL_APROVIDER = 1; + public static final int SOURCE_REMOTE_COUNTRY = 2; + + /** + * Provider source. + */ + private int sourceType; + + /** + * Provider URL. + */ + private String providerURL; + + /** + * The local Attribute Provider. + */ + private AttributeProvider provider; + + /** + * The remote Country. + */ + private Country country; + + /** + * Attribute Source Constructor. + * + * @param provider The local Attribute Provider. + * @param pURL URL of the Attribute Provider. + */ + public AttributeSource(final AttributeProvider provider, final String pURL) { + this.setSourceType(SOURCE_LOCAL_APROVIDER); + + this.setProvider(provider); + this.setProviderURL(pURL); + } + + /** + * Attribute Source Constructor. + * + * @param country The remote Country. + * @param pURL URL of the Country. + */ + public AttributeSource(final Country country, final String pURL) { + this.setSourceType(SOURCE_REMOTE_COUNTRY); + + this.setCountry(country); + this.setProviderURL(pURL); + } + + /** + * @param sourceType the sourceType to set + */ + public void setSourceType(int sourceType) { + this.sourceType = sourceType; + } + + /** + * @return the sourceType + */ + public int getSourceType() { + return sourceType; + } + + /** + * @param providerURL the providerURL to set + */ + public void setProviderURL(String providerURL) { + this.providerURL = providerURL; + } + + /** + * @return the providerURL + */ + public String getProviderURL() { + return providerURL; + } + + /** + * @param provider the provider to set + */ + public void setProvider(AttributeProvider provider) { + this.setSourceType(SOURCE_LOCAL_APROVIDER); + + this.provider = provider; + } + + /** + * @return the provider + */ + public AttributeProvider getProvider() { + return provider; + } + + /** + * @param country the country to set + */ + public void setCountry(Country country) { + this.setSourceType(SOURCE_REMOTE_COUNTRY); + + this.country = country; + } + + /** + * @return the country + */ + public Country getCountry() { + return country; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base new file mode 100644 index 000000000..84e3576e5 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base @@ -0,0 +1,231 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.lang.StringUtils; + +/** + * This class holds static helper methods. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.5 $, $Date: 2010-12-15 23:19:59 $ + */ +public final class AttributeUtil { + + /** + * Private constructor. Prevents the class from being instantiated. + */ + private AttributeUtil() { + // empty constructor + } + + /** + * Safe escape any given string. + * + * @param value The HTTP Value to escaped. + * + * @return The value escaped value. + */ + public static String escape(final String value) { + + final String attrSep = PEPSValues.ATTRIBUTE_SEP.toString(); + final String attrTupleSep = PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(); + final String attrValueSep = PEPSValues.ATTRIBUTE_VALUE_SEP.toString(); + + final String escAttrSep = "%" + (int) attrSep.charAt(0); + final String escAttrTupleSep = "%" + (int) attrTupleSep.charAt(0); + final String escAttrValueSep = "%" + (int) attrValueSep.charAt(0); + + return value.replace(attrSep, escAttrSep) + .replace(attrTupleSep, escAttrTupleSep) + .replace(attrValueSep, escAttrValueSep); + } + + /** + * Unescape any given string. + * + * @param value The HTTP Value to be unescaped. + * + * @return The value unescaped value. + */ + public static String unescape(final String value) { + final String attrSep = PEPSValues.ATTRIBUTE_SEP.toString(); + final String attrTupleSep = PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(); + final String attrValueSep = PEPSValues.ATTRIBUTE_VALUE_SEP.toString(); + + final String escAttrSep = "%" + (int) attrSep.charAt(0); + final String escAttrTupleSep = "%" + (int) attrTupleSep.charAt(0); + final String escAttrValueSep = "%" + (int) attrValueSep.charAt(0); + + return value.replace(escAttrSep, attrSep) + .replace(escAttrTupleSep, attrTupleSep) + .replace(escAttrValueSep, attrValueSep); + } + + /** + * Appends the string representation of an object to a StringBuilder. + * + * @param strBuilder The StringBuilder to append to. + * @param val The string representation of an object. + */ + public static void appendIfNotNull(final StringBuilder strBuilder, + final Object val) { + + if (val != null) { + strBuilder.append(val); + } + } + + /** + * Given a separator and a list of strings, joins the list, as a string, + * separated by the separator string. + * + * @param list The list of strings to join. + * @param separator The separator string. + * @return the list, as a string, separated by the separator string. + */ + public static String listToString(final List list, + final String separator) { + + final StringBuilder strBuilder = new StringBuilder(); + for (final String s : list) { + if (!StringUtils.isEmpty(s)) { + strBuilder.append(AttributeUtil.escape(s) + separator); + } + } + return strBuilder.toString(); + } + + /** + * Given a separator and a map of strings to strings, joins the map, as a + * string, separated by the separator string with the pair key/value + * concatenated with a '='. + * + * @param map The map of strings to join. + * @param separator The separator string. + * + * @return the map of strings, as a string, separated by the separator string + * with the pair key/value concatenated with a '='. + */ + public static String mapToString(final Map map, + final String separator) { + + final StringBuilder strBuilder = new StringBuilder(); + final Iterator> valuesIt = map.entrySet().iterator(); + while (valuesIt.hasNext()) { + final Entry entry = valuesIt.next(); + strBuilder.append(entry.getKey()); + strBuilder.append('='); + strBuilder.append(AttributeUtil.escape(entry.getValue())); + strBuilder.append(separator); + } + return strBuilder.toString(); + } + + /** + * Validates the attribute value format. + * + * @param value The attribute value to validate. + * + * @return true if value has a valid format. + */ + public static boolean isValidValue(final String value) { + boolean retVal = false; + if (value != null && value.charAt(0) == '[' && value.endsWith("]")) { + final String tmpAttrValue = value.substring(1, value.length() - 1); + final String[] vals = + tmpAttrValue.split(PEPSValues.ATTRIBUTE_VALUE_SEP.toString()); + + if (tmpAttrValue.length() >= 0 + || (vals.length > 0 && vals[0].length() > 0)) { + retVal = true; + } + } + return retVal; + } + + /** + * Validates the attribute type value. It's case insensitive. E.g. return true + * value to: a) "true", "TRUE", "True", ... b) "false", "FALSE", "False", ... + * + * @param type The attribute type value. + * + * @return true if type has a true or false (case insensitive) value. + */ + public static boolean isValidType(final String type) { + return StringUtils.isNotEmpty(type) && (PEPSValues.TRUE.toString().equalsIgnoreCase(type) || PEPSValues.FALSE.toString().equalsIgnoreCase(type)) ; + } + + /** + * Validates the Personal attribute tuple. E.g. name:type:[value]:status + * + * @param tuples The Personal attribute's tuple. + * + * @return true if the tuples' format is valid. + * + * @see PEPSUtil#validateParameter(String, String, String) + * @see String#equalsIgnoreCase(String) + */ + public static boolean hasValidTuples(final String[] tuples) { + boolean retVal = false; + + int numberTuples = AttributeConstants.NUMBER_TUPLES.intValue(); + if (tuples != null && tuples.length == numberTuples) { + // validate attrName + final int attrNameIndex = AttributeConstants.ATTR_NAME_INDEX.intValue(); + final int attrTypeIndex = AttributeConstants.ATTR_TYPE_INDEX.intValue(); + final int attrValueIndex = AttributeConstants.ATTR_VALUE_INDEX.intValue(); + + retVal = + StringUtils.isNotEmpty(tuples[attrNameIndex]) + && StringUtils.isNotEmpty(tuples[attrTypeIndex]) + && StringUtils.isNotEmpty(tuples[attrValueIndex]) + && AttributeUtil.isValidType(tuples[attrTypeIndex]) + && AttributeUtil.isValidValue(tuples[attrValueIndex]); + } + return retVal; + } + + /** + * Check if all mandatory attributes have values. + * + * @param personalAttrList The Personal Attributes List. + * + * @return true if all mandatory attributes have values, false if at least one + * attribute doesn't have value. + */ + public static boolean checkMandatoryAttributes( + final IPersonalAttributeList personalAttrList) { + + final Iterator itAttributes = + personalAttrList.values().iterator(); + boolean retVal = true; + while (itAttributes.hasNext() && retVal) { + final PersonalAttribute attr = itAttributes.next(); + if (attr.isRequired() + && !STORKStatusCode.STATUS_AVAILABLE.toString() + .equals(attr.getStatus())) { + retVal = false; + } + } + return retVal; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base new file mode 100644 index 000000000..2245178f4 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base @@ -0,0 +1,123 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class is a bean used to store the information relative to the Citizen + * Consent. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class CitizenConsent { + + /** + * Mandatory attributes list. + */ + private List mandatoryList; + + /** + * Optional attributes list. + */ + private List optionalList; + + /** + * Citizen Consent default Constructor. + */ + public CitizenConsent() { + this.mandatoryList = new ArrayList(); + this.optionalList = new ArrayList(); + } + + /** + * Getter for the mandatoryList value. + * + * @return The mandatoryList value. + */ + public List getMandatoryList() { + return this.mandatoryList; + } + + /** + * Setter for the mandatoryList value. + * + * @param mandatoryAttrList Mandatory parameters list. + */ + public void setMandatoryList(final List mandatoryAttrList) { + this.mandatoryList = mandatoryAttrList; + } + + /** + * Setter for some mandatoryAttribute. Adds the input parameter to the + * mandatoryList. + * + * @param mandatoryAttr Attribute to add to the mandatoryList. + */ + public void setMandatoryAttribute(final String mandatoryAttr) { + this.mandatoryList.add(mandatoryAttr); + } + + /** + * Getter for the optionalList value. + * + * @return The optionalList value. + */ + public List getOptionalList() { + return optionalList; + } + + /** + * Setter for the optionalList value. + * + * @param optAttrList Optional parameters list. + */ + public void setOptionalList(final List optAttrList) { + this.optionalList = optAttrList; + } + + /** + * Setter for some optionalAttr. Adds the input parameter to the optionalList. + * + * @param optionalAttr Attribute to add to the optionalList. + */ + public void setOptionalAttribute(final String optionalAttr) { + this.optionalList.add(optionalAttr); + } + + /** + * Returns a string in the following format. "Mandatory attributes: + * mandatoryAttr1;mandatoryAttr2;mandatoryAttrN Optional attributes: + * optionalAttr1;optionalAttr2;optionalAttrN" + * + * @return {@inheritDoc} + */ + public String toString() { + final StringBuilder strbldr = new StringBuilder(); + strbldr.append("Mandatory attributes: "); + for (String str : mandatoryList) { + strbldr.append(str + ";"); + } + strbldr.append(" Optional attributes: "); + for (String str : optionalList) { + strbldr.append(str + ";"); + } + return strbldr.toString(); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base new file mode 100644 index 000000000..001f9317a --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base @@ -0,0 +1,95 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +/** + * This class is a bean used to store the information relative to the Country. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.10 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class Country implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1135994036496370993L; + +/** + * Country Id. + */ + private String countryId; + + /** + * Country Name. + */ + private String countryName; + + /** + * Country Constructor. + * + * @param cId Id of the Country. + * @param cName Name of the Country. + */ + public Country(final String cId, final String cName) { + + this.countryId = cId; + this.countryName = cName; + } + + /** + * Getter for the countryId value. + * + * @return The countryId value. + */ + public String getCountryId() { + + return countryId; + } + + /** + * Setter for the countryId value. + * + * @param cId Id of the Country. + */ + public void setCountryId(final String cId) { + + this.countryId = cId; + } + + /** + * Getter for the countryName value. + * + * @return The countryName value. + */ + public String getCountryName() { + + return countryName; + } + + /** + * Setter for the countryName value. + * + * @param name Name of the Country. + */ + public void setCountryName(final String name) { + + this.countryName = name; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base new file mode 100644 index 000000000..54345f3ea --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base @@ -0,0 +1,79 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.Arrays; +import java.util.List; + +/** + * This class contains all the ISO 3166-1 Alpha 3 Country Codes. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.2 $, $Date: 2011-04-14 00:24:56 $ + */ +public final class CountryCodes { + + /** + * Private Constructor. + */ + private CountryCodes() { + + } + + /** + * ISO 3166-1 Alpha 3 Country Codes. + */ + private static List countrysAlpha3 = Arrays.asList("ABW", "AFG", + "AGO", "AIA", "ALA", "ALB", "AND", "ANT", "ARE", "ARG", "ARM", "ASM", + "ATA", "ATF", "ATG", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BES", + "BFA", "BGD", "BGR", "BHR", "BHS", "BIH", "BLM", "BLR", "BLZ", "BMU", + "BOL", "BRA", "BRB", "BRN", "BTN", "BUR", "BVT", "BWA", "BYS", "CAF", + "CAN", "CCK", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COK", + "COL", "COM", "CPV", "CRI", "CSK", "CUB", "CUW", "CXR", "CYM", "CYP", + "CZE", "DEU", "DJI", "DMA", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI", + "ESH", "ESP", "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "FRO", "FSM", + "GAB", "GBR", "GEO", "GGY", "GHA", "GIB", "GIN", "GLP", "GMB", "GNB", + "GNQ", "GRC", "GRD", "GRL", "GTM", "GUF", "GUM", "GUY", "HKG", "HMD", + "HND", "HRV", "HTI", "HUN", "IDN", "IMN", "IND", "IOT", "IRL", "IRN", + "IRQ", "ISL", "ISR", "ITA", "JAM", "JEY", "JOR", "JPN", "KAZ", "KEN", + "KGZ", "KHM", "KIR", "KNA", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", + "LCA", "LIE", "LKA", "LSO", "LTU", "LUX", "LVA", "MAC", "MAF", "MAR", + "MCO", "MDA", "MDG", "MDV", "MEX", "MHL", "MKD", "MLI", "MLT", "MMR", + "MNE", "MNG", "MNP", "MOZ", "MRT", "MSR", "MTQ", "MUS", "MWI", "MYS", + "MYT", "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NIU", "NLD", "NOR", + "NPL", "NRU", "NZL", "OMN", "PAK", "PAN", "PCN", "PER", "PHL", "PLW", + "PNG", "POL", "PRI", "PRK", "PRT", "PRY", "PSE", "PYF", "QAT", "REU", + "ROM", "ROU", "RUS", "RWA", "SAU", "SCG", "SDN", "SEN", "SGP", "SGS", + "SHN", "SJM", "SLB", "SLE", "SLV", "SMR", "SOM", "SPM", "SRB", "STP", + "SUR", "SVK", "SVN", "SXW", "SWE", "SWZ", "SYC", "SYR", "TCA", "TCD", + "TGO", "THA", "TJK", "TKL", "TKM", "TLS", "TMP", "TON", "TTO", "TUN", + "TUR", "TUV", "TWN", "TZA", "UGA", "UKR", "UMI", "URY", "USA", "UZB", + "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "YEM", + "YUG", "ZAF", "ZAR", "ZMB", "ZWE"); + + /** + * Searches the CountryCode (3166-1 alpha3 format) an return true if it + * exists. + * + * @param countryCode The Country code to search. + * + * @return true if the CountryCode exists, false otherwise. + */ + public static boolean hasCountryCodeAlpha3(final String countryCode) { + + return CountryCodes.countrysAlpha3.contains(countryCode); + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base new file mode 100644 index 000000000..9c0bd6775 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base @@ -0,0 +1,169 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.sql.Timestamp; +import java.util.GregorianCalendar; + +import org.apache.log4j.Logger; +import org.joda.time.DateTime; +import org.joda.time.Years; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import eu.stork.peps.auth.commons.exceptions.SecurityPEPSException; + +/** + * This class holds static helper methods for Date Operations. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.4 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class DateUtil { + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(DateUtil.class.getName()); + + /** + * yyyy Date format size. + */ + private static final int YEAR_DATE_SIZE = 4; + + /** + * yyyyMM Date format size. + */ + private static final int MONTH_DATE_SIZE = 6; + + /** + * Private constructor. Prevents the class from being instantiated. + */ + private DateUtil() { + // empty constructor + } + + /** + * Fulfils dateValue with a valid date. The following roles are applied: a) If + * the dateValue only contains the year then fulfils with last year's day. + * e.g. this method returns 19951231 to the 1995 dateValue. b) If the + * dateValue contains the year and the month then fulfils with last month's + * day. e.g. this method returns 19950630 to the 199505 dateValue. + * + * @param dateValue The date to be fulfilled. + * + * @return The dateValue fulfilled. + */ + private static String fulfilDate(final String dateValue) { + + final StringBuffer strBuf = new StringBuffer(); + strBuf.append(dateValue); + // if the IdP just provides the year then we must fullfil the date. + if (dateValue.length() == YEAR_DATE_SIZE) { + strBuf.append(PEPSValues.LAST_MONTH.toString()); + } + // if the IdP provides the year and the month then we must fullfil the + // date. + if (dateValue.length() == MONTH_DATE_SIZE + || strBuf.length() == MONTH_DATE_SIZE) { + // IdP doesn't provide the day, so we will use DateTime to + // calculate it. + final String noDayCons = PEPSValues.NO_DAY_DATE_FORMAT.toString(); + final DateTimeFormatter fmt = DateTimeFormat.forPattern(noDayCons); + final DateTime dateTime = fmt.parseDateTime(strBuf.toString()); + // Append the last month's day. + strBuf.append(dateTime.dayOfMonth().withMaximumValue().getDayOfMonth()); + } + + return strBuf.toString(); + } + + /** + * Validates the dateValue format: a) if has a valid size; b) if has a numeric + * value; Note: dateValue must have the format yyyyMMdd. + * + * @param dateValueTmp The date to be validated. + * @param pattern The accepted date format. + * + * @return true if the date has a valid format. + */ + public static boolean isValidFormatDate(final String dateValueTmp, + final String pattern) { + + boolean retVal = true; + try { + final String dateValue = DateUtil.fulfilDate(dateValueTmp); + + final DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + fmt.parseDateTime(dateValue); + } catch (final Exception e) { + // We catch Exception because we only have to return false + // value! + retVal = false; + } + return retVal; + } + + /** + * Calculates the age for a given date string. + * + * @param dateVal The date to be validated. + * @param now The current date. + * @param pattern The date pattern. + * + * @return The age value. + */ + public static int calculateAge(final String dateVal, final DateTime now, + final String pattern) { + + if (DateUtil.isValidFormatDate(dateVal, pattern)) { + try { + final String dateValueTemp = DateUtil.fulfilDate(dateVal); + final DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + final DateTime dateTime = fmt.parseDateTime(dateValueTemp); + // Calculating age + final Years age = Years.yearsBetween(dateTime, now); + + return age.getYears(); + } catch (final IllegalArgumentException e) { + LOG.warn("Invalid date format (" + pattern + + ") or an invalid dateValue."); + throw new SecurityPEPSException( + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorMessage()), + e); + } + } else { + LOG.warn("Couldn't calculate Age, invalid date!"); + throw new SecurityPEPSException( + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorMessage())); + } + + } + + /** + * Generates the current timestamp. + * + * @return timestamp The current timestamp + */ + public static Timestamp currentTimeStamp() { + final GregorianCalendar cal = new GregorianCalendar(); + final long millis = cal.getTimeInMillis(); + return new Timestamp(millis); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base new file mode 100644 index 000000000..733399ca3 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base @@ -0,0 +1,82 @@ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; + +/** + * Interface for Attributes Providers map. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-09-20 $ + */ +public interface IAttributeProvidersMap { + + /** + * Returns the object associated the the given key. + * + * @param key with which the specified value is to be associated. + * + * @return The object associated the the given key. + */ + IPersonalAttributeList get(AttributeSource key); + + /** + * Associates a key to a value, and inserts them in the session object. + * + * @param key with which the specified value is to be associated. + * @param value to be associated with the specified key. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + Object put(AttributeSource key, IPersonalAttributeList value); + + /** + * Removes the mapping for this key. + * + * @param key with which the specified value is to be associated. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + IPersonalAttributeList remove(AttributeSource key); + + /** + * Returns the number of key-value mappings in this map. + * + * @return the number of key-value mappings in this map. + */ + int size(); + + /** + * Returns true if this map contains a mapping for the specified key. + * + * @param key with which the specified value is to be associated. + * + * @return true if this map contains a mapping for the specified key. + */ + boolean containsKey(AttributeSource key); + + /** + * Removes all mappings from this map. + */ + void clear(); + + /** + * Returns true if this map contains no key-value mappings. + * + * @return true if this map contains no key-value mappings. + */ + boolean isEmpty(); + + /** + * Returns an Iterator of the keys contained in this map. The implementation must + * take care in order for the Iterator to have predictable order of the returned + * keys. + * + * @return an iterator of the keys contained in this map + */ + Iterator keyIterator(); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base new file mode 100644 index 000000000..83b8e57fe --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base @@ -0,0 +1,140 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.Collection; +import java.util.Iterator; + +/** + * Interface for {@link PersonalAttributeList}. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.16 $, $Date: 2010-11-17 05:15:28 $ + * + * @see PersonalAttribute + */ +@SuppressWarnings("PMD.CloneMethodMustImplementCloneable") +public interface IPersonalAttributeList extends Iterable, + Cloneable { + + /** + * Associates the specified value with the specified key in this Personal + * Attribute List. + * + * @param key with which the specified value is to be associated. + * @param value to be associated with the specified key. + * + * @return the previous value associated with key, or null if there was no + * mapping for key. + * + * @see PersonalAttribute + */ + PersonalAttribute put(String key, PersonalAttribute value); + + /** + * Returns the value to which the specified key is mapped, or null if this map + * contains no mapping for the key. + * + * @param key whose associated value is to be returned. + * + * @return The value to which the specified key is mapped, or null if this map + * contains no mapping for the key. + * + * @see PersonalAttribute + */ + PersonalAttribute get(Object key); + + /** + * Adds to the PersonalAttributeList the given PersonalAttribute. It sets the + * attribute name as the key to the attribute value. + * + * @param value PersonalAttribute to add to the PersonalAttributeList + */ + void add(PersonalAttribute value); + + /** + * Get the size of the Personal Attribute List. + * + * @return size of the Personal Attribute List. + */ + int size(); + + /** + * Checks if the Personal Attribute List contains the given key. + * + * @param key with which the specified value is to be associated. + * + * @return true if the Personal Attribute List contains the given key, false + * otherwise. + */ + boolean containsKey(Object key); + + /** + * Getter for the iterator of the Personal Attribute List values. + * + * @return The iterator for the Personal Attribute List values. + * + * @see PersonalAttribute + */ + Iterator iterator(); + + /** + * Creates a Personal Attribute List from a String representing an Attribute + * List. + * + * @param attrList String Object representing the attribute list. + */ + void populate(String attrList); + + /** + * Removes the mapping for this key from this map if present. + * + * @param key key whose mapping is to be removed from the map. + * @return previous value associated with specified key, or null if + * there was no mapping for key. A null return can also + * indicate that the map previously associated null with the + * specified key. + */ + PersonalAttribute remove(Object key); + + /** + * Returns a collection view of the values contained in this map. The + * collection is backed by the map, so changes to the map are reflected in the + * collection, and vice-versa. The collection supports element removal, which + * removes the corresponding mapping from this map, via the + * Iterator.remove, Collection.remove, removeAll, + * retainAll, and clear operations. It does not support the + * add or addAll operations. + * + * @return a collection view of the values contained in this map. + */ + Collection values(); + + /** + * Returns true if this map contains no key-value mappings. + * + * @return true if this map contains no key-value mappings. + */ + boolean isEmpty(); + + /** + * Returns a copy of this IPersonalAttributeList instance. + * + * @return The copy of this IPersonalAttributeList. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base new file mode 100644 index 000000000..33eb618f0 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base @@ -0,0 +1,239 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * Interface for stork logging. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.10 $, $Date: 2011-02-17 22:44:34 $ + */ +public interface IStorkLogger { + + /** + * Getter for SpApplication. + * + * @return The SpApplication value. + */ + String getSpApplication(); + + /** + * Setter for SpApplication. + * + * @param spApplication The SP Application. + */ + void setSpApplication(String spApplication); + + /** + * Getter for ProviderName. + * + * @return The ProviderName value. + */ + String getProviderName(); + + /** + * Setter for ProviderName. + * + * @param providerName The provider name. + */ + void setProviderName(String providerName); + + /** + * + * Getter for Origin. + * + * @return The Origin value. + * + */ + String getOrigin(); + + /** + * Setter for Origin. + * + * @param origin The origin. + */ + void setOrigin(String origin); + + /** + * + * Getter for QAA Level. + * + * @return The QAA Level value. + * + */ + int getQaaLevel(); + + /** + * Setter for QAA Level. + * + * @param qaaLevel The qaa level. + */ + void setQaaLevel(int qaaLevel); + + /** + * + * Getter for timestamp. + * + * @return The timestamp value. + * + */ + String getTimestamp(); + + /** + * Setter for timestamp. + * + * @param timestamp The request's timestamp. + */ + void setTimestamp(String timestamp); + + /** + * Getter for InResponseTo. + * + * @return The InResponseTo value. + */ + String getInResponseTo(); + + /** + * Setter for InResponseTo. + * + * @param inResponseTo The Saml's response id. + */ + void setInResponseTo(String inResponseTo); + + /** + * Getter for InResponseToSPReq. + * + * @return The InResponseToSPReq value. + */ + String getInResponseToSPReq(); + + /** + * Setter for InResponseToSPRequ. + * + * @param inResponseToSPReq The Saml's response id. + */ + void setInResponseToSPReq(String inResponseToSPReq); + + /** + * Getter for opType. + * + * @return The opType value. + */ + String getOpType(); + + /** + * Setter for opType. + * + * @param opType The operation type. + */ + void setOpType(String opType); + + /** + * Getter for destination. + * + * @return The destination value. + */ + String getDestination(); + + /** + * Setter for destinationIp. + * + * @param destination The remote IP. + */ + void setDestination(String destination); + + /** + * Getter for message or assertion consumer. + * + * @return The message or assertion consumer. + */ + String getMessage(); + + /** + * Setter for message or assertion consumer. + * + * @param message or assertion consumer. + */ + void setMessage(String message); + + /** + * Getter for country. + * + * @return The country value. + */ + String getCountry(); + + /** + * Setter for country. + * + * @param country The country. + */ + void setCountry(String country); + + /** + * Getter for samlHash. + * + * @return The samlHash value. + */ + byte[] getSamlHash(); + + /** + * Setter for samlHash. + * + * @param samlHash the encrypted SAML token + */ + void setSamlHash(byte[] samlHash); + + /** + * Getter for msgId. + * + * @return the msgId + */ + String getMsgId(); + + /** + * Setter for msgId. + * + * @param msgId the ID of the originator of this message + */ + void setMsgId(String msgId); + + /** + * Getter for sPMsgId. + * + * @return the sPMsgId + */ + String getSPMsgId(); + + /** + * Setter for sPMsgId. + * + * @param sPMsgId the ID of the originator of this message + */ + void setSPMsgId(String sPMsgId); + + /** + * The format of the returned String must be the following: + * "requestCounter#ddMMMyyyykk:mm:ss#opType#originIp#originName + * #destinationIp#destinationName#samlHash#[originatorName#msgId#]" + * + * The values enclosed in '[]' only apply when logging responses. + * + * @return {@inheritDoc} + */ + @Override + String toString(); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base new file mode 100644 index 000000000..f38b41838 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base @@ -0,0 +1,85 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * Interface for stork session. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.9 $, $Date: 2010-11-17 05:15:28 $ + */ +public interface IStorkSession { + + /** + * Returns the object associated the the given key. + * + * @param key with which the specified value is to be associated. + * + * @return The object associated the the given key. + */ + Object get(Object key); + + /** + * Associates a key to a value, and inserts them in the session object. + * + * @param key with which the specified value is to be associated. + * @param value to be associated with the specified key. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + Object put(String key, Object value); + + /** + * Removes the mapping for this key. + * + * @param key with which the specified value is to be associated. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + Object remove(Object key); + + /** + * Returns the number of key-value mappings in this map. + * + * @return the number of key-value mappings in this map. + */ + int size(); + + /** + * Returns true if this map contains a mapping for the specified key. + * + * @param key with which the specified value is to be associated. + * + * @return true if this map contains a mapping for the specified key. + */ + boolean containsKey(Object key); + + /** + * Removes all mappings from this map. + */ + void clear(); + + /** + * Returns true if this map contains no key-value mappings. + * + * @return true if this map contains no key-value mappings. + */ + boolean isEmpty(); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base new file mode 100644 index 000000000..43d3adaa9 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base @@ -0,0 +1,173 @@ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; + +/** + * This class is a bean used to store the information of Attribute Providers, the Attribute + * List to be requested, the Assertions returned by the Attribute Providers and the values + * that each Attribute has. This information along with the current status of the Linker (the + * attribute providers that were queried and the remaining providers) is used by the PEPS + * actions in order to complete the Attribute gathering. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.20 $, $Date: 2013-10-28 $ + */ +public final class Linker { + /** + * Attributes Providers map. + */ + private IAttributeProvidersMap attributeProvidersMap; + + /** + * The current index of local (domestic) Attribute Providers. + */ + private int localIndex; + + /** + * The current index of remote (foreign) Attribute Providers - countries. + */ + private int remoteIndex; + + /** + * Constructs an empty Linker object. + */ + public Linker() { + localIndex = 0; + remoteIndex = 0; + } + + /** + * Based on the internal state of the Linker it returns the next local Attribute Source + * + * @return The next Attribute Source or null if not found + * + * @see AttributeSource + */ + public AttributeSource getNextLocalProvider() { + Iterator iterator; + AttributeSource source, found; + int curIndex = 0; + + found = null; + + if ( attributeProvidersMap!=null && !attributeProvidersMap.isEmpty() ) { + iterator = attributeProvidersMap.keyIterator(); + while (iterator.hasNext()) { + source = iterator.next(); + + if ( source.getSourceType()==AttributeSource.SOURCE_LOCAL_APROVIDER ) { + if ( curIndex>=localIndex ) { + found = source; + + break; + } + + curIndex++; + } + } + } + + return found; + } + + /** + * Based on the internal state of the Linker it returns the next remote Attribute Source + * + * @return The next Attribute Source or null if not found + * + * @see AttributeSource + */ + public AttributeSource getNextRemoteProvider() { + Iterator iterator; + AttributeSource source, found; + int curIndex = 0; + + found = null; + + if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) { + iterator = attributeProvidersMap.keyIterator(); + while (iterator.hasNext()) { + source = iterator.next(); + + if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) { + if ( curIndex>=remoteIndex ) { + found = source; + + break; + } + + curIndex++; + } + } + } + + return found; + } + + /** + * It updates the Linker with the values returned by the Attribute Source. It also advances + * to the next index in order to mark this attribute source as completed. + * + * @param source The Attribute Source that was queried for attribute values. + * @param attrResponse The attrResponse returned by the Attribute Source that contains the attribute values. + * + * @see AttributeSource, STORKAttrQueryResponse + */ + public void setProviderReponse(AttributeSource source, STORKAttrQueryResponse attrResponse) { + if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) + remoteIndex++; + else + localIndex++; + + //TODO How to store Assertions (format: byte, base64 string, entire object?) + + this.attributeProvidersMap.put(source, attrResponse.getPersonalAttributeList()); + } + + /** + * Reset the internal state of the local Attribute Source in order to start over. + */ + public void resetLocalIndex() { + localIndex = 0; + } + + /** + * Reset the internal state of the remote Attribute Source in order to start over. + */ + public void resetRemoteIndex() { + remoteIndex = 0; + } + + /** + * Setter for attributeProvidersMap. + * + * @param attributeProvidersMap The attributeProvidersMap to set. + */ + public void setAttributeProvidersMap(IAttributeProvidersMap attributeProvidersMap) { + this.attributeProvidersMap = attributeProvidersMap; + } + + /** + * Getter for attributeProvidersMap. + * + * @return attributeProvidersMap + */ + public IAttributeProvidersMap getAttributeProvidersMap() { + return attributeProvidersMap; + } + + /** + * Returns the Personal Attribute list of the provided Attribute Source. + * + * @return The IPersonalAttributeList assosiated with this source or null if empty + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getProviderAttributes(AttributeSource source) { + if ( attributeProvidersMap.containsKey(source) ) + return attributeProvidersMap.get(source); + else + return null; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base new file mode 100644 index 000000000..3aa549a06 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base @@ -0,0 +1,348 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the STORK PEPS, Commons and Specific errors + * constant identifiers. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.10 $, $Date: 2011-02-17 22:44:34 $ + */ +public enum PEPSErrors { + + /** + * Represents the 'authenticationFailed' constant error identifier. + */ + AUTHENTICATION_FAILED_ERROR("authenticationFailed"), + /** + * Represents the 'spCountrySelector.errorCreatingSAML' constant error + * identifier. + */ + SP_COUNTRY_SELECTOR_ERROR_CREATE_SAML("spCountrySelector.errorCreatingSAML"), + /** + * Represents the 'spCountrySelector.destNull' constant error identifier. + */ + SP_COUNTRY_SELECTOR_DESTNULL("spCountrySelector.destNull"), + /** + * Represents the 'spCountrySelector.invalidAttr' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_ATTR("spCountrySelector.invalidAttr"), + /** + * Represents the 'spCountrySelector.invalidProviderName' constant error + * identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_PROVIDER_NAME( + "spCountrySelector.invalidProviderName"), + /** + * Represents the 'spCountrySelector.invalidQaaSPid' constant error + * identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_QAASPID("spCountrySelector.invalidQaaSPid"), + /** + * Represents the 'spCountrySelector.invalidSpId' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_SPID("spCountrySelector.invalidSpId"), + /** + * Represents the 'spCountrySelector.invalidSPQAA' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_SPQAA("spCountrySelector.invalidSPQAA"), + /** + * Represents the 'spCountrySelector.invalidSpURL' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_SPURL("spCountrySelector.invalidSpURL"), + /** + * Represents the 'spCountrySelector.spNotAllowed' constant error identifier. + */ + SP_COUNTRY_SELECTOR_SPNOTALLOWED("spCountrySelector.spNotAllowed"), + + /** + * Represents the 'sProviderAction.errorCreatingSAML' constant error + * identifier. + */ + SPROVIDER_SELECTOR_ERROR_CREATE_SAML("sProviderAction.errorCreatingSAML"), + /** + * Represents the 'sProviderAction.attr' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_ATTR("sProviderAction.invalidAttr"), + /** + * Represents the 'sProviderAction.country' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_COUNTRY("sProviderAction.invalidCountry"), + /** + * Represents the 'sProviderAction.relayState' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_RELAY_STATE("sProviderAction.invalidRelayState"), + /** + * Represents the 'sProviderAction.saml' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SAML("sProviderAction.invalidSaml"), + /** + * Represents the 'sProviderAction.spAlias' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPALIAS("sProviderAction.invalidSPAlias"), + /** + * Represents the 'sProviderAction.spDomain' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPDOMAIN("sProviderAction.invalidSPDomain"), + /** + * Represents the 'sProviderAction.spId' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPID("sProviderAction.invalidSPId"), + /** + * Represents the 'sProviderAction.spQAA' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPQAA("sProviderAction.invalidSPQAA"), + /** + * Represents the 'sProviderAction.spQAAId' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPQAAID("sProviderAction.invalidSPQAAId"), + /** + * Represents the 'sProviderAction.spRedirect' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPREDIRECT("sProviderAction.invalidSPRedirect"), + /** + * Represents the 'sProviderAction.invalidSPProviderName' constant error + * identifier. + */ + SPROVIDER_SELECTOR_INVALID_SP_PROVIDERNAME( + "sProviderAction.invalidSPProviderName"), + /** + * Represents the 'sProviderAction.spNotAllowed' constant error identifier. + */ + SPROVIDER_SELECTOR_SPNOTALLOWED("sProviderAction.spNotAllowed"), + + + /** + * Represents the 'internalError' constant error identifier. + */ + INTERNAL_ERROR("internalError"), + + /** + * Represents the 'colleagueRequest.attrNull' constant error identifier. + */ + COLLEAGUE_REQ_ATTR_NULL("colleagueRequest.attrNull"), + /** + * Represents the 'colleagueRequest.errorCreatingSAML' constant error + * identifier. + */ + COLLEAGUE_REQ_ERROR_CREATE_SAML("colleagueRequest.errorCreatingSAML"), + /** + * Represents the 'colleagueRequest.invalidCountryCode' constant error + * identifier. + */ + COLLEAGUE_REQ_INVALID_COUNTRYCODE("colleagueRequest.invalidCountryCode"), + /** + * Represents the 'colleagueRequest.invalidDestUrl' constant error identifier. + */ + COLLEAGUE_REQ_INVALID_DEST_URL("colleagueRequest.invalidDestUrl"), + /** + * Represents the 'colleagueRequest.invalidQaa' constant error identifier. + */ + COLLEAGUE_REQ_INVALID_QAA("colleagueRequest.invalidQaa"), + /** + * Represents the 'colleagueRequest.invalidRedirect' constant error + * identifier. + */ + COLLEAGUE_REQ_INVALID_REDIRECT("colleagueRequest.invalidRedirect"), + /** + * Represents the 'colleagueRequest.invalidSAML' constant error identifier. + */ + COLLEAGUE_REQ_INVALID_SAML("colleagueRequest.invalidSAML"), + + + /** + * Represents the 'cpepsRedirectUrl' constant error identifier. + */ + CPEPS_REDIRECT_URL("cpepsRedirectUrl"), + /** + * Represents the 'spepsRedirectUrl' constant error identifier. + */ + SPEPS_REDIRECT_URL("spepsRedirectUrl"), + /** + * Represents the 'sProviderAction.invCountry' constant error identifier. + */ + SP_ACTION_INV_COUNTRY("sProviderAction.invCountry"), + + /** + * Represents the 'providernameAlias.invalid' constant error identifier. + */ + PROVIDER_ALIAS_INVALID("providernameAlias.invalid"), + + + /** + * Represents the 'cPeps.attrNull' constant error identifier. + */ + CPEPS_ATTR_NULL("cPeps.attrNull"), + + /** + * Represents the 'colleagueResponse.invalidSAML' constant error identifier. + */ + COLLEAGUE_RESP_INVALID_SAML("colleagueResponse.invalidSAML"), + + /** + * Represents the 'citizenNoConsent.mandatory' constant error identifier. + */ + CITIZEN_NO_CONSENT_MANDATORY("citizenNoConsent.mandatory"), + /** + * Represents the 'citizenResponse.mandatory' constant error identifier. + */ + CITIZEN_RESPONSE_MANDATORY("citizenResponse.mandatory"), + /** + * Represents the 'attVerification.mandatory' constant error identifier. + */ + ATT_VERIFICATION_MANDATORY("attVerification.mandatory"), + /** + * Represents the 'attrValue.verification' constant error identifier. + */ + ATTR_VALUE_VERIFICATION("attrValue.verification"), + + /** + * Represents the 'audienceRestrictionError' constant error identifier. + */ + AUDIENCE_RESTRICTION("audienceRestrictionError"), + /** + * Represents the 'auRequestIdError' constant error identifier. + */ + AU_REQUEST_ID("auRequestIdError"), + /** + * Represents the 'domain' constant error identifier. + */ + DOMAIN("domain"), + /** + * Represents the 'hash.error' constant error identifier. + */ + HASH_ERROR("hash.error"), + /** + * Represents the 'invalidAttributeList' constant error identifier. + */ + INVALID_ATTRIBUTE_LIST("invalidAttributeList"), + /** + * Represents the 'invalidAttributeValue' constant error identifier. + */ + INVALID_ATTRIBUTE_VALUE("invalidAttributeValue"), + /** + * Represents the 'qaaLevel' constant error identifier. + */ + QAALEVEL("qaaLevel"), + /** + * Represents the 'requests' constant error identifier. + */ + REQUESTS("requests"), + /** + * Represents the 'SPSAMLRequest' constant error identifier. + */ + SP_SAML_REQUEST("SPSAMLRequest"), + /** + * Represents the 'spepsSAMLRequest' constant error identifier. + */ + SPEPS_SAML_REQUEST("spepsSAMLRequest"), + /** + * Represents the 'IdPSAMLResponse' constant error identifier. + */ + IDP_SAML_RESPONSE("IdPSAMLResponse"), + /** + * Represents the 'cpepsSAMLResponse' constant error identifier. + */ + CPEPS_SAML_RESPONSE("cpepsSAMLResponse"), + /** + * Represents the 'cpepsSAMLResponse' constant error identifier. + */ + SPEPS_SAML_RESPONSE("spepsSAMLResponse"), + /** + * Represents the 'session' constant error identifier. + */ + SESSION("session"), + /** + * Represents the 'invalid.session' constant error identifier. + */ + INVALID_SESSION("invalid.session"), + /** + * Represents the 'invalid.sessionId' constant error identifier. + */ + INVALID_SESSION_ID("invalid.sessionId"), + /** + * Represents the 'missing.sessionId' constant error identifier. + */ + MISSING_SESSION_ID("sessionError"), + /** + * Represents the 'AtPSAMLResponse' constant error identifier. + */ + ATP_SAML_RESPONSE("AtPSAMLResponse"); + + /** + * Represents the constant's value. + */ + private String error; + + /** + * Solo Constructor. + * + * @param nError The Constant error value. + */ + PEPSErrors(final String nError) { + this.error = nError; + } + + /** + * Construct the errorCode Constant value. + * + * @return The errorCode Constant. + */ + public String errorCode() { + return error + ".code"; + } + + /** + * Construct the errorCode Constant value with the given code text. + * + * @param text the code text to append to the constant. + * + * @return The errorCode Constant for the given code text. + */ + public String errorCode(final String text) { + return error + "." + text + ".code"; + } + + /** + * Construct the errorMessage constant value. + * + * @return The errorMessage constant. + */ + public String errorMessage() { + return error + ".message"; + } + + /** + * Construct the errorMessage Constant value with the given message text. + * + * @param text the message text to append to the constant. + * + * @return The errorMessage Constant for the given text. + */ + public String errorMessage(final String text) { + return error + "." + text + ".message"; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + return error; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base new file mode 100644 index 000000000..37b204351 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base @@ -0,0 +1,511 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the STORK PEPS, Commons and Specific Parameters. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2011-07-07 20:48:45 $ + */ +public enum PEPSParameters { + + /** + * Represents the 'apId' parameter constant. + */ + AP_ID("apId"), + /** + * Represents the 'apUrl' parameter constant. + */ + AP_URL("apUrl"), + /** + * Represents the 'ap.number' parameter constant. + */ + AP_NUMBER("ap.number"), + + /** + * Represents the 'assertionConsumerServiceURL' parameter constant. + */ + ASSERTION_CONSUMER_S_URL("assertionConsumerServiceURL"), + + /** + * Represents the 'auth' parameter constant. + */ + AUTHENTICATION("auth"), + + /** + * Represents the 'auth-on-behalf-of' parameter constant. + */ + AUTHENTICATION_ON_BEHALF_OF("auth-on-behalf-of"), + + /** + * Represents the 'attr' parameter constant. + */ + ATTRIBUTE("attr"), + /** + * Represents the 'attrName' parameter constant. + */ + ATTRIBUTE_NAME("attrName"), + /** + * Represents the 'attrStatus' parameter constant. + */ + ATTRIBUTE_STATUS("attrStatus"), + /** + * Represents the 'attrType' parameter constant. + */ + ATTRIBUTE_TYPE("attrType"), + /** + * Represents the 'attrValue' parameter constant. + */ + ATTRIBUTE_VALUE("attrValue"), + /** + * Represents the 'attrList' parameter constant. + */ + ATTRIBUTE_LIST("attrList"), + /** + * Represents the 'attrTuple' parameter constant. + */ + ATTRIBUTE_TUPLE("attrTuple"), + /** + * Represents the 'attribute-missing' parameter constant. + */ + ATTRIBUTE_MISSING("attribute-missing"), + /** + * Represents the 'attributesNotAllowed' parameter constant. + */ + ATTRIBUTES_NOT_ALLOWED("attributesNotAllowed"), + /** + * Represents the 'authnRequest' parameter constant. + */ + AUTH_REQUEST("authnRequest"), + + /** + * Represents the 'attrValue.number' parameter constant. + */ + ATTR_VALUE_NUMBER("attrValue.number"), + + /** + * Represents the 'derivation.date.format' parameter constant. + */ + DERIVATION_DATE_FORMAT("derivation.date.format"), + /** + * Represents the 'deriveAttr.number' parameter constant. + */ + DERIVE_ATTRIBUTE_NUMBER("deriveAttr.number"), + + /** + * Represents the complex attributes parameter constant. + */ + COMPLEX_ADDRESS_VALUE("canonicalResidenceAddress"), + COMPLEX_NEWATTRIBUTE_VALUE("newAttribute2"), + COMPLEX_HASDEGREE_VALUE("hasDegree"), + COMPLEX_MANDATECONTENT_VALUE("mandateContent"), + /** + * Represents the 'consent-type' parameter constant. + */ + CONSENT_TYPE("consent-type"), + /** + * Represents the 'consent-value' parameter constant. + */ + CONSENT_VALUE("consent-value"), + /** + * Represents the 'country' parameter constant. + */ + COUNTRY("country"), + /** + * Represents the 'countryOrigin' parameter constant. + */ + COUNTRY_ORIGIN("countryOrigin"), + + /** + * Represents the 'cpepsURL' parameter constant. + */ + CPEPS_URL("cpepsURL"), + /** + * Represents the 'callback' parameter constant. + */ + CPEPS_CALLBACK("callback"), + /** + * Represents the 'peps.specificidpredirect.url' parameter constant. + */ + CPEPS_IDP_CALLBACK_VALUE("peps.specificidpredirect.url"), + /** + * Represents the 'peps.specificapredirect.url' parameter constant. + */ + CPEPS_AP_CALLBACK_VALUE("peps.specificapredirect.url"), + + /** + * Represents the 'errorCode' parameter constant. + */ + ERROR_CODE("errorCode"), + /** + * Represents the 'subCode' parameter constant. + */ + ERROR_SUBCODE("subCode"), + /** + * Represents the 'errorMessage' parameter constant. + */ + ERROR_MESSAGE("errorMessage"), + /** + * Represents the 'errorRedirectUrl' parameter constant. + */ + ERROR_REDIRECT_URL("errorRedirectUrl"), + + /** + * errorRedirectUrl Represents the 'external-authentication' parameter + * constant. + */ + EXTERNAL_AUTH("external-authentication"), + /** + * Represents the 'external-ap' parameter constant. + */ + EXTERNAL_AP("external-ap"), + /** + * Represents the 'external-sig-module' parameter constant. + */ + EXT_SIG_CREATOR_MOD("external-sig-module"), + + /** + * Represents the 'http-x-forwarded-for' parameter constant. + */ + HTTP_X_FORWARDED_FOR("http-x-forwarded-for"), + + /** + * Represents the 'idp.url' parameter constant. + */ + IDP_URL("idp.url"), + /** + * Represents the 'idpAUB.url' parameter constant. + */ + IDPAUB_URL("idpAUB.url"), + /** + * Represents the 'internal-authentication' parameter constant. + */ + INTERNAL_AUTH("internal-authentication"), + /** + * Represents the 'internal-ap' parameter constant. + */ + INTERNAL_AP("internal-ap"), + + /** + * Represents the 'samlIssuer' parameter constant. + */ + ISSUER("samlIssuer"), + /** + * Represents the 'samlIssuer.idp' parameter constant. + */ + ISSUER_IDP("samlIssuer.idp"), + /** + * Represents the 'samlIssuer.atp' parameter constant. + */ + ISSUER_ATP("samlIssuer.atp"), + + /** + * Represents the 'mandatory' parameter constant. + */ + MANDATORY("mandatory"), + /** + * Represents the 'mandatoryAttributeMissing' parameter constant. + */ + MANDATORY_ATTR_MISSING("mandatoryAttributeMissing"), + /** + * Represents the 'mandatoryConsentAttrMissing' parameter constant. + */ + MANDATORY_CONSENT_MISSING("mandatoryConsentAttrMissing"), + /** + * Represents the 'optional' parameter constant. + */ + OPTIONAL("optional"), + + /** + * Represents the 'no-consent-type' parameter constant. + */ + NO_CONSENT_TYPE("no-consent-type"), + /** + * Represents the 'no-consent-value' parameter constant. + */ + NO_CONSENT_VALUE("no-consent-value"), + + /** + * Represents the 'provider.name' parameter constant. + */ + PROVIDER_NAME_VALUE("providerName"), + /** + * Represents the 'cpeps.askconsent' parameter constant. + */ + PEPS_ASK_CONSENT("cpeps.askconsent"), + /** + * Represents the 'cpeps.askconsentvalue' parameter constant. + */ + PEPS_ASK_CONSENT_VALUE("cpeps.askconsentvalue"), + /** + * Represents the 'pepsAuth' parameter constant. + */ + PEPS_AUTH_CONSENT("pepsAuth"), + /** + * Represents the 'validation.bypass' parameter constant. + */ + PEPS_BYPASS("validation.bypass"), + /** + * Represents the 'cpeps.number' parameter constant. + */ + PEPS_NUMBER("cpeps.number"), + /** + * Represents the 'cpeps.specificapredirect.url' parameter constant. + */ + PEPS_SPECIFIC_URL("cpeps.specificapredirect.url"), + + /** + * Represents the 'qaaLevel' parameter constant. + */ + QAALEVEL("qaaLevel"), + + /** + * Represents the 'speps.redirectUrl' parameter constant. + */ + SPEPS_REDIRECT_URL("speps.redirectUrl"), + + /** + * Represents the 'sp.redirectUrl' parameter constant. + */ + SP_REDIRECT_URL("sp.redirectUrl"), + /** + * Represents the 'cpeps.redirectUrl' parameter constant. + */ + CPEPS_REDIRECT_URL("cpeps.redirectUrl"), + /** + * Represents the 'RelayState' parameter constant. + */ + RELAY_STATE("RelayState"), + /** + * Represents the 'remoteAddr' parameter constant. + */ + REMOTE_ADDR("remoteAddr"), + /** + * Represents the 'remoteUser' parameter constant. + */ + REMOTE_USER("remoteUser"), + + /** + * Represents the 'SAMLRequest' parameter constant. + */ + SAML_REQUEST("SAMLRequest"), + /** + * Represents the 'SAMLResponse' parameter constant. + */ + SAML_RESPONSE("SAMLResponse"), + /** + * Represents the 'SAMLFail' parameter constant. + */ + SAML_TOKEN_FAIL("SAMLFail"), + /** + * Represents the 'TokenId' parameter constant. + */ + SAML_TOKEN_ID("TokenId"), + /** + * Represents the 'inResponseTo' parameter constant. + */ + SAML_IN_RESPONSE_TO("inResponseTo"), + /** + * Represents the 'inResponseTo.idp' parameter constant. + */ + SAML_IN_RESPONSE_TO_IDP("inResponseTo.idp"), + /** + * Represents the 'inResponseTo.atp' parameter constant. + */ + SAML_IN_RESPONSE_TO_ATP("inResponseTo.atp"), + /** + * Represents the 'SignatureResponse' parameter constant. + */ + SIGNATURE_RESPONSE("SignatureResponse"), + + /** + * Represents the 'cPepsSession' parameter constant. + */ + SESSION_ID_URL("cPepsSession"), + /** + * Represents the 'spId' parameter constant. + */ + SP_ID("spId"), + /** + * Represents the 'spQaaLevel' parameter constant. + */ + SP_QAALEVEL("spQaaLevel"), + /** + * Represents the 'spUrl' parameter constant. + */ + SP_URL("spUrl"), + + /** + * Represents the 'allow.derivation.all' parameter constant. + */ + SPECIFIC_ALLOW_DERIVATION_ALL("allow.derivation.all"), + /** + * Represents the ''allow.unknowns parameter constant. + */ + SPECIFIC_ALLOW_UNKNOWNS("allow.unknowns"), + /** + * Represents the 'derivation.date.separator' parameter constant. + */ + SPECIFIC_DERIVATION_DATE_SEP("derivation.date.separator"), + /** + * Represents the 'derivation.month.position' parameter constant. + */ + SPECIFIC_DERIVATION_MONTH_POS("derivation.month.position"), + /** + * Represents the 'derivation.day.position' parameter constant. + */ + SPECIFIC_DERIVATION_DAY_POS("derivation.day.position"), + /** + * Represents the 'derivation.year.position' parameter constant. + */ + SPECIFIC_DERIVATION_YEAR_POS("derivation.year.position"), + + /** + * sp.authorized.parameters Represents the '' parameter constant. + */ + SPEPS_AUTHORIZED("sp.authorized.parameters"), + + /** + * Represents the 'spSector' constant value. + */ + SPSECTOR("spSector"), + /** + * Represents the 'spApplication' constant value. + */ + SPAPPLICATION("spApplication"), + /** + * Represents the 'spCountry' constant value. + */ + SPCOUNTRY("spCountry"), + /** + * Represents the 'spInstitution' constant value. + */ + SPINSTITUTION("spInstitution"), + /** + * Represents the 'storkAttribute.number' parameter constant. + */ + STORK_ATTRIBUTE_NUMBER("storkAttribute.number"), + /** + * Represents the 'storkAttributeValue.number' parameter constant. + */ + STORK_ATTRIBUTE_VALUE_NUMBER("storkAttributeValue.number"), + + /** + * Represents the 'username' parameter constant. + */ + USERNAME("username"), + + /** + * Represents the 'tooManyParameters' parameter constant. + */ + TOO_MANY_PARAMETERS("tooManyParameters"), + /** + * Represents the 'validation.active' parameter constant. + */ + VALIDATION_ACTIVE("validation.active"), + + /** + * Represents the 'x-forwarded-for' parameter constant. + */ + X_FORWARDED_FOR("x-forwarded-for"), + /** + * Represents the 'x-forwarded-host' parameter constant. + */ + X_FORWARDED_HOST("x-forwarded-host"), + /** + * Represents the 'XMLResponse' parameter constant. + */ + XML_RESPONSE("XMLResponse"), + + /** + * Represents the 'ap-cpeps.number' parameter constant. + */ + AP_PEPS_NUMBER("ap-cpeps.number"), + + /** + * Represents the 'atp.number' parameter constant. + */ + ATTRIBUTE_PROVIDER_NUMBER("atp.number"), + + /** + * Represents the 'apLinker' parameter constant. + */ + AP_LINKER("apLinker"), + + /** + * Represents the 'NOSEL' parameter constant (no attribute provider selected). + */ + AP_NO_SELECTION("NOSEL"), + + /** + * Represents the 'OCSEL' parameter constant (attribute provider in another country). + */ + AP_OTHER_COUNTRY("OCSEL"), + + /** + * Represents the '_provider' suffix parameter constant. + */ + AP_PROVIDER_SELECT_SUFFIX("_provider"), + + /** + * Represents the '_country' suffix parameter constant. + */ + AP_COUNTRY_SELECT_SUFFIX("_country"), + + /** + * Represents the 'next-ap' parameter constant. + */ + NEXT_AP("next-ap"), + + /** + * Represents the 'next-apeps' parameter constant. + */ + NEXT_APEPS("next-apeps"), + + /** + * Represents the 'attr-filter.number' parameter constant. + */ + ATTRIBUTES_FILTER_NUMBER("attr-filter.number"), + + /** + * Represents the 'atp.url' parameter constant. + */ + ATP_URL("atp.url"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param nValue The Constant value. + */ + PEPSParameters(final String nValue) { + this.value = nValue; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + return value; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base new file mode 100644 index 000000000..ae1f203f5 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base @@ -0,0 +1,353 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.UnsupportedEncodingException; +import java.util.Properties; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.bouncycastle.crypto.Digest; +import org.bouncycastle.util.encoders.Base64; + +import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; +import eu.stork.peps.auth.commons.exceptions.InvalidParameterPEPSException; + +/** + * This class holds static helper methods. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.75 $, $Date: 2010-11-23 00:05:35 $ + */ +public final class PEPSUtil { + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(PEPSUtil.class.getName()); + + /** + * Configurations object. + */ + private static Properties configs; + + /** + * Max prefix. + */ + private static final String MAX_PARAM_PREFIX = "max."; + + /** + * Code prefix to get error code. + */ + private static final String CODE_PARAM_SUFFIX = ".code"; + + /** + * param's size prefix to get max param size. + */ + private static final String MAX_PARAM_SUFFIX = ".size"; + + /** + * Message prefix to get error message. + */ + private static final String MSG_PARAM_SUFFIX = ".message"; + + /** + * Private constructor. Prevents the class from being instantiated. + */ + private PEPSUtil() { + // empty constructor + } + + /** + * Creates a single instance of this class and sets the properties. + * + * @param nConfigs The set of available configurations. + * + * @return The created PEPSUtil's class. + */ + public static PEPSUtil createInstance(final Properties nConfigs) { + if (nConfigs != null) { + PEPSUtil.configs = nConfigs; + } + return new PEPSUtil(); + } + + /** + * Getter for the Properties. + * + * @return configs The properties value. + */ + public Properties getConfigs() { + return configs; + } + + /** + * Setter for the Properties. + * + * @param nConfigs The new properties value. + */ + public static void setConfigs(final Properties nConfigs) { + if (nConfigs != null) { + PEPSUtil.configs = nConfigs; + } + } + + /** + * Returns the identifier of some configuration given a set of configurations + * and the corresponding configuration key. + * + * @param configKey The key that IDs some configuration. + * + * @return The configuration String value. + */ + public static String getConfig(final String configKey) { + return configs.getProperty(configKey); + } + + /** + * Validates the input paramValue identified by the paramName. + * + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + * + * @return true if the parameter is valid. + */ + public static boolean isValidParameter(final String paramName, + final String paramValue) { + + final String validationParam = + PEPSUtil.getConfig(PEPSParameters.VALIDATION_ACTIVE.toString()); + boolean retVal = true; + + final String paramConf = MAX_PARAM_PREFIX + paramName + MAX_PARAM_SUFFIX; + + if (PEPSValues.TRUE.toString().equals(validationParam)) { + final String paramSizeStr = PEPSUtil.getConfig(paramConf); + // Checking if the parameter size exists and if it's numeric + if (StringUtils.isNumeric(paramSizeStr)) { + final int maxParamSize = Integer.valueOf(paramSizeStr); + if (StringUtils.isEmpty(paramValue) + || (paramValue.length() > maxParamSize)) { + retVal = false; + LOG.warn("Invalid parameter [" + paramName + "] value " + paramValue); + } + } else { + retVal = false; + LOG.error("Missing " + paramConf + + " configuration in the pepsUtils.properties configuration file"); + } + } + return retVal; + } + + /** + * Validates the Parameter and throws an exception if an error occurs. Throws + * an InvalidParameterPEPSException runtime exception if the parameter is + * invalid. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + */ + public static void validateParameter(final String className, + final String paramName, final Object paramValue) { + + if (paramValue == null) { + PEPSUtil.validateParameter(className, paramName, ""); + } else { + PEPSUtil.validateParameter(className, paramName, paramValue.toString()); + } + } + + /** + * Validates the Parameters and throws an exception if an error occurs. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + */ + public static void validateParameter(final String className, + final String paramName, final String paramValue) { + + PEPSUtil.validateParameter(className, paramName, paramValue, + PEPSUtil.getErrorCode(paramName), PEPSUtil.getErrorMessage(paramName)); + } + + /** + * Validates the Parameters and throws an exception if an error occurs. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + * @param error The PEPSError to get error code and messages from configs. + */ + public static void validateParameter(final String className, + final String paramName, final String paramValue, final PEPSErrors error) { + + PEPSUtil.validateParameter(className, paramName, paramValue, + PEPSUtil.getConfig(error.errorCode()), + PEPSUtil.getConfig(error.errorMessage())); + } + + /** + * Validates the HTTP Parameter and throws an exception if an error occurs. + * Throws an InvalidParameterPEPSException runtime exception if the parameter + * is invalid. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + * @param errorCode The error code to include on the exception. + * @param errorMessage The error message to include on the exception. + */ + public static void validateParameter(final String className, + final String paramName, final String paramValue, final String errorCode, + final String errorMessage) { + + if (!isValidParameter(paramName, paramValue)) { + LOG.warn("Invalid parameter [" + paramName + "] value found at " + + className); + throw new InvalidParameterPEPSException(errorCode, errorMessage); + } + } + + /** + * Getter for the error code of some given error related to the input param. + * + * @param paramName The name of the parameter associated with the error. + * + * @return The code of the error. + */ + private static String getErrorCode(final String paramName) { + return getConfig(paramName + CODE_PARAM_SUFFIX); + } + + /** + * Getter for the error message of some given error related to the input + * parameter. + * + * @param paramName The name of the parameter associated with the message. + * + * @return The message for the error. + */ + private static String getErrorMessage(final String paramName) { + return getConfig(paramName + MSG_PARAM_SUFFIX); + } + + /** + * {@link Base64} encodes the input samlToken parameter. + * + * @param samlToken the SAML Token to be encoded. + * + * @return The Base64 String representing the samlToken. + * + * @see Base64#encode + */ + public static String encodeSAMLToken(final byte[] samlToken) { + try { + return new String(Base64.encode(samlToken), "UTF8"); + } catch (UnsupportedEncodingException e) { + LOG.error(PEPSErrors.INTERNAL_ERROR.errorMessage(), e); + return null; + } + } + + /** + * Decodes the {@link Base64} String input parameter representing a samlToken. + * + * @param samlToken the SAML Token to be decoded. + * + * @return The samlToken decoded bytes. + * + * @see Base64#decode + */ + public static byte[] decodeSAMLToken(final String samlToken) { + return Base64.decode(samlToken); + } + + /** + * Hashes a SAML token. Throws an InternalErrorPEPSException runtime exception + * if the Cryptographic Engine fails. + * + * @param samlToken the SAML Token to be hashed. + * + * @return byte[] with the hashed SAML Token. + */ + public static byte[] hashPersonalToken(final byte[] samlToken) { + try { + final String className = + PEPSUtil.getConfig(PEPSValues.HASH_DIGEST_CLASS.toString()); + + final Digest digest = + (Digest) Class.forName(className).getConstructor() + .newInstance((Object[]) null); + digest.update(samlToken, 0, samlToken.length); + + final int retLength = digest.getDigestSize(); + final byte[] ret = new byte[retLength]; + + digest.doFinal(ret, 0); + return ret; + + } catch (final Exception e) { + // For all those exceptions that could be thrown, we always log it and + // thrown an InternalErrorPEPSException. + LOG.error(PEPSErrors.HASH_ERROR.errorMessage(), e); + throw new InternalErrorPEPSException( + PEPSUtil.getConfig(PEPSErrors.HASH_ERROR.errorCode()), + PEPSUtil.getConfig(PEPSErrors.HASH_ERROR.errorMessage()), e); + } + } + + /** + * Gets the Stork error code in the error message if exists! + * + * @param errorMessage The message to get the error code if exists; + * + * @return the error code if exists. Returns null otherwise. + */ + public static String getStorkErrorCode(final String errorMessage) { + if (StringUtils.isNotBlank(errorMessage) + && errorMessage.indexOf(PEPSValues.ERROR_MESSAGE_SEP.toString()) >= 0) { + final String[] msgSplitted = + errorMessage.split(PEPSValues.ERROR_MESSAGE_SEP.toString()); + if (msgSplitted.length == 2 && StringUtils.isNumeric(msgSplitted[0])) { + return msgSplitted[0]; + } + } + return null; + } + + /** + * Gets the Stork error message in the saml message if exists! + * + * @param errorMessage The message to get in the saml message if exists; + * + * @return the error message if exists. Returns the original message + * otherwise. + */ + public static String getStorkErrorMessage(final String errorMessage) { + if (StringUtils.isNotBlank(errorMessage) + && errorMessage.indexOf(PEPSValues.ERROR_MESSAGE_SEP.toString()) >= 0) { + final String[] msgSplitted = + errorMessage.split(PEPSValues.ERROR_MESSAGE_SEP.toString()); + if (msgSplitted.length == 2 && StringUtils.isNumeric(msgSplitted[0])) { + return msgSplitted[1]; + } + } + return errorMessage; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base new file mode 100644 index 000000000..568c25053 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base @@ -0,0 +1,325 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the value constants. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.17 $, $Date: 2011-07-07 20:48:45 $ + */ +public enum PEPSValues { + + /** + * Represents the 'all' constant value. + */ + ALL("all"), + /** + * Represents the 'none' constant value. + */ + NONE("none"), + /** + * Represents the 'true' constant value. + */ + TRUE("true"), + /** + * Represents the 'false' constant value. + */ + FALSE("false"), + /** + * Represents the empty string constant value. + */ + EMPTY_STRING(""), + + /** + * Represents the ',' separator constant value. + */ + ATTRIBUTE_VALUE_SEP(","), + /** + * Represents the ';' separator constant value. + */ + ATTRIBUTE_SEP(";"), + /** + * Represents the ':' separator constant value. + */ + ATTRIBUTE_TUPLE_SEP(":"), + /** + * Represents the '/' separator constant value. + */ + EID_SEPARATOR("/"), + /** + * Represents the ' - ' separator constant value. + */ + ERROR_MESSAGE_SEP(" - "), + /** + * Represents the '#' parameter constant value. + */ + LOGGER_SEP("#"), + /** + * Represents the 'NOT_AVAILABLE' parameter constant value. + */ + NOT_AVAILABLE("NotAvailable"), + /** + * Represents the ';' parameter constant value. + */ + SPEPS_AUTHORIZED_SEP(";"), + + /** + * Represents the 'ap' constant value. + */ + AP("ap"), + /** + * Represents the 'C-PEPS' constant value. + */ + CPEPS("C-PEPS"), + /** + * Represents the 'cpeps' constant value. + */ + CPEPS_PREFIX("cpeps"), + /** + * Represents the 'peps' constant value. + */ + PEPS("peps"), + /** + * Represents the '-PEPS' constant value. + */ + PEPS_SUFFIX("-PEPS"), + /** + * Represents the 'SP' constant value. + */ + SP("SP"), + /** + * Represents the 'S-PEPS' constant value. + */ + SPEPS("S-PEPS"), + /** + * Represents the 'speps' constant value. + */ + SPEPS_PREFIX("speps"), + /** + * Represents the 'sp.default.parameters' constant value. + */ + DEFAULT("sp.default.parameters"), + /** + * Represents the default saml id constant value. + */ + DEFAULT_SAML_ID("1"), + /** + * Represents the 'hashDigest.className' constant value. + */ + HASH_DIGEST_CLASS("hashDigest.className"), + + /** + * Represents the 'eu.stork.communication.requests' constant value. + */ + STORK_PACKAGE_REQUEST_LOGGER_VALUE("eu.stork.communication.requests"), + /** + * Represents the 'eu.stork.communication.responses' constant value. + */ + STORK_PACKAGE_RESPONSE_LOGGER_VALUE("eu.stork.communication.responses"), + + /** + * Represents the 'S-PEPS receives request from SP' constant value. + */ + SP_REQUEST("S-PEPS receives request from SP"), + /** + * Represents the 'Get Citizen Consent' constant value. + */ + CITIZEN_CONSENT_LOG("Get Citizen Consent"), + /** + * Represents the 'C-PEPS receives request from S-PEPS' constant value. + */ + CPEPS_REQUEST("C-PEPS receives request from S-PEPS"), + /** + * Represents the 'C-PEPS generates response to S-PEPS' constant value. + */ + CPEPS_RESPONSE("C-PEPS generates response to S-PEPS"), + /** + * Represents the 'S-PEPS generates request to C-PEPS' constant value. + */ + SPEPS_REQUEST("S-PEPS generates request to C-PEPS"), + /** + * Represents the 'S-PEPS receives response from C-PEPS' constant value. + */ + SPEPS_RESPONSE("S-PEPS receives response from C-PEPS"), + /** + * Represents the 'S-PEPS generates response to SP' constant value. + */ + SP_RESPONSE("S-PEPS generates response to SP"), + /** + * Represents the 'Success' constant value. + */ + SUCCESS("Success"), + /** + * Represents the December's month number constant value. + */ + LAST_MONTH("12"), + /** + * Represents the yyyyMM constant value. + */ + NO_DAY_DATE_FORMAT("yyyyMM"), + + /** + * Represents the 'attrValue' constant value. + */ + ATTRIBUTE("attrValue"), + /** + * Represents the 'derivedAttr' constant value. + */ + DERIVE_ATTRIBUTE("deriveAttr"), + /** + * Represents the 'storkAttribute' constant value. + */ + STORK_ATTRIBUTE("storkAttribute"), + + /** + * Represents the 'properties' constant value. + */ + PROPERTIES("properties"), + /** + * Represents the 'referer' constant value. + */ + REFERER("referer"), + /** + * Represents the 'host' constant value. + */ + HOST("host"), + /** + * Represents the 'spid' constant value. + */ + SPID("spid"), + /** + * Represents the 'domain' constant value. + */ + DOMAIN("domain"), + /** + * Represents the '.validation' constant value. + */ + VALIDATION_SUFFIX(".validation"), + /** + * Represents the 'jsessionid' constant value. + */ + EQUAL("="), + /** + * Represents the 'HttpOnly' constant value. + */ + HTTP_ONLY("HttpOnly"), + /** + * Represents the 'SET-COOKIE' constant value. + */ + JSSESSION("JSESSIONID"), + /** + * Represents the '=' constant value. + */ + SETCOOKIE("SET-COOKIE"), + /** + * Represents the ';' constant value. + */ + SEMICOLON(";"), + /** + * Represents the ' ' constant value. + */ + SPACE(" "), + /** + * Represents the 'atp' constant value. + */ + APROVIDER_PREFIX("atp"), + /** + * Represents the 'ap-cpeps' constant value. + */ + AP_CPEPS_PREFIX("ap-cpeps"), + /** + * Represents the 'attr-filter' constant value. + */ + AP_ATTRFILTER_PREFIX("attr-filter"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param val The Constant value. + */ + PEPSValues(final String val) { + + this.value = val; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + + return value; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".id". + * + * @param index the number. + * + * @return The concatenated String value. + */ + public String index(final int index) { + + return value + index + ".id"; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".value". + * + * @param index the number. + * + * @return The concatenated string value. + */ + public String value(final int index) { + + return value + index + ".value"; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".name". + * + * @param index the number. + * + * @return The concatenated String value. + */ + public String name(final int index) { + + return value + index + ".name"; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".url". + * + * @param index the number. + * + * @return The concatenated String value. + */ + public String url(final int index) { + + return value + index + ".url"; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base new file mode 100644 index 000000000..bb9b3b694 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base @@ -0,0 +1,323 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; + +/** + * This class is a bean used to store the information relative to the + * PersonalAttribute. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.22 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class PersonalAttribute implements Serializable, Cloneable { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 2612951678412632174L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(PersonalAttribute.class + .getName()); + + /** + * Name of the personal attribute. + */ + private String name; + + /** + * Values of the personal attribute. + */ + private List value = new ArrayList(); + + /** + * Complex values of the personal attribute. + */ + private Map complexValue = new HashMap(); + + /** + * Is the personal attribute mandatory? + */ + private transient boolean required; + + /** + * Returned status of the attribute from the IdP. + */ + private String status; + + /** + * Name of the personal attribute. + */ + private String friendlyName; + + /** + * Empty Constructor. + */ + public PersonalAttribute() { + super(); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final List attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's complex value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final Map attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setComplexValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Object clone() { + + try { + final PersonalAttribute personalAttr = (PersonalAttribute) super.clone(); + personalAttr.setIsRequired(this.isRequired()); + personalAttr.setName(this.getName()); + personalAttr.setStatus(this.getStatus()); + if (!isEmptyValue()) { + final List val = + (List) ((ArrayList) this.getValue()).clone(); + personalAttr.setValue(val); + } + if (!isEmptyComplexValue()) { + final Map complexVal = + (Map) ((HashMap) this + .getComplexValue()).clone(); + personalAttr.setComplexValue(complexVal); + } + return personalAttr; + } catch (final CloneNotSupportedException e) { + // assert false; + LOG.trace("Nothing to do."); + throw new InternalErrorPEPSException( + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorMessage()), e); + } + } + + /** + * Getter for the required value. + * + * @return The required value. + */ + public boolean isRequired() { + return required; + } + + /** + * Setter for the required value. + * + * @param attrIsRequired this attribute? + */ + public void setIsRequired(final boolean attrIsRequired) { + this.required = attrIsRequired; + } + + /** + * Getter for the name value. + * + * @return The name value. + */ + public String getName() { + return name; + } + + /** + * Setter for the name value. + * + * @param attrName The personal attribute name. + */ + public void setName(final String attrName) { + this.name = attrName; + } + + /** + * Getter for the value. + * + * @return The list of values. + */ + public List getValue() { + return value; + } + + /** + * Setter for the list of values. + * + * @param attrValue The personal attribute value. + */ + public void setValue(final List attrValue) { + if (attrValue != null) { + this.value = attrValue; + } + } + + /** + * Getter for the status. + * + * @return The status value. + */ + public String getStatus() { + return status; + } + + /** + * Setter for the status value. + * + * @param attrStatus The personal attribute status. + */ + public void setStatus(final String attrStatus) { + this.status = attrStatus; + } + + /** + * Getter for the complex value. + * + * @return The complex value. + */ + public Map getComplexValue() { + return complexValue; + } + + /** + * Setter for the complex value. + * + * @param complexVal The personal attribute Complex value. + */ + public void setComplexValue(final Map complexVal) { + if (complexVal != null) { + this.complexValue = complexVal; + } + } + + /** + * Getter for the personal's friendly name. + * + * @return The personal's friendly name value. + */ + public String getFriendlyName() { + return friendlyName; + } + + /** + * Setter for the personal's friendly name. + * + * @param fName The personal's friendly name. + */ + public void setFriendlyName(final String fName) { + this.friendlyName = fName; + } + + /** + * Return true the value is empty. + * + * @return True if the value is empty "[]"; + */ + public boolean isEmptyValue() { + return value.isEmpty() || (value.size() == 1 && value.get(0).length() == 0); + } + + /** + * Returns true if the Complex Value is empty. + * + * @return True if the Complex Value is empty; + */ + public boolean isEmptyComplexValue() { + return complexValue.isEmpty(); + } + + /** + * Returns true if the Status is empty. + * + * @return True if the Status is empty; + */ + public boolean isEmptyStatus() { + return (status == null || status.length() == 0); + } + + /** + * Prints the PersonalAttribute in the following format. + * name:required:[v,a,l,u,e,s]|[v=a,l=u,e=s]:status; + * + * @return The PersonalAttribute as a string. + */ + public String toString() { + final StringBuilder strBuild = new StringBuilder(); + + AttributeUtil.appendIfNotNull(strBuild, getName()); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, String.valueOf(isRequired())); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + strBuild.append('['); + + if (isEmptyValue()) { + if (!isEmptyComplexValue()) { + AttributeUtil.appendIfNotNull(strBuild, AttributeUtil.mapToString( + getComplexValue(), PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + } else { + AttributeUtil.appendIfNotNull( + strBuild, + AttributeUtil.listToString(getValue(), + PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + + strBuild.append(']'); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, getStatus()); + strBuild.append(PEPSValues.ATTRIBUTE_SEP.toString()); + + return strBuild.toString(); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base new file mode 100644 index 000000000..d33ccfe18 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base @@ -0,0 +1,305 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.StringTokenizer; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +/** + * This class is a bean used to store the information relative to the + * PersonalAttributeList. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.27 $, $Date: 2010-11-18 22:54:56 $ + * + * @see PersonalAttribute + */ +@SuppressWarnings("PMD") +public final class PersonalAttributeList extends + HashMap implements IPersonalAttributeList{ + + /** + * Logger object. + */ + private static final Logger LOG = Logger + .getLogger(PersonalAttributeList.class.getName()); + + /** + * Serial id. + */ + private static final long serialVersionUID = 7375127363889975062L; + + /** + * Hash with the latest fetched attribute name alias. + */ + private final transient Map latestAttrAlias = + new HashMap(); + + /** + * Hash with mapping number of alias or the attribute name. + */ + private final transient Map attrAliasNumber = + new HashMap(); + + /** + * Default constructor. + */ + public PersonalAttributeList() { + // The best practices recommend to call the super constructor. + super(); + } + + /** + * Constructor with initial capacity for the PersonalAttributeList size. + * + * @param capacity The initial capacity for the PersonalAttributeList. + */ + public PersonalAttributeList(final int capacity) { + super(capacity); + } + + /** + * {@inheritDoc} + */ + public Iterator iterator() { + return this.values().iterator(); + } + + /** + * {@inheritDoc} + */ + public PersonalAttribute get(final Object key) { + String attrName = (String) key; + + if (this.latestAttrAlias.containsKey(key)) { + attrName = attrName + this.latestAttrAlias.get(key); + } else { + if (this.attrAliasNumber.containsKey(key)) { + this.latestAttrAlias.put(attrName, this.attrAliasNumber.get(key)); + } + } + return super.get(attrName); + } + + /** + * {@inheritDoc} + */ + public void add(final PersonalAttribute value) { + if (value != null) { + this.put(value.getName(), value); + } + } + + /** + * {@inheritDoc} + */ + public PersonalAttribute put(final String key, final PersonalAttribute val) { + if (StringUtils.isNotEmpty(key) && val != null) { + // Validate if attribute name already exists! + String attrAlias = key; + if (this.containsKey(key)) { + if (!val.isEmptyValue() && StringUtils.isNumeric(val.getValue().get(0))) { + final String attrValue = val.getValue().get(0); + attrAlias = key + attrValue; + this.attrAliasNumber.put(key, Integer.valueOf(attrValue)); + } else { + final PersonalAttribute attr = super.get(key); + if (!attr.isEmptyValue() + && StringUtils.isNumeric(attr.getValue().get(0))) { + attrAlias = key + attr.getValue().get(0); + super.put(key, (PersonalAttribute) attr); + this.attrAliasNumber.put(key, null); + } + } + } + return super.put(attrAlias, val); + } else { + return null; + } + } + + /** + * {@inheritDoc} + */ + public void populate(final String attrList) { + final StringTokenizer strToken = + new StringTokenizer(attrList, PEPSValues.ATTRIBUTE_SEP.toString()); + + while (strToken.hasMoreTokens()) { + final PersonalAttribute persAttr = new PersonalAttribute(); + String[] tuples = + strToken.nextToken().split(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(), + AttributeConstants.NUMBER_TUPLES.intValue()); + + // Convert to the new format if needed! + tuples = convertFormat(tuples); + + if (AttributeUtil.hasValidTuples(tuples)) { + final int attrValueIndex = + AttributeConstants.ATTR_VALUE_INDEX.intValue(); + final String tmpAttrValue = + tuples[attrValueIndex].substring(1, + tuples[attrValueIndex].length() - 1); + final String[] vals = + tmpAttrValue.split(PEPSValues.ATTRIBUTE_VALUE_SEP.toString()); + + persAttr.setName(tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()]); + persAttr.setIsRequired(Boolean + .valueOf(tuples[AttributeConstants.ATTR_TYPE_INDEX.intValue()])); + + // check if it is a complex value + if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_ADDRESS_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_NEWATTRIBUTE_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + + else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_HASDEGREE_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_MANDATECONTENT_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + else + { + persAttr.setValue(createValues(vals)); + } + + if (tuples.length == AttributeConstants.NUMBER_TUPLES.intValue()) { + persAttr.setStatus(tuples[AttributeConstants.ATTR_STATUS_INDEX + .intValue()]); + } + this.put(tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()], + persAttr); + + } else { + LOG.warn("Invalid personal attribute list tuples"); + } + + } + } + + /** + * Returns a copy of this IPersonalAttributeList instance. + * + * @return The copy of this IPersonalAttributeList. + */ + public Object clone() { + return (PersonalAttributeList) super.clone(); + } + + /** + * Creates a string in the following format. + * + * attrName:attrType:[attrValue1,attrValue2=attrComplexValue]:attrStatus; + * + * @return {@inheritDoc} + */ + @Override + public String toString() { + final Iterator> itAttrs = + this.entrySet().iterator(); + final StringBuilder strBuilder = new StringBuilder(); + + while (itAttrs.hasNext()) { + final Entry attrEntry = itAttrs.next(); + final PersonalAttribute attr = attrEntry.getValue(); + strBuilder.append(attr.toString()); + } + + return strBuilder.toString(); + } + + /** + * Validates and creates the attribute's complex values. + * + * @param values The complex values. + * + * @return The {@link Map} with the complex values. + * + * @see Map + */ + private Map createComplexValue(final String[] values) { + final Map complexValue = new HashMap(); + for (final String val : values) { + final String[] tVal = val.split("="); + if (StringUtils.isNotEmpty(val) && tVal.length == 2) { + complexValue.put(tVal[0], AttributeUtil.unescape(tVal[1])); + } + } + return complexValue; + } + + /** + * Validates and creates the attribute values. + * + * @param vals The attribute values. + * + * @return The {@link List} with the attribute values. + * + * @see List + */ + private List createValues(final String[] vals) { + final List values = new ArrayList(); + for (final String val : vals) { + if (StringUtils.isNotEmpty(val)) { + values.add(AttributeUtil.unescape(val)); + } + } + return values; + } + + /** + * Converts the attribute tuple (attrName:attrType...) to the new format. + * + * @param tuples The attribute tuples to convert. + * + * @return The attribute tuples in the new format. + */ + private String[] convertFormat(final String[] tuples) { + final String[] newFormatTuples = + new String[AttributeConstants.NUMBER_TUPLES.intValue()]; + if (tuples != null) { + System.arraycopy(tuples, 0, newFormatTuples, 0, tuples.length); + + for (int i = tuples.length; i < newFormatTuples.length; i++) { + if (i == AttributeConstants.ATTR_VALUE_INDEX.intValue()) { + newFormatTuples[i] = "[]"; + } else { + newFormatTuples[i] = ""; + } + } + } + return newFormatTuples; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base new file mode 100644 index 000000000..33160f2ac --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base @@ -0,0 +1,426 @@ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +public class STORKAttrQueryRequest implements Serializable, Cloneable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 4778480781609392750L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAttrQueryRequest.class + .getName()); + + /** The samlId. */ + private String samlId; + + /** The destination. */ + private String destination; + + /** The distinguished name. */ + private String distinguishedName; + + /** The e id sector share. */ + private boolean eIDSectorShare; + + /** The e id cross sector share. */ + private boolean eIDCrossSectorShare; + + /** The e id cross border share. */ + private boolean eIDCrossBorderShare; + + /** The personal attribute list. */ + private IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** The qaa. */ + private int qaa; + + /** The token saml. */ + private byte[] tokenSaml = new byte[0]; + + /** The issuer. */ + private String issuer; + + /** The service provider sector. */ + private String spSector; + + /** The service provider institution. */ + private String spInstitution; + + /** The service provider application. */ + private String spApplication; + + /** The service provider country. */ + private String spCountry; + + /** The country. */ + private String country; + + /** The citizen country code. */ + private String citizenCountry; + + /** The Service Provider ID. */ + private String sPID; + + /** The Alias used at the keystore for saving this certificate. */ + private String alias; + + /** + * Gets the SP's Certificate Alias. + * + * @return alias The SP's Certificate Alias. + */ + public String getAlias() { + return alias; + } + + /** + * Sets the SP's Certificate Alias. + * + * @param nAlias The SP's Certificate Alias. + */ + public void setAlias(final String nAlias) { + this.alias = nAlias; + } + + /** + * Gets the SP ID. + * + * @return sPID The SP ID. + */ + public String getSPID() { + return sPID; + } + + /** + * Sets the SP ID. + * + * @param sPId The new sp samlId. + */ + public void setSPID(final String sPId) { + this.sPID = sPId; + } + + /** + * Gets the citizen country code. + * + * @return The citizen country code value. + */ + public String getCitizenCountryCode() { + return citizenCountry; + } + + /** + * Sets the citizen country code. + * + * @param countryCode the new citizen country code value. + */ + public void setCitizenCountryCode(final String countryCode) { + this.citizenCountry = countryCode; + } + + /** + * Gets the sp country. + * + * @return The sp country value. + */ + public String getSpCountry() { + return spCountry; + } + + /** + * Sets the sp country. + * + * @param sPCountry the new sp country value. + */ + public void setSpCountry(final String sPCountry) { + this.spCountry = sPCountry; + } + + /** + * Gets the issuer. + * + * @return The issuer value. + */ + public String getIssuer() { + return issuer; + } + + /** + * Sets the issuer. + * + * @param samlIssuer the new issuer value. + */ + public void setIssuer(final String samlIssuer) { + this.issuer = samlIssuer; + } + + /** + * Gets the SAML Token. + * + * @return The SAML Token value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Sets the SAML Token. + * + * @param samlToken The new SAML Token value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Gets the country. + * + * @return The country value. + */ + public String getCountry() { + return country; + } + + /** + * Sets the country. + * + * @param nCountry the new country value. + */ + public void setCountry(final String nCountry) { + this.country = nCountry; + } + + /** + * Getter for the qaa value. + * + * @return The qaa value value. + */ + public int getQaa() { + return qaa; + } + + /** + * Setter for the qaa value. + * + * @param qaaLevel The new qaa value. + */ + public void setQaa(final int qaaLevel) { + this.qaa = qaaLevel; + } + + /** + * Getter for the destination value. + * + * @return The destination value. + */ + public String getDestination() { + return destination; + } + + /** + * Setter for the destination value. + * + * @param detination the new destination value. + */ + public void setDestination(final String detination) { + this.destination = detination; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param newSamlId the new samlId value. + */ + public void setSamlId(final String newSamlId) { + this.samlId = newSamlId; + } + + + /** + * Getter for the attributeList value. + * + * @return The attributeList value. + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the attributeList value. + * + * @param attrList the personal attribute list value. + * + * @see IPersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the distinguishedName value. + * + * @return The distinguishedName value. + */ + public String getDistinguishedName() { + return distinguishedName; + } + + /** + * Setter for the distinguishedName value. + * + * @param certDN the distinguished name value. + */ + public void setDistinguishedName(final String certDN) { + this.distinguishedName = certDN; + } + + /** + * Gets the service provider sector. + * + * @return The service provider sector value. + */ + public String getSpSector() { + return spSector; + } + + /** + * Sets the service provider sector. + * + * @param samlSPSector the new service provider sector value. + */ + public void setSpSector(final String samlSPSector) { + this.spSector = samlSPSector; + } + + /** + * Gets the service provider institution. + * + * @return The service provider institution value. + */ + public String getSpInstitution() { + return spInstitution; + } + + /** + * Sets the service provider institution. + * + * @param samlSPInst the new service provider institution value. + */ + public void setSpInstitution(final String samlSPInst) { + this.spInstitution = samlSPInst; + } + + /** + * Gets the service provider application. + * + * @return The service provider application value. + */ + public String getSpApplication() { + return spApplication; + } + + /** + * Sets the service provider application. + * + * @param samlSPApp the new service provider application value. + */ + public void setSpApplication(final String samlSPApp) { + this.spApplication = samlSPApp; + } + + /** + * Checks if is eId sector share. + * + * @return true, if is eId sector share. + */ + public boolean isEIDSectorShare() { + return eIDSectorShare; + } + + /** + * Sets the eId sector share. + * + * @param eIdSectorShare the new eId sector share value. + */ + public void setEIDSectorShare(final boolean eIdSectorShare) { + this.eIDSectorShare = eIdSectorShare; + } + + /** + * Checks if is eId cross sector share. + * + * @return true, if is eId cross sector share. + */ + public boolean isEIDCrossSectorShare() { + return eIDCrossSectorShare; + } + + /** + * Sets the eId cross sector share. + * + * @param eIdCrossSectorShare the new eId cross sector share value. + */ + public void setEIDCrossSectorShare(final boolean eIdCrossSectorShare) { + this.eIDCrossSectorShare = eIdCrossSectorShare; + } + + /** + * Checks if is eId cross border share. + * + * @return true, if is eId cross border share. + */ + public boolean isEIDCrossBorderShare() { + return eIDCrossBorderShare; + } + + /** + * Sets the eId cross border share. + * + * @param eIdCrossBorderShare the new eId cross border share value. + */ + public void setEIDCrossBorderShare(final boolean eIdCrossBorderShare) { + this.eIDCrossBorderShare = eIdCrossBorderShare; + } + + /** + * Returns a copy of this STORKAttrQueryRequest instance. + * + * @return The copy of this STORKAttrQueryRequest. + * @throws CloneNotSupportedException on clone exception + */ + @Override + public Object clone() throws CloneNotSupportedException{ + STORKAttrQueryRequest storkAttrQueryReq = null; + storkAttrQueryReq = (STORKAttrQueryRequest) super.clone(); + storkAttrQueryReq.setPersonalAttributeList(getPersonalAttributeList()); + storkAttrQueryReq.setTokenSaml(getTokenSaml()); + return storkAttrQueryReq; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base new file mode 100644 index 000000000..215b978dc --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base @@ -0,0 +1,301 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import org.apache.log4j.Logger; +import org.joda.time.DateTime; + +public class STORKAttrQueryResponse { + + /** Response Id. */ + private String samlId; + + /** Request failed? */ + private boolean fail; + + /** Status code. */ + private String statusCode; + + /** Secondary status code. */ + private String subStatusCode; + + /** Audience restriction. */ + private transient String audienceRest; + + /** Error message. */ + private String message; + + /** Id of the request that originated this response. */ + private String inResponseTo; + + /** Expiration date. */ + private DateTime notOnOrAfter; + + /** Creation date. */ + private DateTime notBefore; + + /** The SAML token. */ + private byte[] tokenSaml = new byte[0]; + + /** Country. */ + private String country; + + /** Citizen's personal attribute list. */ + private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAttrQueryResponse.class.getName()); + + /** + * Getter for the subStatusCode. + * + * @return The subStatusCode value. + */ + public String getSubStatusCode() { + return subStatusCode; + } + + /** + * Setter for the subStatusCode. + * + * @param samlSubStatusCode the new subStatusCode value. + */ + public void setSubStatusCode(final String samlSubStatusCode) { + this.subStatusCode = samlSubStatusCode; + } + + /** + * Getter for audienceRest. + * + * @return The audienceRest value. + */ + public String getAudienceRestriction() { + return audienceRest; + } + + /** + * Setter for audienceRest. + * + * @param audRest the new audienceRest value. + */ + public void setAudienceRestriction(final String audRest) { + this.audienceRest = audRest; + } + + /** + * Getter for the samlToken. + * + * @return The samlToken value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Setter for samlToken. + * + * @param samlToken the new tokenSaml value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Getter for the country name. + * + * @return The country name value. + */ + public String getCountry() { + return country; + } + + /** + * Setter for the country name. + * + * @param cCountry the new country name value. + */ + public void setCountry(final String cCountry) { + this.country = cCountry; + } + + /** + * Getter for pal value. + * + * @return The pal value. + * + * @see PersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the inResponseTo value. + * + * @return The inResponseTo value. + */ + public String getInResponseTo() { + return inResponseTo; + } + + /** + * Setter for the inResponseTo value. + * + * @param samlInResponseTo the new inResponseTo value. + */ + public void setInResponseTo(final String samlInResponseTo) { + this.inResponseTo = samlInResponseTo; + } + + /** + * Getter for the fail value. + * + * @return The fail value. + */ + public boolean isFail() { + return fail; + } + + /** + * Setter for the fail value. + * + * @param failVal the new fail value. + */ + public void setFail(final boolean failVal) { + this.fail = failVal; + } + + /** + * Getter for the message value. + * + * @return The message value. + */ + public String getMessage() { + return message; + } + + /** + * Setter for the message value. + * + * @param msg the new message value. + */ + public void setMessage(final String msg) { + this.message = msg; + } + + /** + * Getter for the statusCode value. + * + * @return The statusCode value. + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Setter for the statusCode value. + * + * @param status the new statusCode value. + */ + public void setStatusCode(final String status) { + this.statusCode = status; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param nSamlId the new samlId value. + */ + public void setSamlId(final String nSamlId) { + this.samlId = nSamlId; + } + + /** + * Getter for the notOnOrAfter value. + * + * @return The notOnOrAfter value. + * + * @see DateTime + */ + public DateTime getNotOnOrAfter() { + return this.notOnOrAfter; + } + + /** + * Setter for the notOnOrAfter value. + * + * @param nOnOrAfter the new notOnOrAfter value. + * + * @see DateTime + */ + public void setNotOnOrAfter(final DateTime nOnOrAfter) { + this.notOnOrAfter = nOnOrAfter; + } + + /** + * Getter for the notBefore value. + * + * @return The notBefore value. + * + * @see DateTime + */ + public DateTime getNotBefore() { + return notBefore; + } + + /** + * Setter for the notBefore value. + * + * @param nBefore the new notBefore value. + * + * @see DateTime + */ + public void setNotBefore(final DateTime nBefore) { + this.notBefore = nBefore; + } + +} + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base new file mode 100644 index 000000000..2354d0eb1 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base @@ -0,0 +1,495 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +/** + * This class is a bean used to store the information relative to the + * STORKAuthnRequest (SAML Token Request). + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.21 $, $Date: 2011-02-17 22:44:34 $ + */ +public final class STORKAuthnRequest implements Serializable, Cloneable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 4778480781609392750L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAuthnRequest.class + .getName()); + + /** The samlId. */ + private String samlId; + + /** The assertion consumer service url. */ + private String serviceURL; + + /** The destination. */ + private String destination; + + /** The provider name. */ + private String providerName; + + /** The distinguished name. */ + private String distinguishedName; + + /** The e id sector share. */ + private boolean eIDSectorShare; + + /** The e id cross sector share. */ + private boolean eIDCrossSectorShare; + + /** The e id cross border share. */ + private boolean eIDCrossBorderShare; + + /** The personal attribute list. */ + private IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** The qaa. */ + private int qaa; + + /** The token saml. */ + private byte[] tokenSaml = new byte[0]; + + /** The issuer. */ + private String issuer; + + /** The service provider sector. */ + private String spSector; + + /** The service provider institution. */ + private String spInstitution; + + /** The service provider application. */ + private String spApplication; + + /** The service provider country. */ + private String spCountry; + + /** The country. */ + private String country; + + /** The citizen country code. */ + private String citizenCountry; + + /** The Service Provider ID. */ + private String sPID; + + /** The Alias used at the keystore for saving this certificate. */ + private String alias; + + /** + * Gets the SP's Certificate Alias. + * + * @return alias The SP's Certificate Alias. + */ + public String getAlias() { + return alias; + } + + /** + * Sets the SP's Certificate Alias. + * + * @param nAlias The SP's Certificate Alias. + */ + public void setAlias(final String nAlias) { + this.alias = nAlias; + } + + /** + * Gets the SP ID. + * + * @return sPID The SP ID. + */ + public String getSPID() { + return sPID; + } + + /** + * Sets the SP ID. + * + * @param sPId The new sp samlId. + */ + public void setSPID(final String sPId) { + this.sPID = sPId; + } + + /** + * Gets the citizen country code. + * + * @return The citizen country code value. + */ + public String getCitizenCountryCode() { + return citizenCountry; + } + + /** + * Sets the citizen country code. + * + * @param countryCode the new citizen country code value. + */ + public void setCitizenCountryCode(final String countryCode) { + this.citizenCountry = countryCode; + } + + /** + * Gets the sp country. + * + * @return The sp country value. + */ + public String getSpCountry() { + return spCountry; + } + + /** + * Sets the sp country. + * + * @param sPCountry the new sp country value. + */ + public void setSpCountry(final String sPCountry) { + this.spCountry = sPCountry; + } + + /** + * Gets the issuer. + * + * @return The issuer value. + */ + public String getIssuer() { + return issuer; + } + + /** + * Sets the issuer. + * + * @param samlIssuer the new issuer value. + */ + public void setIssuer(final String samlIssuer) { + this.issuer = samlIssuer; + } + + /** + * Gets the SAML Token. + * + * @return The SAML Token value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Sets the SAML Token. + * + * @param samlToken The new SAML Token value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Gets the country. + * + * @return The country value. + */ + public String getCountry() { + return country; + } + + /** + * Sets the country. + * + * @param nCountry the new country value. + */ + public void setCountry(final String nCountry) { + this.country = nCountry; + } + + /** + * Getter for the qaa value. + * + * @return The qaa value value. + */ + public int getQaa() { + return qaa; + } + + /** + * Setter for the qaa value. + * + * @param qaaLevel The new qaa value. + */ + public void setQaa(final int qaaLevel) { + this.qaa = qaaLevel; + } + + /** + * Getter for the serviceURL value. + * + * @return The serviceURL value. + */ + public String getAssertionConsumerServiceURL() { + return serviceURL; + } + + /** + * Setter for the serviceURL value. + * + * @param newServiceURL the assertion consumer service URL. + */ + public void setAssertionConsumerServiceURL(final String newServiceURL) { + this.serviceURL = newServiceURL; + } + + /** + * Getter for the destination value. + * + * @return The destination value. + */ + public String getDestination() { + return destination; + } + + /** + * Setter for the destination value. + * + * @param detination the new destination value. + */ + public void setDestination(final String detination) { + this.destination = detination; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param newSamlId the new samlId value. + */ + public void setSamlId(final String newSamlId) { + this.samlId = newSamlId; + } + + /** + * Getter for the providerName value. + * + * @return The provider name value. + */ + public String getProviderName() { + return providerName; + } + + /** + * Setter for the providerName value. + * + * @param samlProvider the provider name value. + */ + public void setProviderName(final String samlProvider) { + this.providerName = samlProvider; + } + + /** + * Getter for the attributeList value. + * + * @return The attributeList value. + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the attributeList value. + * + * @param attrList the personal attribute list value. + * + * @see IPersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the distinguishedName value. + * + * @return The distinguishedName value. + */ + public String getDistinguishedName() { + return distinguishedName; + } + + /** + * Setter for the distinguishedName value. + * + * @param certDN the distinguished name value. + */ + public void setDistinguishedName(final String certDN) { + this.distinguishedName = certDN; + } + + /** + * Gets the service provider sector. + * + * @return The service provider sector value. + */ + public String getSpSector() { + return spSector; + } + + /** + * Sets the service provider sector. + * + * @param samlSPSector the new service provider sector value. + */ + public void setSpSector(final String samlSPSector) { + this.spSector = samlSPSector; + } + + /** + * Gets the service provider institution. + * + * @return The service provider institution value. + */ + public String getSpInstitution() { + return spInstitution; + } + + /** + * Sets the service provider institution. + * + * @param samlSPInst the new service provider institution value. + */ + public void setSpInstitution(final String samlSPInst) { + this.spInstitution = samlSPInst; + } + + /** + * Gets the service provider application. + * + * @return The service provider application value. + */ + public String getSpApplication() { + return spApplication; + } + + /** + * Sets the service provider application. + * + * @param samlSPApp the new service provider application value. + */ + public void setSpApplication(final String samlSPApp) { + this.spApplication = samlSPApp; + } + + /** + * Checks if is eId sector share. + * + * @return true, if is eId sector share. + */ + public boolean isEIDSectorShare() { + return eIDSectorShare; + } + + /** + * Sets the eId sector share. + * + * @param eIdSectorShare the new eId sector share value. + */ + public void setEIDSectorShare(final boolean eIdSectorShare) { + this.eIDSectorShare = eIdSectorShare; + } + + /** + * Checks if is eId cross sector share. + * + * @return true, if is eId cross sector share. + */ + public boolean isEIDCrossSectorShare() { + return eIDCrossSectorShare; + } + + /** + * Sets the eId cross sector share. + * + * @param eIdCrossSectorShare the new eId cross sector share value. + */ + public void setEIDCrossSectorShare(final boolean eIdCrossSectorShare) { + this.eIDCrossSectorShare = eIdCrossSectorShare; + } + + /** + * Checks if is eId cross border share. + * + * @return true, if is eId cross border share. + */ + public boolean isEIDCrossBorderShare() { + return eIDCrossBorderShare; + } + + /** + * Sets the eId cross border share. + * + * @param eIdCrossBorderShare the new eId cross border share value. + */ + public void setEIDCrossBorderShare(final boolean eIdCrossBorderShare) { + this.eIDCrossBorderShare = eIdCrossBorderShare; + } + + /** + * Returns a copy of this STORKAuthnRequest instance. + * + * @return The copy of this STORKAuthnRequest. + * @throws CloneNotSupportedException on clone exception + */ + @Override + public Object clone() throws CloneNotSupportedException{ + STORKAuthnRequest storkAuthnReq = null; + try { + storkAuthnReq = (STORKAuthnRequest) super.clone(); + storkAuthnReq.setPersonalAttributeList(getPersonalAttributeList()); + storkAuthnReq.setTokenSaml(getTokenSaml()); + } catch (final CloneNotSupportedException e) { + // assert false; + LOG.trace("[PersonalAttribute] Nothing to do."); + } + + return storkAuthnReq; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base new file mode 100644 index 000000000..aa98974f6 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base @@ -0,0 +1,309 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import org.apache.log4j.Logger; +import org.joda.time.DateTime; + +/** + * This class is a bean used to store the information relative to the + * STORKAuthnResponse. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class STORKAuthnResponse { + + /** Response Id. */ + private String samlId; + + /** Authentication failed? */ + private boolean fail; + + /** Status code. */ + private String statusCode; + + /** Secondary status code. */ + private String subStatusCode; + + /** Audience restriction. */ + private transient String audienceRest; + + /** Error message. */ + private String message; + + /** Id of the request that originated this response. */ + private String inResponseTo; + + /** Expiration date. */ + private DateTime notOnOrAfter; + + /** Creation date. */ + private DateTime notBefore; + + /** The SAML token. */ + private byte[] tokenSaml = new byte[0]; + + /** Country. */ + private String country; + + /** Citizen's personal attribute list. */ + private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAuthnResponse.class.getName()); + + /** + * Getter for the subStatusCode. + * + * @return The subStatusCode value. + */ + public String getSubStatusCode() { + return subStatusCode; + } + + /** + * Setter for the subStatusCode. + * + * @param samlSubStatusCode the new subStatusCode value. + */ + public void setSubStatusCode(final String samlSubStatusCode) { + this.subStatusCode = samlSubStatusCode; + } + + /** + * Getter for audienceRest. + * + * @return The audienceRest value. + */ + public String getAudienceRestriction() { + return audienceRest; + } + + /** + * Setter for audienceRest. + * + * @param audRest the new audienceRest value. + */ + public void setAudienceRestriction(final String audRest) { + this.audienceRest = audRest; + } + + /** + * Getter for the samlToken. + * + * @return The samlToken value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Setter for samlToken. + * + * @param samlToken the new tokenSaml value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Getter for the country name. + * + * @return The country name value. + */ + public String getCountry() { + return country; + } + + /** + * Setter for the country name. + * + * @param cCountry the new country name value. + */ + public void setCountry(final String cCountry) { + this.country = cCountry; + } + + /** + * Getter for pal value. + * + * @return The pal value. + * + * @see PersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the inResponseTo value. + * + * @return The inResponseTo value. + */ + public String getInResponseTo() { + return inResponseTo; + } + + /** + * Setter for the inResponseTo value. + * + * @param samlInResponseTo the new inResponseTo value. + */ + public void setInResponseTo(final String samlInResponseTo) { + this.inResponseTo = samlInResponseTo; + } + + /** + * Getter for the fail value. + * + * @return The fail value. + */ + public boolean isFail() { + return fail; + } + + /** + * Setter for the fail value. + * + * @param failVal the new fail value. + */ + public void setFail(final boolean failVal) { + this.fail = failVal; + } + + /** + * Getter for the message value. + * + * @return The message value. + */ + public String getMessage() { + return message; + } + + /** + * Setter for the message value. + * + * @param msg the new message value. + */ + public void setMessage(final String msg) { + this.message = msg; + } + + /** + * Getter for the statusCode value. + * + * @return The statusCode value. + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Setter for the statusCode value. + * + * @param status the new statusCode value. + */ + public void setStatusCode(final String status) { + this.statusCode = status; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param nSamlId the new samlId value. + */ + public void setSamlId(final String nSamlId) { + this.samlId = nSamlId; + } + + /** + * Getter for the notOnOrAfter value. + * + * @return The notOnOrAfter value. + * + * @see DateTime + */ + public DateTime getNotOnOrAfter() { + return this.notOnOrAfter; + } + + /** + * Setter for the notOnOrAfter value. + * + * @param nOnOrAfter the new notOnOrAfter value. + * + * @see DateTime + */ + public void setNotOnOrAfter(final DateTime nOnOrAfter) { + this.notOnOrAfter = nOnOrAfter; + } + + /** + * Getter for the notBefore value. + * + * @return The notBefore value. + * + * @see DateTime + */ + public DateTime getNotBefore() { + return notBefore; + } + + /** + * Setter for the notBefore value. + * + * @param nBefore the new notBefore value. + * + * @see DateTime + */ + public void setNotBefore(final DateTime nBefore) { + this.notBefore = nBefore; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base new file mode 100644 index 000000000..a9c4a156b --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base @@ -0,0 +1,68 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains the SAML Token Status Code. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ + */ +public enum STORKStatusCode { + + /** URI for Requester status code. */ + REQUESTER_URI("urn:oasis:names:tc:SAML:2.0:status:Requester"), + + /** URI for Responder status code. */ + RESPONDER_URI("urn:oasis:names:tc:SAML:2.0:status:Responder"), + + /** URI for Success status code. */ + SUCCESS_URI("urn:oasis:names:tc:SAML:2.0:status:Success"), + + /** Attribute is Available. */ + STATUS_AVAILABLE("Available"), + + /** Attribute is NotAvailable. */ + STATUS_NOT_AVAILABLE("NotAvailable"), + + /** Attribute is Withheld. */ + STATUS_WITHHELD("Withheld"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param val The Constant value. + */ + private STORKStatusCode(final String val) { + + this.value = val; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + + return value; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base new file mode 100644 index 000000000..0a711c9b7 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base @@ -0,0 +1,71 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains the SAML Token Sub Status Code. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.7 $, $Date: 2010-11-17 05:15:28 $ + */ +public enum STORKSubStatusCode { + + /** URI for AuthnFailed status code. */ + AUTHN_FAILED_URI("urn:oasis:names:tc:SAML:2.0:status:AuthnFailed"), + + /** URI for InvalidAttrNameOrValue status code. */ + INVALID_ATTR_NAME_VALUE_URI( + "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue"), + + /** URI for InvalidNameIDPolicy status code. */ + INVALID_NAMEID_POLICY_URI( + "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"), + + /** URI for VersionMismatch status code. */ + VERSION_MISMATCH_URI("urn:oasis:names:tc:SAML:2.0:status:VersionMismatch"), + + /** URI for RequestDenied status code. */ + REQUEST_DENIED_URI("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"), + + /** URI for QaaNotSupported status code. */ + QAA_NOT_SUPPORTED( + "http://www.stork.gov.eu/saml20/statusCodes/QAANotSupported"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param val The Constant value. + */ + private STORKSubStatusCode(final String val) { + + this.value = val; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + + return value; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base new file mode 100644 index 000000000..19d45aaa2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base @@ -0,0 +1,9 @@ +/** + * Common Authentication Service functionalities to be deployed in every PEPS + * is contained in this package. + * In particular, it contains the SAML Engine that implements the SAML messages + * management + * + * @since 1.0 + */ +package eu.stork.peps.auth.commons; diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeConstants.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeConstants.java new file mode 100644 index 000000000..09769641c --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeConstants.java @@ -0,0 +1,72 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the STORK PEPS, Commons and Specific errors + * constant identifiers. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.2 $, $Date: 2010-11-17 05:15:28 $ + */ +public enum AttributeConstants { + + /** + * Represents the attribute's name index. + */ + ATTR_NAME_INDEX(0), + /** + * Represents the attribute's type index. + */ + ATTR_TYPE_INDEX(1), + /** + * Represents the attribute's value index. + */ + ATTR_VALUE_INDEX(2), + /** + * Represents the attribute's status index. + */ + ATTR_STATUS_INDEX(3), + /** + * Represents the number of allowed tuples. + */ + NUMBER_TUPLES(4); + + /** + * Represents the constant's value. + */ + private int attribute; + + /** + * Solo Constructor. + * + * @param attr The Attribute Constant value. + */ + AttributeConstants(final int attr) { + + this.attribute = attr; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public int intValue() { + + return attribute; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java new file mode 100644 index 000000000..013f4caf3 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java @@ -0,0 +1,74 @@ +package eu.stork.peps.auth.commons; + +/** + * This class is a bean used to store the information relative to the Attribute Provider. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-09-17 $ + */ +public final class AttributeProvider { + + /** + * Provider Id. + */ + private String providerId; + + /** + * Provider Name. + */ + private String providerName; + + /** + * Attribute Provider Constructor. + * + * @param pId Id of the Attribute Provider. + * @param pName Name of the Attribute Provider. + */ + public AttributeProvider(final String pId, final String pName) { + + this.providerId = pId; + this.providerName = pName; + } + + /** + * Getter for the providerId value. + * + * @return The providerId value. + */ + public String getProviderId() { + + return providerId; + } + + /** + * Setter for the providerId value. + * + * @param pId Id of the Attribute Provider. + */ + public void setProviderId(final String pId) { + + this.providerId = pId; + } + + /** + * Getter for the providerName value. + * + * @return The providerName value. + */ + public String getProviderName() { + + return providerName; + } + + /** + * Setter for the providerName value. + * + * @param name Name of the Attribute Provider. + */ + public void setProviderName(final String name) { + + this.providerName = name; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java new file mode 100644 index 000000000..8806ba866 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java @@ -0,0 +1,94 @@ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; +import java.util.LinkedHashMap; + +import org.apache.log4j.Logger; + +/** + * Implementation of the AttributeProviderMap using a LinkedHashMap. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.01 $, $Date: 2013-09-20 $ + * + * @see LinkedHashMap + */ +public class AttributeProvidersMap extends LinkedHashMap + implements IAttributeProvidersMap { + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(AttributeProvidersMap.class.getName()); + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 8949081185106296122L; + + /** + * {@inheritDoc} + */ + @Override + public IPersonalAttributeList get(AttributeSource key) { + return this.get((Object) key); + } + + /** + * {@inheritDoc} + */ + @Override + public IPersonalAttributeList remove(AttributeSource key) { + return this.remove((Object) key); + } + + /** + * {@inheritDoc} + */ + @Override + public boolean containsKey(AttributeSource key) { + return this.containsKey((Object) key); + } + + /** + * {@inheritDoc} + */ + @Override + public Iterator keyIterator() { + return this.keySet().iterator(); + } + + public void trace() { + Iterator iterator; + Iterator iterator2; + AttributeSource source; + IPersonalAttributeList pal; + PersonalAttribute pa; + + iterator = this.keyIterator(); + LOG.trace("Start dumping of AttributeProvidersMap\n======================="); + while (iterator.hasNext()) { + source = iterator.next(); + + LOG.trace("Source details: type [" + source.getSourceType() + "], URL [" + source.getProviderURL() + "]"); + + if(source.getSourceType() == AttributeSource.SOURCE_LOCAL_APROVIDER) + LOG.trace("-> Attribute Provider: ID [" + source.getProvider().getProviderId() + "], name [" + source.getProvider().getProviderName() + "]"); + else + LOG.trace("-> Country: ID [" + source.getCountry().getCountryId() + "], name [" + source.getCountry().getCountryName() + "]"); + + pal = this.get(source); + LOG.trace("++++++++=>"); + iterator2 = pal.iterator(); + while (iterator2.hasNext()) { + pa = iterator2.next(); + + LOG.trace("-> Citizen Attribute: name [" + pa.getName() + "], name [" + pa.isRequired() + "]"); + } + LOG.trace("<=++++++++"); + + LOG.trace("-----------------------"); + } + LOG.trace("END\n======================="); + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java new file mode 100644 index 000000000..4b9dc33e9 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java @@ -0,0 +1,119 @@ +package eu.stork.peps.auth.commons; + +/** + * This class is a bean used to store the information relative to the Attribute Source (either AttributeProvider or Country). + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-09-19 $ + */ +public final class AttributeSource { + public static final int SOURCE_LOCAL_APROVIDER = 1; + public static final int SOURCE_REMOTE_COUNTRY = 2; + + /** + * Provider source. + */ + private int sourceType; + + /** + * Provider URL. + */ + private String providerURL; + + /** + * The local Attribute Provider. + */ + private AttributeProvider provider; + + /** + * The remote Country. + */ + private Country country; + + /** + * Attribute Source Constructor. + * + * @param provider The local Attribute Provider. + * @param pURL URL of the Attribute Provider. + */ + public AttributeSource(final AttributeProvider provider, final String pURL) { + this.setSourceType(SOURCE_LOCAL_APROVIDER); + + this.setProvider(provider); + this.setProviderURL(pURL); + } + + /** + * Attribute Source Constructor. + * + * @param country The remote Country. + * @param pURL URL of the Country. + */ + public AttributeSource(final Country country, final String pURL) { + this.setSourceType(SOURCE_REMOTE_COUNTRY); + + this.setCountry(country); + this.setProviderURL(pURL); + } + + /** + * @param sourceType the sourceType to set + */ + public void setSourceType(int sourceType) { + this.sourceType = sourceType; + } + + /** + * @return the sourceType + */ + public int getSourceType() { + return sourceType; + } + + /** + * @param providerURL the providerURL to set + */ + public void setProviderURL(String providerURL) { + this.providerURL = providerURL; + } + + /** + * @return the providerURL + */ + public String getProviderURL() { + return providerURL; + } + + /** + * @param provider the provider to set + */ + public void setProvider(AttributeProvider provider) { + this.setSourceType(SOURCE_LOCAL_APROVIDER); + + this.provider = provider; + } + + /** + * @return the provider + */ + public AttributeProvider getProvider() { + return provider; + } + + /** + * @param country the country to set + */ + public void setCountry(Country country) { + this.setSourceType(SOURCE_REMOTE_COUNTRY); + + this.country = country; + } + + /** + * @return the country + */ + public Country getCountry() { + return country; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java new file mode 100644 index 000000000..84e3576e5 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java @@ -0,0 +1,231 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.commons.lang.StringUtils; + +/** + * This class holds static helper methods. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.5 $, $Date: 2010-12-15 23:19:59 $ + */ +public final class AttributeUtil { + + /** + * Private constructor. Prevents the class from being instantiated. + */ + private AttributeUtil() { + // empty constructor + } + + /** + * Safe escape any given string. + * + * @param value The HTTP Value to escaped. + * + * @return The value escaped value. + */ + public static String escape(final String value) { + + final String attrSep = PEPSValues.ATTRIBUTE_SEP.toString(); + final String attrTupleSep = PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(); + final String attrValueSep = PEPSValues.ATTRIBUTE_VALUE_SEP.toString(); + + final String escAttrSep = "%" + (int) attrSep.charAt(0); + final String escAttrTupleSep = "%" + (int) attrTupleSep.charAt(0); + final String escAttrValueSep = "%" + (int) attrValueSep.charAt(0); + + return value.replace(attrSep, escAttrSep) + .replace(attrTupleSep, escAttrTupleSep) + .replace(attrValueSep, escAttrValueSep); + } + + /** + * Unescape any given string. + * + * @param value The HTTP Value to be unescaped. + * + * @return The value unescaped value. + */ + public static String unescape(final String value) { + final String attrSep = PEPSValues.ATTRIBUTE_SEP.toString(); + final String attrTupleSep = PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(); + final String attrValueSep = PEPSValues.ATTRIBUTE_VALUE_SEP.toString(); + + final String escAttrSep = "%" + (int) attrSep.charAt(0); + final String escAttrTupleSep = "%" + (int) attrTupleSep.charAt(0); + final String escAttrValueSep = "%" + (int) attrValueSep.charAt(0); + + return value.replace(escAttrSep, attrSep) + .replace(escAttrTupleSep, attrTupleSep) + .replace(escAttrValueSep, attrValueSep); + } + + /** + * Appends the string representation of an object to a StringBuilder. + * + * @param strBuilder The StringBuilder to append to. + * @param val The string representation of an object. + */ + public static void appendIfNotNull(final StringBuilder strBuilder, + final Object val) { + + if (val != null) { + strBuilder.append(val); + } + } + + /** + * Given a separator and a list of strings, joins the list, as a string, + * separated by the separator string. + * + * @param list The list of strings to join. + * @param separator The separator string. + * @return the list, as a string, separated by the separator string. + */ + public static String listToString(final List list, + final String separator) { + + final StringBuilder strBuilder = new StringBuilder(); + for (final String s : list) { + if (!StringUtils.isEmpty(s)) { + strBuilder.append(AttributeUtil.escape(s) + separator); + } + } + return strBuilder.toString(); + } + + /** + * Given a separator and a map of strings to strings, joins the map, as a + * string, separated by the separator string with the pair key/value + * concatenated with a '='. + * + * @param map The map of strings to join. + * @param separator The separator string. + * + * @return the map of strings, as a string, separated by the separator string + * with the pair key/value concatenated with a '='. + */ + public static String mapToString(final Map map, + final String separator) { + + final StringBuilder strBuilder = new StringBuilder(); + final Iterator> valuesIt = map.entrySet().iterator(); + while (valuesIt.hasNext()) { + final Entry entry = valuesIt.next(); + strBuilder.append(entry.getKey()); + strBuilder.append('='); + strBuilder.append(AttributeUtil.escape(entry.getValue())); + strBuilder.append(separator); + } + return strBuilder.toString(); + } + + /** + * Validates the attribute value format. + * + * @param value The attribute value to validate. + * + * @return true if value has a valid format. + */ + public static boolean isValidValue(final String value) { + boolean retVal = false; + if (value != null && value.charAt(0) == '[' && value.endsWith("]")) { + final String tmpAttrValue = value.substring(1, value.length() - 1); + final String[] vals = + tmpAttrValue.split(PEPSValues.ATTRIBUTE_VALUE_SEP.toString()); + + if (tmpAttrValue.length() >= 0 + || (vals.length > 0 && vals[0].length() > 0)) { + retVal = true; + } + } + return retVal; + } + + /** + * Validates the attribute type value. It's case insensitive. E.g. return true + * value to: a) "true", "TRUE", "True", ... b) "false", "FALSE", "False", ... + * + * @param type The attribute type value. + * + * @return true if type has a true or false (case insensitive) value. + */ + public static boolean isValidType(final String type) { + return StringUtils.isNotEmpty(type) && (PEPSValues.TRUE.toString().equalsIgnoreCase(type) || PEPSValues.FALSE.toString().equalsIgnoreCase(type)) ; + } + + /** + * Validates the Personal attribute tuple. E.g. name:type:[value]:status + * + * @param tuples The Personal attribute's tuple. + * + * @return true if the tuples' format is valid. + * + * @see PEPSUtil#validateParameter(String, String, String) + * @see String#equalsIgnoreCase(String) + */ + public static boolean hasValidTuples(final String[] tuples) { + boolean retVal = false; + + int numberTuples = AttributeConstants.NUMBER_TUPLES.intValue(); + if (tuples != null && tuples.length == numberTuples) { + // validate attrName + final int attrNameIndex = AttributeConstants.ATTR_NAME_INDEX.intValue(); + final int attrTypeIndex = AttributeConstants.ATTR_TYPE_INDEX.intValue(); + final int attrValueIndex = AttributeConstants.ATTR_VALUE_INDEX.intValue(); + + retVal = + StringUtils.isNotEmpty(tuples[attrNameIndex]) + && StringUtils.isNotEmpty(tuples[attrTypeIndex]) + && StringUtils.isNotEmpty(tuples[attrValueIndex]) + && AttributeUtil.isValidType(tuples[attrTypeIndex]) + && AttributeUtil.isValidValue(tuples[attrValueIndex]); + } + return retVal; + } + + /** + * Check if all mandatory attributes have values. + * + * @param personalAttrList The Personal Attributes List. + * + * @return true if all mandatory attributes have values, false if at least one + * attribute doesn't have value. + */ + public static boolean checkMandatoryAttributes( + final IPersonalAttributeList personalAttrList) { + + final Iterator itAttributes = + personalAttrList.values().iterator(); + boolean retVal = true; + while (itAttributes.hasNext() && retVal) { + final PersonalAttribute attr = itAttributes.next(); + if (attr.isRequired() + && !STORKStatusCode.STATUS_AVAILABLE.toString() + .equals(attr.getStatus())) { + retVal = false; + } + } + return retVal; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java new file mode 100644 index 000000000..2245178f4 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java @@ -0,0 +1,123 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.ArrayList; +import java.util.List; + +/** + * This class is a bean used to store the information relative to the Citizen + * Consent. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class CitizenConsent { + + /** + * Mandatory attributes list. + */ + private List mandatoryList; + + /** + * Optional attributes list. + */ + private List optionalList; + + /** + * Citizen Consent default Constructor. + */ + public CitizenConsent() { + this.mandatoryList = new ArrayList(); + this.optionalList = new ArrayList(); + } + + /** + * Getter for the mandatoryList value. + * + * @return The mandatoryList value. + */ + public List getMandatoryList() { + return this.mandatoryList; + } + + /** + * Setter for the mandatoryList value. + * + * @param mandatoryAttrList Mandatory parameters list. + */ + public void setMandatoryList(final List mandatoryAttrList) { + this.mandatoryList = mandatoryAttrList; + } + + /** + * Setter for some mandatoryAttribute. Adds the input parameter to the + * mandatoryList. + * + * @param mandatoryAttr Attribute to add to the mandatoryList. + */ + public void setMandatoryAttribute(final String mandatoryAttr) { + this.mandatoryList.add(mandatoryAttr); + } + + /** + * Getter for the optionalList value. + * + * @return The optionalList value. + */ + public List getOptionalList() { + return optionalList; + } + + /** + * Setter for the optionalList value. + * + * @param optAttrList Optional parameters list. + */ + public void setOptionalList(final List optAttrList) { + this.optionalList = optAttrList; + } + + /** + * Setter for some optionalAttr. Adds the input parameter to the optionalList. + * + * @param optionalAttr Attribute to add to the optionalList. + */ + public void setOptionalAttribute(final String optionalAttr) { + this.optionalList.add(optionalAttr); + } + + /** + * Returns a string in the following format. "Mandatory attributes: + * mandatoryAttr1;mandatoryAttr2;mandatoryAttrN Optional attributes: + * optionalAttr1;optionalAttr2;optionalAttrN" + * + * @return {@inheritDoc} + */ + public String toString() { + final StringBuilder strbldr = new StringBuilder(); + strbldr.append("Mandatory attributes: "); + for (String str : mandatoryList) { + strbldr.append(str + ";"); + } + strbldr.append(" Optional attributes: "); + for (String str : optionalList) { + strbldr.append(str + ";"); + } + return strbldr.toString(); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Country.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Country.java new file mode 100644 index 000000000..001f9317a --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Country.java @@ -0,0 +1,95 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +/** + * This class is a bean used to store the information relative to the Country. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.10 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class Country implements Serializable { + + /** + * + */ + private static final long serialVersionUID = 1135994036496370993L; + +/** + * Country Id. + */ + private String countryId; + + /** + * Country Name. + */ + private String countryName; + + /** + * Country Constructor. + * + * @param cId Id of the Country. + * @param cName Name of the Country. + */ + public Country(final String cId, final String cName) { + + this.countryId = cId; + this.countryName = cName; + } + + /** + * Getter for the countryId value. + * + * @return The countryId value. + */ + public String getCountryId() { + + return countryId; + } + + /** + * Setter for the countryId value. + * + * @param cId Id of the Country. + */ + public void setCountryId(final String cId) { + + this.countryId = cId; + } + + /** + * Getter for the countryName value. + * + * @return The countryName value. + */ + public String getCountryName() { + + return countryName; + } + + /** + * Setter for the countryName value. + * + * @param name Name of the Country. + */ + public void setCountryName(final String name) { + + this.countryName = name; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CountryCodes.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CountryCodes.java new file mode 100644 index 000000000..54345f3ea --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CountryCodes.java @@ -0,0 +1,79 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.Arrays; +import java.util.List; + +/** + * This class contains all the ISO 3166-1 Alpha 3 Country Codes. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.2 $, $Date: 2011-04-14 00:24:56 $ + */ +public final class CountryCodes { + + /** + * Private Constructor. + */ + private CountryCodes() { + + } + + /** + * ISO 3166-1 Alpha 3 Country Codes. + */ + private static List countrysAlpha3 = Arrays.asList("ABW", "AFG", + "AGO", "AIA", "ALA", "ALB", "AND", "ANT", "ARE", "ARG", "ARM", "ASM", + "ATA", "ATF", "ATG", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BES", + "BFA", "BGD", "BGR", "BHR", "BHS", "BIH", "BLM", "BLR", "BLZ", "BMU", + "BOL", "BRA", "BRB", "BRN", "BTN", "BUR", "BVT", "BWA", "BYS", "CAF", + "CAN", "CCK", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COK", + "COL", "COM", "CPV", "CRI", "CSK", "CUB", "CUW", "CXR", "CYM", "CYP", + "CZE", "DEU", "DJI", "DMA", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI", + "ESH", "ESP", "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "FRO", "FSM", + "GAB", "GBR", "GEO", "GGY", "GHA", "GIB", "GIN", "GLP", "GMB", "GNB", + "GNQ", "GRC", "GRD", "GRL", "GTM", "GUF", "GUM", "GUY", "HKG", "HMD", + "HND", "HRV", "HTI", "HUN", "IDN", "IMN", "IND", "IOT", "IRL", "IRN", + "IRQ", "ISL", "ISR", "ITA", "JAM", "JEY", "JOR", "JPN", "KAZ", "KEN", + "KGZ", "KHM", "KIR", "KNA", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", + "LCA", "LIE", "LKA", "LSO", "LTU", "LUX", "LVA", "MAC", "MAF", "MAR", + "MCO", "MDA", "MDG", "MDV", "MEX", "MHL", "MKD", "MLI", "MLT", "MMR", + "MNE", "MNG", "MNP", "MOZ", "MRT", "MSR", "MTQ", "MUS", "MWI", "MYS", + "MYT", "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NIU", "NLD", "NOR", + "NPL", "NRU", "NZL", "OMN", "PAK", "PAN", "PCN", "PER", "PHL", "PLW", + "PNG", "POL", "PRI", "PRK", "PRT", "PRY", "PSE", "PYF", "QAT", "REU", + "ROM", "ROU", "RUS", "RWA", "SAU", "SCG", "SDN", "SEN", "SGP", "SGS", + "SHN", "SJM", "SLB", "SLE", "SLV", "SMR", "SOM", "SPM", "SRB", "STP", + "SUR", "SVK", "SVN", "SXW", "SWE", "SWZ", "SYC", "SYR", "TCA", "TCD", + "TGO", "THA", "TJK", "TKL", "TKM", "TLS", "TMP", "TON", "TTO", "TUN", + "TUR", "TUV", "TWN", "TZA", "UGA", "UKR", "UMI", "URY", "USA", "UZB", + "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "YEM", + "YUG", "ZAF", "ZAR", "ZMB", "ZWE"); + + /** + * Searches the CountryCode (3166-1 alpha3 format) an return true if it + * exists. + * + * @param countryCode The Country code to search. + * + * @return true if the CountryCode exists, false otherwise. + */ + public static boolean hasCountryCodeAlpha3(final String countryCode) { + + return CountryCodes.countrysAlpha3.contains(countryCode); + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/DateUtil.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/DateUtil.java new file mode 100644 index 000000000..9c0bd6775 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/DateUtil.java @@ -0,0 +1,169 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.sql.Timestamp; +import java.util.GregorianCalendar; + +import org.apache.log4j.Logger; +import org.joda.time.DateTime; +import org.joda.time.Years; +import org.joda.time.format.DateTimeFormat; +import org.joda.time.format.DateTimeFormatter; + +import eu.stork.peps.auth.commons.exceptions.SecurityPEPSException; + +/** + * This class holds static helper methods for Date Operations. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.4 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class DateUtil { + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(DateUtil.class.getName()); + + /** + * yyyy Date format size. + */ + private static final int YEAR_DATE_SIZE = 4; + + /** + * yyyyMM Date format size. + */ + private static final int MONTH_DATE_SIZE = 6; + + /** + * Private constructor. Prevents the class from being instantiated. + */ + private DateUtil() { + // empty constructor + } + + /** + * Fulfils dateValue with a valid date. The following roles are applied: a) If + * the dateValue only contains the year then fulfils with last year's day. + * e.g. this method returns 19951231 to the 1995 dateValue. b) If the + * dateValue contains the year and the month then fulfils with last month's + * day. e.g. this method returns 19950630 to the 199505 dateValue. + * + * @param dateValue The date to be fulfilled. + * + * @return The dateValue fulfilled. + */ + private static String fulfilDate(final String dateValue) { + + final StringBuffer strBuf = new StringBuffer(); + strBuf.append(dateValue); + // if the IdP just provides the year then we must fullfil the date. + if (dateValue.length() == YEAR_DATE_SIZE) { + strBuf.append(PEPSValues.LAST_MONTH.toString()); + } + // if the IdP provides the year and the month then we must fullfil the + // date. + if (dateValue.length() == MONTH_DATE_SIZE + || strBuf.length() == MONTH_DATE_SIZE) { + // IdP doesn't provide the day, so we will use DateTime to + // calculate it. + final String noDayCons = PEPSValues.NO_DAY_DATE_FORMAT.toString(); + final DateTimeFormatter fmt = DateTimeFormat.forPattern(noDayCons); + final DateTime dateTime = fmt.parseDateTime(strBuf.toString()); + // Append the last month's day. + strBuf.append(dateTime.dayOfMonth().withMaximumValue().getDayOfMonth()); + } + + return strBuf.toString(); + } + + /** + * Validates the dateValue format: a) if has a valid size; b) if has a numeric + * value; Note: dateValue must have the format yyyyMMdd. + * + * @param dateValueTmp The date to be validated. + * @param pattern The accepted date format. + * + * @return true if the date has a valid format. + */ + public static boolean isValidFormatDate(final String dateValueTmp, + final String pattern) { + + boolean retVal = true; + try { + final String dateValue = DateUtil.fulfilDate(dateValueTmp); + + final DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + fmt.parseDateTime(dateValue); + } catch (final Exception e) { + // We catch Exception because we only have to return false + // value! + retVal = false; + } + return retVal; + } + + /** + * Calculates the age for a given date string. + * + * @param dateVal The date to be validated. + * @param now The current date. + * @param pattern The date pattern. + * + * @return The age value. + */ + public static int calculateAge(final String dateVal, final DateTime now, + final String pattern) { + + if (DateUtil.isValidFormatDate(dateVal, pattern)) { + try { + final String dateValueTemp = DateUtil.fulfilDate(dateVal); + final DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); + final DateTime dateTime = fmt.parseDateTime(dateValueTemp); + // Calculating age + final Years age = Years.yearsBetween(dateTime, now); + + return age.getYears(); + } catch (final IllegalArgumentException e) { + LOG.warn("Invalid date format (" + pattern + + ") or an invalid dateValue."); + throw new SecurityPEPSException( + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorMessage()), + e); + } + } else { + LOG.warn("Couldn't calculate Age, invalid date!"); + throw new SecurityPEPSException( + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorMessage())); + } + + } + + /** + * Generates the current timestamp. + * + * @return timestamp The current timestamp + */ + public static Timestamp currentTimeStamp() { + final GregorianCalendar cal = new GregorianCalendar(); + final long millis = cal.getTimeInMillis(); + return new Timestamp(millis); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeProvidersMap.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeProvidersMap.java new file mode 100644 index 000000000..733399ca3 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeProvidersMap.java @@ -0,0 +1,82 @@ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; + +/** + * Interface for Attributes Providers map. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-09-20 $ + */ +public interface IAttributeProvidersMap { + + /** + * Returns the object associated the the given key. + * + * @param key with which the specified value is to be associated. + * + * @return The object associated the the given key. + */ + IPersonalAttributeList get(AttributeSource key); + + /** + * Associates a key to a value, and inserts them in the session object. + * + * @param key with which the specified value is to be associated. + * @param value to be associated with the specified key. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + Object put(AttributeSource key, IPersonalAttributeList value); + + /** + * Removes the mapping for this key. + * + * @param key with which the specified value is to be associated. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + IPersonalAttributeList remove(AttributeSource key); + + /** + * Returns the number of key-value mappings in this map. + * + * @return the number of key-value mappings in this map. + */ + int size(); + + /** + * Returns true if this map contains a mapping for the specified key. + * + * @param key with which the specified value is to be associated. + * + * @return true if this map contains a mapping for the specified key. + */ + boolean containsKey(AttributeSource key); + + /** + * Removes all mappings from this map. + */ + void clear(); + + /** + * Returns true if this map contains no key-value mappings. + * + * @return true if this map contains no key-value mappings. + */ + boolean isEmpty(); + + /** + * Returns an Iterator of the keys contained in this map. The implementation must + * take care in order for the Iterator to have predictable order of the returned + * keys. + * + * @return an iterator of the keys contained in this map + */ + Iterator keyIterator(); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java new file mode 100644 index 000000000..83b8e57fe --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java @@ -0,0 +1,140 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.Collection; +import java.util.Iterator; + +/** + * Interface for {@link PersonalAttributeList}. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.16 $, $Date: 2010-11-17 05:15:28 $ + * + * @see PersonalAttribute + */ +@SuppressWarnings("PMD.CloneMethodMustImplementCloneable") +public interface IPersonalAttributeList extends Iterable, + Cloneable { + + /** + * Associates the specified value with the specified key in this Personal + * Attribute List. + * + * @param key with which the specified value is to be associated. + * @param value to be associated with the specified key. + * + * @return the previous value associated with key, or null if there was no + * mapping for key. + * + * @see PersonalAttribute + */ + PersonalAttribute put(String key, PersonalAttribute value); + + /** + * Returns the value to which the specified key is mapped, or null if this map + * contains no mapping for the key. + * + * @param key whose associated value is to be returned. + * + * @return The value to which the specified key is mapped, or null if this map + * contains no mapping for the key. + * + * @see PersonalAttribute + */ + PersonalAttribute get(Object key); + + /** + * Adds to the PersonalAttributeList the given PersonalAttribute. It sets the + * attribute name as the key to the attribute value. + * + * @param value PersonalAttribute to add to the PersonalAttributeList + */ + void add(PersonalAttribute value); + + /** + * Get the size of the Personal Attribute List. + * + * @return size of the Personal Attribute List. + */ + int size(); + + /** + * Checks if the Personal Attribute List contains the given key. + * + * @param key with which the specified value is to be associated. + * + * @return true if the Personal Attribute List contains the given key, false + * otherwise. + */ + boolean containsKey(Object key); + + /** + * Getter for the iterator of the Personal Attribute List values. + * + * @return The iterator for the Personal Attribute List values. + * + * @see PersonalAttribute + */ + Iterator iterator(); + + /** + * Creates a Personal Attribute List from a String representing an Attribute + * List. + * + * @param attrList String Object representing the attribute list. + */ + void populate(String attrList); + + /** + * Removes the mapping for this key from this map if present. + * + * @param key key whose mapping is to be removed from the map. + * @return previous value associated with specified key, or null if + * there was no mapping for key. A null return can also + * indicate that the map previously associated null with the + * specified key. + */ + PersonalAttribute remove(Object key); + + /** + * Returns a collection view of the values contained in this map. The + * collection is backed by the map, so changes to the map are reflected in the + * collection, and vice-versa. The collection supports element removal, which + * removes the corresponding mapping from this map, via the + * Iterator.remove, Collection.remove, removeAll, + * retainAll, and clear operations. It does not support the + * add or addAll operations. + * + * @return a collection view of the values contained in this map. + */ + Collection values(); + + /** + * Returns true if this map contains no key-value mappings. + * + * @return true if this map contains no key-value mappings. + */ + boolean isEmpty(); + + /** + * Returns a copy of this IPersonalAttributeList instance. + * + * @return The copy of this IPersonalAttributeList. + */ + Object clone() throws CloneNotSupportedException; + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkLogger.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkLogger.java new file mode 100644 index 000000000..33eb618f0 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkLogger.java @@ -0,0 +1,239 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * Interface for stork logging. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.10 $, $Date: 2011-02-17 22:44:34 $ + */ +public interface IStorkLogger { + + /** + * Getter for SpApplication. + * + * @return The SpApplication value. + */ + String getSpApplication(); + + /** + * Setter for SpApplication. + * + * @param spApplication The SP Application. + */ + void setSpApplication(String spApplication); + + /** + * Getter for ProviderName. + * + * @return The ProviderName value. + */ + String getProviderName(); + + /** + * Setter for ProviderName. + * + * @param providerName The provider name. + */ + void setProviderName(String providerName); + + /** + * + * Getter for Origin. + * + * @return The Origin value. + * + */ + String getOrigin(); + + /** + * Setter for Origin. + * + * @param origin The origin. + */ + void setOrigin(String origin); + + /** + * + * Getter for QAA Level. + * + * @return The QAA Level value. + * + */ + int getQaaLevel(); + + /** + * Setter for QAA Level. + * + * @param qaaLevel The qaa level. + */ + void setQaaLevel(int qaaLevel); + + /** + * + * Getter for timestamp. + * + * @return The timestamp value. + * + */ + String getTimestamp(); + + /** + * Setter for timestamp. + * + * @param timestamp The request's timestamp. + */ + void setTimestamp(String timestamp); + + /** + * Getter for InResponseTo. + * + * @return The InResponseTo value. + */ + String getInResponseTo(); + + /** + * Setter for InResponseTo. + * + * @param inResponseTo The Saml's response id. + */ + void setInResponseTo(String inResponseTo); + + /** + * Getter for InResponseToSPReq. + * + * @return The InResponseToSPReq value. + */ + String getInResponseToSPReq(); + + /** + * Setter for InResponseToSPRequ. + * + * @param inResponseToSPReq The Saml's response id. + */ + void setInResponseToSPReq(String inResponseToSPReq); + + /** + * Getter for opType. + * + * @return The opType value. + */ + String getOpType(); + + /** + * Setter for opType. + * + * @param opType The operation type. + */ + void setOpType(String opType); + + /** + * Getter for destination. + * + * @return The destination value. + */ + String getDestination(); + + /** + * Setter for destinationIp. + * + * @param destination The remote IP. + */ + void setDestination(String destination); + + /** + * Getter for message or assertion consumer. + * + * @return The message or assertion consumer. + */ + String getMessage(); + + /** + * Setter for message or assertion consumer. + * + * @param message or assertion consumer. + */ + void setMessage(String message); + + /** + * Getter for country. + * + * @return The country value. + */ + String getCountry(); + + /** + * Setter for country. + * + * @param country The country. + */ + void setCountry(String country); + + /** + * Getter for samlHash. + * + * @return The samlHash value. + */ + byte[] getSamlHash(); + + /** + * Setter for samlHash. + * + * @param samlHash the encrypted SAML token + */ + void setSamlHash(byte[] samlHash); + + /** + * Getter for msgId. + * + * @return the msgId + */ + String getMsgId(); + + /** + * Setter for msgId. + * + * @param msgId the ID of the originator of this message + */ + void setMsgId(String msgId); + + /** + * Getter for sPMsgId. + * + * @return the sPMsgId + */ + String getSPMsgId(); + + /** + * Setter for sPMsgId. + * + * @param sPMsgId the ID of the originator of this message + */ + void setSPMsgId(String sPMsgId); + + /** + * The format of the returned String must be the following: + * "requestCounter#ddMMMyyyykk:mm:ss#opType#originIp#originName + * #destinationIp#destinationName#samlHash#[originatorName#msgId#]" + * + * The values enclosed in '[]' only apply when logging responses. + * + * @return {@inheritDoc} + */ + @Override + String toString(); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkSession.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkSession.java new file mode 100644 index 000000000..f38b41838 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IStorkSession.java @@ -0,0 +1,85 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * Interface for stork session. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.9 $, $Date: 2010-11-17 05:15:28 $ + */ +public interface IStorkSession { + + /** + * Returns the object associated the the given key. + * + * @param key with which the specified value is to be associated. + * + * @return The object associated the the given key. + */ + Object get(Object key); + + /** + * Associates a key to a value, and inserts them in the session object. + * + * @param key with which the specified value is to be associated. + * @param value to be associated with the specified key. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + Object put(String key, Object value); + + /** + * Removes the mapping for this key. + * + * @param key with which the specified value is to be associated. + * + * @return previous value associated with specified key, or null if there was + * no mapping for key. A null return can also indicate that the map + * previously associated null with the specified key. + */ + Object remove(Object key); + + /** + * Returns the number of key-value mappings in this map. + * + * @return the number of key-value mappings in this map. + */ + int size(); + + /** + * Returns true if this map contains a mapping for the specified key. + * + * @param key with which the specified value is to be associated. + * + * @return true if this map contains a mapping for the specified key. + */ + boolean containsKey(Object key); + + /** + * Removes all mappings from this map. + */ + void clear(); + + /** + * Returns true if this map contains no key-value mappings. + * + * @return true if this map contains no key-value mappings. + */ + boolean isEmpty(); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java new file mode 100644 index 000000000..43d3adaa9 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java @@ -0,0 +1,173 @@ +package eu.stork.peps.auth.commons; + +import java.util.Iterator; + +/** + * This class is a bean used to store the information of Attribute Providers, the Attribute + * List to be requested, the Assertions returned by the Attribute Providers and the values + * that each Attribute has. This information along with the current status of the Linker (the + * attribute providers that were queried and the remaining providers) is used by the PEPS + * actions in order to complete the Attribute gathering. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.20 $, $Date: 2013-10-28 $ + */ +public final class Linker { + /** + * Attributes Providers map. + */ + private IAttributeProvidersMap attributeProvidersMap; + + /** + * The current index of local (domestic) Attribute Providers. + */ + private int localIndex; + + /** + * The current index of remote (foreign) Attribute Providers - countries. + */ + private int remoteIndex; + + /** + * Constructs an empty Linker object. + */ + public Linker() { + localIndex = 0; + remoteIndex = 0; + } + + /** + * Based on the internal state of the Linker it returns the next local Attribute Source + * + * @return The next Attribute Source or null if not found + * + * @see AttributeSource + */ + public AttributeSource getNextLocalProvider() { + Iterator iterator; + AttributeSource source, found; + int curIndex = 0; + + found = null; + + if ( attributeProvidersMap!=null && !attributeProvidersMap.isEmpty() ) { + iterator = attributeProvidersMap.keyIterator(); + while (iterator.hasNext()) { + source = iterator.next(); + + if ( source.getSourceType()==AttributeSource.SOURCE_LOCAL_APROVIDER ) { + if ( curIndex>=localIndex ) { + found = source; + + break; + } + + curIndex++; + } + } + } + + return found; + } + + /** + * Based on the internal state of the Linker it returns the next remote Attribute Source + * + * @return The next Attribute Source or null if not found + * + * @see AttributeSource + */ + public AttributeSource getNextRemoteProvider() { + Iterator iterator; + AttributeSource source, found; + int curIndex = 0; + + found = null; + + if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) { + iterator = attributeProvidersMap.keyIterator(); + while (iterator.hasNext()) { + source = iterator.next(); + + if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) { + if ( curIndex>=remoteIndex ) { + found = source; + + break; + } + + curIndex++; + } + } + } + + return found; + } + + /** + * It updates the Linker with the values returned by the Attribute Source. It also advances + * to the next index in order to mark this attribute source as completed. + * + * @param source The Attribute Source that was queried for attribute values. + * @param attrResponse The attrResponse returned by the Attribute Source that contains the attribute values. + * + * @see AttributeSource, STORKAttrQueryResponse + */ + public void setProviderReponse(AttributeSource source, STORKAttrQueryResponse attrResponse) { + if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) + remoteIndex++; + else + localIndex++; + + //TODO How to store Assertions (format: byte, base64 string, entire object?) + + this.attributeProvidersMap.put(source, attrResponse.getPersonalAttributeList()); + } + + /** + * Reset the internal state of the local Attribute Source in order to start over. + */ + public void resetLocalIndex() { + localIndex = 0; + } + + /** + * Reset the internal state of the remote Attribute Source in order to start over. + */ + public void resetRemoteIndex() { + remoteIndex = 0; + } + + /** + * Setter for attributeProvidersMap. + * + * @param attributeProvidersMap The attributeProvidersMap to set. + */ + public void setAttributeProvidersMap(IAttributeProvidersMap attributeProvidersMap) { + this.attributeProvidersMap = attributeProvidersMap; + } + + /** + * Getter for attributeProvidersMap. + * + * @return attributeProvidersMap + */ + public IAttributeProvidersMap getAttributeProvidersMap() { + return attributeProvidersMap; + } + + /** + * Returns the Personal Attribute list of the provided Attribute Source. + * + * @return The IPersonalAttributeList assosiated with this source or null if empty + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getProviderAttributes(AttributeSource source) { + if ( attributeProvidersMap.containsKey(source) ) + return attributeProvidersMap.get(source); + else + return null; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java new file mode 100644 index 000000000..3aa549a06 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java @@ -0,0 +1,348 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the STORK PEPS, Commons and Specific errors + * constant identifiers. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.10 $, $Date: 2011-02-17 22:44:34 $ + */ +public enum PEPSErrors { + + /** + * Represents the 'authenticationFailed' constant error identifier. + */ + AUTHENTICATION_FAILED_ERROR("authenticationFailed"), + /** + * Represents the 'spCountrySelector.errorCreatingSAML' constant error + * identifier. + */ + SP_COUNTRY_SELECTOR_ERROR_CREATE_SAML("spCountrySelector.errorCreatingSAML"), + /** + * Represents the 'spCountrySelector.destNull' constant error identifier. + */ + SP_COUNTRY_SELECTOR_DESTNULL("spCountrySelector.destNull"), + /** + * Represents the 'spCountrySelector.invalidAttr' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_ATTR("spCountrySelector.invalidAttr"), + /** + * Represents the 'spCountrySelector.invalidProviderName' constant error + * identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_PROVIDER_NAME( + "spCountrySelector.invalidProviderName"), + /** + * Represents the 'spCountrySelector.invalidQaaSPid' constant error + * identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_QAASPID("spCountrySelector.invalidQaaSPid"), + /** + * Represents the 'spCountrySelector.invalidSpId' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_SPID("spCountrySelector.invalidSpId"), + /** + * Represents the 'spCountrySelector.invalidSPQAA' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_SPQAA("spCountrySelector.invalidSPQAA"), + /** + * Represents the 'spCountrySelector.invalidSpURL' constant error identifier. + */ + SP_COUNTRY_SELECTOR_INVALID_SPURL("spCountrySelector.invalidSpURL"), + /** + * Represents the 'spCountrySelector.spNotAllowed' constant error identifier. + */ + SP_COUNTRY_SELECTOR_SPNOTALLOWED("spCountrySelector.spNotAllowed"), + + /** + * Represents the 'sProviderAction.errorCreatingSAML' constant error + * identifier. + */ + SPROVIDER_SELECTOR_ERROR_CREATE_SAML("sProviderAction.errorCreatingSAML"), + /** + * Represents the 'sProviderAction.attr' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_ATTR("sProviderAction.invalidAttr"), + /** + * Represents the 'sProviderAction.country' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_COUNTRY("sProviderAction.invalidCountry"), + /** + * Represents the 'sProviderAction.relayState' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_RELAY_STATE("sProviderAction.invalidRelayState"), + /** + * Represents the 'sProviderAction.saml' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SAML("sProviderAction.invalidSaml"), + /** + * Represents the 'sProviderAction.spAlias' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPALIAS("sProviderAction.invalidSPAlias"), + /** + * Represents the 'sProviderAction.spDomain' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPDOMAIN("sProviderAction.invalidSPDomain"), + /** + * Represents the 'sProviderAction.spId' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPID("sProviderAction.invalidSPId"), + /** + * Represents the 'sProviderAction.spQAA' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPQAA("sProviderAction.invalidSPQAA"), + /** + * Represents the 'sProviderAction.spQAAId' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPQAAID("sProviderAction.invalidSPQAAId"), + /** + * Represents the 'sProviderAction.spRedirect' constant error identifier. + */ + SPROVIDER_SELECTOR_INVALID_SPREDIRECT("sProviderAction.invalidSPRedirect"), + /** + * Represents the 'sProviderAction.invalidSPProviderName' constant error + * identifier. + */ + SPROVIDER_SELECTOR_INVALID_SP_PROVIDERNAME( + "sProviderAction.invalidSPProviderName"), + /** + * Represents the 'sProviderAction.spNotAllowed' constant error identifier. + */ + SPROVIDER_SELECTOR_SPNOTALLOWED("sProviderAction.spNotAllowed"), + + + /** + * Represents the 'internalError' constant error identifier. + */ + INTERNAL_ERROR("internalError"), + + /** + * Represents the 'colleagueRequest.attrNull' constant error identifier. + */ + COLLEAGUE_REQ_ATTR_NULL("colleagueRequest.attrNull"), + /** + * Represents the 'colleagueRequest.errorCreatingSAML' constant error + * identifier. + */ + COLLEAGUE_REQ_ERROR_CREATE_SAML("colleagueRequest.errorCreatingSAML"), + /** + * Represents the 'colleagueRequest.invalidCountryCode' constant error + * identifier. + */ + COLLEAGUE_REQ_INVALID_COUNTRYCODE("colleagueRequest.invalidCountryCode"), + /** + * Represents the 'colleagueRequest.invalidDestUrl' constant error identifier. + */ + COLLEAGUE_REQ_INVALID_DEST_URL("colleagueRequest.invalidDestUrl"), + /** + * Represents the 'colleagueRequest.invalidQaa' constant error identifier. + */ + COLLEAGUE_REQ_INVALID_QAA("colleagueRequest.invalidQaa"), + /** + * Represents the 'colleagueRequest.invalidRedirect' constant error + * identifier. + */ + COLLEAGUE_REQ_INVALID_REDIRECT("colleagueRequest.invalidRedirect"), + /** + * Represents the 'colleagueRequest.invalidSAML' constant error identifier. + */ + COLLEAGUE_REQ_INVALID_SAML("colleagueRequest.invalidSAML"), + + + /** + * Represents the 'cpepsRedirectUrl' constant error identifier. + */ + CPEPS_REDIRECT_URL("cpepsRedirectUrl"), + /** + * Represents the 'spepsRedirectUrl' constant error identifier. + */ + SPEPS_REDIRECT_URL("spepsRedirectUrl"), + /** + * Represents the 'sProviderAction.invCountry' constant error identifier. + */ + SP_ACTION_INV_COUNTRY("sProviderAction.invCountry"), + + /** + * Represents the 'providernameAlias.invalid' constant error identifier. + */ + PROVIDER_ALIAS_INVALID("providernameAlias.invalid"), + + + /** + * Represents the 'cPeps.attrNull' constant error identifier. + */ + CPEPS_ATTR_NULL("cPeps.attrNull"), + + /** + * Represents the 'colleagueResponse.invalidSAML' constant error identifier. + */ + COLLEAGUE_RESP_INVALID_SAML("colleagueResponse.invalidSAML"), + + /** + * Represents the 'citizenNoConsent.mandatory' constant error identifier. + */ + CITIZEN_NO_CONSENT_MANDATORY("citizenNoConsent.mandatory"), + /** + * Represents the 'citizenResponse.mandatory' constant error identifier. + */ + CITIZEN_RESPONSE_MANDATORY("citizenResponse.mandatory"), + /** + * Represents the 'attVerification.mandatory' constant error identifier. + */ + ATT_VERIFICATION_MANDATORY("attVerification.mandatory"), + /** + * Represents the 'attrValue.verification' constant error identifier. + */ + ATTR_VALUE_VERIFICATION("attrValue.verification"), + + /** + * Represents the 'audienceRestrictionError' constant error identifier. + */ + AUDIENCE_RESTRICTION("audienceRestrictionError"), + /** + * Represents the 'auRequestIdError' constant error identifier. + */ + AU_REQUEST_ID("auRequestIdError"), + /** + * Represents the 'domain' constant error identifier. + */ + DOMAIN("domain"), + /** + * Represents the 'hash.error' constant error identifier. + */ + HASH_ERROR("hash.error"), + /** + * Represents the 'invalidAttributeList' constant error identifier. + */ + INVALID_ATTRIBUTE_LIST("invalidAttributeList"), + /** + * Represents the 'invalidAttributeValue' constant error identifier. + */ + INVALID_ATTRIBUTE_VALUE("invalidAttributeValue"), + /** + * Represents the 'qaaLevel' constant error identifier. + */ + QAALEVEL("qaaLevel"), + /** + * Represents the 'requests' constant error identifier. + */ + REQUESTS("requests"), + /** + * Represents the 'SPSAMLRequest' constant error identifier. + */ + SP_SAML_REQUEST("SPSAMLRequest"), + /** + * Represents the 'spepsSAMLRequest' constant error identifier. + */ + SPEPS_SAML_REQUEST("spepsSAMLRequest"), + /** + * Represents the 'IdPSAMLResponse' constant error identifier. + */ + IDP_SAML_RESPONSE("IdPSAMLResponse"), + /** + * Represents the 'cpepsSAMLResponse' constant error identifier. + */ + CPEPS_SAML_RESPONSE("cpepsSAMLResponse"), + /** + * Represents the 'cpepsSAMLResponse' constant error identifier. + */ + SPEPS_SAML_RESPONSE("spepsSAMLResponse"), + /** + * Represents the 'session' constant error identifier. + */ + SESSION("session"), + /** + * Represents the 'invalid.session' constant error identifier. + */ + INVALID_SESSION("invalid.session"), + /** + * Represents the 'invalid.sessionId' constant error identifier. + */ + INVALID_SESSION_ID("invalid.sessionId"), + /** + * Represents the 'missing.sessionId' constant error identifier. + */ + MISSING_SESSION_ID("sessionError"), + /** + * Represents the 'AtPSAMLResponse' constant error identifier. + */ + ATP_SAML_RESPONSE("AtPSAMLResponse"); + + /** + * Represents the constant's value. + */ + private String error; + + /** + * Solo Constructor. + * + * @param nError The Constant error value. + */ + PEPSErrors(final String nError) { + this.error = nError; + } + + /** + * Construct the errorCode Constant value. + * + * @return The errorCode Constant. + */ + public String errorCode() { + return error + ".code"; + } + + /** + * Construct the errorCode Constant value with the given code text. + * + * @param text the code text to append to the constant. + * + * @return The errorCode Constant for the given code text. + */ + public String errorCode(final String text) { + return error + "." + text + ".code"; + } + + /** + * Construct the errorMessage constant value. + * + * @return The errorMessage constant. + */ + public String errorMessage() { + return error + ".message"; + } + + /** + * Construct the errorMessage Constant value with the given message text. + * + * @param text the message text to append to the constant. + * + * @return The errorMessage Constant for the given text. + */ + public String errorMessage(final String text) { + return error + "." + text + ".message"; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + return error; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java new file mode 100644 index 000000000..37b204351 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java @@ -0,0 +1,511 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the STORK PEPS, Commons and Specific Parameters. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2011-07-07 20:48:45 $ + */ +public enum PEPSParameters { + + /** + * Represents the 'apId' parameter constant. + */ + AP_ID("apId"), + /** + * Represents the 'apUrl' parameter constant. + */ + AP_URL("apUrl"), + /** + * Represents the 'ap.number' parameter constant. + */ + AP_NUMBER("ap.number"), + + /** + * Represents the 'assertionConsumerServiceURL' parameter constant. + */ + ASSERTION_CONSUMER_S_URL("assertionConsumerServiceURL"), + + /** + * Represents the 'auth' parameter constant. + */ + AUTHENTICATION("auth"), + + /** + * Represents the 'auth-on-behalf-of' parameter constant. + */ + AUTHENTICATION_ON_BEHALF_OF("auth-on-behalf-of"), + + /** + * Represents the 'attr' parameter constant. + */ + ATTRIBUTE("attr"), + /** + * Represents the 'attrName' parameter constant. + */ + ATTRIBUTE_NAME("attrName"), + /** + * Represents the 'attrStatus' parameter constant. + */ + ATTRIBUTE_STATUS("attrStatus"), + /** + * Represents the 'attrType' parameter constant. + */ + ATTRIBUTE_TYPE("attrType"), + /** + * Represents the 'attrValue' parameter constant. + */ + ATTRIBUTE_VALUE("attrValue"), + /** + * Represents the 'attrList' parameter constant. + */ + ATTRIBUTE_LIST("attrList"), + /** + * Represents the 'attrTuple' parameter constant. + */ + ATTRIBUTE_TUPLE("attrTuple"), + /** + * Represents the 'attribute-missing' parameter constant. + */ + ATTRIBUTE_MISSING("attribute-missing"), + /** + * Represents the 'attributesNotAllowed' parameter constant. + */ + ATTRIBUTES_NOT_ALLOWED("attributesNotAllowed"), + /** + * Represents the 'authnRequest' parameter constant. + */ + AUTH_REQUEST("authnRequest"), + + /** + * Represents the 'attrValue.number' parameter constant. + */ + ATTR_VALUE_NUMBER("attrValue.number"), + + /** + * Represents the 'derivation.date.format' parameter constant. + */ + DERIVATION_DATE_FORMAT("derivation.date.format"), + /** + * Represents the 'deriveAttr.number' parameter constant. + */ + DERIVE_ATTRIBUTE_NUMBER("deriveAttr.number"), + + /** + * Represents the complex attributes parameter constant. + */ + COMPLEX_ADDRESS_VALUE("canonicalResidenceAddress"), + COMPLEX_NEWATTRIBUTE_VALUE("newAttribute2"), + COMPLEX_HASDEGREE_VALUE("hasDegree"), + COMPLEX_MANDATECONTENT_VALUE("mandateContent"), + /** + * Represents the 'consent-type' parameter constant. + */ + CONSENT_TYPE("consent-type"), + /** + * Represents the 'consent-value' parameter constant. + */ + CONSENT_VALUE("consent-value"), + /** + * Represents the 'country' parameter constant. + */ + COUNTRY("country"), + /** + * Represents the 'countryOrigin' parameter constant. + */ + COUNTRY_ORIGIN("countryOrigin"), + + /** + * Represents the 'cpepsURL' parameter constant. + */ + CPEPS_URL("cpepsURL"), + /** + * Represents the 'callback' parameter constant. + */ + CPEPS_CALLBACK("callback"), + /** + * Represents the 'peps.specificidpredirect.url' parameter constant. + */ + CPEPS_IDP_CALLBACK_VALUE("peps.specificidpredirect.url"), + /** + * Represents the 'peps.specificapredirect.url' parameter constant. + */ + CPEPS_AP_CALLBACK_VALUE("peps.specificapredirect.url"), + + /** + * Represents the 'errorCode' parameter constant. + */ + ERROR_CODE("errorCode"), + /** + * Represents the 'subCode' parameter constant. + */ + ERROR_SUBCODE("subCode"), + /** + * Represents the 'errorMessage' parameter constant. + */ + ERROR_MESSAGE("errorMessage"), + /** + * Represents the 'errorRedirectUrl' parameter constant. + */ + ERROR_REDIRECT_URL("errorRedirectUrl"), + + /** + * errorRedirectUrl Represents the 'external-authentication' parameter + * constant. + */ + EXTERNAL_AUTH("external-authentication"), + /** + * Represents the 'external-ap' parameter constant. + */ + EXTERNAL_AP("external-ap"), + /** + * Represents the 'external-sig-module' parameter constant. + */ + EXT_SIG_CREATOR_MOD("external-sig-module"), + + /** + * Represents the 'http-x-forwarded-for' parameter constant. + */ + HTTP_X_FORWARDED_FOR("http-x-forwarded-for"), + + /** + * Represents the 'idp.url' parameter constant. + */ + IDP_URL("idp.url"), + /** + * Represents the 'idpAUB.url' parameter constant. + */ + IDPAUB_URL("idpAUB.url"), + /** + * Represents the 'internal-authentication' parameter constant. + */ + INTERNAL_AUTH("internal-authentication"), + /** + * Represents the 'internal-ap' parameter constant. + */ + INTERNAL_AP("internal-ap"), + + /** + * Represents the 'samlIssuer' parameter constant. + */ + ISSUER("samlIssuer"), + /** + * Represents the 'samlIssuer.idp' parameter constant. + */ + ISSUER_IDP("samlIssuer.idp"), + /** + * Represents the 'samlIssuer.atp' parameter constant. + */ + ISSUER_ATP("samlIssuer.atp"), + + /** + * Represents the 'mandatory' parameter constant. + */ + MANDATORY("mandatory"), + /** + * Represents the 'mandatoryAttributeMissing' parameter constant. + */ + MANDATORY_ATTR_MISSING("mandatoryAttributeMissing"), + /** + * Represents the 'mandatoryConsentAttrMissing' parameter constant. + */ + MANDATORY_CONSENT_MISSING("mandatoryConsentAttrMissing"), + /** + * Represents the 'optional' parameter constant. + */ + OPTIONAL("optional"), + + /** + * Represents the 'no-consent-type' parameter constant. + */ + NO_CONSENT_TYPE("no-consent-type"), + /** + * Represents the 'no-consent-value' parameter constant. + */ + NO_CONSENT_VALUE("no-consent-value"), + + /** + * Represents the 'provider.name' parameter constant. + */ + PROVIDER_NAME_VALUE("providerName"), + /** + * Represents the 'cpeps.askconsent' parameter constant. + */ + PEPS_ASK_CONSENT("cpeps.askconsent"), + /** + * Represents the 'cpeps.askconsentvalue' parameter constant. + */ + PEPS_ASK_CONSENT_VALUE("cpeps.askconsentvalue"), + /** + * Represents the 'pepsAuth' parameter constant. + */ + PEPS_AUTH_CONSENT("pepsAuth"), + /** + * Represents the 'validation.bypass' parameter constant. + */ + PEPS_BYPASS("validation.bypass"), + /** + * Represents the 'cpeps.number' parameter constant. + */ + PEPS_NUMBER("cpeps.number"), + /** + * Represents the 'cpeps.specificapredirect.url' parameter constant. + */ + PEPS_SPECIFIC_URL("cpeps.specificapredirect.url"), + + /** + * Represents the 'qaaLevel' parameter constant. + */ + QAALEVEL("qaaLevel"), + + /** + * Represents the 'speps.redirectUrl' parameter constant. + */ + SPEPS_REDIRECT_URL("speps.redirectUrl"), + + /** + * Represents the 'sp.redirectUrl' parameter constant. + */ + SP_REDIRECT_URL("sp.redirectUrl"), + /** + * Represents the 'cpeps.redirectUrl' parameter constant. + */ + CPEPS_REDIRECT_URL("cpeps.redirectUrl"), + /** + * Represents the 'RelayState' parameter constant. + */ + RELAY_STATE("RelayState"), + /** + * Represents the 'remoteAddr' parameter constant. + */ + REMOTE_ADDR("remoteAddr"), + /** + * Represents the 'remoteUser' parameter constant. + */ + REMOTE_USER("remoteUser"), + + /** + * Represents the 'SAMLRequest' parameter constant. + */ + SAML_REQUEST("SAMLRequest"), + /** + * Represents the 'SAMLResponse' parameter constant. + */ + SAML_RESPONSE("SAMLResponse"), + /** + * Represents the 'SAMLFail' parameter constant. + */ + SAML_TOKEN_FAIL("SAMLFail"), + /** + * Represents the 'TokenId' parameter constant. + */ + SAML_TOKEN_ID("TokenId"), + /** + * Represents the 'inResponseTo' parameter constant. + */ + SAML_IN_RESPONSE_TO("inResponseTo"), + /** + * Represents the 'inResponseTo.idp' parameter constant. + */ + SAML_IN_RESPONSE_TO_IDP("inResponseTo.idp"), + /** + * Represents the 'inResponseTo.atp' parameter constant. + */ + SAML_IN_RESPONSE_TO_ATP("inResponseTo.atp"), + /** + * Represents the 'SignatureResponse' parameter constant. + */ + SIGNATURE_RESPONSE("SignatureResponse"), + + /** + * Represents the 'cPepsSession' parameter constant. + */ + SESSION_ID_URL("cPepsSession"), + /** + * Represents the 'spId' parameter constant. + */ + SP_ID("spId"), + /** + * Represents the 'spQaaLevel' parameter constant. + */ + SP_QAALEVEL("spQaaLevel"), + /** + * Represents the 'spUrl' parameter constant. + */ + SP_URL("spUrl"), + + /** + * Represents the 'allow.derivation.all' parameter constant. + */ + SPECIFIC_ALLOW_DERIVATION_ALL("allow.derivation.all"), + /** + * Represents the ''allow.unknowns parameter constant. + */ + SPECIFIC_ALLOW_UNKNOWNS("allow.unknowns"), + /** + * Represents the 'derivation.date.separator' parameter constant. + */ + SPECIFIC_DERIVATION_DATE_SEP("derivation.date.separator"), + /** + * Represents the 'derivation.month.position' parameter constant. + */ + SPECIFIC_DERIVATION_MONTH_POS("derivation.month.position"), + /** + * Represents the 'derivation.day.position' parameter constant. + */ + SPECIFIC_DERIVATION_DAY_POS("derivation.day.position"), + /** + * Represents the 'derivation.year.position' parameter constant. + */ + SPECIFIC_DERIVATION_YEAR_POS("derivation.year.position"), + + /** + * sp.authorized.parameters Represents the '' parameter constant. + */ + SPEPS_AUTHORIZED("sp.authorized.parameters"), + + /** + * Represents the 'spSector' constant value. + */ + SPSECTOR("spSector"), + /** + * Represents the 'spApplication' constant value. + */ + SPAPPLICATION("spApplication"), + /** + * Represents the 'spCountry' constant value. + */ + SPCOUNTRY("spCountry"), + /** + * Represents the 'spInstitution' constant value. + */ + SPINSTITUTION("spInstitution"), + /** + * Represents the 'storkAttribute.number' parameter constant. + */ + STORK_ATTRIBUTE_NUMBER("storkAttribute.number"), + /** + * Represents the 'storkAttributeValue.number' parameter constant. + */ + STORK_ATTRIBUTE_VALUE_NUMBER("storkAttributeValue.number"), + + /** + * Represents the 'username' parameter constant. + */ + USERNAME("username"), + + /** + * Represents the 'tooManyParameters' parameter constant. + */ + TOO_MANY_PARAMETERS("tooManyParameters"), + /** + * Represents the 'validation.active' parameter constant. + */ + VALIDATION_ACTIVE("validation.active"), + + /** + * Represents the 'x-forwarded-for' parameter constant. + */ + X_FORWARDED_FOR("x-forwarded-for"), + /** + * Represents the 'x-forwarded-host' parameter constant. + */ + X_FORWARDED_HOST("x-forwarded-host"), + /** + * Represents the 'XMLResponse' parameter constant. + */ + XML_RESPONSE("XMLResponse"), + + /** + * Represents the 'ap-cpeps.number' parameter constant. + */ + AP_PEPS_NUMBER("ap-cpeps.number"), + + /** + * Represents the 'atp.number' parameter constant. + */ + ATTRIBUTE_PROVIDER_NUMBER("atp.number"), + + /** + * Represents the 'apLinker' parameter constant. + */ + AP_LINKER("apLinker"), + + /** + * Represents the 'NOSEL' parameter constant (no attribute provider selected). + */ + AP_NO_SELECTION("NOSEL"), + + /** + * Represents the 'OCSEL' parameter constant (attribute provider in another country). + */ + AP_OTHER_COUNTRY("OCSEL"), + + /** + * Represents the '_provider' suffix parameter constant. + */ + AP_PROVIDER_SELECT_SUFFIX("_provider"), + + /** + * Represents the '_country' suffix parameter constant. + */ + AP_COUNTRY_SELECT_SUFFIX("_country"), + + /** + * Represents the 'next-ap' parameter constant. + */ + NEXT_AP("next-ap"), + + /** + * Represents the 'next-apeps' parameter constant. + */ + NEXT_APEPS("next-apeps"), + + /** + * Represents the 'attr-filter.number' parameter constant. + */ + ATTRIBUTES_FILTER_NUMBER("attr-filter.number"), + + /** + * Represents the 'atp.url' parameter constant. + */ + ATP_URL("atp.url"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param nValue The Constant value. + */ + PEPSParameters(final String nValue) { + this.value = nValue; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + return value; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java new file mode 100644 index 000000000..ae1f203f5 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java @@ -0,0 +1,353 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.UnsupportedEncodingException; +import java.util.Properties; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.bouncycastle.crypto.Digest; +import org.bouncycastle.util.encoders.Base64; + +import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; +import eu.stork.peps.auth.commons.exceptions.InvalidParameterPEPSException; + +/** + * This class holds static helper methods. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.75 $, $Date: 2010-11-23 00:05:35 $ + */ +public final class PEPSUtil { + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(PEPSUtil.class.getName()); + + /** + * Configurations object. + */ + private static Properties configs; + + /** + * Max prefix. + */ + private static final String MAX_PARAM_PREFIX = "max."; + + /** + * Code prefix to get error code. + */ + private static final String CODE_PARAM_SUFFIX = ".code"; + + /** + * param's size prefix to get max param size. + */ + private static final String MAX_PARAM_SUFFIX = ".size"; + + /** + * Message prefix to get error message. + */ + private static final String MSG_PARAM_SUFFIX = ".message"; + + /** + * Private constructor. Prevents the class from being instantiated. + */ + private PEPSUtil() { + // empty constructor + } + + /** + * Creates a single instance of this class and sets the properties. + * + * @param nConfigs The set of available configurations. + * + * @return The created PEPSUtil's class. + */ + public static PEPSUtil createInstance(final Properties nConfigs) { + if (nConfigs != null) { + PEPSUtil.configs = nConfigs; + } + return new PEPSUtil(); + } + + /** + * Getter for the Properties. + * + * @return configs The properties value. + */ + public Properties getConfigs() { + return configs; + } + + /** + * Setter for the Properties. + * + * @param nConfigs The new properties value. + */ + public static void setConfigs(final Properties nConfigs) { + if (nConfigs != null) { + PEPSUtil.configs = nConfigs; + } + } + + /** + * Returns the identifier of some configuration given a set of configurations + * and the corresponding configuration key. + * + * @param configKey The key that IDs some configuration. + * + * @return The configuration String value. + */ + public static String getConfig(final String configKey) { + return configs.getProperty(configKey); + } + + /** + * Validates the input paramValue identified by the paramName. + * + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + * + * @return true if the parameter is valid. + */ + public static boolean isValidParameter(final String paramName, + final String paramValue) { + + final String validationParam = + PEPSUtil.getConfig(PEPSParameters.VALIDATION_ACTIVE.toString()); + boolean retVal = true; + + final String paramConf = MAX_PARAM_PREFIX + paramName + MAX_PARAM_SUFFIX; + + if (PEPSValues.TRUE.toString().equals(validationParam)) { + final String paramSizeStr = PEPSUtil.getConfig(paramConf); + // Checking if the parameter size exists and if it's numeric + if (StringUtils.isNumeric(paramSizeStr)) { + final int maxParamSize = Integer.valueOf(paramSizeStr); + if (StringUtils.isEmpty(paramValue) + || (paramValue.length() > maxParamSize)) { + retVal = false; + LOG.warn("Invalid parameter [" + paramName + "] value " + paramValue); + } + } else { + retVal = false; + LOG.error("Missing " + paramConf + + " configuration in the pepsUtils.properties configuration file"); + } + } + return retVal; + } + + /** + * Validates the Parameter and throws an exception if an error occurs. Throws + * an InvalidParameterPEPSException runtime exception if the parameter is + * invalid. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + */ + public static void validateParameter(final String className, + final String paramName, final Object paramValue) { + + if (paramValue == null) { + PEPSUtil.validateParameter(className, paramName, ""); + } else { + PEPSUtil.validateParameter(className, paramName, paramValue.toString()); + } + } + + /** + * Validates the Parameters and throws an exception if an error occurs. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + */ + public static void validateParameter(final String className, + final String paramName, final String paramValue) { + + PEPSUtil.validateParameter(className, paramName, paramValue, + PEPSUtil.getErrorCode(paramName), PEPSUtil.getErrorMessage(paramName)); + } + + /** + * Validates the Parameters and throws an exception if an error occurs. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + * @param error The PEPSError to get error code and messages from configs. + */ + public static void validateParameter(final String className, + final String paramName, final String paramValue, final PEPSErrors error) { + + PEPSUtil.validateParameter(className, paramName, paramValue, + PEPSUtil.getConfig(error.errorCode()), + PEPSUtil.getConfig(error.errorMessage())); + } + + /** + * Validates the HTTP Parameter and throws an exception if an error occurs. + * Throws an InvalidParameterPEPSException runtime exception if the parameter + * is invalid. + * + * @param className The Class Name that invoked the method. + * @param paramName The name of the parameter to validate. + * @param paramValue The value of the parameter to validate. + * @param errorCode The error code to include on the exception. + * @param errorMessage The error message to include on the exception. + */ + public static void validateParameter(final String className, + final String paramName, final String paramValue, final String errorCode, + final String errorMessage) { + + if (!isValidParameter(paramName, paramValue)) { + LOG.warn("Invalid parameter [" + paramName + "] value found at " + + className); + throw new InvalidParameterPEPSException(errorCode, errorMessage); + } + } + + /** + * Getter for the error code of some given error related to the input param. + * + * @param paramName The name of the parameter associated with the error. + * + * @return The code of the error. + */ + private static String getErrorCode(final String paramName) { + return getConfig(paramName + CODE_PARAM_SUFFIX); + } + + /** + * Getter for the error message of some given error related to the input + * parameter. + * + * @param paramName The name of the parameter associated with the message. + * + * @return The message for the error. + */ + private static String getErrorMessage(final String paramName) { + return getConfig(paramName + MSG_PARAM_SUFFIX); + } + + /** + * {@link Base64} encodes the input samlToken parameter. + * + * @param samlToken the SAML Token to be encoded. + * + * @return The Base64 String representing the samlToken. + * + * @see Base64#encode + */ + public static String encodeSAMLToken(final byte[] samlToken) { + try { + return new String(Base64.encode(samlToken), "UTF8"); + } catch (UnsupportedEncodingException e) { + LOG.error(PEPSErrors.INTERNAL_ERROR.errorMessage(), e); + return null; + } + } + + /** + * Decodes the {@link Base64} String input parameter representing a samlToken. + * + * @param samlToken the SAML Token to be decoded. + * + * @return The samlToken decoded bytes. + * + * @see Base64#decode + */ + public static byte[] decodeSAMLToken(final String samlToken) { + return Base64.decode(samlToken); + } + + /** + * Hashes a SAML token. Throws an InternalErrorPEPSException runtime exception + * if the Cryptographic Engine fails. + * + * @param samlToken the SAML Token to be hashed. + * + * @return byte[] with the hashed SAML Token. + */ + public static byte[] hashPersonalToken(final byte[] samlToken) { + try { + final String className = + PEPSUtil.getConfig(PEPSValues.HASH_DIGEST_CLASS.toString()); + + final Digest digest = + (Digest) Class.forName(className).getConstructor() + .newInstance((Object[]) null); + digest.update(samlToken, 0, samlToken.length); + + final int retLength = digest.getDigestSize(); + final byte[] ret = new byte[retLength]; + + digest.doFinal(ret, 0); + return ret; + + } catch (final Exception e) { + // For all those exceptions that could be thrown, we always log it and + // thrown an InternalErrorPEPSException. + LOG.error(PEPSErrors.HASH_ERROR.errorMessage(), e); + throw new InternalErrorPEPSException( + PEPSUtil.getConfig(PEPSErrors.HASH_ERROR.errorCode()), + PEPSUtil.getConfig(PEPSErrors.HASH_ERROR.errorMessage()), e); + } + } + + /** + * Gets the Stork error code in the error message if exists! + * + * @param errorMessage The message to get the error code if exists; + * + * @return the error code if exists. Returns null otherwise. + */ + public static String getStorkErrorCode(final String errorMessage) { + if (StringUtils.isNotBlank(errorMessage) + && errorMessage.indexOf(PEPSValues.ERROR_MESSAGE_SEP.toString()) >= 0) { + final String[] msgSplitted = + errorMessage.split(PEPSValues.ERROR_MESSAGE_SEP.toString()); + if (msgSplitted.length == 2 && StringUtils.isNumeric(msgSplitted[0])) { + return msgSplitted[0]; + } + } + return null; + } + + /** + * Gets the Stork error message in the saml message if exists! + * + * @param errorMessage The message to get in the saml message if exists; + * + * @return the error message if exists. Returns the original message + * otherwise. + */ + public static String getStorkErrorMessage(final String errorMessage) { + if (StringUtils.isNotBlank(errorMessage) + && errorMessage.indexOf(PEPSValues.ERROR_MESSAGE_SEP.toString()) >= 0) { + final String[] msgSplitted = + errorMessage.split(PEPSValues.ERROR_MESSAGE_SEP.toString()); + if (msgSplitted.length == 2 && StringUtils.isNumeric(msgSplitted[0])) { + return msgSplitted[1]; + } + } + return errorMessage; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java new file mode 100644 index 000000000..568c25053 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java @@ -0,0 +1,325 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains all the value constants. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.17 $, $Date: 2011-07-07 20:48:45 $ + */ +public enum PEPSValues { + + /** + * Represents the 'all' constant value. + */ + ALL("all"), + /** + * Represents the 'none' constant value. + */ + NONE("none"), + /** + * Represents the 'true' constant value. + */ + TRUE("true"), + /** + * Represents the 'false' constant value. + */ + FALSE("false"), + /** + * Represents the empty string constant value. + */ + EMPTY_STRING(""), + + /** + * Represents the ',' separator constant value. + */ + ATTRIBUTE_VALUE_SEP(","), + /** + * Represents the ';' separator constant value. + */ + ATTRIBUTE_SEP(";"), + /** + * Represents the ':' separator constant value. + */ + ATTRIBUTE_TUPLE_SEP(":"), + /** + * Represents the '/' separator constant value. + */ + EID_SEPARATOR("/"), + /** + * Represents the ' - ' separator constant value. + */ + ERROR_MESSAGE_SEP(" - "), + /** + * Represents the '#' parameter constant value. + */ + LOGGER_SEP("#"), + /** + * Represents the 'NOT_AVAILABLE' parameter constant value. + */ + NOT_AVAILABLE("NotAvailable"), + /** + * Represents the ';' parameter constant value. + */ + SPEPS_AUTHORIZED_SEP(";"), + + /** + * Represents the 'ap' constant value. + */ + AP("ap"), + /** + * Represents the 'C-PEPS' constant value. + */ + CPEPS("C-PEPS"), + /** + * Represents the 'cpeps' constant value. + */ + CPEPS_PREFIX("cpeps"), + /** + * Represents the 'peps' constant value. + */ + PEPS("peps"), + /** + * Represents the '-PEPS' constant value. + */ + PEPS_SUFFIX("-PEPS"), + /** + * Represents the 'SP' constant value. + */ + SP("SP"), + /** + * Represents the 'S-PEPS' constant value. + */ + SPEPS("S-PEPS"), + /** + * Represents the 'speps' constant value. + */ + SPEPS_PREFIX("speps"), + /** + * Represents the 'sp.default.parameters' constant value. + */ + DEFAULT("sp.default.parameters"), + /** + * Represents the default saml id constant value. + */ + DEFAULT_SAML_ID("1"), + /** + * Represents the 'hashDigest.className' constant value. + */ + HASH_DIGEST_CLASS("hashDigest.className"), + + /** + * Represents the 'eu.stork.communication.requests' constant value. + */ + STORK_PACKAGE_REQUEST_LOGGER_VALUE("eu.stork.communication.requests"), + /** + * Represents the 'eu.stork.communication.responses' constant value. + */ + STORK_PACKAGE_RESPONSE_LOGGER_VALUE("eu.stork.communication.responses"), + + /** + * Represents the 'S-PEPS receives request from SP' constant value. + */ + SP_REQUEST("S-PEPS receives request from SP"), + /** + * Represents the 'Get Citizen Consent' constant value. + */ + CITIZEN_CONSENT_LOG("Get Citizen Consent"), + /** + * Represents the 'C-PEPS receives request from S-PEPS' constant value. + */ + CPEPS_REQUEST("C-PEPS receives request from S-PEPS"), + /** + * Represents the 'C-PEPS generates response to S-PEPS' constant value. + */ + CPEPS_RESPONSE("C-PEPS generates response to S-PEPS"), + /** + * Represents the 'S-PEPS generates request to C-PEPS' constant value. + */ + SPEPS_REQUEST("S-PEPS generates request to C-PEPS"), + /** + * Represents the 'S-PEPS receives response from C-PEPS' constant value. + */ + SPEPS_RESPONSE("S-PEPS receives response from C-PEPS"), + /** + * Represents the 'S-PEPS generates response to SP' constant value. + */ + SP_RESPONSE("S-PEPS generates response to SP"), + /** + * Represents the 'Success' constant value. + */ + SUCCESS("Success"), + /** + * Represents the December's month number constant value. + */ + LAST_MONTH("12"), + /** + * Represents the yyyyMM constant value. + */ + NO_DAY_DATE_FORMAT("yyyyMM"), + + /** + * Represents the 'attrValue' constant value. + */ + ATTRIBUTE("attrValue"), + /** + * Represents the 'derivedAttr' constant value. + */ + DERIVE_ATTRIBUTE("deriveAttr"), + /** + * Represents the 'storkAttribute' constant value. + */ + STORK_ATTRIBUTE("storkAttribute"), + + /** + * Represents the 'properties' constant value. + */ + PROPERTIES("properties"), + /** + * Represents the 'referer' constant value. + */ + REFERER("referer"), + /** + * Represents the 'host' constant value. + */ + HOST("host"), + /** + * Represents the 'spid' constant value. + */ + SPID("spid"), + /** + * Represents the 'domain' constant value. + */ + DOMAIN("domain"), + /** + * Represents the '.validation' constant value. + */ + VALIDATION_SUFFIX(".validation"), + /** + * Represents the 'jsessionid' constant value. + */ + EQUAL("="), + /** + * Represents the 'HttpOnly' constant value. + */ + HTTP_ONLY("HttpOnly"), + /** + * Represents the 'SET-COOKIE' constant value. + */ + JSSESSION("JSESSIONID"), + /** + * Represents the '=' constant value. + */ + SETCOOKIE("SET-COOKIE"), + /** + * Represents the ';' constant value. + */ + SEMICOLON(";"), + /** + * Represents the ' ' constant value. + */ + SPACE(" "), + /** + * Represents the 'atp' constant value. + */ + APROVIDER_PREFIX("atp"), + /** + * Represents the 'ap-cpeps' constant value. + */ + AP_CPEPS_PREFIX("ap-cpeps"), + /** + * Represents the 'attr-filter' constant value. + */ + AP_ATTRFILTER_PREFIX("attr-filter"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param val The Constant value. + */ + PEPSValues(final String val) { + + this.value = val; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + + return value; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".id". + * + * @param index the number. + * + * @return The concatenated String value. + */ + public String index(final int index) { + + return value + index + ".id"; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".value". + * + * @param index the number. + * + * @return The concatenated string value. + */ + public String value(final int index) { + + return value + index + ".value"; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".name". + * + * @param index the number. + * + * @return The concatenated String value. + */ + public String name(final int index) { + + return value + index + ".name"; + } + + /** + * Construct the return value with the following structure + * CONSTANT_VALUE+index+".url". + * + * @param index the number. + * + * @return The concatenated String value. + */ + public String url(final int index) { + + return value + index + ".url"; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java new file mode 100644 index 000000000..bb9b3b694 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java @@ -0,0 +1,323 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.log4j.Logger; + +import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; + +/** + * This class is a bean used to store the information relative to the + * PersonalAttribute. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.22 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class PersonalAttribute implements Serializable, Cloneable { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 2612951678412632174L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(PersonalAttribute.class + .getName()); + + /** + * Name of the personal attribute. + */ + private String name; + + /** + * Values of the personal attribute. + */ + private List value = new ArrayList(); + + /** + * Complex values of the personal attribute. + */ + private Map complexValue = new HashMap(); + + /** + * Is the personal attribute mandatory? + */ + private transient boolean required; + + /** + * Returned status of the attribute from the IdP. + */ + private String status; + + /** + * Name of the personal attribute. + */ + private String friendlyName; + + /** + * Empty Constructor. + */ + public PersonalAttribute() { + super(); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final List attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * PersonalAttribute Constructor for complex values. + * + * @param attrName The attribute name. + * @param attrIsRequired The attribute type value. + * @param attrComplexValue The attribute's complex value. + * @param attrStatus The attribute's status value. + */ + public PersonalAttribute(final String attrName, final boolean attrIsRequired, + final Map attrComplexValue, final String attrStatus) { + this.setName(attrName); + this.setIsRequired(attrIsRequired); + this.setComplexValue(attrComplexValue); + this.setStatus(attrStatus); + } + + /** + * {@inheritDoc} + */ + @SuppressWarnings("unchecked") + public Object clone() { + + try { + final PersonalAttribute personalAttr = (PersonalAttribute) super.clone(); + personalAttr.setIsRequired(this.isRequired()); + personalAttr.setName(this.getName()); + personalAttr.setStatus(this.getStatus()); + if (!isEmptyValue()) { + final List val = + (List) ((ArrayList) this.getValue()).clone(); + personalAttr.setValue(val); + } + if (!isEmptyComplexValue()) { + final Map complexVal = + (Map) ((HashMap) this + .getComplexValue()).clone(); + personalAttr.setComplexValue(complexVal); + } + return personalAttr; + } catch (final CloneNotSupportedException e) { + // assert false; + LOG.trace("Nothing to do."); + throw new InternalErrorPEPSException( + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorCode()), + PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorMessage()), e); + } + } + + /** + * Getter for the required value. + * + * @return The required value. + */ + public boolean isRequired() { + return required; + } + + /** + * Setter for the required value. + * + * @param attrIsRequired this attribute? + */ + public void setIsRequired(final boolean attrIsRequired) { + this.required = attrIsRequired; + } + + /** + * Getter for the name value. + * + * @return The name value. + */ + public String getName() { + return name; + } + + /** + * Setter for the name value. + * + * @param attrName The personal attribute name. + */ + public void setName(final String attrName) { + this.name = attrName; + } + + /** + * Getter for the value. + * + * @return The list of values. + */ + public List getValue() { + return value; + } + + /** + * Setter for the list of values. + * + * @param attrValue The personal attribute value. + */ + public void setValue(final List attrValue) { + if (attrValue != null) { + this.value = attrValue; + } + } + + /** + * Getter for the status. + * + * @return The status value. + */ + public String getStatus() { + return status; + } + + /** + * Setter for the status value. + * + * @param attrStatus The personal attribute status. + */ + public void setStatus(final String attrStatus) { + this.status = attrStatus; + } + + /** + * Getter for the complex value. + * + * @return The complex value. + */ + public Map getComplexValue() { + return complexValue; + } + + /** + * Setter for the complex value. + * + * @param complexVal The personal attribute Complex value. + */ + public void setComplexValue(final Map complexVal) { + if (complexVal != null) { + this.complexValue = complexVal; + } + } + + /** + * Getter for the personal's friendly name. + * + * @return The personal's friendly name value. + */ + public String getFriendlyName() { + return friendlyName; + } + + /** + * Setter for the personal's friendly name. + * + * @param fName The personal's friendly name. + */ + public void setFriendlyName(final String fName) { + this.friendlyName = fName; + } + + /** + * Return true the value is empty. + * + * @return True if the value is empty "[]"; + */ + public boolean isEmptyValue() { + return value.isEmpty() || (value.size() == 1 && value.get(0).length() == 0); + } + + /** + * Returns true if the Complex Value is empty. + * + * @return True if the Complex Value is empty; + */ + public boolean isEmptyComplexValue() { + return complexValue.isEmpty(); + } + + /** + * Returns true if the Status is empty. + * + * @return True if the Status is empty; + */ + public boolean isEmptyStatus() { + return (status == null || status.length() == 0); + } + + /** + * Prints the PersonalAttribute in the following format. + * name:required:[v,a,l,u,e,s]|[v=a,l=u,e=s]:status; + * + * @return The PersonalAttribute as a string. + */ + public String toString() { + final StringBuilder strBuild = new StringBuilder(); + + AttributeUtil.appendIfNotNull(strBuild, getName()); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, String.valueOf(isRequired())); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + strBuild.append('['); + + if (isEmptyValue()) { + if (!isEmptyComplexValue()) { + AttributeUtil.appendIfNotNull(strBuild, AttributeUtil.mapToString( + getComplexValue(), PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + } else { + AttributeUtil.appendIfNotNull( + strBuild, + AttributeUtil.listToString(getValue(), + PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); + } + + strBuild.append(']'); + strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); + AttributeUtil.appendIfNotNull(strBuild, getStatus()); + strBuild.append(PEPSValues.ATTRIBUTE_SEP.toString()); + + return strBuild.toString(); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java new file mode 100644 index 000000000..d33ccfe18 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java @@ -0,0 +1,305 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; +import java.util.StringTokenizer; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +/** + * This class is a bean used to store the information relative to the + * PersonalAttributeList. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.27 $, $Date: 2010-11-18 22:54:56 $ + * + * @see PersonalAttribute + */ +@SuppressWarnings("PMD") +public final class PersonalAttributeList extends + HashMap implements IPersonalAttributeList{ + + /** + * Logger object. + */ + private static final Logger LOG = Logger + .getLogger(PersonalAttributeList.class.getName()); + + /** + * Serial id. + */ + private static final long serialVersionUID = 7375127363889975062L; + + /** + * Hash with the latest fetched attribute name alias. + */ + private final transient Map latestAttrAlias = + new HashMap(); + + /** + * Hash with mapping number of alias or the attribute name. + */ + private final transient Map attrAliasNumber = + new HashMap(); + + /** + * Default constructor. + */ + public PersonalAttributeList() { + // The best practices recommend to call the super constructor. + super(); + } + + /** + * Constructor with initial capacity for the PersonalAttributeList size. + * + * @param capacity The initial capacity for the PersonalAttributeList. + */ + public PersonalAttributeList(final int capacity) { + super(capacity); + } + + /** + * {@inheritDoc} + */ + public Iterator iterator() { + return this.values().iterator(); + } + + /** + * {@inheritDoc} + */ + public PersonalAttribute get(final Object key) { + String attrName = (String) key; + + if (this.latestAttrAlias.containsKey(key)) { + attrName = attrName + this.latestAttrAlias.get(key); + } else { + if (this.attrAliasNumber.containsKey(key)) { + this.latestAttrAlias.put(attrName, this.attrAliasNumber.get(key)); + } + } + return super.get(attrName); + } + + /** + * {@inheritDoc} + */ + public void add(final PersonalAttribute value) { + if (value != null) { + this.put(value.getName(), value); + } + } + + /** + * {@inheritDoc} + */ + public PersonalAttribute put(final String key, final PersonalAttribute val) { + if (StringUtils.isNotEmpty(key) && val != null) { + // Validate if attribute name already exists! + String attrAlias = key; + if (this.containsKey(key)) { + if (!val.isEmptyValue() && StringUtils.isNumeric(val.getValue().get(0))) { + final String attrValue = val.getValue().get(0); + attrAlias = key + attrValue; + this.attrAliasNumber.put(key, Integer.valueOf(attrValue)); + } else { + final PersonalAttribute attr = super.get(key); + if (!attr.isEmptyValue() + && StringUtils.isNumeric(attr.getValue().get(0))) { + attrAlias = key + attr.getValue().get(0); + super.put(key, (PersonalAttribute) attr); + this.attrAliasNumber.put(key, null); + } + } + } + return super.put(attrAlias, val); + } else { + return null; + } + } + + /** + * {@inheritDoc} + */ + public void populate(final String attrList) { + final StringTokenizer strToken = + new StringTokenizer(attrList, PEPSValues.ATTRIBUTE_SEP.toString()); + + while (strToken.hasMoreTokens()) { + final PersonalAttribute persAttr = new PersonalAttribute(); + String[] tuples = + strToken.nextToken().split(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(), + AttributeConstants.NUMBER_TUPLES.intValue()); + + // Convert to the new format if needed! + tuples = convertFormat(tuples); + + if (AttributeUtil.hasValidTuples(tuples)) { + final int attrValueIndex = + AttributeConstants.ATTR_VALUE_INDEX.intValue(); + final String tmpAttrValue = + tuples[attrValueIndex].substring(1, + tuples[attrValueIndex].length() - 1); + final String[] vals = + tmpAttrValue.split(PEPSValues.ATTRIBUTE_VALUE_SEP.toString()); + + persAttr.setName(tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()]); + persAttr.setIsRequired(Boolean + .valueOf(tuples[AttributeConstants.ATTR_TYPE_INDEX.intValue()])); + + // check if it is a complex value + if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_ADDRESS_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_NEWATTRIBUTE_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + + else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_HASDEGREE_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] + .equals(PEPSParameters.COMPLEX_MANDATECONTENT_VALUE.toString())) + { + persAttr.setComplexValue(createComplexValue(vals)); + } + else + { + persAttr.setValue(createValues(vals)); + } + + if (tuples.length == AttributeConstants.NUMBER_TUPLES.intValue()) { + persAttr.setStatus(tuples[AttributeConstants.ATTR_STATUS_INDEX + .intValue()]); + } + this.put(tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()], + persAttr); + + } else { + LOG.warn("Invalid personal attribute list tuples"); + } + + } + } + + /** + * Returns a copy of this IPersonalAttributeList instance. + * + * @return The copy of this IPersonalAttributeList. + */ + public Object clone() { + return (PersonalAttributeList) super.clone(); + } + + /** + * Creates a string in the following format. + * + * attrName:attrType:[attrValue1,attrValue2=attrComplexValue]:attrStatus; + * + * @return {@inheritDoc} + */ + @Override + public String toString() { + final Iterator> itAttrs = + this.entrySet().iterator(); + final StringBuilder strBuilder = new StringBuilder(); + + while (itAttrs.hasNext()) { + final Entry attrEntry = itAttrs.next(); + final PersonalAttribute attr = attrEntry.getValue(); + strBuilder.append(attr.toString()); + } + + return strBuilder.toString(); + } + + /** + * Validates and creates the attribute's complex values. + * + * @param values The complex values. + * + * @return The {@link Map} with the complex values. + * + * @see Map + */ + private Map createComplexValue(final String[] values) { + final Map complexValue = new HashMap(); + for (final String val : values) { + final String[] tVal = val.split("="); + if (StringUtils.isNotEmpty(val) && tVal.length == 2) { + complexValue.put(tVal[0], AttributeUtil.unescape(tVal[1])); + } + } + return complexValue; + } + + /** + * Validates and creates the attribute values. + * + * @param vals The attribute values. + * + * @return The {@link List} with the attribute values. + * + * @see List + */ + private List createValues(final String[] vals) { + final List values = new ArrayList(); + for (final String val : vals) { + if (StringUtils.isNotEmpty(val)) { + values.add(AttributeUtil.unescape(val)); + } + } + return values; + } + + /** + * Converts the attribute tuple (attrName:attrType...) to the new format. + * + * @param tuples The attribute tuples to convert. + * + * @return The attribute tuples in the new format. + */ + private String[] convertFormat(final String[] tuples) { + final String[] newFormatTuples = + new String[AttributeConstants.NUMBER_TUPLES.intValue()]; + if (tuples != null) { + System.arraycopy(tuples, 0, newFormatTuples, 0, tuples.length); + + for (int i = tuples.length; i < newFormatTuples.length; i++) { + if (i == AttributeConstants.ATTR_VALUE_INDEX.intValue()) { + newFormatTuples[i] = "[]"; + } else { + newFormatTuples[i] = ""; + } + } + } + return newFormatTuples; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java new file mode 100644 index 000000000..33160f2ac --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java @@ -0,0 +1,426 @@ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +public class STORKAttrQueryRequest implements Serializable, Cloneable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 4778480781609392750L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAttrQueryRequest.class + .getName()); + + /** The samlId. */ + private String samlId; + + /** The destination. */ + private String destination; + + /** The distinguished name. */ + private String distinguishedName; + + /** The e id sector share. */ + private boolean eIDSectorShare; + + /** The e id cross sector share. */ + private boolean eIDCrossSectorShare; + + /** The e id cross border share. */ + private boolean eIDCrossBorderShare; + + /** The personal attribute list. */ + private IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** The qaa. */ + private int qaa; + + /** The token saml. */ + private byte[] tokenSaml = new byte[0]; + + /** The issuer. */ + private String issuer; + + /** The service provider sector. */ + private String spSector; + + /** The service provider institution. */ + private String spInstitution; + + /** The service provider application. */ + private String spApplication; + + /** The service provider country. */ + private String spCountry; + + /** The country. */ + private String country; + + /** The citizen country code. */ + private String citizenCountry; + + /** The Service Provider ID. */ + private String sPID; + + /** The Alias used at the keystore for saving this certificate. */ + private String alias; + + /** + * Gets the SP's Certificate Alias. + * + * @return alias The SP's Certificate Alias. + */ + public String getAlias() { + return alias; + } + + /** + * Sets the SP's Certificate Alias. + * + * @param nAlias The SP's Certificate Alias. + */ + public void setAlias(final String nAlias) { + this.alias = nAlias; + } + + /** + * Gets the SP ID. + * + * @return sPID The SP ID. + */ + public String getSPID() { + return sPID; + } + + /** + * Sets the SP ID. + * + * @param sPId The new sp samlId. + */ + public void setSPID(final String sPId) { + this.sPID = sPId; + } + + /** + * Gets the citizen country code. + * + * @return The citizen country code value. + */ + public String getCitizenCountryCode() { + return citizenCountry; + } + + /** + * Sets the citizen country code. + * + * @param countryCode the new citizen country code value. + */ + public void setCitizenCountryCode(final String countryCode) { + this.citizenCountry = countryCode; + } + + /** + * Gets the sp country. + * + * @return The sp country value. + */ + public String getSpCountry() { + return spCountry; + } + + /** + * Sets the sp country. + * + * @param sPCountry the new sp country value. + */ + public void setSpCountry(final String sPCountry) { + this.spCountry = sPCountry; + } + + /** + * Gets the issuer. + * + * @return The issuer value. + */ + public String getIssuer() { + return issuer; + } + + /** + * Sets the issuer. + * + * @param samlIssuer the new issuer value. + */ + public void setIssuer(final String samlIssuer) { + this.issuer = samlIssuer; + } + + /** + * Gets the SAML Token. + * + * @return The SAML Token value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Sets the SAML Token. + * + * @param samlToken The new SAML Token value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Gets the country. + * + * @return The country value. + */ + public String getCountry() { + return country; + } + + /** + * Sets the country. + * + * @param nCountry the new country value. + */ + public void setCountry(final String nCountry) { + this.country = nCountry; + } + + /** + * Getter for the qaa value. + * + * @return The qaa value value. + */ + public int getQaa() { + return qaa; + } + + /** + * Setter for the qaa value. + * + * @param qaaLevel The new qaa value. + */ + public void setQaa(final int qaaLevel) { + this.qaa = qaaLevel; + } + + /** + * Getter for the destination value. + * + * @return The destination value. + */ + public String getDestination() { + return destination; + } + + /** + * Setter for the destination value. + * + * @param detination the new destination value. + */ + public void setDestination(final String detination) { + this.destination = detination; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param newSamlId the new samlId value. + */ + public void setSamlId(final String newSamlId) { + this.samlId = newSamlId; + } + + + /** + * Getter for the attributeList value. + * + * @return The attributeList value. + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the attributeList value. + * + * @param attrList the personal attribute list value. + * + * @see IPersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the distinguishedName value. + * + * @return The distinguishedName value. + */ + public String getDistinguishedName() { + return distinguishedName; + } + + /** + * Setter for the distinguishedName value. + * + * @param certDN the distinguished name value. + */ + public void setDistinguishedName(final String certDN) { + this.distinguishedName = certDN; + } + + /** + * Gets the service provider sector. + * + * @return The service provider sector value. + */ + public String getSpSector() { + return spSector; + } + + /** + * Sets the service provider sector. + * + * @param samlSPSector the new service provider sector value. + */ + public void setSpSector(final String samlSPSector) { + this.spSector = samlSPSector; + } + + /** + * Gets the service provider institution. + * + * @return The service provider institution value. + */ + public String getSpInstitution() { + return spInstitution; + } + + /** + * Sets the service provider institution. + * + * @param samlSPInst the new service provider institution value. + */ + public void setSpInstitution(final String samlSPInst) { + this.spInstitution = samlSPInst; + } + + /** + * Gets the service provider application. + * + * @return The service provider application value. + */ + public String getSpApplication() { + return spApplication; + } + + /** + * Sets the service provider application. + * + * @param samlSPApp the new service provider application value. + */ + public void setSpApplication(final String samlSPApp) { + this.spApplication = samlSPApp; + } + + /** + * Checks if is eId sector share. + * + * @return true, if is eId sector share. + */ + public boolean isEIDSectorShare() { + return eIDSectorShare; + } + + /** + * Sets the eId sector share. + * + * @param eIdSectorShare the new eId sector share value. + */ + public void setEIDSectorShare(final boolean eIdSectorShare) { + this.eIDSectorShare = eIdSectorShare; + } + + /** + * Checks if is eId cross sector share. + * + * @return true, if is eId cross sector share. + */ + public boolean isEIDCrossSectorShare() { + return eIDCrossSectorShare; + } + + /** + * Sets the eId cross sector share. + * + * @param eIdCrossSectorShare the new eId cross sector share value. + */ + public void setEIDCrossSectorShare(final boolean eIdCrossSectorShare) { + this.eIDCrossSectorShare = eIdCrossSectorShare; + } + + /** + * Checks if is eId cross border share. + * + * @return true, if is eId cross border share. + */ + public boolean isEIDCrossBorderShare() { + return eIDCrossBorderShare; + } + + /** + * Sets the eId cross border share. + * + * @param eIdCrossBorderShare the new eId cross border share value. + */ + public void setEIDCrossBorderShare(final boolean eIdCrossBorderShare) { + this.eIDCrossBorderShare = eIdCrossBorderShare; + } + + /** + * Returns a copy of this STORKAttrQueryRequest instance. + * + * @return The copy of this STORKAttrQueryRequest. + * @throws CloneNotSupportedException on clone exception + */ + @Override + public Object clone() throws CloneNotSupportedException{ + STORKAttrQueryRequest storkAttrQueryReq = null; + storkAttrQueryReq = (STORKAttrQueryRequest) super.clone(); + storkAttrQueryReq.setPersonalAttributeList(getPersonalAttributeList()); + storkAttrQueryReq.setTokenSaml(getTokenSaml()); + return storkAttrQueryReq; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java new file mode 100644 index 000000000..215b978dc --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java @@ -0,0 +1,301 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import org.apache.log4j.Logger; +import org.joda.time.DateTime; + +public class STORKAttrQueryResponse { + + /** Response Id. */ + private String samlId; + + /** Request failed? */ + private boolean fail; + + /** Status code. */ + private String statusCode; + + /** Secondary status code. */ + private String subStatusCode; + + /** Audience restriction. */ + private transient String audienceRest; + + /** Error message. */ + private String message; + + /** Id of the request that originated this response. */ + private String inResponseTo; + + /** Expiration date. */ + private DateTime notOnOrAfter; + + /** Creation date. */ + private DateTime notBefore; + + /** The SAML token. */ + private byte[] tokenSaml = new byte[0]; + + /** Country. */ + private String country; + + /** Citizen's personal attribute list. */ + private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAttrQueryResponse.class.getName()); + + /** + * Getter for the subStatusCode. + * + * @return The subStatusCode value. + */ + public String getSubStatusCode() { + return subStatusCode; + } + + /** + * Setter for the subStatusCode. + * + * @param samlSubStatusCode the new subStatusCode value. + */ + public void setSubStatusCode(final String samlSubStatusCode) { + this.subStatusCode = samlSubStatusCode; + } + + /** + * Getter for audienceRest. + * + * @return The audienceRest value. + */ + public String getAudienceRestriction() { + return audienceRest; + } + + /** + * Setter for audienceRest. + * + * @param audRest the new audienceRest value. + */ + public void setAudienceRestriction(final String audRest) { + this.audienceRest = audRest; + } + + /** + * Getter for the samlToken. + * + * @return The samlToken value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Setter for samlToken. + * + * @param samlToken the new tokenSaml value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Getter for the country name. + * + * @return The country name value. + */ + public String getCountry() { + return country; + } + + /** + * Setter for the country name. + * + * @param cCountry the new country name value. + */ + public void setCountry(final String cCountry) { + this.country = cCountry; + } + + /** + * Getter for pal value. + * + * @return The pal value. + * + * @see PersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the inResponseTo value. + * + * @return The inResponseTo value. + */ + public String getInResponseTo() { + return inResponseTo; + } + + /** + * Setter for the inResponseTo value. + * + * @param samlInResponseTo the new inResponseTo value. + */ + public void setInResponseTo(final String samlInResponseTo) { + this.inResponseTo = samlInResponseTo; + } + + /** + * Getter for the fail value. + * + * @return The fail value. + */ + public boolean isFail() { + return fail; + } + + /** + * Setter for the fail value. + * + * @param failVal the new fail value. + */ + public void setFail(final boolean failVal) { + this.fail = failVal; + } + + /** + * Getter for the message value. + * + * @return The message value. + */ + public String getMessage() { + return message; + } + + /** + * Setter for the message value. + * + * @param msg the new message value. + */ + public void setMessage(final String msg) { + this.message = msg; + } + + /** + * Getter for the statusCode value. + * + * @return The statusCode value. + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Setter for the statusCode value. + * + * @param status the new statusCode value. + */ + public void setStatusCode(final String status) { + this.statusCode = status; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param nSamlId the new samlId value. + */ + public void setSamlId(final String nSamlId) { + this.samlId = nSamlId; + } + + /** + * Getter for the notOnOrAfter value. + * + * @return The notOnOrAfter value. + * + * @see DateTime + */ + public DateTime getNotOnOrAfter() { + return this.notOnOrAfter; + } + + /** + * Setter for the notOnOrAfter value. + * + * @param nOnOrAfter the new notOnOrAfter value. + * + * @see DateTime + */ + public void setNotOnOrAfter(final DateTime nOnOrAfter) { + this.notOnOrAfter = nOnOrAfter; + } + + /** + * Getter for the notBefore value. + * + * @return The notBefore value. + * + * @see DateTime + */ + public DateTime getNotBefore() { + return notBefore; + } + + /** + * Setter for the notBefore value. + * + * @param nBefore the new notBefore value. + * + * @see DateTime + */ + public void setNotBefore(final DateTime nBefore) { + this.notBefore = nBefore; + } + +} + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnRequest.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnRequest.java new file mode 100644 index 000000000..2354d0eb1 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnRequest.java @@ -0,0 +1,495 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +import org.apache.log4j.Logger; + +/** + * This class is a bean used to store the information relative to the + * STORKAuthnRequest (SAML Token Request). + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.21 $, $Date: 2011-02-17 22:44:34 $ + */ +public final class STORKAuthnRequest implements Serializable, Cloneable { + + /** The Constant serialVersionUID. */ + private static final long serialVersionUID = 4778480781609392750L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAuthnRequest.class + .getName()); + + /** The samlId. */ + private String samlId; + + /** The assertion consumer service url. */ + private String serviceURL; + + /** The destination. */ + private String destination; + + /** The provider name. */ + private String providerName; + + /** The distinguished name. */ + private String distinguishedName; + + /** The e id sector share. */ + private boolean eIDSectorShare; + + /** The e id cross sector share. */ + private boolean eIDCrossSectorShare; + + /** The e id cross border share. */ + private boolean eIDCrossBorderShare; + + /** The personal attribute list. */ + private IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** The qaa. */ + private int qaa; + + /** The token saml. */ + private byte[] tokenSaml = new byte[0]; + + /** The issuer. */ + private String issuer; + + /** The service provider sector. */ + private String spSector; + + /** The service provider institution. */ + private String spInstitution; + + /** The service provider application. */ + private String spApplication; + + /** The service provider country. */ + private String spCountry; + + /** The country. */ + private String country; + + /** The citizen country code. */ + private String citizenCountry; + + /** The Service Provider ID. */ + private String sPID; + + /** The Alias used at the keystore for saving this certificate. */ + private String alias; + + /** + * Gets the SP's Certificate Alias. + * + * @return alias The SP's Certificate Alias. + */ + public String getAlias() { + return alias; + } + + /** + * Sets the SP's Certificate Alias. + * + * @param nAlias The SP's Certificate Alias. + */ + public void setAlias(final String nAlias) { + this.alias = nAlias; + } + + /** + * Gets the SP ID. + * + * @return sPID The SP ID. + */ + public String getSPID() { + return sPID; + } + + /** + * Sets the SP ID. + * + * @param sPId The new sp samlId. + */ + public void setSPID(final String sPId) { + this.sPID = sPId; + } + + /** + * Gets the citizen country code. + * + * @return The citizen country code value. + */ + public String getCitizenCountryCode() { + return citizenCountry; + } + + /** + * Sets the citizen country code. + * + * @param countryCode the new citizen country code value. + */ + public void setCitizenCountryCode(final String countryCode) { + this.citizenCountry = countryCode; + } + + /** + * Gets the sp country. + * + * @return The sp country value. + */ + public String getSpCountry() { + return spCountry; + } + + /** + * Sets the sp country. + * + * @param sPCountry the new sp country value. + */ + public void setSpCountry(final String sPCountry) { + this.spCountry = sPCountry; + } + + /** + * Gets the issuer. + * + * @return The issuer value. + */ + public String getIssuer() { + return issuer; + } + + /** + * Sets the issuer. + * + * @param samlIssuer the new issuer value. + */ + public void setIssuer(final String samlIssuer) { + this.issuer = samlIssuer; + } + + /** + * Gets the SAML Token. + * + * @return The SAML Token value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Sets the SAML Token. + * + * @param samlToken The new SAML Token value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Gets the country. + * + * @return The country value. + */ + public String getCountry() { + return country; + } + + /** + * Sets the country. + * + * @param nCountry the new country value. + */ + public void setCountry(final String nCountry) { + this.country = nCountry; + } + + /** + * Getter for the qaa value. + * + * @return The qaa value value. + */ + public int getQaa() { + return qaa; + } + + /** + * Setter for the qaa value. + * + * @param qaaLevel The new qaa value. + */ + public void setQaa(final int qaaLevel) { + this.qaa = qaaLevel; + } + + /** + * Getter for the serviceURL value. + * + * @return The serviceURL value. + */ + public String getAssertionConsumerServiceURL() { + return serviceURL; + } + + /** + * Setter for the serviceURL value. + * + * @param newServiceURL the assertion consumer service URL. + */ + public void setAssertionConsumerServiceURL(final String newServiceURL) { + this.serviceURL = newServiceURL; + } + + /** + * Getter for the destination value. + * + * @return The destination value. + */ + public String getDestination() { + return destination; + } + + /** + * Setter for the destination value. + * + * @param detination the new destination value. + */ + public void setDestination(final String detination) { + this.destination = detination; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param newSamlId the new samlId value. + */ + public void setSamlId(final String newSamlId) { + this.samlId = newSamlId; + } + + /** + * Getter for the providerName value. + * + * @return The provider name value. + */ + public String getProviderName() { + return providerName; + } + + /** + * Setter for the providerName value. + * + * @param samlProvider the provider name value. + */ + public void setProviderName(final String samlProvider) { + this.providerName = samlProvider; + } + + /** + * Getter for the attributeList value. + * + * @return The attributeList value. + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the attributeList value. + * + * @param attrList the personal attribute list value. + * + * @see IPersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the distinguishedName value. + * + * @return The distinguishedName value. + */ + public String getDistinguishedName() { + return distinguishedName; + } + + /** + * Setter for the distinguishedName value. + * + * @param certDN the distinguished name value. + */ + public void setDistinguishedName(final String certDN) { + this.distinguishedName = certDN; + } + + /** + * Gets the service provider sector. + * + * @return The service provider sector value. + */ + public String getSpSector() { + return spSector; + } + + /** + * Sets the service provider sector. + * + * @param samlSPSector the new service provider sector value. + */ + public void setSpSector(final String samlSPSector) { + this.spSector = samlSPSector; + } + + /** + * Gets the service provider institution. + * + * @return The service provider institution value. + */ + public String getSpInstitution() { + return spInstitution; + } + + /** + * Sets the service provider institution. + * + * @param samlSPInst the new service provider institution value. + */ + public void setSpInstitution(final String samlSPInst) { + this.spInstitution = samlSPInst; + } + + /** + * Gets the service provider application. + * + * @return The service provider application value. + */ + public String getSpApplication() { + return spApplication; + } + + /** + * Sets the service provider application. + * + * @param samlSPApp the new service provider application value. + */ + public void setSpApplication(final String samlSPApp) { + this.spApplication = samlSPApp; + } + + /** + * Checks if is eId sector share. + * + * @return true, if is eId sector share. + */ + public boolean isEIDSectorShare() { + return eIDSectorShare; + } + + /** + * Sets the eId sector share. + * + * @param eIdSectorShare the new eId sector share value. + */ + public void setEIDSectorShare(final boolean eIdSectorShare) { + this.eIDSectorShare = eIdSectorShare; + } + + /** + * Checks if is eId cross sector share. + * + * @return true, if is eId cross sector share. + */ + public boolean isEIDCrossSectorShare() { + return eIDCrossSectorShare; + } + + /** + * Sets the eId cross sector share. + * + * @param eIdCrossSectorShare the new eId cross sector share value. + */ + public void setEIDCrossSectorShare(final boolean eIdCrossSectorShare) { + this.eIDCrossSectorShare = eIdCrossSectorShare; + } + + /** + * Checks if is eId cross border share. + * + * @return true, if is eId cross border share. + */ + public boolean isEIDCrossBorderShare() { + return eIDCrossBorderShare; + } + + /** + * Sets the eId cross border share. + * + * @param eIdCrossBorderShare the new eId cross border share value. + */ + public void setEIDCrossBorderShare(final boolean eIdCrossBorderShare) { + this.eIDCrossBorderShare = eIdCrossBorderShare; + } + + /** + * Returns a copy of this STORKAuthnRequest instance. + * + * @return The copy of this STORKAuthnRequest. + * @throws CloneNotSupportedException on clone exception + */ + @Override + public Object clone() throws CloneNotSupportedException{ + STORKAuthnRequest storkAuthnReq = null; + try { + storkAuthnReq = (STORKAuthnRequest) super.clone(); + storkAuthnReq.setPersonalAttributeList(getPersonalAttributeList()); + storkAuthnReq.setTokenSaml(getTokenSaml()); + } catch (final CloneNotSupportedException e) { + // assert false; + LOG.trace("[PersonalAttribute] Nothing to do."); + } + + return storkAuthnReq; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java new file mode 100644 index 000000000..aa98974f6 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java @@ -0,0 +1,309 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +import org.apache.log4j.Logger; +import org.joda.time.DateTime; + +/** + * This class is a bean used to store the information relative to the + * STORKAuthnResponse. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class STORKAuthnResponse { + + /** Response Id. */ + private String samlId; + + /** Authentication failed? */ + private boolean fail; + + /** Status code. */ + private String statusCode; + + /** Secondary status code. */ + private String subStatusCode; + + /** Audience restriction. */ + private transient String audienceRest; + + /** Error message. */ + private String message; + + /** Id of the request that originated this response. */ + private String inResponseTo; + + /** Expiration date. */ + private DateTime notOnOrAfter; + + /** Creation date. */ + private DateTime notBefore; + + /** The SAML token. */ + private byte[] tokenSaml = new byte[0]; + + /** Country. */ + private String country; + + /** Citizen's personal attribute list. */ + private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(STORKAuthnResponse.class.getName()); + + /** + * Getter for the subStatusCode. + * + * @return The subStatusCode value. + */ + public String getSubStatusCode() { + return subStatusCode; + } + + /** + * Setter for the subStatusCode. + * + * @param samlSubStatusCode the new subStatusCode value. + */ + public void setSubStatusCode(final String samlSubStatusCode) { + this.subStatusCode = samlSubStatusCode; + } + + /** + * Getter for audienceRest. + * + * @return The audienceRest value. + */ + public String getAudienceRestriction() { + return audienceRest; + } + + /** + * Setter for audienceRest. + * + * @param audRest the new audienceRest value. + */ + public void setAudienceRestriction(final String audRest) { + this.audienceRest = audRest; + } + + /** + * Getter for the samlToken. + * + * @return The samlToken value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Setter for samlToken. + * + * @param samlToken the new tokenSaml value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Getter for the country name. + * + * @return The country name value. + */ + public String getCountry() { + return country; + } + + /** + * Setter for the country name. + * + * @param cCountry the new country name value. + */ + public void setCountry(final String cCountry) { + this.country = cCountry; + } + + /** + * Getter for pal value. + * + * @return The pal value. + * + * @see PersonalAttributeList + */ + public IPersonalAttributeList getPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.attributeList = attrList; + } + } + + /** + * Getter for the inResponseTo value. + * + * @return The inResponseTo value. + */ + public String getInResponseTo() { + return inResponseTo; + } + + /** + * Setter for the inResponseTo value. + * + * @param samlInResponseTo the new inResponseTo value. + */ + public void setInResponseTo(final String samlInResponseTo) { + this.inResponseTo = samlInResponseTo; + } + + /** + * Getter for the fail value. + * + * @return The fail value. + */ + public boolean isFail() { + return fail; + } + + /** + * Setter for the fail value. + * + * @param failVal the new fail value. + */ + public void setFail(final boolean failVal) { + this.fail = failVal; + } + + /** + * Getter for the message value. + * + * @return The message value. + */ + public String getMessage() { + return message; + } + + /** + * Setter for the message value. + * + * @param msg the new message value. + */ + public void setMessage(final String msg) { + this.message = msg; + } + + /** + * Getter for the statusCode value. + * + * @return The statusCode value. + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Setter for the statusCode value. + * + * @param status the new statusCode value. + */ + public void setStatusCode(final String status) { + this.statusCode = status; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param nSamlId the new samlId value. + */ + public void setSamlId(final String nSamlId) { + this.samlId = nSamlId; + } + + /** + * Getter for the notOnOrAfter value. + * + * @return The notOnOrAfter value. + * + * @see DateTime + */ + public DateTime getNotOnOrAfter() { + return this.notOnOrAfter; + } + + /** + * Setter for the notOnOrAfter value. + * + * @param nOnOrAfter the new notOnOrAfter value. + * + * @see DateTime + */ + public void setNotOnOrAfter(final DateTime nOnOrAfter) { + this.notOnOrAfter = nOnOrAfter; + } + + /** + * Getter for the notBefore value. + * + * @return The notBefore value. + * + * @see DateTime + */ + public DateTime getNotBefore() { + return notBefore; + } + + /** + * Setter for the notBefore value. + * + * @param nBefore the new notBefore value. + * + * @see DateTime + */ + public void setNotBefore(final DateTime nBefore) { + this.notBefore = nBefore; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKStatusCode.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKStatusCode.java new file mode 100644 index 000000000..a9c4a156b --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKStatusCode.java @@ -0,0 +1,68 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains the SAML Token Status Code. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ + */ +public enum STORKStatusCode { + + /** URI for Requester status code. */ + REQUESTER_URI("urn:oasis:names:tc:SAML:2.0:status:Requester"), + + /** URI for Responder status code. */ + RESPONDER_URI("urn:oasis:names:tc:SAML:2.0:status:Responder"), + + /** URI for Success status code. */ + SUCCESS_URI("urn:oasis:names:tc:SAML:2.0:status:Success"), + + /** Attribute is Available. */ + STATUS_AVAILABLE("Available"), + + /** Attribute is NotAvailable. */ + STATUS_NOT_AVAILABLE("NotAvailable"), + + /** Attribute is Withheld. */ + STATUS_WITHHELD("Withheld"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param val The Constant value. + */ + private STORKStatusCode(final String val) { + + this.value = val; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + + return value; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKSubStatusCode.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKSubStatusCode.java new file mode 100644 index 000000000..0a711c9b7 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKSubStatusCode.java @@ -0,0 +1,71 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons; + +/** + * This enum class contains the SAML Token Sub Status Code. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.7 $, $Date: 2010-11-17 05:15:28 $ + */ +public enum STORKSubStatusCode { + + /** URI for AuthnFailed status code. */ + AUTHN_FAILED_URI("urn:oasis:names:tc:SAML:2.0:status:AuthnFailed"), + + /** URI for InvalidAttrNameOrValue status code. */ + INVALID_ATTR_NAME_VALUE_URI( + "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue"), + + /** URI for InvalidNameIDPolicy status code. */ + INVALID_NAMEID_POLICY_URI( + "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"), + + /** URI for VersionMismatch status code. */ + VERSION_MISMATCH_URI("urn:oasis:names:tc:SAML:2.0:status:VersionMismatch"), + + /** URI for RequestDenied status code. */ + REQUEST_DENIED_URI("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"), + + /** URI for QaaNotSupported status code. */ + QAA_NOT_SUPPORTED( + "http://www.stork.gov.eu/saml20/statusCodes/QAANotSupported"); + + /** + * Represents the constant's value. + */ + private String value; + + /** + * Solo Constructor. + * + * @param val The Constant value. + */ + private STORKSubStatusCode(final String val) { + + this.value = val; + } + + /** + * Return the Constant Value. + * + * @return The constant value. + */ + public String toString() { + + return value; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops new file mode 100644 index 000000000..14f05b17c --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops @@ -0,0 +1,53 @@ +K 25 +svn:wc:ra_dav:version-url +V 96 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions +END +InvalidParameterPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 131 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidParameterPEPSException.java +END +SecurityPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 123 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/SecurityPEPSException.java +END +InvalidSessionPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 129 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidSessionPEPSException.java +END +package-info.java +K 25 +svn:wc:ra_dav:version-url +V 114 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/package-info.java +END +CPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 116 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/CPEPSException.java +END +StorkPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 120 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/StorkPEPSException.java +END +AbstractPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 123 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/AbstractPEPSException.java +END +InternalErrorPEPSException.java +K 25 +svn:wc:ra_dav:version-url +V 128 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InternalErrorPEPSException.java +END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries new file mode 100644 index 000000000..c2ced14f4 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries @@ -0,0 +1,300 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +CPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +5d3cb4a7303baeaf2104aaa7da301b21 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +3570 + +StorkPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +fea01f750728ea5f15b449acb517f4b2 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1690 + +AbstractPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +c9aedb030e6dbc9f002c7cd3d52cf03f +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +4422 + +InternalErrorPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +36d8f6310e84c550f65bef78d5dc4238 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +2471 + +InvalidParameterPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +c6ad53378b03a346ca0fc48a381ed771 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1800 + +SecurityPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +78d50b78a69cb0c630e4e14420e3b7be +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +2199 + +InvalidSessionPEPSException.java +file + + + + +2013-12-20T12:27:56.626475Z +5fd7f04ad6f6cc121084e682b2a4e678 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1555 + +package-info.java +file + + + + +2013-12-20T12:27:56.626475Z +7055c01b74382c525c7fcf110646d8fc +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +129 + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base new file mode 100644 index 000000000..e9a96d7c2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base @@ -0,0 +1,173 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +import java.io.Serializable; + +/** + * Abstract class to represent the various PEPS exceptions. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ + */ +public abstract class AbstractPEPSException extends RuntimeException implements + Serializable { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = -1884417567740138022L; + + /** + * Error code. + */ + private String errorCode; + + /** + * Error message. + */ + private String errorMessage; + + /** + * SAML token. + */ + private String samlTokenFail; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param code The error code value. + * @param message The error message value. + */ + public AbstractPEPSException(final String code, final String message) { + + super(message); + this.errorCode = code; + this.errorMessage = message; + } + + /** + * Exception Constructor with the errorMessage as parameters and the Throwable + * cause. + * + * @param message The error message value. + * @param cause The throwable object. + */ + public AbstractPEPSException(final String message, final Throwable cause) { + + super(message, cause); + this.errorMessage = message; + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters and the Throwable cause. + * + * @param code The error code value. + * @param message The error message value. + * @param cause The throwable object. + */ + public AbstractPEPSException(final String code, final String message, + final Throwable cause) { + + super(message, cause); + this.errorCode = code; + this.errorMessage = message; + } + + /** + * Exception Constructor with three Strings representing the errorCode, + * errorMessage and encoded samlToken as parameters. + * + * @param code The error code value. + * @param message The error message value. + * @param samlToken The error SAML Token. + */ + public AbstractPEPSException(final String code, final String message, + final String samlToken) { + + super(message); + this.errorCode = code; + this.errorMessage = message; + this.samlTokenFail = samlToken; + } + + /** + * Constructor with SAML Token as argument. Error message and error code are + * embedded in the SAML. + * + * @param samlToken The error SAML Token. + */ + public AbstractPEPSException(final String samlToken) { + super(); + this.samlTokenFail = samlToken; + } + + /** + * Getter for errorCode. + * + * @return The errorCode value. + */ + public final String getErrorCode() { + return errorCode; + } + + /** + * Setter for errorCode. + * + * @param code The error code value. + */ + public final void setErrorCode(final String code) { + this.errorCode = code; + } + + /** + * Getter for errorMessage. + * + * @return The error Message value. + */ + public final String getErrorMessage() { + return errorMessage; + } + + /** + * Setter for errorMessage. + * + * @param message The error message value. + */ + public final void setErrorMessage(final String message) { + this.errorMessage = message; + } + + /** + * Getter for SAMLTokenFail. + * + * @return The error SAML Token. + */ + public final String getSamlTokenFail() { + return samlTokenFail; + } + + /** + * Setter for SAMLTokenFail. + * + * @param samlToken The error SAML token. + */ + public final void setSamlTokenFail(final String samlToken) { + this.samlTokenFail = samlToken; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base new file mode 100644 index 000000000..69cb20fdd --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base @@ -0,0 +1,143 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * This exception is thrown by the C-PEPS service and holds the relative + * information to present to the citizen. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.9 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class CPEPSException extends RuntimeException { + + /** + * Serial id. + */ + private static final long serialVersionUID = -4012295047127999362L; + + /** + * Error code. + */ + private String errorCode; + + /** + * Error message. + */ + private String errorMessage; + + /** + * SAML token. + */ + private String samlTokenFail; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param samlToken The SAML Token. + * @param code The error code value. + * @param message The error message value. + */ + public CPEPSException(final String samlToken, final String code, + final String message) { + + super(message); + this.setErrorCode(code); + this.setErrorMessage(message); + this.setSamlTokenFail(samlToken); + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param samlToken The SAML Token. + * @param code The error code value. + * @param message The error message value. + * @param cause The original exception; + */ + public CPEPSException(final String samlToken, final String code, + final String message, final Throwable cause) { + + super(message, cause); + this.setErrorCode(code); + this.setErrorMessage(message); + this.setSamlTokenFail(samlToken); + } + + /** + * {@inheritDoc} + */ + public String getMessage() { + return this.getErrorMessage() + " (" + this.getErrorCode() + ")"; + } + + /** + * Getter for the error code. + * + * @return The errorCode value. + */ + public String getErrorCode() { + return errorCode; + } + + /** + * Setter for the error code. + * + * @param code The error code. + */ + public void setErrorCode(final String code) { + this.errorCode = code; + } + + /** + * Getter for the error message. + * + * @return The errorMessage value. + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Setter for the error message. + * + * @param message The error message. + */ + public void setErrorMessage(final String message) { + this.errorMessage = message; + } + + /** + * Getter for the samlTokenFail. + * + * @return The samlTokenFail value. + */ + public String getSamlTokenFail() { + return samlTokenFail; + } + + /** + * Setter for the samlTokenFail. + * + * @param samlToken The error Saml Token. + */ + public void setSamlTokenFail(final String samlToken) { + this.samlTokenFail = samlToken; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base new file mode 100644 index 000000000..67514d4fe --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base @@ -0,0 +1,74 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Internal Error Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ + * + * @see AbstractPEPSException + */ +public final class InternalErrorPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 1193001455410319795L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters and the Throwable cause. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + * @param cause The throwable object. + */ + public InternalErrorPEPSException(final String errorCode, + final String errorMessage, final Throwable cause) { + + super(errorCode, errorMessage, cause); + } + + /** + * Exception Constructor with three strings representing the errorCode, + * errorMessage and encoded samlToken as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + * @param samlTokenFail The error SAML Token. + */ + public InternalErrorPEPSException(final String errorCode, + final String errorMessage, final String samlTokenFail) { + + super(errorCode, errorMessage, samlTokenFail); + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + */ + public InternalErrorPEPSException(final String errorCode, + final String errorMessage) { + + super(errorCode, errorMessage); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base new file mode 100644 index 000000000..12c83b589 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base @@ -0,0 +1,54 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Invalid Parameter Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.11 $, $Date: 2010-11-17 05:15:28 $ + * + * @see InvalidParameterPEPSException + */ +public class InvalidParameterPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 2046282148740524875L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error code message value. + */ + public InvalidParameterPEPSException(final String errorCode, + final String errorMessage) { + super(errorCode, errorMessage); + } + + /** + * Exception Constructor with one String representing the encoded samlToken. + * + * @param samlTokenFail The error SAML Token. + */ + public InvalidParameterPEPSException(final String samlTokenFail) { + super(samlTokenFail); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base new file mode 100644 index 000000000..800525eee --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base @@ -0,0 +1,46 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Invalid session Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.14 $, $Date: 2010-11-17 05:15:28 $ + * + * @see InvalidParameterPEPSException + */ +public class InvalidSessionPEPSException extends InvalidParameterPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 7147090160978319016L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + */ + public InvalidSessionPEPSException(final String errorCode, + final String errorMessage) { + + super(errorCode, errorMessage); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base new file mode 100644 index 000000000..fc27371d2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base @@ -0,0 +1,67 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Security PEPS Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.18 $, $Date: 2010-11-17 05:15:28 $ + * + * @see AbstractPEPSException + */ +public final class SecurityPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 5605743302478554967L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMsg The error message value. + */ + public SecurityPEPSException(final String errorCode, final String errorMsg) { + super(errorCode, errorMsg); + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters and the Throwable cause. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + * @param cause The throwable object. + */ + public SecurityPEPSException(final String errorCode, + final String errorMessage, final Throwable cause) { + + super(errorCode, errorMessage, cause); + } + + /** + * Exception Constructor with one String representing the encoded samlToken. + * + * @param samlTokenFail The error SAML Token. + */ + public SecurityPEPSException(final String samlTokenFail) { + super(samlTokenFail); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base new file mode 100644 index 000000000..a2da61a02 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base @@ -0,0 +1,53 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Security PEPS Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ + * + * @see AbstractPEPSException + */ +public final class StorkPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 8048033129798427574L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMsg The error message value. + */ + public StorkPEPSException(final String errorCode, final String errorMsg) { + super(errorCode, errorMsg); + } + + /** + * {@inheritDoc} + */ + public String getMessage() { + + return "Security Error (" + this.getErrorCode() + ") processing request : " + + this.getErrorMessage(); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base new file mode 100644 index 000000000..d83068beb --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base @@ -0,0 +1,7 @@ +/** + * Package for the PEPS’ Exceptions handling. + * + * @since 1.0 + */ +package eu.stork.peps.auth.commons.exceptions; + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/AbstractPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/AbstractPEPSException.java new file mode 100644 index 000000000..e9a96d7c2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/AbstractPEPSException.java @@ -0,0 +1,173 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +import java.io.Serializable; + +/** + * Abstract class to represent the various PEPS exceptions. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ + */ +public abstract class AbstractPEPSException extends RuntimeException implements + Serializable { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = -1884417567740138022L; + + /** + * Error code. + */ + private String errorCode; + + /** + * Error message. + */ + private String errorMessage; + + /** + * SAML token. + */ + private String samlTokenFail; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param code The error code value. + * @param message The error message value. + */ + public AbstractPEPSException(final String code, final String message) { + + super(message); + this.errorCode = code; + this.errorMessage = message; + } + + /** + * Exception Constructor with the errorMessage as parameters and the Throwable + * cause. + * + * @param message The error message value. + * @param cause The throwable object. + */ + public AbstractPEPSException(final String message, final Throwable cause) { + + super(message, cause); + this.errorMessage = message; + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters and the Throwable cause. + * + * @param code The error code value. + * @param message The error message value. + * @param cause The throwable object. + */ + public AbstractPEPSException(final String code, final String message, + final Throwable cause) { + + super(message, cause); + this.errorCode = code; + this.errorMessage = message; + } + + /** + * Exception Constructor with three Strings representing the errorCode, + * errorMessage and encoded samlToken as parameters. + * + * @param code The error code value. + * @param message The error message value. + * @param samlToken The error SAML Token. + */ + public AbstractPEPSException(final String code, final String message, + final String samlToken) { + + super(message); + this.errorCode = code; + this.errorMessage = message; + this.samlTokenFail = samlToken; + } + + /** + * Constructor with SAML Token as argument. Error message and error code are + * embedded in the SAML. + * + * @param samlToken The error SAML Token. + */ + public AbstractPEPSException(final String samlToken) { + super(); + this.samlTokenFail = samlToken; + } + + /** + * Getter for errorCode. + * + * @return The errorCode value. + */ + public final String getErrorCode() { + return errorCode; + } + + /** + * Setter for errorCode. + * + * @param code The error code value. + */ + public final void setErrorCode(final String code) { + this.errorCode = code; + } + + /** + * Getter for errorMessage. + * + * @return The error Message value. + */ + public final String getErrorMessage() { + return errorMessage; + } + + /** + * Setter for errorMessage. + * + * @param message The error message value. + */ + public final void setErrorMessage(final String message) { + this.errorMessage = message; + } + + /** + * Getter for SAMLTokenFail. + * + * @return The error SAML Token. + */ + public final String getSamlTokenFail() { + return samlTokenFail; + } + + /** + * Setter for SAMLTokenFail. + * + * @param samlToken The error SAML token. + */ + public final void setSamlTokenFail(final String samlToken) { + this.samlTokenFail = samlToken; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/CPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/CPEPSException.java new file mode 100644 index 000000000..69cb20fdd --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/CPEPSException.java @@ -0,0 +1,143 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * This exception is thrown by the C-PEPS service and holds the relative + * information to present to the citizen. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.9 $, $Date: 2010-11-17 05:15:28 $ + */ +public final class CPEPSException extends RuntimeException { + + /** + * Serial id. + */ + private static final long serialVersionUID = -4012295047127999362L; + + /** + * Error code. + */ + private String errorCode; + + /** + * Error message. + */ + private String errorMessage; + + /** + * SAML token. + */ + private String samlTokenFail; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param samlToken The SAML Token. + * @param code The error code value. + * @param message The error message value. + */ + public CPEPSException(final String samlToken, final String code, + final String message) { + + super(message); + this.setErrorCode(code); + this.setErrorMessage(message); + this.setSamlTokenFail(samlToken); + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param samlToken The SAML Token. + * @param code The error code value. + * @param message The error message value. + * @param cause The original exception; + */ + public CPEPSException(final String samlToken, final String code, + final String message, final Throwable cause) { + + super(message, cause); + this.setErrorCode(code); + this.setErrorMessage(message); + this.setSamlTokenFail(samlToken); + } + + /** + * {@inheritDoc} + */ + public String getMessage() { + return this.getErrorMessage() + " (" + this.getErrorCode() + ")"; + } + + /** + * Getter for the error code. + * + * @return The errorCode value. + */ + public String getErrorCode() { + return errorCode; + } + + /** + * Setter for the error code. + * + * @param code The error code. + */ + public void setErrorCode(final String code) { + this.errorCode = code; + } + + /** + * Getter for the error message. + * + * @return The errorMessage value. + */ + public String getErrorMessage() { + return errorMessage; + } + + /** + * Setter for the error message. + * + * @param message The error message. + */ + public void setErrorMessage(final String message) { + this.errorMessage = message; + } + + /** + * Getter for the samlTokenFail. + * + * @return The samlTokenFail value. + */ + public String getSamlTokenFail() { + return samlTokenFail; + } + + /** + * Setter for the samlTokenFail. + * + * @param samlToken The error Saml Token. + */ + public void setSamlTokenFail(final String samlToken) { + this.samlTokenFail = samlToken; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InternalErrorPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InternalErrorPEPSException.java new file mode 100644 index 000000000..67514d4fe --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InternalErrorPEPSException.java @@ -0,0 +1,74 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Internal Error Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ + * + * @see AbstractPEPSException + */ +public final class InternalErrorPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 1193001455410319795L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters and the Throwable cause. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + * @param cause The throwable object. + */ + public InternalErrorPEPSException(final String errorCode, + final String errorMessage, final Throwable cause) { + + super(errorCode, errorMessage, cause); + } + + /** + * Exception Constructor with three strings representing the errorCode, + * errorMessage and encoded samlToken as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + * @param samlTokenFail The error SAML Token. + */ + public InternalErrorPEPSException(final String errorCode, + final String errorMessage, final String samlTokenFail) { + + super(errorCode, errorMessage, samlTokenFail); + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + */ + public InternalErrorPEPSException(final String errorCode, + final String errorMessage) { + + super(errorCode, errorMessage); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidParameterPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidParameterPEPSException.java new file mode 100644 index 000000000..12c83b589 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidParameterPEPSException.java @@ -0,0 +1,54 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Invalid Parameter Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.11 $, $Date: 2010-11-17 05:15:28 $ + * + * @see InvalidParameterPEPSException + */ +public class InvalidParameterPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 2046282148740524875L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error code message value. + */ + public InvalidParameterPEPSException(final String errorCode, + final String errorMessage) { + super(errorCode, errorMessage); + } + + /** + * Exception Constructor with one String representing the encoded samlToken. + * + * @param samlTokenFail The error SAML Token. + */ + public InvalidParameterPEPSException(final String samlTokenFail) { + super(samlTokenFail); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidSessionPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidSessionPEPSException.java new file mode 100644 index 000000000..800525eee --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidSessionPEPSException.java @@ -0,0 +1,46 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Invalid session Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.14 $, $Date: 2010-11-17 05:15:28 $ + * + * @see InvalidParameterPEPSException + */ +public class InvalidSessionPEPSException extends InvalidParameterPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 7147090160978319016L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + */ + public InvalidSessionPEPSException(final String errorCode, + final String errorMessage) { + + super(errorCode, errorMessage); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/SecurityPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/SecurityPEPSException.java new file mode 100644 index 000000000..fc27371d2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/SecurityPEPSException.java @@ -0,0 +1,67 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Security PEPS Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.18 $, $Date: 2010-11-17 05:15:28 $ + * + * @see AbstractPEPSException + */ +public final class SecurityPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 5605743302478554967L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMsg The error message value. + */ + public SecurityPEPSException(final String errorCode, final String errorMsg) { + super(errorCode, errorMsg); + } + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters and the Throwable cause. + * + * @param errorCode The error code value. + * @param errorMessage The error message value. + * @param cause The throwable object. + */ + public SecurityPEPSException(final String errorCode, + final String errorMessage, final Throwable cause) { + + super(errorCode, errorMessage, cause); + } + + /** + * Exception Constructor with one String representing the encoded samlToken. + * + * @param samlTokenFail The error SAML Token. + */ + public SecurityPEPSException(final String samlTokenFail) { + super(samlTokenFail); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/StorkPEPSException.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/StorkPEPSException.java new file mode 100644 index 000000000..a2da61a02 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/StorkPEPSException.java @@ -0,0 +1,53 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.commons.exceptions; + +/** + * Security PEPS Exception class. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com, + * paulo.ribeiro@multicert.com + * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ + * + * @see AbstractPEPSException + */ +public final class StorkPEPSException extends AbstractPEPSException { + + /** + * Unique identifier. + */ + private static final long serialVersionUID = 8048033129798427574L; + + /** + * Exception Constructor with two Strings representing the errorCode and + * errorMessage as parameters. + * + * @param errorCode The error code value. + * @param errorMsg The error message value. + */ + public StorkPEPSException(final String errorCode, final String errorMsg) { + super(errorCode, errorMsg); + } + + /** + * {@inheritDoc} + */ + public String getMessage() { + + return "Security Error (" + this.getErrorCode() + ") processing request : " + + this.getErrorMessage(); + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/package-info.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/package-info.java new file mode 100644 index 000000000..d83068beb --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/package-info.java @@ -0,0 +1,7 @@ +/** + * Package for the PEPS’ Exceptions handling. + * + * @since 1.0 + */ +package eu.stork.peps.auth.commons.exceptions; + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/package-info.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/package-info.java new file mode 100644 index 000000000..19d45aaa2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/package-info.java @@ -0,0 +1,9 @@ +/** + * Common Authentication Service functionalities to be deployed in every PEPS + * is contained in this package. + * In particular, it contains the SAML Engine that implements the SAML messages + * management + * + * @since 1.0 + */ +package eu.stork.peps.auth.commons; diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops new file mode 100644 index 000000000..d23abebd4 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops @@ -0,0 +1,41 @@ +K 25 +svn:wc:ra_dav:version-url +V 86 +/CITnet/svn/STORK2/!svn/ver/73/trunk/Commons/src/main/java/eu/stork/peps/auth/specific +END +ICheckAttributeValue.java +K 25 +svn:wc:ra_dav:version-url +V 112 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/ICheckAttributeValue.java +END +IDeriveAttribute.java +K 25 +svn:wc:ra_dav:version-url +V 108 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/IDeriveAttribute.java +END +IAUService.java +K 25 +svn:wc:ra_dav:version-url +V 102 +/CITnet/svn/STORK2/!svn/ver/73/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java +END +INormaliseValue.java +K 25 +svn:wc:ra_dav:version-url +V 107 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/INormaliseValue.java +END +ITranslatorService.java +K 25 +svn:wc:ra_dav:version-url +V 110 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java +END +package-info.java +K 25 +svn:wc:ra_dav:version-url +V 104 +/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/package-info.java +END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries new file mode 100644 index 000000000..a23f672b5 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries @@ -0,0 +1,232 @@ +10 + +dir +357 +https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth/specific +https://webgate.ec.europa.eu/CITnet/svn/STORK2 + + + +2013-10-28T11:11:01.095477Z +73 +emlelisst + + + + + + + + + + + + + + +aa842e49-f825-43fc-93ba-11ee9fd5a035 + +ITranslatorService.java +file + + + + +2013-12-20T12:27:56.654475Z +e36bd20ddfb7e165262a4a7891440fc9 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +3144 + +package-info.java +file + + + + +2013-12-20T12:27:56.654475Z +eef7721d55c2edb02a432fc08ae9e487 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +164 + +ICheckAttributeValue.java +file + + + + +2013-12-20T12:27:56.654475Z +b0472ff15d1c86f175da134b0f0eda71 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1321 + +IDeriveAttribute.java +file + + + + +2013-12-20T12:27:56.654475Z +dce3856a97583f739cdf50ca78491277 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1504 + +IAUService.java +file + + + + +2013-12-20T12:27:56.654475Z +254f57923746e205391672afffc04313 +2013-10-28T11:11:01.095477Z +73 +emlelisst + + + + + + + + + + + + + + + + + + + + + +6011 + +INormaliseValue.java +file + + + + +2013-12-20T12:27:56.654475Z +09f6e376875762fca294be4dfecb71f1 +2013-07-25T08:54:09.995385Z +7 +emsomavmi + + + + + + + + + + + + + + + + + + + + + +1237 + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base new file mode 100644 index 000000000..157c8f7b6 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base @@ -0,0 +1,183 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import java.util.Map; + +import eu.stork.peps.auth.commons.IPersonalAttributeList; +import eu.stork.peps.auth.commons.IStorkSession; +import eu.stork.peps.auth.commons.STORKAttrQueryResponse; +import eu.stork.peps.auth.commons.STORKAuthnResponse; + +/** + * Interface for Specific Authentication methods. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface IAUService { + + /** + * Prepares the citizen to be redirected to the IdP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * @param requestAttributes The Requested attributes. + * + * @return byte[] containing a SAML Request. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + byte[] prepareCitizenAuthentication(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session); + + /** + * Authenticates a citizen. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param requestAttributes The requested attributes. + * + * @return The updated Personal Attribute List. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList authenticateCitizen( + IPersonalAttributeList personalList, Map parameters, + Map requestAttributes); + + /** + * Prepares the Citizen browser to be redirected to the AP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * @param requestAttributes The requested attributes. + * + * @return true in case of no error. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + boolean prepareAPRedirect(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session); + + /** + * Returns the attributes values from the AP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param requestAttributes The request attributes. + * + * @return The updated Personal Attribute List. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList getAttributesFromAttributeProviders( + IPersonalAttributeList personalList, Map parameters, + Map requestAttributes); + + /** + * Get the attributes from the AP with verification. + * + * @param personalList The Personal Attribute List. + * @param parameters The HTTP Parameters. + * @param requestAttributes The requested Attributes. + * @param session The session object. + * @param auProcessId The SAML identifier. + * + * @return true if the attributes were correctly verified. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + boolean getAttributesWithVerification(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session, String auProcessId); + + /** + * Validates a SAML Response. + * + * @param samlToken The SAML Token. + * @param session The session object. + * + * @return the STORKAuthnResponse associated with the validated response. + * + * @see IStorkSession + */ + STORKAuthnResponse processAuthenticationResponse(byte[] samlToken, + IStorkSession session); + + /** + * Generates a SAML Response in case of error. + * + * @param inResponseTo The SAML's identifier to response. + * @param issuer The issuer value. + * @param assertionURL The assertion URL. + * @param code The error code. + * @param subcode The sub error code. + * @param message The error message. + * @param ipUserAddress The user IP address. + * + * @return byte[] containing the SAML Response. + */ + byte[] generateErrorAuthenticationResponse(String inResponseTo, + String issuer, String assertionURL, String code, String subcode, + String message, String ipUserAddress); + + /** + * Compares two given personal attribute lists. + * + * @param original The original Personal Attribute List. + * @param modified The modified Personal Attribute List. + * @return true if the original list contains the modified one. False + * otherwise. + * + * @see IPersonalAttributeList + */ + boolean comparePersonalAttributeLists(IPersonalAttributeList original, + IPersonalAttributeList modified); + + /** + * Prepares the citizen to be redirected to the AtP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * + * @return byte[] containing a SAML Request. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + byte[] prepareAttributeRequest(IPersonalAttributeList personalList, + Map parameters, IStorkSession session); + + /** + * Validates a SAML Response. + * + * @param samlToken The SAML Token. + * @param session The session object. + * + * @return the STORKAttrQueryResponse associated with the validated response. + * + * @see IStorkSession + */ + STORKAttrQueryResponse processAttributeResponse(byte[] samlToken, + IStorkSession session); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base new file mode 100644 index 000000000..31a8d78ff --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base @@ -0,0 +1,37 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import java.util.List; + +/** + * Interface that defines the methods to work with the validation of attributes. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface ICheckAttributeValue { + + /** + * Checks if the list of values contains the expected value. + * + * @param values The List of values. + * @param expectedValue The value to check if it exists on the list. + * + * @return boolean true, if the value is present in the list. False, + * otherwise. + */ + boolean checkValue(List values, String expectedValue); + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base new file mode 100644 index 000000000..78eb53004 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base @@ -0,0 +1,40 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import eu.stork.peps.auth.commons.IStorkSession; +import eu.stork.peps.auth.commons.PersonalAttribute; + +/** + * Interface that defines the methods to work with derivation of attributes. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface IDeriveAttribute { + + /** + * Derives the attribute value. Set the Personal Attribute value to null if + * the value in session or the value of age are invalid (non-numeric or null). + * + * @param personalAttrList The Personal Attribute List. + * @param session The session object. + * + * @see PersonalAttribute The personal Attribute + * @see IStorkSession The session object. + */ + void deriveAttributeToData(PersonalAttribute personalAttrList, + IStorkSession session); + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base new file mode 100644 index 000000000..ca2114e32 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base @@ -0,0 +1,35 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import eu.stork.peps.auth.commons.PersonalAttribute; + +/** + * Interface for attribute's value normalisation. + * + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface INormaliseValue { + + /** + * Translates the attribute's value from local format to STORK format. + * + * @param personalAttribute The Personal Attribute to normalise the value. + * + * @see PersonalAttribute + */ + void normaliseAttributeValueToStork(PersonalAttribute personalAttribute); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base new file mode 100644 index 000000000..d4c152614 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base @@ -0,0 +1,100 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import eu.stork.peps.auth.commons.IPersonalAttributeList; +import eu.stork.peps.auth.commons.IStorkSession; +import eu.stork.peps.auth.commons.STORKAuthnRequest; + +/** + * Interface for attributes normalization. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface ITranslatorService { + + /** + * Translates the attributes from local format to STORK format. + * + * @param personalList The Personal Attribute List. + * + * @return The Personal Attribute List with normalised attributes. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList normaliseAttributeNamesToStork( + IPersonalAttributeList personalList); + + /** + * Translates the attributes values from local format to STORK format. + * + * @param personalList The Personal Attribute List. + * + * @return The PersonalAttributeList with normalised values. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList normaliseAttributeValuesToStork( + IPersonalAttributeList personalList); + + /** + * Translates the attributes from STORK format to local format. + * + * @param personalList The Personal Attribute List. + * + * @return The PersonalAttributeList with normalised attributes. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList normaliseAttributeNamesFromStork( + IPersonalAttributeList personalList); + + /** + * Derive Attribute Names To Stork format. + * + * @param personalList The Personal Attribute List, + * + * @return The PersonalAttributeList with derived attributes. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList deriveAttributeFromStork( + IPersonalAttributeList personalList); + + /** + * Derive Attribute Names from Stork format. + * + * @param session The session object. + * @param modifiedList The Personal Attribute List. + * + * @return The PersonalAttributeList with derived attributes. + * + * @see IStorkSession + * @see IPersonalAttributeList + */ + IPersonalAttributeList deriveAttributeToStork(IStorkSession session, + IPersonalAttributeList modifiedList); + + /** + * Validate the values of the attributes. + * + * @param authData The SAML's STORKAuthnRequest object. + * + * @return True, if all the attributes have values. False, otherwise. + * + * @see STORKAuthnRequest + */ + boolean checkAttributeValues(STORKAuthnRequest authData); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base new file mode 100644 index 000000000..a25c52311 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base @@ -0,0 +1,8 @@ +/** + * Specific PEPS Interfaces that implements functionality of the Authentication + * Service. + * + * @since 1.0 + */ +package eu.stork.peps.auth.specific; + diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java new file mode 100644 index 000000000..157c8f7b6 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java @@ -0,0 +1,183 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import java.util.Map; + +import eu.stork.peps.auth.commons.IPersonalAttributeList; +import eu.stork.peps.auth.commons.IStorkSession; +import eu.stork.peps.auth.commons.STORKAttrQueryResponse; +import eu.stork.peps.auth.commons.STORKAuthnResponse; + +/** + * Interface for Specific Authentication methods. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface IAUService { + + /** + * Prepares the citizen to be redirected to the IdP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * @param requestAttributes The Requested attributes. + * + * @return byte[] containing a SAML Request. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + byte[] prepareCitizenAuthentication(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session); + + /** + * Authenticates a citizen. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param requestAttributes The requested attributes. + * + * @return The updated Personal Attribute List. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList authenticateCitizen( + IPersonalAttributeList personalList, Map parameters, + Map requestAttributes); + + /** + * Prepares the Citizen browser to be redirected to the AP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * @param requestAttributes The requested attributes. + * + * @return true in case of no error. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + boolean prepareAPRedirect(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session); + + /** + * Returns the attributes values from the AP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param requestAttributes The request attributes. + * + * @return The updated Personal Attribute List. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList getAttributesFromAttributeProviders( + IPersonalAttributeList personalList, Map parameters, + Map requestAttributes); + + /** + * Get the attributes from the AP with verification. + * + * @param personalList The Personal Attribute List. + * @param parameters The HTTP Parameters. + * @param requestAttributes The requested Attributes. + * @param session The session object. + * @param auProcessId The SAML identifier. + * + * @return true if the attributes were correctly verified. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + boolean getAttributesWithVerification(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session, String auProcessId); + + /** + * Validates a SAML Response. + * + * @param samlToken The SAML Token. + * @param session The session object. + * + * @return the STORKAuthnResponse associated with the validated response. + * + * @see IStorkSession + */ + STORKAuthnResponse processAuthenticationResponse(byte[] samlToken, + IStorkSession session); + + /** + * Generates a SAML Response in case of error. + * + * @param inResponseTo The SAML's identifier to response. + * @param issuer The issuer value. + * @param assertionURL The assertion URL. + * @param code The error code. + * @param subcode The sub error code. + * @param message The error message. + * @param ipUserAddress The user IP address. + * + * @return byte[] containing the SAML Response. + */ + byte[] generateErrorAuthenticationResponse(String inResponseTo, + String issuer, String assertionURL, String code, String subcode, + String message, String ipUserAddress); + + /** + * Compares two given personal attribute lists. + * + * @param original The original Personal Attribute List. + * @param modified The modified Personal Attribute List. + * @return true if the original list contains the modified one. False + * otherwise. + * + * @see IPersonalAttributeList + */ + boolean comparePersonalAttributeLists(IPersonalAttributeList original, + IPersonalAttributeList modified); + + /** + * Prepares the citizen to be redirected to the AtP. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * + * @return byte[] containing a SAML Request. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + byte[] prepareAttributeRequest(IPersonalAttributeList personalList, + Map parameters, IStorkSession session); + + /** + * Validates a SAML Response. + * + * @param samlToken The SAML Token. + * @param session The session object. + * + * @return the STORKAttrQueryResponse associated with the validated response. + * + * @see IStorkSession + */ + STORKAttrQueryResponse processAttributeResponse(byte[] samlToken, + IStorkSession session); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ICheckAttributeValue.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ICheckAttributeValue.java new file mode 100644 index 000000000..31a8d78ff --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ICheckAttributeValue.java @@ -0,0 +1,37 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import java.util.List; + +/** + * Interface that defines the methods to work with the validation of attributes. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface ICheckAttributeValue { + + /** + * Checks if the list of values contains the expected value. + * + * @param values The List of values. + * @param expectedValue The value to check if it exists on the list. + * + * @return boolean true, if the value is present in the list. False, + * otherwise. + */ + boolean checkValue(List values, String expectedValue); + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IDeriveAttribute.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IDeriveAttribute.java new file mode 100644 index 000000000..78eb53004 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IDeriveAttribute.java @@ -0,0 +1,40 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import eu.stork.peps.auth.commons.IStorkSession; +import eu.stork.peps.auth.commons.PersonalAttribute; + +/** + * Interface that defines the methods to work with derivation of attributes. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface IDeriveAttribute { + + /** + * Derives the attribute value. Set the Personal Attribute value to null if + * the value in session or the value of age are invalid (non-numeric or null). + * + * @param personalAttrList The Personal Attribute List. + * @param session The session object. + * + * @see PersonalAttribute The personal Attribute + * @see IStorkSession The session object. + */ + void deriveAttributeToData(PersonalAttribute personalAttrList, + IStorkSession session); + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/INormaliseValue.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/INormaliseValue.java new file mode 100644 index 000000000..ca2114e32 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/INormaliseValue.java @@ -0,0 +1,35 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import eu.stork.peps.auth.commons.PersonalAttribute; + +/** + * Interface for attribute's value normalisation. + * + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface INormaliseValue { + + /** + * Translates the attribute's value from local format to STORK format. + * + * @param personalAttribute The Personal Attribute to normalise the value. + * + * @see PersonalAttribute + */ + void normaliseAttributeValueToStork(PersonalAttribute personalAttribute); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java new file mode 100644 index 000000000..d4c152614 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java @@ -0,0 +1,100 @@ +/* + * This work is Open Source and licensed by the European Commission under the + * conditions of the European Public License v1.1 + * + * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); + * + * any use of this file implies acceptance of the conditions of this license. + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + */ +package eu.stork.peps.auth.specific; + +import eu.stork.peps.auth.commons.IPersonalAttributeList; +import eu.stork.peps.auth.commons.IStorkSession; +import eu.stork.peps.auth.commons.STORKAuthnRequest; + +/** + * Interface for attributes normalization. + * + * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, + * luis.felix@multicert.com, hugo.magalhaes@multicert.com + */ +public interface ITranslatorService { + + /** + * Translates the attributes from local format to STORK format. + * + * @param personalList The Personal Attribute List. + * + * @return The Personal Attribute List with normalised attributes. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList normaliseAttributeNamesToStork( + IPersonalAttributeList personalList); + + /** + * Translates the attributes values from local format to STORK format. + * + * @param personalList The Personal Attribute List. + * + * @return The PersonalAttributeList with normalised values. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList normaliseAttributeValuesToStork( + IPersonalAttributeList personalList); + + /** + * Translates the attributes from STORK format to local format. + * + * @param personalList The Personal Attribute List. + * + * @return The PersonalAttributeList with normalised attributes. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList normaliseAttributeNamesFromStork( + IPersonalAttributeList personalList); + + /** + * Derive Attribute Names To Stork format. + * + * @param personalList The Personal Attribute List, + * + * @return The PersonalAttributeList with derived attributes. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList deriveAttributeFromStork( + IPersonalAttributeList personalList); + + /** + * Derive Attribute Names from Stork format. + * + * @param session The session object. + * @param modifiedList The Personal Attribute List. + * + * @return The PersonalAttributeList with derived attributes. + * + * @see IStorkSession + * @see IPersonalAttributeList + */ + IPersonalAttributeList deriveAttributeToStork(IStorkSession session, + IPersonalAttributeList modifiedList); + + /** + * Validate the values of the attributes. + * + * @param authData The SAML's STORKAuthnRequest object. + * + * @return True, if all the attributes have values. False, otherwise. + * + * @see STORKAuthnRequest + */ + boolean checkAttributeValues(STORKAuthnRequest authData); +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/package-info.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/package-info.java new file mode 100644 index 000000000..a25c52311 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/package-info.java @@ -0,0 +1,8 @@ +/** + * Specific PEPS Interfaces that implements functionality of the Authentication + * Service. + * + * @since 1.0 + */ +package eu.stork.peps.auth.specific; + -- cgit v1.2.3 From 9cb68043945f53246928443cea723b58ee2b1c24 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Tue, 21 Jan 2014 14:38:35 +0100 Subject: updated samlengine --- .../src/main/java/eu/.svn/all-wcprops | 5 - .../stork2-commons/src/main/java/eu/.svn/entries | 31 - .../src/main/java/eu/stork/.svn/all-wcprops | 5 - .../src/main/java/eu/stork/.svn/entries | 31 - .../src/main/java/eu/stork/peps/.svn/all-wcprops | 5 - .../src/main/java/eu/stork/peps/.svn/entries | 31 - .../main/java/eu/stork/peps/auth/.svn/all-wcprops | 5 - .../src/main/java/eu/stork/peps/auth/.svn/entries | 34 - .../eu/stork/peps/auth/commons/.svn/all-wcprops | 167 ---- .../java/eu/stork/peps/auth/commons/.svn/entries | 949 --------------------- .../text-base/AttributeConstants.java.svn-base | 72 -- .../.svn/text-base/AttributeProvider.java.svn-base | 74 -- .../text-base/AttributeProvidersMap.java.svn-base | 94 -- .../.svn/text-base/AttributeSource.java.svn-base | 119 --- .../.svn/text-base/AttributeUtil.java.svn-base | 231 ----- .../.svn/text-base/CitizenConsent.java.svn-base | 123 --- .../commons/.svn/text-base/Country.java.svn-base | 95 --- .../.svn/text-base/CountryCodes.java.svn-base | 79 -- .../commons/.svn/text-base/DateUtil.java.svn-base | 169 ---- .../text-base/IAttributeProvidersMap.java.svn-base | 82 -- .../text-base/IPersonalAttributeList.java.svn-base | 140 --- .../.svn/text-base/IStorkLogger.java.svn-base | 239 ------ .../.svn/text-base/IStorkSession.java.svn-base | 85 -- .../commons/.svn/text-base/Linker.java.svn-base | 173 ---- .../.svn/text-base/PEPSErrors.java.svn-base | 348 -------- .../.svn/text-base/PEPSParameters.java.svn-base | 511 ----------- .../commons/.svn/text-base/PEPSUtil.java.svn-base | 353 -------- .../.svn/text-base/PEPSValues.java.svn-base | 325 ------- .../.svn/text-base/PersonalAttribute.java.svn-base | 323 ------- .../text-base/PersonalAttributeList.java.svn-base | 305 ------- .../text-base/STORKAttrQueryRequest.java.svn-base | 426 --------- .../text-base/STORKAttrQueryResponse.java.svn-base | 301 ------- .../.svn/text-base/STORKAuthnRequest.java.svn-base | 495 ----------- .../text-base/STORKAuthnResponse.java.svn-base | 309 ------- .../.svn/text-base/STORKStatusCode.java.svn-base | 68 -- .../text-base/STORKSubStatusCode.java.svn-base | 71 -- .../.svn/text-base/package-info.java.svn-base | 9 - .../eu/stork/peps/auth/commons/AttributeName.java | 74 ++ .../stork/peps/auth/commons/AttributeProvider.java | 12 +- .../peps/auth/commons/AttributeProvidersMap.java | 14 +- .../stork/peps/auth/commons/AttributeSource.java | 81 +- .../eu/stork/peps/auth/commons/AttributeUtil.java | 2 +- .../eu/stork/peps/auth/commons/CitizenConsent.java | 10 +- .../peps/auth/commons/IAttributeListProcessor.java | 148 ++++ .../peps/auth/commons/IPersonalAttributeList.java | 54 ++ .../java/eu/stork/peps/auth/commons/Linker.java | 151 +++- .../eu/stork/peps/auth/commons/PEPSErrors.java | 46 +- .../eu/stork/peps/auth/commons/PEPSParameters.java | 110 ++- .../java/eu/stork/peps/auth/commons/PEPSUtil.java | 2 +- .../eu/stork/peps/auth/commons/PEPSValues.java | 4 + .../stork/peps/auth/commons/PersonalAttribute.java | 27 +- .../peps/auth/commons/PersonalAttributeList.java | 143 +++- .../peps/auth/commons/STORKAttrQueryRequest.java | 23 +- .../peps/auth/commons/STORKAttrQueryResponse.java | 87 ++ .../peps/auth/commons/STORKAuthnResponse.java | 76 +- .../peps/auth/commons/STORKLogoutRequest.java | 197 +++++ .../peps/auth/commons/STORKLogoutResponse.java | 250 ++++++ .../peps/auth/commons/exceptions/.svn/all-wcprops | 53 -- .../peps/auth/commons/exceptions/.svn/entries | 300 ------- .../text-base/AbstractPEPSException.java.svn-base | 173 ---- .../.svn/text-base/CPEPSException.java.svn-base | 143 ---- .../InternalErrorPEPSException.java.svn-base | 74 -- .../InvalidParameterPEPSException.java.svn-base | 54 -- .../InvalidSessionPEPSException.java.svn-base | 46 - .../text-base/SecurityPEPSException.java.svn-base | 67 -- .../text-base/StorkPEPSException.java.svn-base | 53 -- .../.svn/text-base/package-info.java.svn-base | 7 - .../eu/stork/peps/auth/specific/.svn/all-wcprops | 41 - .../java/eu/stork/peps/auth/specific/.svn/entries | 232 ----- .../.svn/text-base/IAUService.java.svn-base | 183 ---- .../text-base/ICheckAttributeValue.java.svn-base | 37 - .../.svn/text-base/IDeriveAttribute.java.svn-base | 40 - .../.svn/text-base/INormaliseValue.java.svn-base | 35 - .../text-base/ITranslatorService.java.svn-base | 100 --- .../.svn/text-base/package-info.java.svn-base | 8 - .../eu/stork/peps/auth/specific/IAUService.java | 32 + .../peps/auth/specific/ITranslatorService.java | 4 +- 77 files changed, 1488 insertions(+), 8587 deletions(-) delete mode 100644 id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeName.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeListProcessor.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutRequest.java create mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutResponse.java delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base delete mode 100644 id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base (limited to 'id/server/stork2-commons/src/main/java/eu') diff --git a/id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops deleted file mode 100644 index b792be687..000000000 --- a/id/server/stork2-commons/src/main/java/eu/.svn/all-wcprops +++ /dev/null @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 61 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu -END diff --git a/id/server/stork2-commons/src/main/java/eu/.svn/entries b/id/server/stork2-commons/src/main/java/eu/.svn/entries deleted file mode 100644 index d746a275b..000000000 --- a/id/server/stork2-commons/src/main/java/eu/.svn/entries +++ /dev/null @@ -1,31 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -stork -dir - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops deleted file mode 100644 index bfb5156c8..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/.svn/all-wcprops +++ /dev/null @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 67 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork -END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/.svn/entries deleted file mode 100644 index 081cc291c..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/.svn/entries +++ /dev/null @@ -1,31 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -peps -dir - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops deleted file mode 100644 index 10f18802a..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/all-wcprops +++ /dev/null @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 72 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps -END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries deleted file mode 100644 index d8fcce9b6..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/.svn/entries +++ /dev/null @@ -1,31 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -auth -dir - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops deleted file mode 100644 index 479002e28..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/all-wcprops +++ /dev/null @@ -1,5 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 77 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth -END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries deleted file mode 100644 index c90333736..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/.svn/entries +++ /dev/null @@ -1,34 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -commons -dir - -specific -dir - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops deleted file mode 100644 index 5c34d72e7..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/all-wcprops +++ /dev/null @@ -1,167 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 85 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons -END -CitizenConsent.java -K 25 -svn:wc:ra_dav:version-url -V 105 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java -END -AttributeProvidersMap.java -K 25 -svn:wc:ra_dav:version-url -V 112 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java -END -AttributeConstants.java -K 25 -svn:wc:ra_dav:version-url -V 109 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeConstants.java -END -AttributeUtil.java -K 25 -svn:wc:ra_dav:version-url -V 104 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java -END -STORKStatusCode.java -K 25 -svn:wc:ra_dav:version-url -V 106 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKStatusCode.java -END -STORKAttrQueryResponse.java -K 25 -svn:wc:ra_dav:version-url -V 113 -/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java -END -PersonalAttributeList.java -K 25 -svn:wc:ra_dav:version-url -V 112 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java -END -Country.java -K 25 -svn:wc:ra_dav:version-url -V 98 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/Country.java -END -PEPSErrors.java -K 25 -svn:wc:ra_dav:version-url -V 101 -/CITnet/svn/STORK2/!svn/ver/73/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java -END -PEPSUtil.java -K 25 -svn:wc:ra_dav:version-url -V 99 -/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java -END -PersonalAttribute.java -K 25 -svn:wc:ra_dav:version-url -V 108 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java -END -IAttributeProvidersMap.java -K 25 -svn:wc:ra_dav:version-url -V 113 -/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IAttributeProvidersMap.java -END -IStorkLogger.java -K 25 -svn:wc:ra_dav:version-url -V 103 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IStorkLogger.java -END -DateUtil.java -K 25 -svn:wc:ra_dav:version-url -V 99 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/DateUtil.java -END -STORKAuthnRequest.java -K 25 -svn:wc:ra_dav:version-url -V 108 -/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnRequest.java -END -STORKSubStatusCode.java -K 25 -svn:wc:ra_dav:version-url -V 109 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKSubStatusCode.java -END -IPersonalAttributeList.java -K 25 -svn:wc:ra_dav:version-url -V 113 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java -END -AttributeProvider.java -K 25 -svn:wc:ra_dav:version-url -V 108 -/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java -END -IStorkSession.java -K 25 -svn:wc:ra_dav:version-url -V 104 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/IStorkSession.java -END -CountryCodes.java -K 25 -svn:wc:ra_dav:version-url -V 103 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/CountryCodes.java -END -STORKAuthnResponse.java -K 25 -svn:wc:ra_dav:version-url -V 109 -/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java -END -package-info.java -K 25 -svn:wc:ra_dav:version-url -V 103 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/package-info.java -END -AttributeSource.java -K 25 -svn:wc:ra_dav:version-url -V 106 -/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java -END -Linker.java -K 25 -svn:wc:ra_dav:version-url -V 97 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/Linker.java -END -PEPSValues.java -K 25 -svn:wc:ra_dav:version-url -V 101 -/CITnet/svn/STORK2/!svn/ver/31/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java -END -PEPSParameters.java -K 25 -svn:wc:ra_dav:version-url -V 105 -/CITnet/svn/STORK2/!svn/ver/96/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java -END -STORKAttrQueryRequest.java -K 25 -svn:wc:ra_dav:version-url -V 112 -/CITnet/svn/STORK2/!svn/ver/56/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java -END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries deleted file mode 100644 index 78c1138bc..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/entries +++ /dev/null @@ -1,949 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth/commons -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -AttributeSource.java -file - - - - -2013-12-20T12:27:56.638475Z -0f5436915d275475d2e30e1ac8aa9916 -2013-10-10T17:38:31.956327Z -31 -emlelisst - - - - - - - - - - - - - - - - - - - - - -2576 - -Linker.java -file - - - - -2013-12-20T12:27:56.638475Z -7e2de1580308d3fa7c91f95eed36fcff -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -4707 - -package-info.java -file - - - - -2013-12-20T12:27:56.638475Z -8d8068e217f10425f76a8d37192ccd80 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -277 - -PEPSValues.java -file - - - - -2013-12-20T12:27:56.638475Z -95c122e156ff030f46dd02bacaef7b2a -2013-10-10T17:38:31.956327Z -31 -emlelisst - - - - - - - - - - - - - - - - - - - - - -7515 - -PEPSParameters.java -file - - - - -2013-12-20T12:27:56.638475Z -3bbae3c0d36d323b2551d8735becbbf3 -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -12811 - -STORKAttrQueryRequest.java -file - - - - -2013-12-20T12:27:56.638475Z -f24b34d7b7778b050000759b8e51e135 -2013-10-24T15:44:04.704923Z -56 -emgrtargr - - - - - - - - - - - - - - - - - - - - - -10086 - -CitizenConsent.java -file - - - - -2013-12-20T12:27:56.638475Z -65152dd2df078e7d9ba767293ee3089e -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -3419 - -AttributeProvidersMap.java -file - - - - -2013-12-20T12:27:56.638475Z -dd0a71bc5e428238622d01103d1ff592 -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -2570 - -AttributeConstants.java -file - - - - -2013-12-20T12:27:56.638475Z -940dcb9e93ede62e221f4b25abd6576b -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1831 - -exceptions -dir - -AttributeUtil.java -file - - - - -2013-12-20T12:27:56.638475Z -fa7359e18bb73f5e6a40a10602334001 -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -7921 - -STORKStatusCode.java -file - - - - -2013-12-20T12:27:56.638475Z -771689c75a8263c7e3966e820d59025e -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1906 - -STORKAttrQueryResponse.java -file - - - - -2013-12-20T12:27:56.638475Z -7f38f84cce71009e69f5b122cc56b9a4 -2013-10-24T15:44:04.704923Z -56 -emgrtargr - - - - - - - - - - - - - - - - - - - - - -6750 - -PersonalAttributeList.java -file - - - - -2013-12-20T12:27:56.638475Z -6d50cc23699503bb7a1444c9a16cff8c -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -9413 - -Country.java -file - - - - -2013-12-20T12:27:56.638475Z -9cbde5f25b646d02dae7ccf424906b4a -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -2208 - -PEPSErrors.java -file - - - - -2013-12-20T12:27:56.638475Z -8cd32a1d957e59b567eeb14ac9d989b6 -2013-10-28T11:11:01.095477Z -73 -emlelisst - - - - - - - - - - - - - - - - - - - - - -10810 - -PEPSUtil.java -file - - - - -2013-12-20T12:27:56.634475Z -54dfabdb89ec6069a2ec2e33c8d925d6 -2013-10-24T15:44:04.704923Z -56 -emgrtargr - - - - - - - - - - - - - - - - - - - - - -11507 - -PersonalAttribute.java -file - - - - -2013-12-20T12:27:56.634475Z -76a8ff69fd13e5f67f1404249ca1d8a1 -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -8471 - -IAttributeProvidersMap.java -file - - - - -2013-12-20T12:27:56.634475Z -225257e8d6d7b9e6bcc4bea2463c33be -2013-10-10T17:38:31.956327Z -31 -emlelisst - - - - - - - - - - - - - - - - - - - - - -2534 - -IStorkLogger.java -file - - - - -2013-12-20T12:27:56.634475Z -f15979b29f52d1674103528aed914ae7 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -4766 - -DateUtil.java -file - - - - -2013-12-20T12:27:56.634475Z -59f9cd2a3d1169a0f1a797b28719921a -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -5702 - -STORKAuthnRequest.java -file - - - - -2013-12-20T12:27:56.634475Z -3f36e65f0c4f1c7df753784b2e64f00b -2013-10-24T15:44:04.704923Z -56 -emgrtargr - - - - - - - - - - - - - - - - - - - - - -11269 - -STORKSubStatusCode.java -file - - - - -2013-12-20T12:27:56.634475Z -65e615e0119d4125d5f4f58af8bcd18b -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -2181 - -IPersonalAttributeList.java -file - - - - -2013-12-20T12:27:56.634475Z -8a39da025b26fd5782611eeadeb69e03 -2013-11-01T20:35:30.927048Z -96 -emferreri - - - - - - - - - - - - - - - - - - - - - -4664 - -AttributeProvider.java -file - - - - -2013-12-20T12:27:56.634475Z -a16d3c5a83ced423ccc22f1d841c3575 -2013-10-10T17:38:31.956327Z -31 -emlelisst - - - - - - - - - - - - - - - - - - - - - -1525 - -IStorkSession.java -file - - - - -2013-12-20T12:27:56.634475Z -5a8701b1fd27998d5cf3280a5c99bcb0 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -2745 - -CountryCodes.java -file - - - - -2013-12-20T12:27:56.638475Z -f91b0f8df0b2a68fe1b900d425257c23 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -3527 - -STORKAuthnResponse.java -file - - - - -2013-12-20T12:27:56.638475Z -413495295761fd9c49a0b1e50befc68f -2013-10-24T15:44:04.704923Z -56 -emgrtargr - - - - - - - - - - - - - - - - - - - - - -6797 - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base deleted file mode 100644 index 09769641c..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeConstants.java.svn-base +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * This enum class contains all the STORK PEPS, Commons and Specific errors - * constant identifiers. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.2 $, $Date: 2010-11-17 05:15:28 $ - */ -public enum AttributeConstants { - - /** - * Represents the attribute's name index. - */ - ATTR_NAME_INDEX(0), - /** - * Represents the attribute's type index. - */ - ATTR_TYPE_INDEX(1), - /** - * Represents the attribute's value index. - */ - ATTR_VALUE_INDEX(2), - /** - * Represents the attribute's status index. - */ - ATTR_STATUS_INDEX(3), - /** - * Represents the number of allowed tuples. - */ - NUMBER_TUPLES(4); - - /** - * Represents the constant's value. - */ - private int attribute; - - /** - * Solo Constructor. - * - * @param attr The Attribute Constant value. - */ - AttributeConstants(final int attr) { - - this.attribute = attr; - } - - /** - * Return the Constant Value. - * - * @return The constant value. - */ - public int intValue() { - - return attribute; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base deleted file mode 100644 index 013f4caf3..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvider.java.svn-base +++ /dev/null @@ -1,74 +0,0 @@ -package eu.stork.peps.auth.commons; - -/** - * This class is a bean used to store the information relative to the Attribute Provider. - * - * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) - * - * @version $Revision: 1.00 $, $Date: 2013-09-17 $ - */ -public final class AttributeProvider { - - /** - * Provider Id. - */ - private String providerId; - - /** - * Provider Name. - */ - private String providerName; - - /** - * Attribute Provider Constructor. - * - * @param pId Id of the Attribute Provider. - * @param pName Name of the Attribute Provider. - */ - public AttributeProvider(final String pId, final String pName) { - - this.providerId = pId; - this.providerName = pName; - } - - /** - * Getter for the providerId value. - * - * @return The providerId value. - */ - public String getProviderId() { - - return providerId; - } - - /** - * Setter for the providerId value. - * - * @param pId Id of the Attribute Provider. - */ - public void setProviderId(final String pId) { - - this.providerId = pId; - } - - /** - * Getter for the providerName value. - * - * @return The providerName value. - */ - public String getProviderName() { - - return providerName; - } - - /** - * Setter for the providerName value. - * - * @param name Name of the Attribute Provider. - */ - public void setProviderName(final String name) { - - this.providerName = name; - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base deleted file mode 100644 index 8806ba866..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeProvidersMap.java.svn-base +++ /dev/null @@ -1,94 +0,0 @@ -package eu.stork.peps.auth.commons; - -import java.util.Iterator; -import java.util.LinkedHashMap; - -import org.apache.log4j.Logger; - -/** - * Implementation of the AttributeProviderMap using a LinkedHashMap. - * - * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) - * - * @version $Revision: 1.01 $, $Date: 2013-09-20 $ - * - * @see LinkedHashMap - */ -public class AttributeProvidersMap extends LinkedHashMap - implements IAttributeProvidersMap { - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(AttributeProvidersMap.class.getName()); - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 8949081185106296122L; - - /** - * {@inheritDoc} - */ - @Override - public IPersonalAttributeList get(AttributeSource key) { - return this.get((Object) key); - } - - /** - * {@inheritDoc} - */ - @Override - public IPersonalAttributeList remove(AttributeSource key) { - return this.remove((Object) key); - } - - /** - * {@inheritDoc} - */ - @Override - public boolean containsKey(AttributeSource key) { - return this.containsKey((Object) key); - } - - /** - * {@inheritDoc} - */ - @Override - public Iterator keyIterator() { - return this.keySet().iterator(); - } - - public void trace() { - Iterator iterator; - Iterator iterator2; - AttributeSource source; - IPersonalAttributeList pal; - PersonalAttribute pa; - - iterator = this.keyIterator(); - LOG.trace("Start dumping of AttributeProvidersMap\n======================="); - while (iterator.hasNext()) { - source = iterator.next(); - - LOG.trace("Source details: type [" + source.getSourceType() + "], URL [" + source.getProviderURL() + "]"); - - if(source.getSourceType() == AttributeSource.SOURCE_LOCAL_APROVIDER) - LOG.trace("-> Attribute Provider: ID [" + source.getProvider().getProviderId() + "], name [" + source.getProvider().getProviderName() + "]"); - else - LOG.trace("-> Country: ID [" + source.getCountry().getCountryId() + "], name [" + source.getCountry().getCountryName() + "]"); - - pal = this.get(source); - LOG.trace("++++++++=>"); - iterator2 = pal.iterator(); - while (iterator2.hasNext()) { - pa = iterator2.next(); - - LOG.trace("-> Citizen Attribute: name [" + pa.getName() + "], name [" + pa.isRequired() + "]"); - } - LOG.trace("<=++++++++"); - - LOG.trace("-----------------------"); - } - LOG.trace("END\n======================="); - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base deleted file mode 100644 index 4b9dc33e9..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeSource.java.svn-base +++ /dev/null @@ -1,119 +0,0 @@ -package eu.stork.peps.auth.commons; - -/** - * This class is a bean used to store the information relative to the Attribute Source (either AttributeProvider or Country). - * - * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) - * - * @version $Revision: 1.00 $, $Date: 2013-09-19 $ - */ -public final class AttributeSource { - public static final int SOURCE_LOCAL_APROVIDER = 1; - public static final int SOURCE_REMOTE_COUNTRY = 2; - - /** - * Provider source. - */ - private int sourceType; - - /** - * Provider URL. - */ - private String providerURL; - - /** - * The local Attribute Provider. - */ - private AttributeProvider provider; - - /** - * The remote Country. - */ - private Country country; - - /** - * Attribute Source Constructor. - * - * @param provider The local Attribute Provider. - * @param pURL URL of the Attribute Provider. - */ - public AttributeSource(final AttributeProvider provider, final String pURL) { - this.setSourceType(SOURCE_LOCAL_APROVIDER); - - this.setProvider(provider); - this.setProviderURL(pURL); - } - - /** - * Attribute Source Constructor. - * - * @param country The remote Country. - * @param pURL URL of the Country. - */ - public AttributeSource(final Country country, final String pURL) { - this.setSourceType(SOURCE_REMOTE_COUNTRY); - - this.setCountry(country); - this.setProviderURL(pURL); - } - - /** - * @param sourceType the sourceType to set - */ - public void setSourceType(int sourceType) { - this.sourceType = sourceType; - } - - /** - * @return the sourceType - */ - public int getSourceType() { - return sourceType; - } - - /** - * @param providerURL the providerURL to set - */ - public void setProviderURL(String providerURL) { - this.providerURL = providerURL; - } - - /** - * @return the providerURL - */ - public String getProviderURL() { - return providerURL; - } - - /** - * @param provider the provider to set - */ - public void setProvider(AttributeProvider provider) { - this.setSourceType(SOURCE_LOCAL_APROVIDER); - - this.provider = provider; - } - - /** - * @return the provider - */ - public AttributeProvider getProvider() { - return provider; - } - - /** - * @param country the country to set - */ - public void setCountry(Country country) { - this.setSourceType(SOURCE_REMOTE_COUNTRY); - - this.country = country; - } - - /** - * @return the country - */ - public Country getCountry() { - return country; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base deleted file mode 100644 index 84e3576e5..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/AttributeUtil.java.svn-base +++ /dev/null @@ -1,231 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; - -import org.apache.commons.lang.StringUtils; - -/** - * This class holds static helper methods. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.5 $, $Date: 2010-12-15 23:19:59 $ - */ -public final class AttributeUtil { - - /** - * Private constructor. Prevents the class from being instantiated. - */ - private AttributeUtil() { - // empty constructor - } - - /** - * Safe escape any given string. - * - * @param value The HTTP Value to escaped. - * - * @return The value escaped value. - */ - public static String escape(final String value) { - - final String attrSep = PEPSValues.ATTRIBUTE_SEP.toString(); - final String attrTupleSep = PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(); - final String attrValueSep = PEPSValues.ATTRIBUTE_VALUE_SEP.toString(); - - final String escAttrSep = "%" + (int) attrSep.charAt(0); - final String escAttrTupleSep = "%" + (int) attrTupleSep.charAt(0); - final String escAttrValueSep = "%" + (int) attrValueSep.charAt(0); - - return value.replace(attrSep, escAttrSep) - .replace(attrTupleSep, escAttrTupleSep) - .replace(attrValueSep, escAttrValueSep); - } - - /** - * Unescape any given string. - * - * @param value The HTTP Value to be unescaped. - * - * @return The value unescaped value. - */ - public static String unescape(final String value) { - final String attrSep = PEPSValues.ATTRIBUTE_SEP.toString(); - final String attrTupleSep = PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(); - final String attrValueSep = PEPSValues.ATTRIBUTE_VALUE_SEP.toString(); - - final String escAttrSep = "%" + (int) attrSep.charAt(0); - final String escAttrTupleSep = "%" + (int) attrTupleSep.charAt(0); - final String escAttrValueSep = "%" + (int) attrValueSep.charAt(0); - - return value.replace(escAttrSep, attrSep) - .replace(escAttrTupleSep, attrTupleSep) - .replace(escAttrValueSep, attrValueSep); - } - - /** - * Appends the string representation of an object to a StringBuilder. - * - * @param strBuilder The StringBuilder to append to. - * @param val The string representation of an object. - */ - public static void appendIfNotNull(final StringBuilder strBuilder, - final Object val) { - - if (val != null) { - strBuilder.append(val); - } - } - - /** - * Given a separator and a list of strings, joins the list, as a string, - * separated by the separator string. - * - * @param list The list of strings to join. - * @param separator The separator string. - * @return the list, as a string, separated by the separator string. - */ - public static String listToString(final List list, - final String separator) { - - final StringBuilder strBuilder = new StringBuilder(); - for (final String s : list) { - if (!StringUtils.isEmpty(s)) { - strBuilder.append(AttributeUtil.escape(s) + separator); - } - } - return strBuilder.toString(); - } - - /** - * Given a separator and a map of strings to strings, joins the map, as a - * string, separated by the separator string with the pair key/value - * concatenated with a '='. - * - * @param map The map of strings to join. - * @param separator The separator string. - * - * @return the map of strings, as a string, separated by the separator string - * with the pair key/value concatenated with a '='. - */ - public static String mapToString(final Map map, - final String separator) { - - final StringBuilder strBuilder = new StringBuilder(); - final Iterator> valuesIt = map.entrySet().iterator(); - while (valuesIt.hasNext()) { - final Entry entry = valuesIt.next(); - strBuilder.append(entry.getKey()); - strBuilder.append('='); - strBuilder.append(AttributeUtil.escape(entry.getValue())); - strBuilder.append(separator); - } - return strBuilder.toString(); - } - - /** - * Validates the attribute value format. - * - * @param value The attribute value to validate. - * - * @return true if value has a valid format. - */ - public static boolean isValidValue(final String value) { - boolean retVal = false; - if (value != null && value.charAt(0) == '[' && value.endsWith("]")) { - final String tmpAttrValue = value.substring(1, value.length() - 1); - final String[] vals = - tmpAttrValue.split(PEPSValues.ATTRIBUTE_VALUE_SEP.toString()); - - if (tmpAttrValue.length() >= 0 - || (vals.length > 0 && vals[0].length() > 0)) { - retVal = true; - } - } - return retVal; - } - - /** - * Validates the attribute type value. It's case insensitive. E.g. return true - * value to: a) "true", "TRUE", "True", ... b) "false", "FALSE", "False", ... - * - * @param type The attribute type value. - * - * @return true if type has a true or false (case insensitive) value. - */ - public static boolean isValidType(final String type) { - return StringUtils.isNotEmpty(type) && (PEPSValues.TRUE.toString().equalsIgnoreCase(type) || PEPSValues.FALSE.toString().equalsIgnoreCase(type)) ; - } - - /** - * Validates the Personal attribute tuple. E.g. name:type:[value]:status - * - * @param tuples The Personal attribute's tuple. - * - * @return true if the tuples' format is valid. - * - * @see PEPSUtil#validateParameter(String, String, String) - * @see String#equalsIgnoreCase(String) - */ - public static boolean hasValidTuples(final String[] tuples) { - boolean retVal = false; - - int numberTuples = AttributeConstants.NUMBER_TUPLES.intValue(); - if (tuples != null && tuples.length == numberTuples) { - // validate attrName - final int attrNameIndex = AttributeConstants.ATTR_NAME_INDEX.intValue(); - final int attrTypeIndex = AttributeConstants.ATTR_TYPE_INDEX.intValue(); - final int attrValueIndex = AttributeConstants.ATTR_VALUE_INDEX.intValue(); - - retVal = - StringUtils.isNotEmpty(tuples[attrNameIndex]) - && StringUtils.isNotEmpty(tuples[attrTypeIndex]) - && StringUtils.isNotEmpty(tuples[attrValueIndex]) - && AttributeUtil.isValidType(tuples[attrTypeIndex]) - && AttributeUtil.isValidValue(tuples[attrValueIndex]); - } - return retVal; - } - - /** - * Check if all mandatory attributes have values. - * - * @param personalAttrList The Personal Attributes List. - * - * @return true if all mandatory attributes have values, false if at least one - * attribute doesn't have value. - */ - public static boolean checkMandatoryAttributes( - final IPersonalAttributeList personalAttrList) { - - final Iterator itAttributes = - personalAttrList.values().iterator(); - boolean retVal = true; - while (itAttributes.hasNext() && retVal) { - final PersonalAttribute attr = itAttributes.next(); - if (attr.isRequired() - && !STORKStatusCode.STATUS_AVAILABLE.toString() - .equals(attr.getStatus())) { - retVal = false; - } - } - return retVal; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base deleted file mode 100644 index 2245178f4..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CitizenConsent.java.svn-base +++ /dev/null @@ -1,123 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.util.ArrayList; -import java.util.List; - -/** - * This class is a bean used to store the information relative to the Citizen - * Consent. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class CitizenConsent { - - /** - * Mandatory attributes list. - */ - private List mandatoryList; - - /** - * Optional attributes list. - */ - private List optionalList; - - /** - * Citizen Consent default Constructor. - */ - public CitizenConsent() { - this.mandatoryList = new ArrayList(); - this.optionalList = new ArrayList(); - } - - /** - * Getter for the mandatoryList value. - * - * @return The mandatoryList value. - */ - public List getMandatoryList() { - return this.mandatoryList; - } - - /** - * Setter for the mandatoryList value. - * - * @param mandatoryAttrList Mandatory parameters list. - */ - public void setMandatoryList(final List mandatoryAttrList) { - this.mandatoryList = mandatoryAttrList; - } - - /** - * Setter for some mandatoryAttribute. Adds the input parameter to the - * mandatoryList. - * - * @param mandatoryAttr Attribute to add to the mandatoryList. - */ - public void setMandatoryAttribute(final String mandatoryAttr) { - this.mandatoryList.add(mandatoryAttr); - } - - /** - * Getter for the optionalList value. - * - * @return The optionalList value. - */ - public List getOptionalList() { - return optionalList; - } - - /** - * Setter for the optionalList value. - * - * @param optAttrList Optional parameters list. - */ - public void setOptionalList(final List optAttrList) { - this.optionalList = optAttrList; - } - - /** - * Setter for some optionalAttr. Adds the input parameter to the optionalList. - * - * @param optionalAttr Attribute to add to the optionalList. - */ - public void setOptionalAttribute(final String optionalAttr) { - this.optionalList.add(optionalAttr); - } - - /** - * Returns a string in the following format. "Mandatory attributes: - * mandatoryAttr1;mandatoryAttr2;mandatoryAttrN Optional attributes: - * optionalAttr1;optionalAttr2;optionalAttrN" - * - * @return {@inheritDoc} - */ - public String toString() { - final StringBuilder strbldr = new StringBuilder(); - strbldr.append("Mandatory attributes: "); - for (String str : mandatoryList) { - strbldr.append(str + ";"); - } - strbldr.append(" Optional attributes: "); - for (String str : optionalList) { - strbldr.append(str + ";"); - } - return strbldr.toString(); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base deleted file mode 100644 index 001f9317a..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Country.java.svn-base +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.io.Serializable; - -/** - * This class is a bean used to store the information relative to the Country. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.10 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class Country implements Serializable { - - /** - * - */ - private static final long serialVersionUID = 1135994036496370993L; - -/** - * Country Id. - */ - private String countryId; - - /** - * Country Name. - */ - private String countryName; - - /** - * Country Constructor. - * - * @param cId Id of the Country. - * @param cName Name of the Country. - */ - public Country(final String cId, final String cName) { - - this.countryId = cId; - this.countryName = cName; - } - - /** - * Getter for the countryId value. - * - * @return The countryId value. - */ - public String getCountryId() { - - return countryId; - } - - /** - * Setter for the countryId value. - * - * @param cId Id of the Country. - */ - public void setCountryId(final String cId) { - - this.countryId = cId; - } - - /** - * Getter for the countryName value. - * - * @return The countryName value. - */ - public String getCountryName() { - - return countryName; - } - - /** - * Setter for the countryName value. - * - * @param name Name of the Country. - */ - public void setCountryName(final String name) { - - this.countryName = name; - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base deleted file mode 100644 index 54345f3ea..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/CountryCodes.java.svn-base +++ /dev/null @@ -1,79 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.util.Arrays; -import java.util.List; - -/** - * This class contains all the ISO 3166-1 Alpha 3 Country Codes. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.2 $, $Date: 2011-04-14 00:24:56 $ - */ -public final class CountryCodes { - - /** - * Private Constructor. - */ - private CountryCodes() { - - } - - /** - * ISO 3166-1 Alpha 3 Country Codes. - */ - private static List countrysAlpha3 = Arrays.asList("ABW", "AFG", - "AGO", "AIA", "ALA", "ALB", "AND", "ANT", "ARE", "ARG", "ARM", "ASM", - "ATA", "ATF", "ATG", "AUS", "AUT", "AZE", "BDI", "BEL", "BEN", "BES", - "BFA", "BGD", "BGR", "BHR", "BHS", "BIH", "BLM", "BLR", "BLZ", "BMU", - "BOL", "BRA", "BRB", "BRN", "BTN", "BUR", "BVT", "BWA", "BYS", "CAF", - "CAN", "CCK", "CHE", "CHL", "CHN", "CIV", "CMR", "COD", "COG", "COK", - "COL", "COM", "CPV", "CRI", "CSK", "CUB", "CUW", "CXR", "CYM", "CYP", - "CZE", "DEU", "DJI", "DMA", "DNK", "DOM", "DZA", "ECU", "EGY", "ERI", - "ESH", "ESP", "EST", "ETH", "FIN", "FJI", "FLK", "FRA", "FRO", "FSM", - "GAB", "GBR", "GEO", "GGY", "GHA", "GIB", "GIN", "GLP", "GMB", "GNB", - "GNQ", "GRC", "GRD", "GRL", "GTM", "GUF", "GUM", "GUY", "HKG", "HMD", - "HND", "HRV", "HTI", "HUN", "IDN", "IMN", "IND", "IOT", "IRL", "IRN", - "IRQ", "ISL", "ISR", "ITA", "JAM", "JEY", "JOR", "JPN", "KAZ", "KEN", - "KGZ", "KHM", "KIR", "KNA", "KOR", "KWT", "LAO", "LBN", "LBR", "LBY", - "LCA", "LIE", "LKA", "LSO", "LTU", "LUX", "LVA", "MAC", "MAF", "MAR", - "MCO", "MDA", "MDG", "MDV", "MEX", "MHL", "MKD", "MLI", "MLT", "MMR", - "MNE", "MNG", "MNP", "MOZ", "MRT", "MSR", "MTQ", "MUS", "MWI", "MYS", - "MYT", "NAM", "NCL", "NER", "NFK", "NGA", "NIC", "NIU", "NLD", "NOR", - "NPL", "NRU", "NZL", "OMN", "PAK", "PAN", "PCN", "PER", "PHL", "PLW", - "PNG", "POL", "PRI", "PRK", "PRT", "PRY", "PSE", "PYF", "QAT", "REU", - "ROM", "ROU", "RUS", "RWA", "SAU", "SCG", "SDN", "SEN", "SGP", "SGS", - "SHN", "SJM", "SLB", "SLE", "SLV", "SMR", "SOM", "SPM", "SRB", "STP", - "SUR", "SVK", "SVN", "SXW", "SWE", "SWZ", "SYC", "SYR", "TCA", "TCD", - "TGO", "THA", "TJK", "TKL", "TKM", "TLS", "TMP", "TON", "TTO", "TUN", - "TUR", "TUV", "TWN", "TZA", "UGA", "UKR", "UMI", "URY", "USA", "UZB", - "VAT", "VCT", "VEN", "VGB", "VIR", "VNM", "VUT", "WLF", "WSM", "YEM", - "YUG", "ZAF", "ZAR", "ZMB", "ZWE"); - - /** - * Searches the CountryCode (3166-1 alpha3 format) an return true if it - * exists. - * - * @param countryCode The Country code to search. - * - * @return true if the CountryCode exists, false otherwise. - */ - public static boolean hasCountryCodeAlpha3(final String countryCode) { - - return CountryCodes.countrysAlpha3.contains(countryCode); - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base deleted file mode 100644 index 9c0bd6775..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/DateUtil.java.svn-base +++ /dev/null @@ -1,169 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.sql.Timestamp; -import java.util.GregorianCalendar; - -import org.apache.log4j.Logger; -import org.joda.time.DateTime; -import org.joda.time.Years; -import org.joda.time.format.DateTimeFormat; -import org.joda.time.format.DateTimeFormatter; - -import eu.stork.peps.auth.commons.exceptions.SecurityPEPSException; - -/** - * This class holds static helper methods for Date Operations. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.4 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class DateUtil { - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(DateUtil.class.getName()); - - /** - * yyyy Date format size. - */ - private static final int YEAR_DATE_SIZE = 4; - - /** - * yyyyMM Date format size. - */ - private static final int MONTH_DATE_SIZE = 6; - - /** - * Private constructor. Prevents the class from being instantiated. - */ - private DateUtil() { - // empty constructor - } - - /** - * Fulfils dateValue with a valid date. The following roles are applied: a) If - * the dateValue only contains the year then fulfils with last year's day. - * e.g. this method returns 19951231 to the 1995 dateValue. b) If the - * dateValue contains the year and the month then fulfils with last month's - * day. e.g. this method returns 19950630 to the 199505 dateValue. - * - * @param dateValue The date to be fulfilled. - * - * @return The dateValue fulfilled. - */ - private static String fulfilDate(final String dateValue) { - - final StringBuffer strBuf = new StringBuffer(); - strBuf.append(dateValue); - // if the IdP just provides the year then we must fullfil the date. - if (dateValue.length() == YEAR_DATE_SIZE) { - strBuf.append(PEPSValues.LAST_MONTH.toString()); - } - // if the IdP provides the year and the month then we must fullfil the - // date. - if (dateValue.length() == MONTH_DATE_SIZE - || strBuf.length() == MONTH_DATE_SIZE) { - // IdP doesn't provide the day, so we will use DateTime to - // calculate it. - final String noDayCons = PEPSValues.NO_DAY_DATE_FORMAT.toString(); - final DateTimeFormatter fmt = DateTimeFormat.forPattern(noDayCons); - final DateTime dateTime = fmt.parseDateTime(strBuf.toString()); - // Append the last month's day. - strBuf.append(dateTime.dayOfMonth().withMaximumValue().getDayOfMonth()); - } - - return strBuf.toString(); - } - - /** - * Validates the dateValue format: a) if has a valid size; b) if has a numeric - * value; Note: dateValue must have the format yyyyMMdd. - * - * @param dateValueTmp The date to be validated. - * @param pattern The accepted date format. - * - * @return true if the date has a valid format. - */ - public static boolean isValidFormatDate(final String dateValueTmp, - final String pattern) { - - boolean retVal = true; - try { - final String dateValue = DateUtil.fulfilDate(dateValueTmp); - - final DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); - fmt.parseDateTime(dateValue); - } catch (final Exception e) { - // We catch Exception because we only have to return false - // value! - retVal = false; - } - return retVal; - } - - /** - * Calculates the age for a given date string. - * - * @param dateVal The date to be validated. - * @param now The current date. - * @param pattern The date pattern. - * - * @return The age value. - */ - public static int calculateAge(final String dateVal, final DateTime now, - final String pattern) { - - if (DateUtil.isValidFormatDate(dateVal, pattern)) { - try { - final String dateValueTemp = DateUtil.fulfilDate(dateVal); - final DateTimeFormatter fmt = DateTimeFormat.forPattern(pattern); - final DateTime dateTime = fmt.parseDateTime(dateValueTemp); - // Calculating age - final Years age = Years.yearsBetween(dateTime, now); - - return age.getYears(); - } catch (final IllegalArgumentException e) { - LOG.warn("Invalid date format (" + pattern - + ") or an invalid dateValue."); - throw new SecurityPEPSException( - PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorCode()), - PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorMessage()), - e); - } - } else { - LOG.warn("Couldn't calculate Age, invalid date!"); - throw new SecurityPEPSException( - PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorCode()), - PEPSUtil.getConfig(PEPSErrors.INVALID_ATTRIBUTE_VALUE.errorMessage())); - } - - } - - /** - * Generates the current timestamp. - * - * @return timestamp The current timestamp - */ - public static Timestamp currentTimeStamp() { - final GregorianCalendar cal = new GregorianCalendar(); - final long millis = cal.getTimeInMillis(); - return new Timestamp(millis); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base deleted file mode 100644 index 733399ca3..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IAttributeProvidersMap.java.svn-base +++ /dev/null @@ -1,82 +0,0 @@ -package eu.stork.peps.auth.commons; - -import java.util.Iterator; - -/** - * Interface for Attributes Providers map. - * - * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) - * - * @version $Revision: 1.00 $, $Date: 2013-09-20 $ - */ -public interface IAttributeProvidersMap { - - /** - * Returns the object associated the the given key. - * - * @param key with which the specified value is to be associated. - * - * @return The object associated the the given key. - */ - IPersonalAttributeList get(AttributeSource key); - - /** - * Associates a key to a value, and inserts them in the session object. - * - * @param key with which the specified value is to be associated. - * @param value to be associated with the specified key. - * - * @return previous value associated with specified key, or null if there was - * no mapping for key. A null return can also indicate that the map - * previously associated null with the specified key. - */ - Object put(AttributeSource key, IPersonalAttributeList value); - - /** - * Removes the mapping for this key. - * - * @param key with which the specified value is to be associated. - * - * @return previous value associated with specified key, or null if there was - * no mapping for key. A null return can also indicate that the map - * previously associated null with the specified key. - */ - IPersonalAttributeList remove(AttributeSource key); - - /** - * Returns the number of key-value mappings in this map. - * - * @return the number of key-value mappings in this map. - */ - int size(); - - /** - * Returns true if this map contains a mapping for the specified key. - * - * @param key with which the specified value is to be associated. - * - * @return true if this map contains a mapping for the specified key. - */ - boolean containsKey(AttributeSource key); - - /** - * Removes all mappings from this map. - */ - void clear(); - - /** - * Returns true if this map contains no key-value mappings. - * - * @return true if this map contains no key-value mappings. - */ - boolean isEmpty(); - - /** - * Returns an Iterator of the keys contained in this map. The implementation must - * take care in order for the Iterator to have predictable order of the returned - * keys. - * - * @return an iterator of the keys contained in this map - */ - Iterator keyIterator(); -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base deleted file mode 100644 index 83b8e57fe..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IPersonalAttributeList.java.svn-base +++ /dev/null @@ -1,140 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.util.Collection; -import java.util.Iterator; - -/** - * Interface for {@link PersonalAttributeList}. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.16 $, $Date: 2010-11-17 05:15:28 $ - * - * @see PersonalAttribute - */ -@SuppressWarnings("PMD.CloneMethodMustImplementCloneable") -public interface IPersonalAttributeList extends Iterable, - Cloneable { - - /** - * Associates the specified value with the specified key in this Personal - * Attribute List. - * - * @param key with which the specified value is to be associated. - * @param value to be associated with the specified key. - * - * @return the previous value associated with key, or null if there was no - * mapping for key. - * - * @see PersonalAttribute - */ - PersonalAttribute put(String key, PersonalAttribute value); - - /** - * Returns the value to which the specified key is mapped, or null if this map - * contains no mapping for the key. - * - * @param key whose associated value is to be returned. - * - * @return The value to which the specified key is mapped, or null if this map - * contains no mapping for the key. - * - * @see PersonalAttribute - */ - PersonalAttribute get(Object key); - - /** - * Adds to the PersonalAttributeList the given PersonalAttribute. It sets the - * attribute name as the key to the attribute value. - * - * @param value PersonalAttribute to add to the PersonalAttributeList - */ - void add(PersonalAttribute value); - - /** - * Get the size of the Personal Attribute List. - * - * @return size of the Personal Attribute List. - */ - int size(); - - /** - * Checks if the Personal Attribute List contains the given key. - * - * @param key with which the specified value is to be associated. - * - * @return true if the Personal Attribute List contains the given key, false - * otherwise. - */ - boolean containsKey(Object key); - - /** - * Getter for the iterator of the Personal Attribute List values. - * - * @return The iterator for the Personal Attribute List values. - * - * @see PersonalAttribute - */ - Iterator iterator(); - - /** - * Creates a Personal Attribute List from a String representing an Attribute - * List. - * - * @param attrList String Object representing the attribute list. - */ - void populate(String attrList); - - /** - * Removes the mapping for this key from this map if present. - * - * @param key key whose mapping is to be removed from the map. - * @return previous value associated with specified key, or null if - * there was no mapping for key. A null return can also - * indicate that the map previously associated null with the - * specified key. - */ - PersonalAttribute remove(Object key); - - /** - * Returns a collection view of the values contained in this map. The - * collection is backed by the map, so changes to the map are reflected in the - * collection, and vice-versa. The collection supports element removal, which - * removes the corresponding mapping from this map, via the - * Iterator.remove, Collection.remove, removeAll, - * retainAll, and clear operations. It does not support the - * add or addAll operations. - * - * @return a collection view of the values contained in this map. - */ - Collection values(); - - /** - * Returns true if this map contains no key-value mappings. - * - * @return true if this map contains no key-value mappings. - */ - boolean isEmpty(); - - /** - * Returns a copy of this IPersonalAttributeList instance. - * - * @return The copy of this IPersonalAttributeList. - */ - Object clone() throws CloneNotSupportedException; - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base deleted file mode 100644 index 33eb618f0..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkLogger.java.svn-base +++ /dev/null @@ -1,239 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * Interface for stork logging. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.10 $, $Date: 2011-02-17 22:44:34 $ - */ -public interface IStorkLogger { - - /** - * Getter for SpApplication. - * - * @return The SpApplication value. - */ - String getSpApplication(); - - /** - * Setter for SpApplication. - * - * @param spApplication The SP Application. - */ - void setSpApplication(String spApplication); - - /** - * Getter for ProviderName. - * - * @return The ProviderName value. - */ - String getProviderName(); - - /** - * Setter for ProviderName. - * - * @param providerName The provider name. - */ - void setProviderName(String providerName); - - /** - * - * Getter for Origin. - * - * @return The Origin value. - * - */ - String getOrigin(); - - /** - * Setter for Origin. - * - * @param origin The origin. - */ - void setOrigin(String origin); - - /** - * - * Getter for QAA Level. - * - * @return The QAA Level value. - * - */ - int getQaaLevel(); - - /** - * Setter for QAA Level. - * - * @param qaaLevel The qaa level. - */ - void setQaaLevel(int qaaLevel); - - /** - * - * Getter for timestamp. - * - * @return The timestamp value. - * - */ - String getTimestamp(); - - /** - * Setter for timestamp. - * - * @param timestamp The request's timestamp. - */ - void setTimestamp(String timestamp); - - /** - * Getter for InResponseTo. - * - * @return The InResponseTo value. - */ - String getInResponseTo(); - - /** - * Setter for InResponseTo. - * - * @param inResponseTo The Saml's response id. - */ - void setInResponseTo(String inResponseTo); - - /** - * Getter for InResponseToSPReq. - * - * @return The InResponseToSPReq value. - */ - String getInResponseToSPReq(); - - /** - * Setter for InResponseToSPRequ. - * - * @param inResponseToSPReq The Saml's response id. - */ - void setInResponseToSPReq(String inResponseToSPReq); - - /** - * Getter for opType. - * - * @return The opType value. - */ - String getOpType(); - - /** - * Setter for opType. - * - * @param opType The operation type. - */ - void setOpType(String opType); - - /** - * Getter for destination. - * - * @return The destination value. - */ - String getDestination(); - - /** - * Setter for destinationIp. - * - * @param destination The remote IP. - */ - void setDestination(String destination); - - /** - * Getter for message or assertion consumer. - * - * @return The message or assertion consumer. - */ - String getMessage(); - - /** - * Setter for message or assertion consumer. - * - * @param message or assertion consumer. - */ - void setMessage(String message); - - /** - * Getter for country. - * - * @return The country value. - */ - String getCountry(); - - /** - * Setter for country. - * - * @param country The country. - */ - void setCountry(String country); - - /** - * Getter for samlHash. - * - * @return The samlHash value. - */ - byte[] getSamlHash(); - - /** - * Setter for samlHash. - * - * @param samlHash the encrypted SAML token - */ - void setSamlHash(byte[] samlHash); - - /** - * Getter for msgId. - * - * @return the msgId - */ - String getMsgId(); - - /** - * Setter for msgId. - * - * @param msgId the ID of the originator of this message - */ - void setMsgId(String msgId); - - /** - * Getter for sPMsgId. - * - * @return the sPMsgId - */ - String getSPMsgId(); - - /** - * Setter for sPMsgId. - * - * @param sPMsgId the ID of the originator of this message - */ - void setSPMsgId(String sPMsgId); - - /** - * The format of the returned String must be the following: - * "requestCounter#ddMMMyyyykk:mm:ss#opType#originIp#originName - * #destinationIp#destinationName#samlHash#[originatorName#msgId#]" - * - * The values enclosed in '[]' only apply when logging responses. - * - * @return {@inheritDoc} - */ - @Override - String toString(); -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base deleted file mode 100644 index f38b41838..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/IStorkSession.java.svn-base +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * Interface for stork session. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.9 $, $Date: 2010-11-17 05:15:28 $ - */ -public interface IStorkSession { - - /** - * Returns the object associated the the given key. - * - * @param key with which the specified value is to be associated. - * - * @return The object associated the the given key. - */ - Object get(Object key); - - /** - * Associates a key to a value, and inserts them in the session object. - * - * @param key with which the specified value is to be associated. - * @param value to be associated with the specified key. - * - * @return previous value associated with specified key, or null if there was - * no mapping for key. A null return can also indicate that the map - * previously associated null with the specified key. - */ - Object put(String key, Object value); - - /** - * Removes the mapping for this key. - * - * @param key with which the specified value is to be associated. - * - * @return previous value associated with specified key, or null if there was - * no mapping for key. A null return can also indicate that the map - * previously associated null with the specified key. - */ - Object remove(Object key); - - /** - * Returns the number of key-value mappings in this map. - * - * @return the number of key-value mappings in this map. - */ - int size(); - - /** - * Returns true if this map contains a mapping for the specified key. - * - * @param key with which the specified value is to be associated. - * - * @return true if this map contains a mapping for the specified key. - */ - boolean containsKey(Object key); - - /** - * Removes all mappings from this map. - */ - void clear(); - - /** - * Returns true if this map contains no key-value mappings. - * - * @return true if this map contains no key-value mappings. - */ - boolean isEmpty(); -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base deleted file mode 100644 index 43d3adaa9..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/Linker.java.svn-base +++ /dev/null @@ -1,173 +0,0 @@ -package eu.stork.peps.auth.commons; - -import java.util.Iterator; - -/** - * This class is a bean used to store the information of Attribute Providers, the Attribute - * List to be requested, the Assertions returned by the Attribute Providers and the values - * that each Attribute has. This information along with the current status of the Linker (the - * attribute providers that were queried and the remaining providers) is used by the PEPS - * actions in order to complete the Attribute gathering. - * - * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) - * - * @version $Revision: 1.20 $, $Date: 2013-10-28 $ - */ -public final class Linker { - /** - * Attributes Providers map. - */ - private IAttributeProvidersMap attributeProvidersMap; - - /** - * The current index of local (domestic) Attribute Providers. - */ - private int localIndex; - - /** - * The current index of remote (foreign) Attribute Providers - countries. - */ - private int remoteIndex; - - /** - * Constructs an empty Linker object. - */ - public Linker() { - localIndex = 0; - remoteIndex = 0; - } - - /** - * Based on the internal state of the Linker it returns the next local Attribute Source - * - * @return The next Attribute Source or null if not found - * - * @see AttributeSource - */ - public AttributeSource getNextLocalProvider() { - Iterator iterator; - AttributeSource source, found; - int curIndex = 0; - - found = null; - - if ( attributeProvidersMap!=null && !attributeProvidersMap.isEmpty() ) { - iterator = attributeProvidersMap.keyIterator(); - while (iterator.hasNext()) { - source = iterator.next(); - - if ( source.getSourceType()==AttributeSource.SOURCE_LOCAL_APROVIDER ) { - if ( curIndex>=localIndex ) { - found = source; - - break; - } - - curIndex++; - } - } - } - - return found; - } - - /** - * Based on the internal state of the Linker it returns the next remote Attribute Source - * - * @return The next Attribute Source or null if not found - * - * @see AttributeSource - */ - public AttributeSource getNextRemoteProvider() { - Iterator iterator; - AttributeSource source, found; - int curIndex = 0; - - found = null; - - if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) { - iterator = attributeProvidersMap.keyIterator(); - while (iterator.hasNext()) { - source = iterator.next(); - - if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) { - if ( curIndex>=remoteIndex ) { - found = source; - - break; - } - - curIndex++; - } - } - } - - return found; - } - - /** - * It updates the Linker with the values returned by the Attribute Source. It also advances - * to the next index in order to mark this attribute source as completed. - * - * @param source The Attribute Source that was queried for attribute values. - * @param attrResponse The attrResponse returned by the Attribute Source that contains the attribute values. - * - * @see AttributeSource, STORKAttrQueryResponse - */ - public void setProviderReponse(AttributeSource source, STORKAttrQueryResponse attrResponse) { - if ( source.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) - remoteIndex++; - else - localIndex++; - - //TODO How to store Assertions (format: byte, base64 string, entire object?) - - this.attributeProvidersMap.put(source, attrResponse.getPersonalAttributeList()); - } - - /** - * Reset the internal state of the local Attribute Source in order to start over. - */ - public void resetLocalIndex() { - localIndex = 0; - } - - /** - * Reset the internal state of the remote Attribute Source in order to start over. - */ - public void resetRemoteIndex() { - remoteIndex = 0; - } - - /** - * Setter for attributeProvidersMap. - * - * @param attributeProvidersMap The attributeProvidersMap to set. - */ - public void setAttributeProvidersMap(IAttributeProvidersMap attributeProvidersMap) { - this.attributeProvidersMap = attributeProvidersMap; - } - - /** - * Getter for attributeProvidersMap. - * - * @return attributeProvidersMap - */ - public IAttributeProvidersMap getAttributeProvidersMap() { - return attributeProvidersMap; - } - - /** - * Returns the Personal Attribute list of the provided Attribute Source. - * - * @return The IPersonalAttributeList assosiated with this source or null if empty - * - * @see IPersonalAttributeList - */ - public IPersonalAttributeList getProviderAttributes(AttributeSource source) { - if ( attributeProvidersMap.containsKey(source) ) - return attributeProvidersMap.get(source); - else - return null; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base deleted file mode 100644 index 3aa549a06..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSErrors.java.svn-base +++ /dev/null @@ -1,348 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * This enum class contains all the STORK PEPS, Commons and Specific errors - * constant identifiers. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.10 $, $Date: 2011-02-17 22:44:34 $ - */ -public enum PEPSErrors { - - /** - * Represents the 'authenticationFailed' constant error identifier. - */ - AUTHENTICATION_FAILED_ERROR("authenticationFailed"), - /** - * Represents the 'spCountrySelector.errorCreatingSAML' constant error - * identifier. - */ - SP_COUNTRY_SELECTOR_ERROR_CREATE_SAML("spCountrySelector.errorCreatingSAML"), - /** - * Represents the 'spCountrySelector.destNull' constant error identifier. - */ - SP_COUNTRY_SELECTOR_DESTNULL("spCountrySelector.destNull"), - /** - * Represents the 'spCountrySelector.invalidAttr' constant error identifier. - */ - SP_COUNTRY_SELECTOR_INVALID_ATTR("spCountrySelector.invalidAttr"), - /** - * Represents the 'spCountrySelector.invalidProviderName' constant error - * identifier. - */ - SP_COUNTRY_SELECTOR_INVALID_PROVIDER_NAME( - "spCountrySelector.invalidProviderName"), - /** - * Represents the 'spCountrySelector.invalidQaaSPid' constant error - * identifier. - */ - SP_COUNTRY_SELECTOR_INVALID_QAASPID("spCountrySelector.invalidQaaSPid"), - /** - * Represents the 'spCountrySelector.invalidSpId' constant error identifier. - */ - SP_COUNTRY_SELECTOR_INVALID_SPID("spCountrySelector.invalidSpId"), - /** - * Represents the 'spCountrySelector.invalidSPQAA' constant error identifier. - */ - SP_COUNTRY_SELECTOR_INVALID_SPQAA("spCountrySelector.invalidSPQAA"), - /** - * Represents the 'spCountrySelector.invalidSpURL' constant error identifier. - */ - SP_COUNTRY_SELECTOR_INVALID_SPURL("spCountrySelector.invalidSpURL"), - /** - * Represents the 'spCountrySelector.spNotAllowed' constant error identifier. - */ - SP_COUNTRY_SELECTOR_SPNOTALLOWED("spCountrySelector.spNotAllowed"), - - /** - * Represents the 'sProviderAction.errorCreatingSAML' constant error - * identifier. - */ - SPROVIDER_SELECTOR_ERROR_CREATE_SAML("sProviderAction.errorCreatingSAML"), - /** - * Represents the 'sProviderAction.attr' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_ATTR("sProviderAction.invalidAttr"), - /** - * Represents the 'sProviderAction.country' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_COUNTRY("sProviderAction.invalidCountry"), - /** - * Represents the 'sProviderAction.relayState' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_RELAY_STATE("sProviderAction.invalidRelayState"), - /** - * Represents the 'sProviderAction.saml' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SAML("sProviderAction.invalidSaml"), - /** - * Represents the 'sProviderAction.spAlias' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SPALIAS("sProviderAction.invalidSPAlias"), - /** - * Represents the 'sProviderAction.spDomain' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SPDOMAIN("sProviderAction.invalidSPDomain"), - /** - * Represents the 'sProviderAction.spId' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SPID("sProviderAction.invalidSPId"), - /** - * Represents the 'sProviderAction.spQAA' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SPQAA("sProviderAction.invalidSPQAA"), - /** - * Represents the 'sProviderAction.spQAAId' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SPQAAID("sProviderAction.invalidSPQAAId"), - /** - * Represents the 'sProviderAction.spRedirect' constant error identifier. - */ - SPROVIDER_SELECTOR_INVALID_SPREDIRECT("sProviderAction.invalidSPRedirect"), - /** - * Represents the 'sProviderAction.invalidSPProviderName' constant error - * identifier. - */ - SPROVIDER_SELECTOR_INVALID_SP_PROVIDERNAME( - "sProviderAction.invalidSPProviderName"), - /** - * Represents the 'sProviderAction.spNotAllowed' constant error identifier. - */ - SPROVIDER_SELECTOR_SPNOTALLOWED("sProviderAction.spNotAllowed"), - - - /** - * Represents the 'internalError' constant error identifier. - */ - INTERNAL_ERROR("internalError"), - - /** - * Represents the 'colleagueRequest.attrNull' constant error identifier. - */ - COLLEAGUE_REQ_ATTR_NULL("colleagueRequest.attrNull"), - /** - * Represents the 'colleagueRequest.errorCreatingSAML' constant error - * identifier. - */ - COLLEAGUE_REQ_ERROR_CREATE_SAML("colleagueRequest.errorCreatingSAML"), - /** - * Represents the 'colleagueRequest.invalidCountryCode' constant error - * identifier. - */ - COLLEAGUE_REQ_INVALID_COUNTRYCODE("colleagueRequest.invalidCountryCode"), - /** - * Represents the 'colleagueRequest.invalidDestUrl' constant error identifier. - */ - COLLEAGUE_REQ_INVALID_DEST_URL("colleagueRequest.invalidDestUrl"), - /** - * Represents the 'colleagueRequest.invalidQaa' constant error identifier. - */ - COLLEAGUE_REQ_INVALID_QAA("colleagueRequest.invalidQaa"), - /** - * Represents the 'colleagueRequest.invalidRedirect' constant error - * identifier. - */ - COLLEAGUE_REQ_INVALID_REDIRECT("colleagueRequest.invalidRedirect"), - /** - * Represents the 'colleagueRequest.invalidSAML' constant error identifier. - */ - COLLEAGUE_REQ_INVALID_SAML("colleagueRequest.invalidSAML"), - - - /** - * Represents the 'cpepsRedirectUrl' constant error identifier. - */ - CPEPS_REDIRECT_URL("cpepsRedirectUrl"), - /** - * Represents the 'spepsRedirectUrl' constant error identifier. - */ - SPEPS_REDIRECT_URL("spepsRedirectUrl"), - /** - * Represents the 'sProviderAction.invCountry' constant error identifier. - */ - SP_ACTION_INV_COUNTRY("sProviderAction.invCountry"), - - /** - * Represents the 'providernameAlias.invalid' constant error identifier. - */ - PROVIDER_ALIAS_INVALID("providernameAlias.invalid"), - - - /** - * Represents the 'cPeps.attrNull' constant error identifier. - */ - CPEPS_ATTR_NULL("cPeps.attrNull"), - - /** - * Represents the 'colleagueResponse.invalidSAML' constant error identifier. - */ - COLLEAGUE_RESP_INVALID_SAML("colleagueResponse.invalidSAML"), - - /** - * Represents the 'citizenNoConsent.mandatory' constant error identifier. - */ - CITIZEN_NO_CONSENT_MANDATORY("citizenNoConsent.mandatory"), - /** - * Represents the 'citizenResponse.mandatory' constant error identifier. - */ - CITIZEN_RESPONSE_MANDATORY("citizenResponse.mandatory"), - /** - * Represents the 'attVerification.mandatory' constant error identifier. - */ - ATT_VERIFICATION_MANDATORY("attVerification.mandatory"), - /** - * Represents the 'attrValue.verification' constant error identifier. - */ - ATTR_VALUE_VERIFICATION("attrValue.verification"), - - /** - * Represents the 'audienceRestrictionError' constant error identifier. - */ - AUDIENCE_RESTRICTION("audienceRestrictionError"), - /** - * Represents the 'auRequestIdError' constant error identifier. - */ - AU_REQUEST_ID("auRequestIdError"), - /** - * Represents the 'domain' constant error identifier. - */ - DOMAIN("domain"), - /** - * Represents the 'hash.error' constant error identifier. - */ - HASH_ERROR("hash.error"), - /** - * Represents the 'invalidAttributeList' constant error identifier. - */ - INVALID_ATTRIBUTE_LIST("invalidAttributeList"), - /** - * Represents the 'invalidAttributeValue' constant error identifier. - */ - INVALID_ATTRIBUTE_VALUE("invalidAttributeValue"), - /** - * Represents the 'qaaLevel' constant error identifier. - */ - QAALEVEL("qaaLevel"), - /** - * Represents the 'requests' constant error identifier. - */ - REQUESTS("requests"), - /** - * Represents the 'SPSAMLRequest' constant error identifier. - */ - SP_SAML_REQUEST("SPSAMLRequest"), - /** - * Represents the 'spepsSAMLRequest' constant error identifier. - */ - SPEPS_SAML_REQUEST("spepsSAMLRequest"), - /** - * Represents the 'IdPSAMLResponse' constant error identifier. - */ - IDP_SAML_RESPONSE("IdPSAMLResponse"), - /** - * Represents the 'cpepsSAMLResponse' constant error identifier. - */ - CPEPS_SAML_RESPONSE("cpepsSAMLResponse"), - /** - * Represents the 'cpepsSAMLResponse' constant error identifier. - */ - SPEPS_SAML_RESPONSE("spepsSAMLResponse"), - /** - * Represents the 'session' constant error identifier. - */ - SESSION("session"), - /** - * Represents the 'invalid.session' constant error identifier. - */ - INVALID_SESSION("invalid.session"), - /** - * Represents the 'invalid.sessionId' constant error identifier. - */ - INVALID_SESSION_ID("invalid.sessionId"), - /** - * Represents the 'missing.sessionId' constant error identifier. - */ - MISSING_SESSION_ID("sessionError"), - /** - * Represents the 'AtPSAMLResponse' constant error identifier. - */ - ATP_SAML_RESPONSE("AtPSAMLResponse"); - - /** - * Represents the constant's value. - */ - private String error; - - /** - * Solo Constructor. - * - * @param nError The Constant error value. - */ - PEPSErrors(final String nError) { - this.error = nError; - } - - /** - * Construct the errorCode Constant value. - * - * @return The errorCode Constant. - */ - public String errorCode() { - return error + ".code"; - } - - /** - * Construct the errorCode Constant value with the given code text. - * - * @param text the code text to append to the constant. - * - * @return The errorCode Constant for the given code text. - */ - public String errorCode(final String text) { - return error + "." + text + ".code"; - } - - /** - * Construct the errorMessage constant value. - * - * @return The errorMessage constant. - */ - public String errorMessage() { - return error + ".message"; - } - - /** - * Construct the errorMessage Constant value with the given message text. - * - * @param text the message text to append to the constant. - * - * @return The errorMessage Constant for the given text. - */ - public String errorMessage(final String text) { - return error + "." + text + ".message"; - } - - /** - * Return the Constant Value. - * - * @return The constant value. - */ - public String toString() { - return error; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base deleted file mode 100644 index 37b204351..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSParameters.java.svn-base +++ /dev/null @@ -1,511 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * This enum class contains all the STORK PEPS, Commons and Specific Parameters. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.13 $, $Date: 2011-07-07 20:48:45 $ - */ -public enum PEPSParameters { - - /** - * Represents the 'apId' parameter constant. - */ - AP_ID("apId"), - /** - * Represents the 'apUrl' parameter constant. - */ - AP_URL("apUrl"), - /** - * Represents the 'ap.number' parameter constant. - */ - AP_NUMBER("ap.number"), - - /** - * Represents the 'assertionConsumerServiceURL' parameter constant. - */ - ASSERTION_CONSUMER_S_URL("assertionConsumerServiceURL"), - - /** - * Represents the 'auth' parameter constant. - */ - AUTHENTICATION("auth"), - - /** - * Represents the 'auth-on-behalf-of' parameter constant. - */ - AUTHENTICATION_ON_BEHALF_OF("auth-on-behalf-of"), - - /** - * Represents the 'attr' parameter constant. - */ - ATTRIBUTE("attr"), - /** - * Represents the 'attrName' parameter constant. - */ - ATTRIBUTE_NAME("attrName"), - /** - * Represents the 'attrStatus' parameter constant. - */ - ATTRIBUTE_STATUS("attrStatus"), - /** - * Represents the 'attrType' parameter constant. - */ - ATTRIBUTE_TYPE("attrType"), - /** - * Represents the 'attrValue' parameter constant. - */ - ATTRIBUTE_VALUE("attrValue"), - /** - * Represents the 'attrList' parameter constant. - */ - ATTRIBUTE_LIST("attrList"), - /** - * Represents the 'attrTuple' parameter constant. - */ - ATTRIBUTE_TUPLE("attrTuple"), - /** - * Represents the 'attribute-missing' parameter constant. - */ - ATTRIBUTE_MISSING("attribute-missing"), - /** - * Represents the 'attributesNotAllowed' parameter constant. - */ - ATTRIBUTES_NOT_ALLOWED("attributesNotAllowed"), - /** - * Represents the 'authnRequest' parameter constant. - */ - AUTH_REQUEST("authnRequest"), - - /** - * Represents the 'attrValue.number' parameter constant. - */ - ATTR_VALUE_NUMBER("attrValue.number"), - - /** - * Represents the 'derivation.date.format' parameter constant. - */ - DERIVATION_DATE_FORMAT("derivation.date.format"), - /** - * Represents the 'deriveAttr.number' parameter constant. - */ - DERIVE_ATTRIBUTE_NUMBER("deriveAttr.number"), - - /** - * Represents the complex attributes parameter constant. - */ - COMPLEX_ADDRESS_VALUE("canonicalResidenceAddress"), - COMPLEX_NEWATTRIBUTE_VALUE("newAttribute2"), - COMPLEX_HASDEGREE_VALUE("hasDegree"), - COMPLEX_MANDATECONTENT_VALUE("mandateContent"), - /** - * Represents the 'consent-type' parameter constant. - */ - CONSENT_TYPE("consent-type"), - /** - * Represents the 'consent-value' parameter constant. - */ - CONSENT_VALUE("consent-value"), - /** - * Represents the 'country' parameter constant. - */ - COUNTRY("country"), - /** - * Represents the 'countryOrigin' parameter constant. - */ - COUNTRY_ORIGIN("countryOrigin"), - - /** - * Represents the 'cpepsURL' parameter constant. - */ - CPEPS_URL("cpepsURL"), - /** - * Represents the 'callback' parameter constant. - */ - CPEPS_CALLBACK("callback"), - /** - * Represents the 'peps.specificidpredirect.url' parameter constant. - */ - CPEPS_IDP_CALLBACK_VALUE("peps.specificidpredirect.url"), - /** - * Represents the 'peps.specificapredirect.url' parameter constant. - */ - CPEPS_AP_CALLBACK_VALUE("peps.specificapredirect.url"), - - /** - * Represents the 'errorCode' parameter constant. - */ - ERROR_CODE("errorCode"), - /** - * Represents the 'subCode' parameter constant. - */ - ERROR_SUBCODE("subCode"), - /** - * Represents the 'errorMessage' parameter constant. - */ - ERROR_MESSAGE("errorMessage"), - /** - * Represents the 'errorRedirectUrl' parameter constant. - */ - ERROR_REDIRECT_URL("errorRedirectUrl"), - - /** - * errorRedirectUrl Represents the 'external-authentication' parameter - * constant. - */ - EXTERNAL_AUTH("external-authentication"), - /** - * Represents the 'external-ap' parameter constant. - */ - EXTERNAL_AP("external-ap"), - /** - * Represents the 'external-sig-module' parameter constant. - */ - EXT_SIG_CREATOR_MOD("external-sig-module"), - - /** - * Represents the 'http-x-forwarded-for' parameter constant. - */ - HTTP_X_FORWARDED_FOR("http-x-forwarded-for"), - - /** - * Represents the 'idp.url' parameter constant. - */ - IDP_URL("idp.url"), - /** - * Represents the 'idpAUB.url' parameter constant. - */ - IDPAUB_URL("idpAUB.url"), - /** - * Represents the 'internal-authentication' parameter constant. - */ - INTERNAL_AUTH("internal-authentication"), - /** - * Represents the 'internal-ap' parameter constant. - */ - INTERNAL_AP("internal-ap"), - - /** - * Represents the 'samlIssuer' parameter constant. - */ - ISSUER("samlIssuer"), - /** - * Represents the 'samlIssuer.idp' parameter constant. - */ - ISSUER_IDP("samlIssuer.idp"), - /** - * Represents the 'samlIssuer.atp' parameter constant. - */ - ISSUER_ATP("samlIssuer.atp"), - - /** - * Represents the 'mandatory' parameter constant. - */ - MANDATORY("mandatory"), - /** - * Represents the 'mandatoryAttributeMissing' parameter constant. - */ - MANDATORY_ATTR_MISSING("mandatoryAttributeMissing"), - /** - * Represents the 'mandatoryConsentAttrMissing' parameter constant. - */ - MANDATORY_CONSENT_MISSING("mandatoryConsentAttrMissing"), - /** - * Represents the 'optional' parameter constant. - */ - OPTIONAL("optional"), - - /** - * Represents the 'no-consent-type' parameter constant. - */ - NO_CONSENT_TYPE("no-consent-type"), - /** - * Represents the 'no-consent-value' parameter constant. - */ - NO_CONSENT_VALUE("no-consent-value"), - - /** - * Represents the 'provider.name' parameter constant. - */ - PROVIDER_NAME_VALUE("providerName"), - /** - * Represents the 'cpeps.askconsent' parameter constant. - */ - PEPS_ASK_CONSENT("cpeps.askconsent"), - /** - * Represents the 'cpeps.askconsentvalue' parameter constant. - */ - PEPS_ASK_CONSENT_VALUE("cpeps.askconsentvalue"), - /** - * Represents the 'pepsAuth' parameter constant. - */ - PEPS_AUTH_CONSENT("pepsAuth"), - /** - * Represents the 'validation.bypass' parameter constant. - */ - PEPS_BYPASS("validation.bypass"), - /** - * Represents the 'cpeps.number' parameter constant. - */ - PEPS_NUMBER("cpeps.number"), - /** - * Represents the 'cpeps.specificapredirect.url' parameter constant. - */ - PEPS_SPECIFIC_URL("cpeps.specificapredirect.url"), - - /** - * Represents the 'qaaLevel' parameter constant. - */ - QAALEVEL("qaaLevel"), - - /** - * Represents the 'speps.redirectUrl' parameter constant. - */ - SPEPS_REDIRECT_URL("speps.redirectUrl"), - - /** - * Represents the 'sp.redirectUrl' parameter constant. - */ - SP_REDIRECT_URL("sp.redirectUrl"), - /** - * Represents the 'cpeps.redirectUrl' parameter constant. - */ - CPEPS_REDIRECT_URL("cpeps.redirectUrl"), - /** - * Represents the 'RelayState' parameter constant. - */ - RELAY_STATE("RelayState"), - /** - * Represents the 'remoteAddr' parameter constant. - */ - REMOTE_ADDR("remoteAddr"), - /** - * Represents the 'remoteUser' parameter constant. - */ - REMOTE_USER("remoteUser"), - - /** - * Represents the 'SAMLRequest' parameter constant. - */ - SAML_REQUEST("SAMLRequest"), - /** - * Represents the 'SAMLResponse' parameter constant. - */ - SAML_RESPONSE("SAMLResponse"), - /** - * Represents the 'SAMLFail' parameter constant. - */ - SAML_TOKEN_FAIL("SAMLFail"), - /** - * Represents the 'TokenId' parameter constant. - */ - SAML_TOKEN_ID("TokenId"), - /** - * Represents the 'inResponseTo' parameter constant. - */ - SAML_IN_RESPONSE_TO("inResponseTo"), - /** - * Represents the 'inResponseTo.idp' parameter constant. - */ - SAML_IN_RESPONSE_TO_IDP("inResponseTo.idp"), - /** - * Represents the 'inResponseTo.atp' parameter constant. - */ - SAML_IN_RESPONSE_TO_ATP("inResponseTo.atp"), - /** - * Represents the 'SignatureResponse' parameter constant. - */ - SIGNATURE_RESPONSE("SignatureResponse"), - - /** - * Represents the 'cPepsSession' parameter constant. - */ - SESSION_ID_URL("cPepsSession"), - /** - * Represents the 'spId' parameter constant. - */ - SP_ID("spId"), - /** - * Represents the 'spQaaLevel' parameter constant. - */ - SP_QAALEVEL("spQaaLevel"), - /** - * Represents the 'spUrl' parameter constant. - */ - SP_URL("spUrl"), - - /** - * Represents the 'allow.derivation.all' parameter constant. - */ - SPECIFIC_ALLOW_DERIVATION_ALL("allow.derivation.all"), - /** - * Represents the ''allow.unknowns parameter constant. - */ - SPECIFIC_ALLOW_UNKNOWNS("allow.unknowns"), - /** - * Represents the 'derivation.date.separator' parameter constant. - */ - SPECIFIC_DERIVATION_DATE_SEP("derivation.date.separator"), - /** - * Represents the 'derivation.month.position' parameter constant. - */ - SPECIFIC_DERIVATION_MONTH_POS("derivation.month.position"), - /** - * Represents the 'derivation.day.position' parameter constant. - */ - SPECIFIC_DERIVATION_DAY_POS("derivation.day.position"), - /** - * Represents the 'derivation.year.position' parameter constant. - */ - SPECIFIC_DERIVATION_YEAR_POS("derivation.year.position"), - - /** - * sp.authorized.parameters Represents the '' parameter constant. - */ - SPEPS_AUTHORIZED("sp.authorized.parameters"), - - /** - * Represents the 'spSector' constant value. - */ - SPSECTOR("spSector"), - /** - * Represents the 'spApplication' constant value. - */ - SPAPPLICATION("spApplication"), - /** - * Represents the 'spCountry' constant value. - */ - SPCOUNTRY("spCountry"), - /** - * Represents the 'spInstitution' constant value. - */ - SPINSTITUTION("spInstitution"), - /** - * Represents the 'storkAttribute.number' parameter constant. - */ - STORK_ATTRIBUTE_NUMBER("storkAttribute.number"), - /** - * Represents the 'storkAttributeValue.number' parameter constant. - */ - STORK_ATTRIBUTE_VALUE_NUMBER("storkAttributeValue.number"), - - /** - * Represents the 'username' parameter constant. - */ - USERNAME("username"), - - /** - * Represents the 'tooManyParameters' parameter constant. - */ - TOO_MANY_PARAMETERS("tooManyParameters"), - /** - * Represents the 'validation.active' parameter constant. - */ - VALIDATION_ACTIVE("validation.active"), - - /** - * Represents the 'x-forwarded-for' parameter constant. - */ - X_FORWARDED_FOR("x-forwarded-for"), - /** - * Represents the 'x-forwarded-host' parameter constant. - */ - X_FORWARDED_HOST("x-forwarded-host"), - /** - * Represents the 'XMLResponse' parameter constant. - */ - XML_RESPONSE("XMLResponse"), - - /** - * Represents the 'ap-cpeps.number' parameter constant. - */ - AP_PEPS_NUMBER("ap-cpeps.number"), - - /** - * Represents the 'atp.number' parameter constant. - */ - ATTRIBUTE_PROVIDER_NUMBER("atp.number"), - - /** - * Represents the 'apLinker' parameter constant. - */ - AP_LINKER("apLinker"), - - /** - * Represents the 'NOSEL' parameter constant (no attribute provider selected). - */ - AP_NO_SELECTION("NOSEL"), - - /** - * Represents the 'OCSEL' parameter constant (attribute provider in another country). - */ - AP_OTHER_COUNTRY("OCSEL"), - - /** - * Represents the '_provider' suffix parameter constant. - */ - AP_PROVIDER_SELECT_SUFFIX("_provider"), - - /** - * Represents the '_country' suffix parameter constant. - */ - AP_COUNTRY_SELECT_SUFFIX("_country"), - - /** - * Represents the 'next-ap' parameter constant. - */ - NEXT_AP("next-ap"), - - /** - * Represents the 'next-apeps' parameter constant. - */ - NEXT_APEPS("next-apeps"), - - /** - * Represents the 'attr-filter.number' parameter constant. - */ - ATTRIBUTES_FILTER_NUMBER("attr-filter.number"), - - /** - * Represents the 'atp.url' parameter constant. - */ - ATP_URL("atp.url"); - - /** - * Represents the constant's value. - */ - private String value; - - /** - * Solo Constructor. - * - * @param nValue The Constant value. - */ - PEPSParameters(final String nValue) { - this.value = nValue; - } - - /** - * Return the Constant Value. - * - * @return The constant value. - */ - public String toString() { - return value; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base deleted file mode 100644 index ae1f203f5..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSUtil.java.svn-base +++ /dev/null @@ -1,353 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.io.UnsupportedEncodingException; -import java.util.Properties; - -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.bouncycastle.crypto.Digest; -import org.bouncycastle.util.encoders.Base64; - -import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; -import eu.stork.peps.auth.commons.exceptions.InvalidParameterPEPSException; - -/** - * This class holds static helper methods. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.75 $, $Date: 2010-11-23 00:05:35 $ - */ -public final class PEPSUtil { - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(PEPSUtil.class.getName()); - - /** - * Configurations object. - */ - private static Properties configs; - - /** - * Max prefix. - */ - private static final String MAX_PARAM_PREFIX = "max."; - - /** - * Code prefix to get error code. - */ - private static final String CODE_PARAM_SUFFIX = ".code"; - - /** - * param's size prefix to get max param size. - */ - private static final String MAX_PARAM_SUFFIX = ".size"; - - /** - * Message prefix to get error message. - */ - private static final String MSG_PARAM_SUFFIX = ".message"; - - /** - * Private constructor. Prevents the class from being instantiated. - */ - private PEPSUtil() { - // empty constructor - } - - /** - * Creates a single instance of this class and sets the properties. - * - * @param nConfigs The set of available configurations. - * - * @return The created PEPSUtil's class. - */ - public static PEPSUtil createInstance(final Properties nConfigs) { - if (nConfigs != null) { - PEPSUtil.configs = nConfigs; - } - return new PEPSUtil(); - } - - /** - * Getter for the Properties. - * - * @return configs The properties value. - */ - public Properties getConfigs() { - return configs; - } - - /** - * Setter for the Properties. - * - * @param nConfigs The new properties value. - */ - public static void setConfigs(final Properties nConfigs) { - if (nConfigs != null) { - PEPSUtil.configs = nConfigs; - } - } - - /** - * Returns the identifier of some configuration given a set of configurations - * and the corresponding configuration key. - * - * @param configKey The key that IDs some configuration. - * - * @return The configuration String value. - */ - public static String getConfig(final String configKey) { - return configs.getProperty(configKey); - } - - /** - * Validates the input paramValue identified by the paramName. - * - * @param paramName The name of the parameter to validate. - * @param paramValue The value of the parameter to validate. - * - * @return true if the parameter is valid. - */ - public static boolean isValidParameter(final String paramName, - final String paramValue) { - - final String validationParam = - PEPSUtil.getConfig(PEPSParameters.VALIDATION_ACTIVE.toString()); - boolean retVal = true; - - final String paramConf = MAX_PARAM_PREFIX + paramName + MAX_PARAM_SUFFIX; - - if (PEPSValues.TRUE.toString().equals(validationParam)) { - final String paramSizeStr = PEPSUtil.getConfig(paramConf); - // Checking if the parameter size exists and if it's numeric - if (StringUtils.isNumeric(paramSizeStr)) { - final int maxParamSize = Integer.valueOf(paramSizeStr); - if (StringUtils.isEmpty(paramValue) - || (paramValue.length() > maxParamSize)) { - retVal = false; - LOG.warn("Invalid parameter [" + paramName + "] value " + paramValue); - } - } else { - retVal = false; - LOG.error("Missing " + paramConf - + " configuration in the pepsUtils.properties configuration file"); - } - } - return retVal; - } - - /** - * Validates the Parameter and throws an exception if an error occurs. Throws - * an InvalidParameterPEPSException runtime exception if the parameter is - * invalid. - * - * @param className The Class Name that invoked the method. - * @param paramName The name of the parameter to validate. - * @param paramValue The value of the parameter to validate. - */ - public static void validateParameter(final String className, - final String paramName, final Object paramValue) { - - if (paramValue == null) { - PEPSUtil.validateParameter(className, paramName, ""); - } else { - PEPSUtil.validateParameter(className, paramName, paramValue.toString()); - } - } - - /** - * Validates the Parameters and throws an exception if an error occurs. - * - * @param className The Class Name that invoked the method. - * @param paramName The name of the parameter to validate. - * @param paramValue The value of the parameter to validate. - */ - public static void validateParameter(final String className, - final String paramName, final String paramValue) { - - PEPSUtil.validateParameter(className, paramName, paramValue, - PEPSUtil.getErrorCode(paramName), PEPSUtil.getErrorMessage(paramName)); - } - - /** - * Validates the Parameters and throws an exception if an error occurs. - * - * @param className The Class Name that invoked the method. - * @param paramName The name of the parameter to validate. - * @param paramValue The value of the parameter to validate. - * @param error The PEPSError to get error code and messages from configs. - */ - public static void validateParameter(final String className, - final String paramName, final String paramValue, final PEPSErrors error) { - - PEPSUtil.validateParameter(className, paramName, paramValue, - PEPSUtil.getConfig(error.errorCode()), - PEPSUtil.getConfig(error.errorMessage())); - } - - /** - * Validates the HTTP Parameter and throws an exception if an error occurs. - * Throws an InvalidParameterPEPSException runtime exception if the parameter - * is invalid. - * - * @param className The Class Name that invoked the method. - * @param paramName The name of the parameter to validate. - * @param paramValue The value of the parameter to validate. - * @param errorCode The error code to include on the exception. - * @param errorMessage The error message to include on the exception. - */ - public static void validateParameter(final String className, - final String paramName, final String paramValue, final String errorCode, - final String errorMessage) { - - if (!isValidParameter(paramName, paramValue)) { - LOG.warn("Invalid parameter [" + paramName + "] value found at " - + className); - throw new InvalidParameterPEPSException(errorCode, errorMessage); - } - } - - /** - * Getter for the error code of some given error related to the input param. - * - * @param paramName The name of the parameter associated with the error. - * - * @return The code of the error. - */ - private static String getErrorCode(final String paramName) { - return getConfig(paramName + CODE_PARAM_SUFFIX); - } - - /** - * Getter for the error message of some given error related to the input - * parameter. - * - * @param paramName The name of the parameter associated with the message. - * - * @return The message for the error. - */ - private static String getErrorMessage(final String paramName) { - return getConfig(paramName + MSG_PARAM_SUFFIX); - } - - /** - * {@link Base64} encodes the input samlToken parameter. - * - * @param samlToken the SAML Token to be encoded. - * - * @return The Base64 String representing the samlToken. - * - * @see Base64#encode - */ - public static String encodeSAMLToken(final byte[] samlToken) { - try { - return new String(Base64.encode(samlToken), "UTF8"); - } catch (UnsupportedEncodingException e) { - LOG.error(PEPSErrors.INTERNAL_ERROR.errorMessage(), e); - return null; - } - } - - /** - * Decodes the {@link Base64} String input parameter representing a samlToken. - * - * @param samlToken the SAML Token to be decoded. - * - * @return The samlToken decoded bytes. - * - * @see Base64#decode - */ - public static byte[] decodeSAMLToken(final String samlToken) { - return Base64.decode(samlToken); - } - - /** - * Hashes a SAML token. Throws an InternalErrorPEPSException runtime exception - * if the Cryptographic Engine fails. - * - * @param samlToken the SAML Token to be hashed. - * - * @return byte[] with the hashed SAML Token. - */ - public static byte[] hashPersonalToken(final byte[] samlToken) { - try { - final String className = - PEPSUtil.getConfig(PEPSValues.HASH_DIGEST_CLASS.toString()); - - final Digest digest = - (Digest) Class.forName(className).getConstructor() - .newInstance((Object[]) null); - digest.update(samlToken, 0, samlToken.length); - - final int retLength = digest.getDigestSize(); - final byte[] ret = new byte[retLength]; - - digest.doFinal(ret, 0); - return ret; - - } catch (final Exception e) { - // For all those exceptions that could be thrown, we always log it and - // thrown an InternalErrorPEPSException. - LOG.error(PEPSErrors.HASH_ERROR.errorMessage(), e); - throw new InternalErrorPEPSException( - PEPSUtil.getConfig(PEPSErrors.HASH_ERROR.errorCode()), - PEPSUtil.getConfig(PEPSErrors.HASH_ERROR.errorMessage()), e); - } - } - - /** - * Gets the Stork error code in the error message if exists! - * - * @param errorMessage The message to get the error code if exists; - * - * @return the error code if exists. Returns null otherwise. - */ - public static String getStorkErrorCode(final String errorMessage) { - if (StringUtils.isNotBlank(errorMessage) - && errorMessage.indexOf(PEPSValues.ERROR_MESSAGE_SEP.toString()) >= 0) { - final String[] msgSplitted = - errorMessage.split(PEPSValues.ERROR_MESSAGE_SEP.toString()); - if (msgSplitted.length == 2 && StringUtils.isNumeric(msgSplitted[0])) { - return msgSplitted[0]; - } - } - return null; - } - - /** - * Gets the Stork error message in the saml message if exists! - * - * @param errorMessage The message to get in the saml message if exists; - * - * @return the error message if exists. Returns the original message - * otherwise. - */ - public static String getStorkErrorMessage(final String errorMessage) { - if (StringUtils.isNotBlank(errorMessage) - && errorMessage.indexOf(PEPSValues.ERROR_MESSAGE_SEP.toString()) >= 0) { - final String[] msgSplitted = - errorMessage.split(PEPSValues.ERROR_MESSAGE_SEP.toString()); - if (msgSplitted.length == 2 && StringUtils.isNumeric(msgSplitted[0])) { - return msgSplitted[1]; - } - } - return errorMessage; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base deleted file mode 100644 index 568c25053..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PEPSValues.java.svn-base +++ /dev/null @@ -1,325 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * This enum class contains all the value constants. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.17 $, $Date: 2011-07-07 20:48:45 $ - */ -public enum PEPSValues { - - /** - * Represents the 'all' constant value. - */ - ALL("all"), - /** - * Represents the 'none' constant value. - */ - NONE("none"), - /** - * Represents the 'true' constant value. - */ - TRUE("true"), - /** - * Represents the 'false' constant value. - */ - FALSE("false"), - /** - * Represents the empty string constant value. - */ - EMPTY_STRING(""), - - /** - * Represents the ',' separator constant value. - */ - ATTRIBUTE_VALUE_SEP(","), - /** - * Represents the ';' separator constant value. - */ - ATTRIBUTE_SEP(";"), - /** - * Represents the ':' separator constant value. - */ - ATTRIBUTE_TUPLE_SEP(":"), - /** - * Represents the '/' separator constant value. - */ - EID_SEPARATOR("/"), - /** - * Represents the ' - ' separator constant value. - */ - ERROR_MESSAGE_SEP(" - "), - /** - * Represents the '#' parameter constant value. - */ - LOGGER_SEP("#"), - /** - * Represents the 'NOT_AVAILABLE' parameter constant value. - */ - NOT_AVAILABLE("NotAvailable"), - /** - * Represents the ';' parameter constant value. - */ - SPEPS_AUTHORIZED_SEP(";"), - - /** - * Represents the 'ap' constant value. - */ - AP("ap"), - /** - * Represents the 'C-PEPS' constant value. - */ - CPEPS("C-PEPS"), - /** - * Represents the 'cpeps' constant value. - */ - CPEPS_PREFIX("cpeps"), - /** - * Represents the 'peps' constant value. - */ - PEPS("peps"), - /** - * Represents the '-PEPS' constant value. - */ - PEPS_SUFFIX("-PEPS"), - /** - * Represents the 'SP' constant value. - */ - SP("SP"), - /** - * Represents the 'S-PEPS' constant value. - */ - SPEPS("S-PEPS"), - /** - * Represents the 'speps' constant value. - */ - SPEPS_PREFIX("speps"), - /** - * Represents the 'sp.default.parameters' constant value. - */ - DEFAULT("sp.default.parameters"), - /** - * Represents the default saml id constant value. - */ - DEFAULT_SAML_ID("1"), - /** - * Represents the 'hashDigest.className' constant value. - */ - HASH_DIGEST_CLASS("hashDigest.className"), - - /** - * Represents the 'eu.stork.communication.requests' constant value. - */ - STORK_PACKAGE_REQUEST_LOGGER_VALUE("eu.stork.communication.requests"), - /** - * Represents the 'eu.stork.communication.responses' constant value. - */ - STORK_PACKAGE_RESPONSE_LOGGER_VALUE("eu.stork.communication.responses"), - - /** - * Represents the 'S-PEPS receives request from SP' constant value. - */ - SP_REQUEST("S-PEPS receives request from SP"), - /** - * Represents the 'Get Citizen Consent' constant value. - */ - CITIZEN_CONSENT_LOG("Get Citizen Consent"), - /** - * Represents the 'C-PEPS receives request from S-PEPS' constant value. - */ - CPEPS_REQUEST("C-PEPS receives request from S-PEPS"), - /** - * Represents the 'C-PEPS generates response to S-PEPS' constant value. - */ - CPEPS_RESPONSE("C-PEPS generates response to S-PEPS"), - /** - * Represents the 'S-PEPS generates request to C-PEPS' constant value. - */ - SPEPS_REQUEST("S-PEPS generates request to C-PEPS"), - /** - * Represents the 'S-PEPS receives response from C-PEPS' constant value. - */ - SPEPS_RESPONSE("S-PEPS receives response from C-PEPS"), - /** - * Represents the 'S-PEPS generates response to SP' constant value. - */ - SP_RESPONSE("S-PEPS generates response to SP"), - /** - * Represents the 'Success' constant value. - */ - SUCCESS("Success"), - /** - * Represents the December's month number constant value. - */ - LAST_MONTH("12"), - /** - * Represents the yyyyMM constant value. - */ - NO_DAY_DATE_FORMAT("yyyyMM"), - - /** - * Represents the 'attrValue' constant value. - */ - ATTRIBUTE("attrValue"), - /** - * Represents the 'derivedAttr' constant value. - */ - DERIVE_ATTRIBUTE("deriveAttr"), - /** - * Represents the 'storkAttribute' constant value. - */ - STORK_ATTRIBUTE("storkAttribute"), - - /** - * Represents the 'properties' constant value. - */ - PROPERTIES("properties"), - /** - * Represents the 'referer' constant value. - */ - REFERER("referer"), - /** - * Represents the 'host' constant value. - */ - HOST("host"), - /** - * Represents the 'spid' constant value. - */ - SPID("spid"), - /** - * Represents the 'domain' constant value. - */ - DOMAIN("domain"), - /** - * Represents the '.validation' constant value. - */ - VALIDATION_SUFFIX(".validation"), - /** - * Represents the 'jsessionid' constant value. - */ - EQUAL("="), - /** - * Represents the 'HttpOnly' constant value. - */ - HTTP_ONLY("HttpOnly"), - /** - * Represents the 'SET-COOKIE' constant value. - */ - JSSESSION("JSESSIONID"), - /** - * Represents the '=' constant value. - */ - SETCOOKIE("SET-COOKIE"), - /** - * Represents the ';' constant value. - */ - SEMICOLON(";"), - /** - * Represents the ' ' constant value. - */ - SPACE(" "), - /** - * Represents the 'atp' constant value. - */ - APROVIDER_PREFIX("atp"), - /** - * Represents the 'ap-cpeps' constant value. - */ - AP_CPEPS_PREFIX("ap-cpeps"), - /** - * Represents the 'attr-filter' constant value. - */ - AP_ATTRFILTER_PREFIX("attr-filter"); - - /** - * Represents the constant's value. - */ - private String value; - - /** - * Solo Constructor. - * - * @param val The Constant value. - */ - PEPSValues(final String val) { - - this.value = val; - } - - /** - * Return the Constant Value. - * - * @return The constant value. - */ - public String toString() { - - return value; - } - - /** - * Construct the return value with the following structure - * CONSTANT_VALUE+index+".id". - * - * @param index the number. - * - * @return The concatenated String value. - */ - public String index(final int index) { - - return value + index + ".id"; - } - - /** - * Construct the return value with the following structure - * CONSTANT_VALUE+index+".value". - * - * @param index the number. - * - * @return The concatenated string value. - */ - public String value(final int index) { - - return value + index + ".value"; - } - - /** - * Construct the return value with the following structure - * CONSTANT_VALUE+index+".name". - * - * @param index the number. - * - * @return The concatenated String value. - */ - public String name(final int index) { - - return value + index + ".name"; - } - - /** - * Construct the return value with the following structure - * CONSTANT_VALUE+index+".url". - * - * @param index the number. - * - * @return The concatenated String value. - */ - public String url(final int index) { - - return value + index + ".url"; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base deleted file mode 100644 index bb9b3b694..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttribute.java.svn-base +++ /dev/null @@ -1,323 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.apache.log4j.Logger; - -import eu.stork.peps.auth.commons.exceptions.InternalErrorPEPSException; - -/** - * This class is a bean used to store the information relative to the - * PersonalAttribute. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.22 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class PersonalAttribute implements Serializable, Cloneable { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 2612951678412632174L; - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(PersonalAttribute.class - .getName()); - - /** - * Name of the personal attribute. - */ - private String name; - - /** - * Values of the personal attribute. - */ - private List value = new ArrayList(); - - /** - * Complex values of the personal attribute. - */ - private Map complexValue = new HashMap(); - - /** - * Is the personal attribute mandatory? - */ - private transient boolean required; - - /** - * Returned status of the attribute from the IdP. - */ - private String status; - - /** - * Name of the personal attribute. - */ - private String friendlyName; - - /** - * Empty Constructor. - */ - public PersonalAttribute() { - super(); - } - - /** - * PersonalAttribute Constructor for complex values. - * - * @param attrName The attribute name. - * @param attrIsRequired The attribute type value. - * @param attrComplexValue The attribute's value. - * @param attrStatus The attribute's status value. - */ - public PersonalAttribute(final String attrName, final boolean attrIsRequired, - final List attrComplexValue, final String attrStatus) { - this.setName(attrName); - this.setIsRequired(attrIsRequired); - this.setValue(attrComplexValue); - this.setStatus(attrStatus); - } - - /** - * PersonalAttribute Constructor for complex values. - * - * @param attrName The attribute name. - * @param attrIsRequired The attribute type value. - * @param attrComplexValue The attribute's complex value. - * @param attrStatus The attribute's status value. - */ - public PersonalAttribute(final String attrName, final boolean attrIsRequired, - final Map attrComplexValue, final String attrStatus) { - this.setName(attrName); - this.setIsRequired(attrIsRequired); - this.setComplexValue(attrComplexValue); - this.setStatus(attrStatus); - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public Object clone() { - - try { - final PersonalAttribute personalAttr = (PersonalAttribute) super.clone(); - personalAttr.setIsRequired(this.isRequired()); - personalAttr.setName(this.getName()); - personalAttr.setStatus(this.getStatus()); - if (!isEmptyValue()) { - final List val = - (List) ((ArrayList) this.getValue()).clone(); - personalAttr.setValue(val); - } - if (!isEmptyComplexValue()) { - final Map complexVal = - (Map) ((HashMap) this - .getComplexValue()).clone(); - personalAttr.setComplexValue(complexVal); - } - return personalAttr; - } catch (final CloneNotSupportedException e) { - // assert false; - LOG.trace("Nothing to do."); - throw new InternalErrorPEPSException( - PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorCode()), - PEPSUtil.getConfig(PEPSErrors.INTERNAL_ERROR.errorMessage()), e); - } - } - - /** - * Getter for the required value. - * - * @return The required value. - */ - public boolean isRequired() { - return required; - } - - /** - * Setter for the required value. - * - * @param attrIsRequired this attribute? - */ - public void setIsRequired(final boolean attrIsRequired) { - this.required = attrIsRequired; - } - - /** - * Getter for the name value. - * - * @return The name value. - */ - public String getName() { - return name; - } - - /** - * Setter for the name value. - * - * @param attrName The personal attribute name. - */ - public void setName(final String attrName) { - this.name = attrName; - } - - /** - * Getter for the value. - * - * @return The list of values. - */ - public List getValue() { - return value; - } - - /** - * Setter for the list of values. - * - * @param attrValue The personal attribute value. - */ - public void setValue(final List attrValue) { - if (attrValue != null) { - this.value = attrValue; - } - } - - /** - * Getter for the status. - * - * @return The status value. - */ - public String getStatus() { - return status; - } - - /** - * Setter for the status value. - * - * @param attrStatus The personal attribute status. - */ - public void setStatus(final String attrStatus) { - this.status = attrStatus; - } - - /** - * Getter for the complex value. - * - * @return The complex value. - */ - public Map getComplexValue() { - return complexValue; - } - - /** - * Setter for the complex value. - * - * @param complexVal The personal attribute Complex value. - */ - public void setComplexValue(final Map complexVal) { - if (complexVal != null) { - this.complexValue = complexVal; - } - } - - /** - * Getter for the personal's friendly name. - * - * @return The personal's friendly name value. - */ - public String getFriendlyName() { - return friendlyName; - } - - /** - * Setter for the personal's friendly name. - * - * @param fName The personal's friendly name. - */ - public void setFriendlyName(final String fName) { - this.friendlyName = fName; - } - - /** - * Return true the value is empty. - * - * @return True if the value is empty "[]"; - */ - public boolean isEmptyValue() { - return value.isEmpty() || (value.size() == 1 && value.get(0).length() == 0); - } - - /** - * Returns true if the Complex Value is empty. - * - * @return True if the Complex Value is empty; - */ - public boolean isEmptyComplexValue() { - return complexValue.isEmpty(); - } - - /** - * Returns true if the Status is empty. - * - * @return True if the Status is empty; - */ - public boolean isEmptyStatus() { - return (status == null || status.length() == 0); - } - - /** - * Prints the PersonalAttribute in the following format. - * name:required:[v,a,l,u,e,s]|[v=a,l=u,e=s]:status; - * - * @return The PersonalAttribute as a string. - */ - public String toString() { - final StringBuilder strBuild = new StringBuilder(); - - AttributeUtil.appendIfNotNull(strBuild, getName()); - strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); - AttributeUtil.appendIfNotNull(strBuild, String.valueOf(isRequired())); - strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); - strBuild.append('['); - - if (isEmptyValue()) { - if (!isEmptyComplexValue()) { - AttributeUtil.appendIfNotNull(strBuild, AttributeUtil.mapToString( - getComplexValue(), PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); - } - } else { - AttributeUtil.appendIfNotNull( - strBuild, - AttributeUtil.listToString(getValue(), - PEPSValues.ATTRIBUTE_VALUE_SEP.toString())); - } - - strBuild.append(']'); - strBuild.append(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString()); - AttributeUtil.appendIfNotNull(strBuild, getStatus()); - strBuild.append(PEPSValues.ATTRIBUTE_SEP.toString()); - - return strBuild.toString(); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base deleted file mode 100644 index d33ccfe18..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/PersonalAttributeList.java.svn-base +++ /dev/null @@ -1,305 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.StringTokenizer; - -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; - -/** - * This class is a bean used to store the information relative to the - * PersonalAttributeList. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.27 $, $Date: 2010-11-18 22:54:56 $ - * - * @see PersonalAttribute - */ -@SuppressWarnings("PMD") -public final class PersonalAttributeList extends - HashMap implements IPersonalAttributeList{ - - /** - * Logger object. - */ - private static final Logger LOG = Logger - .getLogger(PersonalAttributeList.class.getName()); - - /** - * Serial id. - */ - private static final long serialVersionUID = 7375127363889975062L; - - /** - * Hash with the latest fetched attribute name alias. - */ - private final transient Map latestAttrAlias = - new HashMap(); - - /** - * Hash with mapping number of alias or the attribute name. - */ - private final transient Map attrAliasNumber = - new HashMap(); - - /** - * Default constructor. - */ - public PersonalAttributeList() { - // The best practices recommend to call the super constructor. - super(); - } - - /** - * Constructor with initial capacity for the PersonalAttributeList size. - * - * @param capacity The initial capacity for the PersonalAttributeList. - */ - public PersonalAttributeList(final int capacity) { - super(capacity); - } - - /** - * {@inheritDoc} - */ - public Iterator iterator() { - return this.values().iterator(); - } - - /** - * {@inheritDoc} - */ - public PersonalAttribute get(final Object key) { - String attrName = (String) key; - - if (this.latestAttrAlias.containsKey(key)) { - attrName = attrName + this.latestAttrAlias.get(key); - } else { - if (this.attrAliasNumber.containsKey(key)) { - this.latestAttrAlias.put(attrName, this.attrAliasNumber.get(key)); - } - } - return super.get(attrName); - } - - /** - * {@inheritDoc} - */ - public void add(final PersonalAttribute value) { - if (value != null) { - this.put(value.getName(), value); - } - } - - /** - * {@inheritDoc} - */ - public PersonalAttribute put(final String key, final PersonalAttribute val) { - if (StringUtils.isNotEmpty(key) && val != null) { - // Validate if attribute name already exists! - String attrAlias = key; - if (this.containsKey(key)) { - if (!val.isEmptyValue() && StringUtils.isNumeric(val.getValue().get(0))) { - final String attrValue = val.getValue().get(0); - attrAlias = key + attrValue; - this.attrAliasNumber.put(key, Integer.valueOf(attrValue)); - } else { - final PersonalAttribute attr = super.get(key); - if (!attr.isEmptyValue() - && StringUtils.isNumeric(attr.getValue().get(0))) { - attrAlias = key + attr.getValue().get(0); - super.put(key, (PersonalAttribute) attr); - this.attrAliasNumber.put(key, null); - } - } - } - return super.put(attrAlias, val); - } else { - return null; - } - } - - /** - * {@inheritDoc} - */ - public void populate(final String attrList) { - final StringTokenizer strToken = - new StringTokenizer(attrList, PEPSValues.ATTRIBUTE_SEP.toString()); - - while (strToken.hasMoreTokens()) { - final PersonalAttribute persAttr = new PersonalAttribute(); - String[] tuples = - strToken.nextToken().split(PEPSValues.ATTRIBUTE_TUPLE_SEP.toString(), - AttributeConstants.NUMBER_TUPLES.intValue()); - - // Convert to the new format if needed! - tuples = convertFormat(tuples); - - if (AttributeUtil.hasValidTuples(tuples)) { - final int attrValueIndex = - AttributeConstants.ATTR_VALUE_INDEX.intValue(); - final String tmpAttrValue = - tuples[attrValueIndex].substring(1, - tuples[attrValueIndex].length() - 1); - final String[] vals = - tmpAttrValue.split(PEPSValues.ATTRIBUTE_VALUE_SEP.toString()); - - persAttr.setName(tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()]); - persAttr.setIsRequired(Boolean - .valueOf(tuples[AttributeConstants.ATTR_TYPE_INDEX.intValue()])); - - // check if it is a complex value - if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_ADDRESS_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } - else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_NEWATTRIBUTE_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } - - else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_HASDEGREE_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } - else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_MANDATECONTENT_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } - else - { - persAttr.setValue(createValues(vals)); - } - - if (tuples.length == AttributeConstants.NUMBER_TUPLES.intValue()) { - persAttr.setStatus(tuples[AttributeConstants.ATTR_STATUS_INDEX - .intValue()]); - } - this.put(tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()], - persAttr); - - } else { - LOG.warn("Invalid personal attribute list tuples"); - } - - } - } - - /** - * Returns a copy of this IPersonalAttributeList instance. - * - * @return The copy of this IPersonalAttributeList. - */ - public Object clone() { - return (PersonalAttributeList) super.clone(); - } - - /** - * Creates a string in the following format. - * - * attrName:attrType:[attrValue1,attrValue2=attrComplexValue]:attrStatus; - * - * @return {@inheritDoc} - */ - @Override - public String toString() { - final Iterator> itAttrs = - this.entrySet().iterator(); - final StringBuilder strBuilder = new StringBuilder(); - - while (itAttrs.hasNext()) { - final Entry attrEntry = itAttrs.next(); - final PersonalAttribute attr = attrEntry.getValue(); - strBuilder.append(attr.toString()); - } - - return strBuilder.toString(); - } - - /** - * Validates and creates the attribute's complex values. - * - * @param values The complex values. - * - * @return The {@link Map} with the complex values. - * - * @see Map - */ - private Map createComplexValue(final String[] values) { - final Map complexValue = new HashMap(); - for (final String val : values) { - final String[] tVal = val.split("="); - if (StringUtils.isNotEmpty(val) && tVal.length == 2) { - complexValue.put(tVal[0], AttributeUtil.unescape(tVal[1])); - } - } - return complexValue; - } - - /** - * Validates and creates the attribute values. - * - * @param vals The attribute values. - * - * @return The {@link List} with the attribute values. - * - * @see List - */ - private List createValues(final String[] vals) { - final List values = new ArrayList(); - for (final String val : vals) { - if (StringUtils.isNotEmpty(val)) { - values.add(AttributeUtil.unescape(val)); - } - } - return values; - } - - /** - * Converts the attribute tuple (attrName:attrType...) to the new format. - * - * @param tuples The attribute tuples to convert. - * - * @return The attribute tuples in the new format. - */ - private String[] convertFormat(final String[] tuples) { - final String[] newFormatTuples = - new String[AttributeConstants.NUMBER_TUPLES.intValue()]; - if (tuples != null) { - System.arraycopy(tuples, 0, newFormatTuples, 0, tuples.length); - - for (int i = tuples.length; i < newFormatTuples.length; i++) { - if (i == AttributeConstants.ATTR_VALUE_INDEX.intValue()) { - newFormatTuples[i] = "[]"; - } else { - newFormatTuples[i] = ""; - } - } - } - return newFormatTuples; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base deleted file mode 100644 index 33160f2ac..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryRequest.java.svn-base +++ /dev/null @@ -1,426 +0,0 @@ -package eu.stork.peps.auth.commons; - -import java.io.Serializable; - -import org.apache.log4j.Logger; - -public class STORKAttrQueryRequest implements Serializable, Cloneable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 4778480781609392750L; - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(STORKAttrQueryRequest.class - .getName()); - - /** The samlId. */ - private String samlId; - - /** The destination. */ - private String destination; - - /** The distinguished name. */ - private String distinguishedName; - - /** The e id sector share. */ - private boolean eIDSectorShare; - - /** The e id cross sector share. */ - private boolean eIDCrossSectorShare; - - /** The e id cross border share. */ - private boolean eIDCrossBorderShare; - - /** The personal attribute list. */ - private IPersonalAttributeList attributeList = new PersonalAttributeList(); - - /** The qaa. */ - private int qaa; - - /** The token saml. */ - private byte[] tokenSaml = new byte[0]; - - /** The issuer. */ - private String issuer; - - /** The service provider sector. */ - private String spSector; - - /** The service provider institution. */ - private String spInstitution; - - /** The service provider application. */ - private String spApplication; - - /** The service provider country. */ - private String spCountry; - - /** The country. */ - private String country; - - /** The citizen country code. */ - private String citizenCountry; - - /** The Service Provider ID. */ - private String sPID; - - /** The Alias used at the keystore for saving this certificate. */ - private String alias; - - /** - * Gets the SP's Certificate Alias. - * - * @return alias The SP's Certificate Alias. - */ - public String getAlias() { - return alias; - } - - /** - * Sets the SP's Certificate Alias. - * - * @param nAlias The SP's Certificate Alias. - */ - public void setAlias(final String nAlias) { - this.alias = nAlias; - } - - /** - * Gets the SP ID. - * - * @return sPID The SP ID. - */ - public String getSPID() { - return sPID; - } - - /** - * Sets the SP ID. - * - * @param sPId The new sp samlId. - */ - public void setSPID(final String sPId) { - this.sPID = sPId; - } - - /** - * Gets the citizen country code. - * - * @return The citizen country code value. - */ - public String getCitizenCountryCode() { - return citizenCountry; - } - - /** - * Sets the citizen country code. - * - * @param countryCode the new citizen country code value. - */ - public void setCitizenCountryCode(final String countryCode) { - this.citizenCountry = countryCode; - } - - /** - * Gets the sp country. - * - * @return The sp country value. - */ - public String getSpCountry() { - return spCountry; - } - - /** - * Sets the sp country. - * - * @param sPCountry the new sp country value. - */ - public void setSpCountry(final String sPCountry) { - this.spCountry = sPCountry; - } - - /** - * Gets the issuer. - * - * @return The issuer value. - */ - public String getIssuer() { - return issuer; - } - - /** - * Sets the issuer. - * - * @param samlIssuer the new issuer value. - */ - public void setIssuer(final String samlIssuer) { - this.issuer = samlIssuer; - } - - /** - * Gets the SAML Token. - * - * @return The SAML Token value. - */ - public byte[] getTokenSaml() { - return tokenSaml.clone(); - } - - /** - * Sets the SAML Token. - * - * @param samlToken The new SAML Token value. - */ - public void setTokenSaml(final byte[] samlToken) { - if (samlToken != null) { - this.tokenSaml = samlToken.clone(); - } - } - - /** - * Gets the country. - * - * @return The country value. - */ - public String getCountry() { - return country; - } - - /** - * Sets the country. - * - * @param nCountry the new country value. - */ - public void setCountry(final String nCountry) { - this.country = nCountry; - } - - /** - * Getter for the qaa value. - * - * @return The qaa value value. - */ - public int getQaa() { - return qaa; - } - - /** - * Setter for the qaa value. - * - * @param qaaLevel The new qaa value. - */ - public void setQaa(final int qaaLevel) { - this.qaa = qaaLevel; - } - - /** - * Getter for the destination value. - * - * @return The destination value. - */ - public String getDestination() { - return destination; - } - - /** - * Setter for the destination value. - * - * @param detination the new destination value. - */ - public void setDestination(final String detination) { - this.destination = detination; - } - - /** - * Getter for the samlId value. - * - * @return The samlId value. - */ - public String getSamlId() { - return samlId; - } - - /** - * Setter for the samlId value. - * - * @param newSamlId the new samlId value. - */ - public void setSamlId(final String newSamlId) { - this.samlId = newSamlId; - } - - - /** - * Getter for the attributeList value. - * - * @return The attributeList value. - * - * @see IPersonalAttributeList - */ - public IPersonalAttributeList getPersonalAttributeList() { - IPersonalAttributeList personnalAttributeList = null; - try { - personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); - } catch (CloneNotSupportedException e1) { - LOG.trace("[PersonalAttribute] Nothing to do."); - } - return personnalAttributeList; - } - - /** - * Setter for the attributeList value. - * - * @param attrList the personal attribute list value. - * - * @see IPersonalAttributeList - */ - public void setPersonalAttributeList(final IPersonalAttributeList attrList) { - if (attrList != null) { - this.attributeList = attrList; - } - } - - /** - * Getter for the distinguishedName value. - * - * @return The distinguishedName value. - */ - public String getDistinguishedName() { - return distinguishedName; - } - - /** - * Setter for the distinguishedName value. - * - * @param certDN the distinguished name value. - */ - public void setDistinguishedName(final String certDN) { - this.distinguishedName = certDN; - } - - /** - * Gets the service provider sector. - * - * @return The service provider sector value. - */ - public String getSpSector() { - return spSector; - } - - /** - * Sets the service provider sector. - * - * @param samlSPSector the new service provider sector value. - */ - public void setSpSector(final String samlSPSector) { - this.spSector = samlSPSector; - } - - /** - * Gets the service provider institution. - * - * @return The service provider institution value. - */ - public String getSpInstitution() { - return spInstitution; - } - - /** - * Sets the service provider institution. - * - * @param samlSPInst the new service provider institution value. - */ - public void setSpInstitution(final String samlSPInst) { - this.spInstitution = samlSPInst; - } - - /** - * Gets the service provider application. - * - * @return The service provider application value. - */ - public String getSpApplication() { - return spApplication; - } - - /** - * Sets the service provider application. - * - * @param samlSPApp the new service provider application value. - */ - public void setSpApplication(final String samlSPApp) { - this.spApplication = samlSPApp; - } - - /** - * Checks if is eId sector share. - * - * @return true, if is eId sector share. - */ - public boolean isEIDSectorShare() { - return eIDSectorShare; - } - - /** - * Sets the eId sector share. - * - * @param eIdSectorShare the new eId sector share value. - */ - public void setEIDSectorShare(final boolean eIdSectorShare) { - this.eIDSectorShare = eIdSectorShare; - } - - /** - * Checks if is eId cross sector share. - * - * @return true, if is eId cross sector share. - */ - public boolean isEIDCrossSectorShare() { - return eIDCrossSectorShare; - } - - /** - * Sets the eId cross sector share. - * - * @param eIdCrossSectorShare the new eId cross sector share value. - */ - public void setEIDCrossSectorShare(final boolean eIdCrossSectorShare) { - this.eIDCrossSectorShare = eIdCrossSectorShare; - } - - /** - * Checks if is eId cross border share. - * - * @return true, if is eId cross border share. - */ - public boolean isEIDCrossBorderShare() { - return eIDCrossBorderShare; - } - - /** - * Sets the eId cross border share. - * - * @param eIdCrossBorderShare the new eId cross border share value. - */ - public void setEIDCrossBorderShare(final boolean eIdCrossBorderShare) { - this.eIDCrossBorderShare = eIdCrossBorderShare; - } - - /** - * Returns a copy of this STORKAttrQueryRequest instance. - * - * @return The copy of this STORKAttrQueryRequest. - * @throws CloneNotSupportedException on clone exception - */ - @Override - public Object clone() throws CloneNotSupportedException{ - STORKAttrQueryRequest storkAttrQueryReq = null; - storkAttrQueryReq = (STORKAttrQueryRequest) super.clone(); - storkAttrQueryReq.setPersonalAttributeList(getPersonalAttributeList()); - storkAttrQueryReq.setTokenSaml(getTokenSaml()); - return storkAttrQueryReq; - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base deleted file mode 100644 index 215b978dc..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAttrQueryResponse.java.svn-base +++ /dev/null @@ -1,301 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import org.apache.log4j.Logger; -import org.joda.time.DateTime; - -public class STORKAttrQueryResponse { - - /** Response Id. */ - private String samlId; - - /** Request failed? */ - private boolean fail; - - /** Status code. */ - private String statusCode; - - /** Secondary status code. */ - private String subStatusCode; - - /** Audience restriction. */ - private transient String audienceRest; - - /** Error message. */ - private String message; - - /** Id of the request that originated this response. */ - private String inResponseTo; - - /** Expiration date. */ - private DateTime notOnOrAfter; - - /** Creation date. */ - private DateTime notBefore; - - /** The SAML token. */ - private byte[] tokenSaml = new byte[0]; - - /** Country. */ - private String country; - - /** Citizen's personal attribute list. */ - private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(STORKAttrQueryResponse.class.getName()); - - /** - * Getter for the subStatusCode. - * - * @return The subStatusCode value. - */ - public String getSubStatusCode() { - return subStatusCode; - } - - /** - * Setter for the subStatusCode. - * - * @param samlSubStatusCode the new subStatusCode value. - */ - public void setSubStatusCode(final String samlSubStatusCode) { - this.subStatusCode = samlSubStatusCode; - } - - /** - * Getter for audienceRest. - * - * @return The audienceRest value. - */ - public String getAudienceRestriction() { - return audienceRest; - } - - /** - * Setter for audienceRest. - * - * @param audRest the new audienceRest value. - */ - public void setAudienceRestriction(final String audRest) { - this.audienceRest = audRest; - } - - /** - * Getter for the samlToken. - * - * @return The samlToken value. - */ - public byte[] getTokenSaml() { - return tokenSaml.clone(); - } - - /** - * Setter for samlToken. - * - * @param samlToken the new tokenSaml value. - */ - public void setTokenSaml(final byte[] samlToken) { - if (samlToken != null) { - this.tokenSaml = samlToken.clone(); - } - } - - /** - * Getter for the country name. - * - * @return The country name value. - */ - public String getCountry() { - return country; - } - - /** - * Setter for the country name. - * - * @param cCountry the new country name value. - */ - public void setCountry(final String cCountry) { - this.country = cCountry; - } - - /** - * Getter for pal value. - * - * @return The pal value. - * - * @see PersonalAttributeList - */ - public IPersonalAttributeList getPersonalAttributeList() { - IPersonalAttributeList personnalAttributeList = null; - try { - personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); - } catch (CloneNotSupportedException e1) { - LOG.trace("[PersonalAttribute] Nothing to do."); - } - return personnalAttributeList; - } - - /** - * Setter for the Personal Attribute List value. - * - * @param attrList the new value. - * - * @see PersonalAttributeList - */ - public void setPersonalAttributeList(final IPersonalAttributeList attrList) { - if (attrList != null) { - this.attributeList = attrList; - } - } - - /** - * Getter for the inResponseTo value. - * - * @return The inResponseTo value. - */ - public String getInResponseTo() { - return inResponseTo; - } - - /** - * Setter for the inResponseTo value. - * - * @param samlInResponseTo the new inResponseTo value. - */ - public void setInResponseTo(final String samlInResponseTo) { - this.inResponseTo = samlInResponseTo; - } - - /** - * Getter for the fail value. - * - * @return The fail value. - */ - public boolean isFail() { - return fail; - } - - /** - * Setter for the fail value. - * - * @param failVal the new fail value. - */ - public void setFail(final boolean failVal) { - this.fail = failVal; - } - - /** - * Getter for the message value. - * - * @return The message value. - */ - public String getMessage() { - return message; - } - - /** - * Setter for the message value. - * - * @param msg the new message value. - */ - public void setMessage(final String msg) { - this.message = msg; - } - - /** - * Getter for the statusCode value. - * - * @return The statusCode value. - */ - public String getStatusCode() { - return statusCode; - } - - /** - * Setter for the statusCode value. - * - * @param status the new statusCode value. - */ - public void setStatusCode(final String status) { - this.statusCode = status; - } - - /** - * Getter for the samlId value. - * - * @return The samlId value. - */ - public String getSamlId() { - return samlId; - } - - /** - * Setter for the samlId value. - * - * @param nSamlId the new samlId value. - */ - public void setSamlId(final String nSamlId) { - this.samlId = nSamlId; - } - - /** - * Getter for the notOnOrAfter value. - * - * @return The notOnOrAfter value. - * - * @see DateTime - */ - public DateTime getNotOnOrAfter() { - return this.notOnOrAfter; - } - - /** - * Setter for the notOnOrAfter value. - * - * @param nOnOrAfter the new notOnOrAfter value. - * - * @see DateTime - */ - public void setNotOnOrAfter(final DateTime nOnOrAfter) { - this.notOnOrAfter = nOnOrAfter; - } - - /** - * Getter for the notBefore value. - * - * @return The notBefore value. - * - * @see DateTime - */ - public DateTime getNotBefore() { - return notBefore; - } - - /** - * Setter for the notBefore value. - * - * @param nBefore the new notBefore value. - * - * @see DateTime - */ - public void setNotBefore(final DateTime nBefore) { - this.notBefore = nBefore; - } - -} - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base deleted file mode 100644 index 2354d0eb1..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnRequest.java.svn-base +++ /dev/null @@ -1,495 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import java.io.Serializable; - -import org.apache.log4j.Logger; - -/** - * This class is a bean used to store the information relative to the - * STORKAuthnRequest (SAML Token Request). - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.21 $, $Date: 2011-02-17 22:44:34 $ - */ -public final class STORKAuthnRequest implements Serializable, Cloneable { - - /** The Constant serialVersionUID. */ - private static final long serialVersionUID = 4778480781609392750L; - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(STORKAuthnRequest.class - .getName()); - - /** The samlId. */ - private String samlId; - - /** The assertion consumer service url. */ - private String serviceURL; - - /** The destination. */ - private String destination; - - /** The provider name. */ - private String providerName; - - /** The distinguished name. */ - private String distinguishedName; - - /** The e id sector share. */ - private boolean eIDSectorShare; - - /** The e id cross sector share. */ - private boolean eIDCrossSectorShare; - - /** The e id cross border share. */ - private boolean eIDCrossBorderShare; - - /** The personal attribute list. */ - private IPersonalAttributeList attributeList = new PersonalAttributeList(); - - /** The qaa. */ - private int qaa; - - /** The token saml. */ - private byte[] tokenSaml = new byte[0]; - - /** The issuer. */ - private String issuer; - - /** The service provider sector. */ - private String spSector; - - /** The service provider institution. */ - private String spInstitution; - - /** The service provider application. */ - private String spApplication; - - /** The service provider country. */ - private String spCountry; - - /** The country. */ - private String country; - - /** The citizen country code. */ - private String citizenCountry; - - /** The Service Provider ID. */ - private String sPID; - - /** The Alias used at the keystore for saving this certificate. */ - private String alias; - - /** - * Gets the SP's Certificate Alias. - * - * @return alias The SP's Certificate Alias. - */ - public String getAlias() { - return alias; - } - - /** - * Sets the SP's Certificate Alias. - * - * @param nAlias The SP's Certificate Alias. - */ - public void setAlias(final String nAlias) { - this.alias = nAlias; - } - - /** - * Gets the SP ID. - * - * @return sPID The SP ID. - */ - public String getSPID() { - return sPID; - } - - /** - * Sets the SP ID. - * - * @param sPId The new sp samlId. - */ - public void setSPID(final String sPId) { - this.sPID = sPId; - } - - /** - * Gets the citizen country code. - * - * @return The citizen country code value. - */ - public String getCitizenCountryCode() { - return citizenCountry; - } - - /** - * Sets the citizen country code. - * - * @param countryCode the new citizen country code value. - */ - public void setCitizenCountryCode(final String countryCode) { - this.citizenCountry = countryCode; - } - - /** - * Gets the sp country. - * - * @return The sp country value. - */ - public String getSpCountry() { - return spCountry; - } - - /** - * Sets the sp country. - * - * @param sPCountry the new sp country value. - */ - public void setSpCountry(final String sPCountry) { - this.spCountry = sPCountry; - } - - /** - * Gets the issuer. - * - * @return The issuer value. - */ - public String getIssuer() { - return issuer; - } - - /** - * Sets the issuer. - * - * @param samlIssuer the new issuer value. - */ - public void setIssuer(final String samlIssuer) { - this.issuer = samlIssuer; - } - - /** - * Gets the SAML Token. - * - * @return The SAML Token value. - */ - public byte[] getTokenSaml() { - return tokenSaml.clone(); - } - - /** - * Sets the SAML Token. - * - * @param samlToken The new SAML Token value. - */ - public void setTokenSaml(final byte[] samlToken) { - if (samlToken != null) { - this.tokenSaml = samlToken.clone(); - } - } - - /** - * Gets the country. - * - * @return The country value. - */ - public String getCountry() { - return country; - } - - /** - * Sets the country. - * - * @param nCountry the new country value. - */ - public void setCountry(final String nCountry) { - this.country = nCountry; - } - - /** - * Getter for the qaa value. - * - * @return The qaa value value. - */ - public int getQaa() { - return qaa; - } - - /** - * Setter for the qaa value. - * - * @param qaaLevel The new qaa value. - */ - public void setQaa(final int qaaLevel) { - this.qaa = qaaLevel; - } - - /** - * Getter for the serviceURL value. - * - * @return The serviceURL value. - */ - public String getAssertionConsumerServiceURL() { - return serviceURL; - } - - /** - * Setter for the serviceURL value. - * - * @param newServiceURL the assertion consumer service URL. - */ - public void setAssertionConsumerServiceURL(final String newServiceURL) { - this.serviceURL = newServiceURL; - } - - /** - * Getter for the destination value. - * - * @return The destination value. - */ - public String getDestination() { - return destination; - } - - /** - * Setter for the destination value. - * - * @param detination the new destination value. - */ - public void setDestination(final String detination) { - this.destination = detination; - } - - /** - * Getter for the samlId value. - * - * @return The samlId value. - */ - public String getSamlId() { - return samlId; - } - - /** - * Setter for the samlId value. - * - * @param newSamlId the new samlId value. - */ - public void setSamlId(final String newSamlId) { - this.samlId = newSamlId; - } - - /** - * Getter for the providerName value. - * - * @return The provider name value. - */ - public String getProviderName() { - return providerName; - } - - /** - * Setter for the providerName value. - * - * @param samlProvider the provider name value. - */ - public void setProviderName(final String samlProvider) { - this.providerName = samlProvider; - } - - /** - * Getter for the attributeList value. - * - * @return The attributeList value. - * - * @see IPersonalAttributeList - */ - public IPersonalAttributeList getPersonalAttributeList() { - IPersonalAttributeList personnalAttributeList = null; - try { - personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); - } catch (CloneNotSupportedException e1) { - LOG.trace("[PersonalAttribute] Nothing to do."); - } - return personnalAttributeList; - } - - /** - * Setter for the attributeList value. - * - * @param attrList the personal attribute list value. - * - * @see IPersonalAttributeList - */ - public void setPersonalAttributeList(final IPersonalAttributeList attrList) { - if (attrList != null) { - this.attributeList = attrList; - } - } - - /** - * Getter for the distinguishedName value. - * - * @return The distinguishedName value. - */ - public String getDistinguishedName() { - return distinguishedName; - } - - /** - * Setter for the distinguishedName value. - * - * @param certDN the distinguished name value. - */ - public void setDistinguishedName(final String certDN) { - this.distinguishedName = certDN; - } - - /** - * Gets the service provider sector. - * - * @return The service provider sector value. - */ - public String getSpSector() { - return spSector; - } - - /** - * Sets the service provider sector. - * - * @param samlSPSector the new service provider sector value. - */ - public void setSpSector(final String samlSPSector) { - this.spSector = samlSPSector; - } - - /** - * Gets the service provider institution. - * - * @return The service provider institution value. - */ - public String getSpInstitution() { - return spInstitution; - } - - /** - * Sets the service provider institution. - * - * @param samlSPInst the new service provider institution value. - */ - public void setSpInstitution(final String samlSPInst) { - this.spInstitution = samlSPInst; - } - - /** - * Gets the service provider application. - * - * @return The service provider application value. - */ - public String getSpApplication() { - return spApplication; - } - - /** - * Sets the service provider application. - * - * @param samlSPApp the new service provider application value. - */ - public void setSpApplication(final String samlSPApp) { - this.spApplication = samlSPApp; - } - - /** - * Checks if is eId sector share. - * - * @return true, if is eId sector share. - */ - public boolean isEIDSectorShare() { - return eIDSectorShare; - } - - /** - * Sets the eId sector share. - * - * @param eIdSectorShare the new eId sector share value. - */ - public void setEIDSectorShare(final boolean eIdSectorShare) { - this.eIDSectorShare = eIdSectorShare; - } - - /** - * Checks if is eId cross sector share. - * - * @return true, if is eId cross sector share. - */ - public boolean isEIDCrossSectorShare() { - return eIDCrossSectorShare; - } - - /** - * Sets the eId cross sector share. - * - * @param eIdCrossSectorShare the new eId cross sector share value. - */ - public void setEIDCrossSectorShare(final boolean eIdCrossSectorShare) { - this.eIDCrossSectorShare = eIdCrossSectorShare; - } - - /** - * Checks if is eId cross border share. - * - * @return true, if is eId cross border share. - */ - public boolean isEIDCrossBorderShare() { - return eIDCrossBorderShare; - } - - /** - * Sets the eId cross border share. - * - * @param eIdCrossBorderShare the new eId cross border share value. - */ - public void setEIDCrossBorderShare(final boolean eIdCrossBorderShare) { - this.eIDCrossBorderShare = eIdCrossBorderShare; - } - - /** - * Returns a copy of this STORKAuthnRequest instance. - * - * @return The copy of this STORKAuthnRequest. - * @throws CloneNotSupportedException on clone exception - */ - @Override - public Object clone() throws CloneNotSupportedException{ - STORKAuthnRequest storkAuthnReq = null; - try { - storkAuthnReq = (STORKAuthnRequest) super.clone(); - storkAuthnReq.setPersonalAttributeList(getPersonalAttributeList()); - storkAuthnReq.setTokenSaml(getTokenSaml()); - } catch (final CloneNotSupportedException e) { - // assert false; - LOG.trace("[PersonalAttribute] Nothing to do."); - } - - return storkAuthnReq; - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base deleted file mode 100644 index aa98974f6..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKAuthnResponse.java.svn-base +++ /dev/null @@ -1,309 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -import org.apache.log4j.Logger; -import org.joda.time.DateTime; - -/** - * This class is a bean used to store the information relative to the - * STORKAuthnResponse. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class STORKAuthnResponse { - - /** Response Id. */ - private String samlId; - - /** Authentication failed? */ - private boolean fail; - - /** Status code. */ - private String statusCode; - - /** Secondary status code. */ - private String subStatusCode; - - /** Audience restriction. */ - private transient String audienceRest; - - /** Error message. */ - private String message; - - /** Id of the request that originated this response. */ - private String inResponseTo; - - /** Expiration date. */ - private DateTime notOnOrAfter; - - /** Creation date. */ - private DateTime notBefore; - - /** The SAML token. */ - private byte[] tokenSaml = new byte[0]; - - /** Country. */ - private String country; - - /** Citizen's personal attribute list. */ - private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); - - /** - * Logger object. - */ - private static final Logger LOG = Logger.getLogger(STORKAuthnResponse.class.getName()); - - /** - * Getter for the subStatusCode. - * - * @return The subStatusCode value. - */ - public String getSubStatusCode() { - return subStatusCode; - } - - /** - * Setter for the subStatusCode. - * - * @param samlSubStatusCode the new subStatusCode value. - */ - public void setSubStatusCode(final String samlSubStatusCode) { - this.subStatusCode = samlSubStatusCode; - } - - /** - * Getter for audienceRest. - * - * @return The audienceRest value. - */ - public String getAudienceRestriction() { - return audienceRest; - } - - /** - * Setter for audienceRest. - * - * @param audRest the new audienceRest value. - */ - public void setAudienceRestriction(final String audRest) { - this.audienceRest = audRest; - } - - /** - * Getter for the samlToken. - * - * @return The samlToken value. - */ - public byte[] getTokenSaml() { - return tokenSaml.clone(); - } - - /** - * Setter for samlToken. - * - * @param samlToken the new tokenSaml value. - */ - public void setTokenSaml(final byte[] samlToken) { - if (samlToken != null) { - this.tokenSaml = samlToken.clone(); - } - } - - /** - * Getter for the country name. - * - * @return The country name value. - */ - public String getCountry() { - return country; - } - - /** - * Setter for the country name. - * - * @param cCountry the new country name value. - */ - public void setCountry(final String cCountry) { - this.country = cCountry; - } - - /** - * Getter for pal value. - * - * @return The pal value. - * - * @see PersonalAttributeList - */ - public IPersonalAttributeList getPersonalAttributeList() { - IPersonalAttributeList personnalAttributeList = null; - try { - personnalAttributeList = (IPersonalAttributeList) attributeList.clone(); - } catch (CloneNotSupportedException e1) { - LOG.trace("[PersonalAttribute] Nothing to do."); - } - return personnalAttributeList; - } - - /** - * Setter for the Personal Attribute List value. - * - * @param attrList the new value. - * - * @see PersonalAttributeList - */ - public void setPersonalAttributeList(final IPersonalAttributeList attrList) { - if (attrList != null) { - this.attributeList = attrList; - } - } - - /** - * Getter for the inResponseTo value. - * - * @return The inResponseTo value. - */ - public String getInResponseTo() { - return inResponseTo; - } - - /** - * Setter for the inResponseTo value. - * - * @param samlInResponseTo the new inResponseTo value. - */ - public void setInResponseTo(final String samlInResponseTo) { - this.inResponseTo = samlInResponseTo; - } - - /** - * Getter for the fail value. - * - * @return The fail value. - */ - public boolean isFail() { - return fail; - } - - /** - * Setter for the fail value. - * - * @param failVal the new fail value. - */ - public void setFail(final boolean failVal) { - this.fail = failVal; - } - - /** - * Getter for the message value. - * - * @return The message value. - */ - public String getMessage() { - return message; - } - - /** - * Setter for the message value. - * - * @param msg the new message value. - */ - public void setMessage(final String msg) { - this.message = msg; - } - - /** - * Getter for the statusCode value. - * - * @return The statusCode value. - */ - public String getStatusCode() { - return statusCode; - } - - /** - * Setter for the statusCode value. - * - * @param status the new statusCode value. - */ - public void setStatusCode(final String status) { - this.statusCode = status; - } - - /** - * Getter for the samlId value. - * - * @return The samlId value. - */ - public String getSamlId() { - return samlId; - } - - /** - * Setter for the samlId value. - * - * @param nSamlId the new samlId value. - */ - public void setSamlId(final String nSamlId) { - this.samlId = nSamlId; - } - - /** - * Getter for the notOnOrAfter value. - * - * @return The notOnOrAfter value. - * - * @see DateTime - */ - public DateTime getNotOnOrAfter() { - return this.notOnOrAfter; - } - - /** - * Setter for the notOnOrAfter value. - * - * @param nOnOrAfter the new notOnOrAfter value. - * - * @see DateTime - */ - public void setNotOnOrAfter(final DateTime nOnOrAfter) { - this.notOnOrAfter = nOnOrAfter; - } - - /** - * Getter for the notBefore value. - * - * @return The notBefore value. - * - * @see DateTime - */ - public DateTime getNotBefore() { - return notBefore; - } - - /** - * Setter for the notBefore value. - * - * @param nBefore the new notBefore value. - * - * @see DateTime - */ - public void setNotBefore(final DateTime nBefore) { - this.notBefore = nBefore; - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base deleted file mode 100644 index a9c4a156b..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKStatusCode.java.svn-base +++ /dev/null @@ -1,68 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * This enum class contains the SAML Token Status Code. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ - */ -public enum STORKStatusCode { - - /** URI for Requester status code. */ - REQUESTER_URI("urn:oasis:names:tc:SAML:2.0:status:Requester"), - - /** URI for Responder status code. */ - RESPONDER_URI("urn:oasis:names:tc:SAML:2.0:status:Responder"), - - /** URI for Success status code. */ - SUCCESS_URI("urn:oasis:names:tc:SAML:2.0:status:Success"), - - /** Attribute is Available. */ - STATUS_AVAILABLE("Available"), - - /** Attribute is NotAvailable. */ - STATUS_NOT_AVAILABLE("NotAvailable"), - - /** Attribute is Withheld. */ - STATUS_WITHHELD("Withheld"); - - /** - * Represents the constant's value. - */ - private String value; - - /** - * Solo Constructor. - * - * @param val The Constant value. - */ - private STORKStatusCode(final String val) { - - this.value = val; - } - - /** - * Return the Constant Value. - * - * @return The constant value. - */ - public String toString() { - - return value; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base deleted file mode 100644 index 0a711c9b7..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/STORKSubStatusCode.java.svn-base +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons; - -/** - * This enum class contains the SAML Token Sub Status Code. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.7 $, $Date: 2010-11-17 05:15:28 $ - */ -public enum STORKSubStatusCode { - - /** URI for AuthnFailed status code. */ - AUTHN_FAILED_URI("urn:oasis:names:tc:SAML:2.0:status:AuthnFailed"), - - /** URI for InvalidAttrNameOrValue status code. */ - INVALID_ATTR_NAME_VALUE_URI( - "urn:oasis:names:tc:SAML:2.0:status:InvalidAttrNameOrValue"), - - /** URI for InvalidNameIDPolicy status code. */ - INVALID_NAMEID_POLICY_URI( - "urn:oasis:names:tc:SAML:2.0:status:InvalidNameIDPolicy"), - - /** URI for VersionMismatch status code. */ - VERSION_MISMATCH_URI("urn:oasis:names:tc:SAML:2.0:status:VersionMismatch"), - - /** URI for RequestDenied status code. */ - REQUEST_DENIED_URI("urn:oasis:names:tc:SAML:2.0:status:RequestDenied"), - - /** URI for QaaNotSupported status code. */ - QAA_NOT_SUPPORTED( - "http://www.stork.gov.eu/saml20/statusCodes/QAANotSupported"); - - /** - * Represents the constant's value. - */ - private String value; - - /** - * Solo Constructor. - * - * @param val The Constant value. - */ - private STORKSubStatusCode(final String val) { - - this.value = val; - } - - /** - * Return the Constant Value. - * - * @return The constant value. - */ - public String toString() { - - return value; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base deleted file mode 100644 index 19d45aaa2..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/.svn/text-base/package-info.java.svn-base +++ /dev/null @@ -1,9 +0,0 @@ -/** - * Common Authentication Service functionalities to be deployed in every PEPS - * is contained in this package. - * In particular, it contains the SAML Engine that implements the SAML messages - * management - * - * @since 1.0 - */ -package eu.stork.peps.auth.commons; diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeName.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeName.java new file mode 100644 index 000000000..a44768c7e --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeName.java @@ -0,0 +1,74 @@ +package eu.stork.peps.auth.commons; + +/** + * This class is a bean used to store information relative to Attribute Names. + * + * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) + * + * @version $Revision: 1.00 $, $Date: 2013-11-26 $ + */ +public final class AttributeName { + + /** + * Attribute Id. + */ + private String attributeId; + + /** + * Attribute Name. + */ + private String attributeName; + + /** + * Attribute Name Constructor. + * + * @param aId Id of the Attribute Name. + * @param aName Name of the Attribute Name. + */ + public AttributeName(final String aId, final String aName) { + + this.attributeId = aId; + this.attributeName = aName; + } + + /** + * Getter for the attributeId value. + * + * @return The attributeId value. + */ + public String getAttributeId() { + + return attributeId; + } + + /** + * Setter for the attributeId value. + * + * @param aId Id of the Attribute Name. + */ + public void setAttributeId(final String aId) { + + this.attributeId = aId; + } + + /** + * Getter for the attributeName value. + * + * @return The attributeName value. + */ + public String getAttributeName() { + + return attributeName; + } + + /** + * Setter for the attributeName value. + * + * @param name Name of the Attribute Name. + */ + public void setAttributeName(final String name) { + + this.attributeName = name; + } + +} \ No newline at end of file diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java index 013f4caf3..fc776db81 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvider.java @@ -1,15 +1,21 @@ package eu.stork.peps.auth.commons; +import java.io.Serializable; + /** * This class is a bean used to store the information relative to the Attribute Provider. * * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) * - * @version $Revision: 1.00 $, $Date: 2013-09-17 $ + * @version $Revision: 1.01 $, $Date: 2013-11-28 $ */ -public final class AttributeProvider { - +public final class AttributeProvider implements Serializable { /** + * Unique identifier. + */ + private static final long serialVersionUID = 7210186241917444559L; + + /** * Provider Id. */ private String providerId; diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java index 8806ba866..85aec2625 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeProvidersMap.java @@ -30,7 +30,7 @@ public class AttributeProvidersMap extends LinkedHashMap Attribute Provider: ID [" + source.getProvider().getProviderId() + "], name [" + source.getProvider().getProviderName() + "]"); - else + } + else { LOG.trace("-> Country: ID [" + source.getCountry().getCountryId() + "], name [" + source.getCountry().getCountryName() + "]"); + } pal = this.get(source); LOG.trace("++++++++=>"); @@ -83,7 +85,7 @@ public class AttributeProvidersMap extends LinkedHashMap Citizen Attribute: name [" + pa.getName() + "], name [" + pa.isRequired() + "]"); + LOG.trace("-> Citizen Attribute: name [" + pa.getName() + "], required [" + pa.isRequired() + "]"); } LOG.trace("<=++++++++"); diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java index 4b9dc33e9..846f54f67 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeSource.java @@ -1,16 +1,30 @@ package eu.stork.peps.auth.commons; +import java.io.Serializable; + +import org.apache.log4j.Logger; + /** * This class is a bean used to store the information relative to the Attribute Source (either AttributeProvider or Country). * * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) * - * @version $Revision: 1.00 $, $Date: 2013-09-19 $ + * @version $Revision: 1.10 $, $Date: 2013-11-29 $ */ -public final class AttributeSource { +public final class AttributeSource implements Serializable { + /** + * Unique identifier. + */ + private static final long serialVersionUID = 432243595968469014L; + public static final int SOURCE_LOCAL_APROVIDER = 1; public static final int SOURCE_REMOTE_COUNTRY = 2; + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(AttributeSource.class.getName()); + /** * Provider source. */ @@ -60,7 +74,7 @@ public final class AttributeSource { /** * @param sourceType the sourceType to set */ - public void setSourceType(int sourceType) { + public void setSourceType(final int sourceType) { this.sourceType = sourceType; } @@ -74,7 +88,7 @@ public final class AttributeSource { /** * @param providerURL the providerURL to set */ - public void setProviderURL(String providerURL) { + public void setProviderURL(final String providerURL) { this.providerURL = providerURL; } @@ -88,7 +102,7 @@ public final class AttributeSource { /** * @param provider the provider to set */ - public void setProvider(AttributeProvider provider) { + public void setProvider(final AttributeProvider provider) { this.setSourceType(SOURCE_LOCAL_APROVIDER); this.provider = provider; @@ -104,7 +118,7 @@ public final class AttributeSource { /** * @param country the country to set */ - public void setCountry(Country country) { + public void setCountry(final Country country) { this.setSourceType(SOURCE_REMOTE_COUNTRY); this.country = country; @@ -116,4 +130,59 @@ public final class AttributeSource { public Country getCountry() { return country; } + + /** + * {@inheritDoc} + */ + public boolean equals(Object obj) { + boolean outcome = false; + + LOG.debug("Calling equals with Object."); + if ( obj instanceof AttributeSource ) { + LOG.debug("Calling equals with AttributeSource."); + outcome = this.equals((AttributeSource)obj); + } + + LOG.debug("Object equals outcome: " + outcome); + return outcome; + } + + /** + * Compare the given AttributeSource with the current object in order to determinine + * if they are equal. + * + * @param obj The AttributeSource to compare to + * + * @return true if the two objects are equal + */ + public boolean equals(AttributeSource obj) { + boolean outcome = false; + + if ( this.sourceType==obj.getSourceType() ) { + if ( this.sourceType==AttributeSource.SOURCE_LOCAL_APROVIDER ) { + if ( this.provider.getProviderId().equals(obj.getProvider().getProviderId()) ) + outcome = true; + } + else if ( this.sourceType==AttributeSource.SOURCE_REMOTE_COUNTRY ) { + if ( this.country.getCountryId().equals(obj.getCountry().getCountryId()) ) + outcome = true; + } + } + + LOG.debug("AttributeSource equals outcome: " + outcome); + return outcome; + } + + /** + * {@inheritDoc} + */ + public int hashCode() { + int hash = 1; + hash = hash * 17 + this.sourceType; + if ( this.sourceType==AttributeSource.SOURCE_LOCAL_APROVIDER ) + hash = hash * 31 + this.provider.getProviderName().hashCode(); + else + hash = hash * 31 + this.country.getCountryName().hashCode(); + return hash; + } } diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java index 84e3576e5..af7ab6cf3 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/AttributeUtil.java @@ -187,7 +187,7 @@ public final class AttributeUtil { public static boolean hasValidTuples(final String[] tuples) { boolean retVal = false; - int numberTuples = AttributeConstants.NUMBER_TUPLES.intValue(); + final int numberTuples = AttributeConstants.NUMBER_TUPLES.intValue(); if (tuples != null && tuples.length == numberTuples) { // validate attrName final int attrNameIndex = AttributeConstants.ATTR_NAME_INDEX.intValue(); diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java index 2245178f4..9ebcfbd5a 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/CitizenConsent.java @@ -108,14 +108,14 @@ public final class CitizenConsent { * @return {@inheritDoc} */ public String toString() { - final StringBuilder strbldr = new StringBuilder(); + final StringBuilder strbldr = new StringBuilder(46); strbldr.append("Mandatory attributes: "); - for (String str : mandatoryList) { - strbldr.append(str + ";"); + for (final String str : mandatoryList) { + strbldr.append(str).append(';'); } strbldr.append(" Optional attributes: "); - for (String str : optionalList) { - strbldr.append(str + ";"); + for (final String str : optionalList) { + strbldr.append(str).append(';'); } return strbldr.toString(); } diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeListProcessor.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeListProcessor.java new file mode 100644 index 000000000..b13c70f04 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IAttributeListProcessor.java @@ -0,0 +1,148 @@ +package eu.stork.peps.auth.commons; + +import java.util.List; +import java.util.Map; + +/** + * Interface for {@link AttributeListProcessor}. + * + * @author ricardo.ferreira@multicert.com + * + * @version $Revision: $, $Date: $ + * + * @see IPersonalAttributeList + */ +public interface IAttributeListProcessor { + + /** + * Checks if attribute list only contains allowed attributes. + * + * @param attrList the requested attribute list + * @param attributes the allowed attributes + * + * @return true is all the attributes are allowed. + * + * @see IPersonalAttributeList + */ + boolean hasAllowedAttributes(final IPersonalAttributeList attrList, final List attributes); + + /** + * Lookup for business attribute. + * + * @param attrList the requested attribute list + * @param normalAttributes the normal attributes + * + * @return true is at least one business attribute was requested. + * + * @see IPersonalAttributeList + */ + boolean hasBusinessAttributes(final IPersonalAttributeList attrList, final List normalAttributes); + + /** + * Lookup for business attribute in normal attribute list (loaded by + * implementation). + * + * @param attrList the requested attribute list + * + * @return true is at least one business attribute was requested. + * + * @see IPersonalAttributeList + */ + boolean hasBusinessAttributes(final IPersonalAttributeList attrList); + + /** + * Adds eIdentifier, name, surname, and DateOfBirth attributes to get business + * attributes from some AP. + * + * @param attrList the requested attribute list + * @param attributes the list of attributes to add (eIdentifier, name, + * surname, and DateOfBirth). + * + * @return the requested attribute list and the new attributes added + * (eIdentifier, name, surname, and DateOfBirth). + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList addAPMandatoryAttributes(final IPersonalAttributeList attrList, final List attributes); + + /** + * Adds eIdentifier, name, surname, and DateOfBirth attributes, loaded by + * implementation, to get business attributes from some AP. + * + * @param attrList the requested attribute list + * + * @return the requested attribute list and the new attributes added + * (eIdentifier, name, surname, and DateOfBirth). + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList addAPMandatoryAttributes(final IPersonalAttributeList attrList); + + /** + * Removes from attribute list the given list of attributes. + * + * @param attrList the requested attribute list + * @param attributes the list of attributes to remove. + * + * @return the requested attribute list and the attributes removed. + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList removeAPMandatoryAttributes(final IPersonalAttributeList attrList, final List attributes); + + /** + * Removes from attribute list the given list of attributes and change + * attributes status if attribute was optional in the request. + * + * @param attrList the requested attribute list + * @param attributes the map of attributes (attribute name, mandatory/optional) to remove. + * + * @return the requested attribute list and the attributes removed + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList removeAPMandatoryAttributes(IPersonalAttributeList attrList, Map attributes); + + /** + * Checks if mandate attribute exist in the requested Attribute List. Power + * attribute name to lookup is loaded by implementation. + * + * @param attrList the requested attribute list. + * + * @return true if mandate attribute exists or false otherwise. + * + * @see IPersonalAttributeList + */ + boolean hasPowerAttribute(final IPersonalAttributeList attrList); + + /** + * Checks if attribute name was requested and has value. + * + * @param attrList the requested attribute list. + * @param attrName the attribute name to lookup for . + * + * @return true if attribute was requested and has value or false otherwise. + * + * @see IPersonalAttributeList + */ + boolean hasAttributeValue(final IPersonalAttributeList attrList, final String attrName); + + /** + * Checks if attribute has value. + * + * @param attr the attribute to check. + * + * @return true if has value; + * + * @see PersonalAttribute + */ + boolean hasAttributeValue(final PersonalAttribute attr); + + /** + * Gets a map (attribute name, attribute isRequired) of attributes added to attribute list. + * + * @return the Map of attributes added and if is required to attribute list. + */ + Map getNormalAttributesAdded(); + +} \ No newline at end of file diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java index 83b8e57fe..b24c915c0 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/IPersonalAttributeList.java @@ -15,6 +15,7 @@ package eu.stork.peps.auth.commons; import java.util.Collection; import java.util.Iterator; +import java.util.Set; /** * Interface for {@link PersonalAttributeList}. @@ -123,12 +124,65 @@ public interface IPersonalAttributeList extends Iterable, */ Collection values(); + /** + * Returns a {@link Set} view of the keys contained in this map. + * The set is backed by the map, so changes to the map are + * reflected in the set, and vice-versa. If the map is modified + * while an iteration over the set is in progress (except through + * the iterator's own remove operation), the results of + * the iteration are undefined. The set supports element removal, + * which removes the corresponding mapping from the map, via the + * Iterator.remove, Set.remove, + * removeAll, retainAll, and clear + * operations. It does not support the add or addAll + * operations. + * + * @return a set view of the keys contained in this map + */ + Set keySet(); + + + /** + * Returns a IPersonalAttributeList of the complex attributes. + * + * @return an IPersonalAttributeList of the complex attributes. + */ + IPersonalAttributeList getComplexAttributes(); + + /** + * Returns a IPersonalAttributeList of the simple value attributes. + * + * @return an IPersonalAttributeList of the simple value attributes. + */ + IPersonalAttributeList getSimpleValueAttributes(); + + /** + * Returns a IPersonalAttributeList of the mandatory attributes in this map. + * + * @return an IPersonalAttributeList of the mandatory attributes contained in this map. + */ + IPersonalAttributeList getMandatoryAttributes(); + + /** + * Returns a IPersonalAttributeList of the optional attributes in this map. + * + * @return an IPersonalAttributeList of the optional attributes contained in this map. + */ + IPersonalAttributeList getOptionalAttributes(); + /** * Returns true if this map contains no key-value mappings. * * @return true if this map contains no key-value mappings. */ boolean isEmpty(); + + /** + * Returns true if this map contains at least one element that doesn't have value. + * + * @return true if this map contains at least one element that doesn't have value. + */ + boolean hasMissingValues(); /** * Returns a copy of this IPersonalAttributeList instance. diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java index 43d3adaa9..6e7c891da 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/Linker.java @@ -1,6 +1,12 @@ package eu.stork.peps.auth.commons; +import java.io.Serializable; +import java.util.ArrayList; import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; + +import org.apache.log4j.Logger; /** * This class is a bean used to store the information of Attribute Providers, the Attribute @@ -11,14 +17,29 @@ import java.util.Iterator; * * @author Stelios Lelis (stelios.lelis@aegean.gr), Elias Pastos (ilias@aegean.gr) * - * @version $Revision: 1.20 $, $Date: 2013-10-28 $ + * @version $Revision: 1.50 $, $Date: 2013-11-28 $ */ -public final class Linker { +public final class Linker implements Serializable { + /** + * Unique identifier. + */ + private static final long serialVersionUID = -3268006381745987237L; + + /** + * Logger object. + */ + private static final Logger LOG = Logger.getLogger(Linker.class.getName()); + /** * Attributes Providers map. */ private IAttributeProvidersMap attributeProvidersMap; + /** + * Assertion map. + */ + private LinkedHashMap assertions; + /** * The current index of local (domestic) Attribute Providers. */ @@ -35,6 +56,8 @@ public final class Linker { public Linker() { localIndex = 0; remoteIndex = 0; + + assertions = new LinkedHashMap(); } /** @@ -120,9 +143,11 @@ public final class Linker { else localIndex++; - //TODO How to store Assertions (format: byte, base64 string, entire object?) + //Assertion storage + this.assertions.put(source, attrResponse); this.attributeProvidersMap.put(source, attrResponse.getPersonalAttributeList()); + //this.attributeProvidersMap.put(source, attrResponse.getTotalPersonalAttributeList()); } /** @@ -160,6 +185,8 @@ public final class Linker { /** * Returns the Personal Attribute list of the provided Attribute Source. * + * @param source The attributeSource in reference + * * @return The IPersonalAttributeList assosiated with this source or null if empty * * @see IPersonalAttributeList @@ -170,4 +197,120 @@ public final class Linker { else return null; } -} + + /** + * Returns the merged Personal Attribute list from all the Attribute Sources. + * + * @return The IPersonalAttributeList merged Personal Attribute list or null if empty + * + * @see IPersonalAttributeList + */ + public IPersonalAttributeList getAllAttributes() { + Iterator iterator; + AttributeSource source; + IPersonalAttributeList list, merged; + + merged = null; + + if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) { + iterator = attributeProvidersMap.keyIterator(); + + merged = new PersonalAttributeList(); + while (iterator.hasNext()) { + source = iterator.next(); + list = this.getProviderAttributes(source); + + for (final PersonalAttribute pa : list) { + merged.add(pa); + } + } + } + + return merged; + } + + /** + * Returns a List with all the assertions gathered by the AAS-PEPS module + * returned both by local APs or remote A-PEPS. + * + * @return The assertions returned from the APs and A-PEPS + */ + public List getAttrQueryResponseList() { + List originalAssertions; + + originalAssertions = new ArrayList(); + + //Gather all assertions + for (STORKAttrQueryResponse element : this.assertions.values()) { + originalAssertions.add(element); + } + + return originalAssertions; + } + + /** + * Checks the internal state of the Linker and if all Attribute Sources where visited + * returns true, otherwise it returns false. So if you go directly from AtPLinkerAction + * to MoreAttributesAction the call will have, since the method setProviderReponse + * was not executed from every Attribute Source. + * + * @return true if everything is OK, false otherwise + */ + public boolean isComplete() { + boolean outcome = false; + + LOG.debug("Check if linkder is complete: R[" + remoteIndex + "], L[" + localIndex + "], S[" + attributeProvidersMap.size() + "]"); + if ( attributeProvidersMap !=null && !attributeProvidersMap.isEmpty() ) { + if ( (remoteIndex + localIndex)==attributeProvidersMap.size() ) + outcome = true; + } + else { + outcome = true; + } + + return outcome; + } + + /** + * Merge the two Linker objects. + * + * @param previous The other Linker object to merge with this one. + */ + public void mergeWith(Linker previous) { + //BEFORE + if ( LOG.isDebugEnabled() ) { + LOG.debug("The attributeProvidersMap from the current object."); + ((AttributeProvidersMap)this.attributeProvidersMap).trace(); + LOG.debug("The attributeProvidersMap from the provided object."); + ((AttributeProvidersMap)previous.getAttributeProvidersMap()).trace(); + } + + IAttributeProvidersMap map = previous.getAttributeProvidersMap(); + Iterator items = map.keyIterator(); + while( items.hasNext() ) { + AttributeSource item = items.next(); + IPersonalAttributeList pal = map.get(item); + + if ( this.attributeProvidersMap.containsKey(item) ) { + IPersonalAttributeList new_pal = this.attributeProvidersMap.get(item); + + for(PersonalAttribute pa : pal) + new_pal.add(pa); + } + else { + if ( item.getSourceType()==AttributeSource.SOURCE_REMOTE_COUNTRY ) + remoteIndex++; + else + localIndex++; + + this.attributeProvidersMap.put(item, pal); + } + } + + //AFTER + if ( LOG.isDebugEnabled() ) { + LOG.debug("The attributeProvidersMap after the merge."); + ((AttributeProvidersMap)this.attributeProvidersMap).trace(); + } + } +} \ No newline at end of file diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java index 3aa549a06..5da9ba494 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSErrors.java @@ -114,6 +114,11 @@ public enum PEPSErrors { * Represents the 'sProviderAction.spRedirect' constant error identifier. */ SPROVIDER_SELECTOR_INVALID_SPREDIRECT("sProviderAction.invalidSPRedirect"), + /** + * Represents the 'sPPowerValidationAction.invalidSPPVAttrList' constant error identifier. + */ + SPPOWERVALIDATION_SELECTOR_INVALID_SP_PV_ATTR_LIST("sPPowerValidationAction.invalidSPPVAttrList"), + /** * Represents the 'sProviderAction.invalidSPProviderName' constant error * identifier. @@ -163,6 +168,11 @@ public enum PEPSErrors { */ COLLEAGUE_REQ_INVALID_SAML("colleagueRequest.invalidSAML"), + /** + * Represents the 'colleaguePVRequest.invalidPVAttrList' constant error identifier. + */ + COLLEAGUE_PV_REQ_INVALID_PV_ATTR_LIST("colleaguePVRequest.invalidPVAttrList"), + /** * Represents the 'cpepsRedirectUrl' constant error identifier. @@ -278,10 +288,44 @@ public enum PEPSErrors { * Represents the 'missing.sessionId' constant error identifier. */ MISSING_SESSION_ID("sessionError"), + /** + * Represents the 'missing.mandate' constant error identifier. + */ + MISSING_MANDATE("missing.mandate"), + /** + * Represents the 'AtPSAMLResponse' constant error identifier. + */ + ATP_SAML_RESPONSE("AtPSAMLResponse"), + /** * Represents the 'AtPSAMLResponse' constant error identifier. */ - ATP_SAML_RESPONSE("AtPSAMLResponse"); + ATP_RESPONSE_ERROR("atp.response.error"), + + /** + * Represents the 'apepsSAMLRequest' constant error identifier. + */ + APEPS_SAML_REQUEST("apepsSAMLRequest"), + + /** + * Represents the 'apepsSAMLResponse' constant error identifier. + */ + APEPS_SAML_RESPONSE("apepsSAMLResponse"), + + /** + * Represents the 'invalid.apepsRedirectUrl' constant error identifier. + */ + INVALID_APEPS_REDIRECT_URL("invalid.apepsRedirectUrl"), + + /** + * Represents the 'invalid.apepsCallbackUrl' constant error identifier. + */ + INVALID_APEPS_CALLBACK_URL("invalid.apepsCallbackUrl"), + + /** + * Represents the 'colleagueAttributeRequest.invalidSAML' constant error identifier. + */ + COLLEAGUE_ATTR_REQ_INVALID_SAML("colleagueAttributeRequest.invalidSAML"); /** * Represents the constant's value. diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java index 37b204351..146e4c39d 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSParameters.java @@ -75,6 +75,10 @@ public enum PEPSParameters { * Represents the 'attrList' parameter constant. */ ATTRIBUTE_LIST("attrList"), + /** + * Represents the 'apMandAttrList' parameter constant. + */ + AP_MANDATORY_ATTRIBUTE_LIST("apMandAttrList"), /** * Represents the 'attrTuple' parameter constant. */ @@ -173,6 +177,10 @@ public enum PEPSParameters { * Represents the 'external-ap' parameter constant. */ EXTERNAL_AP("external-ap"), + /** + * Represents the 'external-pv' parameter constant. + */ + EXTERNAL_PV("external-pv"), /** * Represents the 'external-sig-module' parameter constant. */ @@ -199,6 +207,10 @@ public enum PEPSParameters { * Represents the 'internal-ap' parameter constant. */ INTERNAL_AP("internal-ap"), + /** + * Represents the 'internal-pv' parameter constant. + */ + INTERNAL_PV("internal-pv"), /** * Represents the 'samlIssuer' parameter constant. @@ -225,6 +237,15 @@ public enum PEPSParameters { * Represents the 'mandatoryConsentAttrMissing' parameter constant. */ MANDATORY_CONSENT_MISSING("mandatoryConsentAttrMissing"), + /** + * Represents the 'missing-attrs' parameter constant. + */ + MISSING_ATTRS("missing-attrs"), + /** + * Represents the 'no-more-attrs' parameter constant. + */ + NO_MORE_ATTRS("no-more-attrs"), + /** * Represents the 'optional' parameter constant. */ @@ -267,6 +288,10 @@ public enum PEPSParameters { * Represents the 'cpeps.specificapredirect.url' parameter constant. */ PEPS_SPECIFIC_URL("cpeps.specificapredirect.url"), + /** + * Represents the 'pv.url' parameter constant. + */ + PV_URL("pv.url"), /** * Represents the 'qaaLevel' parameter constant. @@ -441,11 +466,21 @@ public enum PEPSParameters { */ ATTRIBUTE_PROVIDER_NUMBER("atp.number"), + /** + * Represents the 'atn.number' parameter constant. + */ + ATTRIBUTE_NAME_NUMBER("atn.number"), + /** * Represents the 'apLinker' parameter constant. */ AP_LINKER("apLinker"), + /** + * Represents the 'prevApLinker' parameter constant. + */ + PREV_AP_LINKER("prevApLinker"), + /** * Represents the 'NOSEL' parameter constant (no attribute provider selected). */ @@ -466,6 +501,11 @@ public enum PEPSParameters { */ AP_COUNTRY_SELECT_SUFFIX("_country"), + /** + * Represents the '_name' suffix parameter constant. + */ + AP_NAME_SELECT_SUFFIX("_name"), + /** * Represents the 'next-ap' parameter constant. */ @@ -476,6 +516,21 @@ public enum PEPSParameters { */ NEXT_APEPS("next-apeps"), + /** + * Represents the 'back-to-apeps' parameter constant. + */ + BACK_TO_APEPS("back-to-apeps"), + + /** + * Represents the 'is-remote-apeps' parameter constant. + */ + IS_REMOTE_APEPS("is-remote-apeps"), + + /** + * Represents the 'more-attributes' parameter constant. + */ + MORE_ATTRIBUTES("more-attributes"), + /** * Represents the 'attr-filter.number' parameter constant. */ @@ -484,7 +539,60 @@ public enum PEPSParameters { /** * Represents the 'atp.url' parameter constant. */ - ATP_URL("atp.url"); + ATP_URL("atp.url"), + /** + * Represents the 'apepsURL' parameter constant. + */ + APEPS_URL("apepsUrl"), + + /** + * Represents the 'apepsCountry' parameter constant. + */ + APEPS_COUNTRY("apepsCountry"), + + /** + * Represents the 'apepsAuthRequest' parameter constant. + */ + APEPS_ATTR_REQUEST("apepsAttrRequest"), + + /** + * Represents the 'isApepsRequest' parameter constant. + */ + APEPS_REQUEST_COMPLETE("apeps-request-complete"), + + /** + * Represents the 'apeps.callbackUrl' parameter constant. + */ + APEPS_CALLBACK_URL("apeps.callbackUrl"), + /** + * Represents the 'attrListMand' parameter constant. + */ + ATTR_LIST_MAND("attrListMand"), + + /** + * Represents the 'attrListOpt' parameter constant. + */ + ATTR_LIST_OPT("attrListOpt"), + + /** + * Represents the 'simpleAttrListMand' parameter constant. + */ + SIMPLE_ATTR_LIST_MAND("simpleAttrListMand"), + + /** + * Represents the 'simpleAttrListOpt' parameter constant. + */ + SIMPLE_ATTR_LIST_OPT("simpleAttrListOpt"), + + /** + * Represents the 'complexAttrListMand' parameter constant. + */ + COMPLEX_ATTR_LIST_MAND("complexAttrListMand"), + + /** + * Represents the 'complexAttrListOpt' parameter constant. + */ + COMPLEX_ATTR_LIST_OPT("complexAttrListOpt"); /** * Represents the constant's value. diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java index ae1f203f5..a16b03edb 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSUtil.java @@ -140,7 +140,7 @@ public final class PEPSUtil { if (StringUtils.isNumeric(paramSizeStr)) { final int maxParamSize = Integer.valueOf(paramSizeStr); if (StringUtils.isEmpty(paramValue) - || (paramValue.length() > maxParamSize)) { + || paramValue.length() > maxParamSize) { retVal = false; LOG.warn("Invalid parameter [" + paramName + "] value " + paramValue); } diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java index 568c25053..e14c21cb5 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PEPSValues.java @@ -237,6 +237,10 @@ public enum PEPSValues { * Represents the 'atp' constant value. */ APROVIDER_PREFIX("atp"), + /** + * Represents the 'atn' constant value. + */ + ANAME_PREFIX("atn"), /** * Represents the 'ap-cpeps' constant value. */ diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java index bb9b3b694..5d8281445 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttribute.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import org.apache.log4j.Logger; @@ -55,10 +56,15 @@ public final class PersonalAttribute implements Serializable, Cloneable { */ private List value = new ArrayList(); + /** + * Type of the personal attribute. + */ + private String type; + /** * Complex values of the personal attribute. */ - private Map complexValue = new HashMap(); + private Map complexValue = new ConcurrentHashMap(); /** * Is the personal attribute mandatory? @@ -202,6 +208,25 @@ public final class PersonalAttribute implements Serializable, Cloneable { } } + + /** + * Getter for the type value. + * + * @return The name value. + */ + public String getType() { + return type; + } + + /** + * Setter for the type value. + * + * @param attrName The personal attribute type. + */ + public void setType(final String attrType) { + this.type = attrType; + } + /** * Getter for the status. * diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java index d33ccfe18..642b249d4 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/PersonalAttributeList.java @@ -18,7 +18,7 @@ import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; -import java.util.Map.Entry; +import java.util.concurrent.ConcurrentHashMap; import java.util.StringTokenizer; import org.apache.commons.lang.StringUtils; @@ -37,7 +37,7 @@ import org.apache.log4j.Logger; */ @SuppressWarnings("PMD") public final class PersonalAttributeList extends - HashMap implements IPersonalAttributeList{ + ConcurrentHashMap implements IPersonalAttributeList{ /** * Logger object. @@ -118,8 +118,9 @@ public final class PersonalAttributeList extends if (StringUtils.isNotEmpty(key) && val != null) { // Validate if attribute name already exists! String attrAlias = key; - if (this.containsKey(key)) { - if (!val.isEmptyValue() && StringUtils.isNumeric(val.getValue().get(0))) { + if (this.containsKey(attrAlias)) { + //TODO isAgeOver should not be hardcoded, a better way of handling multipe isAgeOver requests should be implemented. + if (!val.isEmptyValue() && StringUtils.isNumeric(val.getValue().get(0)) && "isAgeOver".equals( val.getName() ) ) { final String attrValue = val.getValue().get(0); attrAlias = key + attrValue; this.attrAliasNumber.put(key, Integer.valueOf(attrValue)); @@ -169,27 +170,9 @@ public final class PersonalAttributeList extends .valueOf(tuples[AttributeConstants.ATTR_TYPE_INDEX.intValue()])); // check if it is a complex value - if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_ADDRESS_VALUE.toString())) - { + if (isComplexValue(vals)) { persAttr.setComplexValue(createComplexValue(vals)); } - else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_NEWATTRIBUTE_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } - - else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_HASDEGREE_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } - else if (tuples[AttributeConstants.ATTR_NAME_INDEX.intValue()] - .equals(PEPSParameters.COMPLEX_MANDATECONTENT_VALUE.toString())) - { - persAttr.setComplexValue(createComplexValue(vals)); - } else { persAttr.setValue(createValues(vals)); @@ -215,7 +198,11 @@ public final class PersonalAttributeList extends * @return The copy of this IPersonalAttributeList. */ public Object clone() { - return (PersonalAttributeList) super.clone(); + try { + return (PersonalAttributeList) super.clone(); + } catch (CloneNotSupportedException e) { + return null; + } } /** @@ -234,7 +221,8 @@ public final class PersonalAttributeList extends while (itAttrs.hasNext()) { final Entry attrEntry = itAttrs.next(); final PersonalAttribute attr = attrEntry.getValue(); - strBuilder.append(attr.toString()); + //strBuilder.append(attr.toString()); + strBuilder.insert(0, attr.toString()); } return strBuilder.toString(); @@ -260,6 +248,22 @@ public final class PersonalAttributeList extends return complexValue; } + /** + * Checks if value is complex or not + * @param values The values to check + * @return True if succesful + */ + private boolean isComplexValue(final String[] values) { + boolean isComplex = false; + if (values.length > 0) { + final String[] tVal = values[0].split("="); + if (StringUtils.isNotEmpty(values[0]) && tVal.length == 2) { + isComplex = true; + } + } + return isComplex; + } + /** * Validates and creates the attribute values. * @@ -302,4 +306,91 @@ public final class PersonalAttributeList extends } return newFormatTuples; } -} + + /** + * Returns a IPersonalAttributeList of the complex attributes in this map. + * + * @return an IPersonalAttributeList of the complex attributes contained in this map. + */ + public IPersonalAttributeList getComplexAttributes() { + LOG.info("get complex attributes"); + IPersonalAttributeList attrList = new PersonalAttributeList(); + for(PersonalAttribute attr: this) { + if(!attr.getComplexValue().isEmpty()) { + attrList.put(attr.getName(), attr); + LOG.info("adding complex attribute:"+attr.getName()); + } + } + return attrList; + } + + /** + * Returns a IPersonalAttributeList of the mandatory attributes in this map. + * + * @return an IPersonalAttributeList of the mandatory attributes contained in this map. + */ + public IPersonalAttributeList getSimpleValueAttributes() { + LOG.info("get simple attributes"); + IPersonalAttributeList attrList = new PersonalAttributeList(); + for(PersonalAttribute attr: this) { + if(attr.getComplexValue().isEmpty()) { + attrList.put(attr.getName(), attr); + LOG.info("adding simple attribute:"+attr.getName()); + } + } + return attrList; + } + + + + /** + * Returns a IPersonalAttributeList of the mandatory attributes in this map. + * + * @return an IPersonalAttributeList of the mandatory attributes contained in this map. + */ + public IPersonalAttributeList getMandatoryAttributes() { + return getAttributesByParam(true); + } + + + /** + * Returns a IPersonalAttributeList of the attributes in this map by parameter value. + * + * @param compareValue The boolean to get mandatory (true) or optional (false) attributes. + * + * @return an IPersonalAttributeList of the mandatory attributes contained in this map if compareValue is true or optional otherwise. + */ + private IPersonalAttributeList getAttributesByParam(final boolean compareValue) { + LOG.info("get attributes by param :"+compareValue); + IPersonalAttributeList attrList = new PersonalAttributeList(); + for(PersonalAttribute attr: this) { + if(attr.isRequired() == compareValue) { + attrList.put(attr.getName(), attr); + LOG.info("adding attribute:"+attr.getName()); + } + } + return attrList; + } + + + /** + * Returns a IPersonalAttributeList of the optional attributes in this map. + * + * @return an IPersonalAttributeList of the optional attributes contained in this map. + */ + public IPersonalAttributeList getOptionalAttributes() { + return getAttributesByParam(false); + } + + /** + * {@inheritDoc} + */ + public boolean hasMissingValues() { + for(PersonalAttribute attr: this) { + if(attr.isEmptyValue() && attr.isEmptyComplexValue()) { + return true; + } + } + return false; + } +} \ No newline at end of file diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java index 33160f2ac..65936f1a8 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryRequest.java @@ -17,9 +17,12 @@ public class STORKAttrQueryRequest implements Serializable, Cloneable { /** The samlId. */ private String samlId; - + /** The destination. */ private String destination; + + /** The assertion consumer service url. */ + private String serviceURL; /** The distinguished name. */ private String distinguishedName; @@ -215,6 +218,24 @@ public class STORKAttrQueryRequest implements Serializable, Cloneable { this.qaa = qaaLevel; } + /** + * Getter for the serviceURL value. + * + * @return The serviceURL value. + */ + public String getAssertionConsumerServiceURL() { + return serviceURL; + } + + /** + * Setter for the serviceURL value. + * + * @param newServiceURL the assertion consumer service URL. + */ + public void setAssertionConsumerServiceURL(final String newServiceURL) { + this.serviceURL = newServiceURL; + } + /** * Getter for the destination value. * diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java index 215b978dc..4e40d6d01 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAttrQueryResponse.java @@ -13,8 +13,11 @@ */ package eu.stork.peps.auth.commons; +import java.util.List; + import org.apache.log4j.Logger; import org.joda.time.DateTime; +import org.opensaml.saml2.core.Assertion; public class STORKAttrQueryResponse { @@ -51,6 +54,18 @@ public class STORKAttrQueryResponse { /** Country. */ private String country; + /** The complete assertion **/ + private Assertion assertion; + + /** List of all assertions in response **/ + private List assertions; + + /** The complete list from all assertions **/ + private transient IPersonalAttributeList totalAttributeList = new PersonalAttributeList(); + + /** All personal attribute lists **/ + private List attributeLists; + /** Citizen's personal attribute list. */ private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); @@ -297,5 +312,77 @@ public class STORKAttrQueryResponse { this.notBefore = nBefore; } + /** Get the assertion from the response **/ + public Assertion getAssertion() { + return assertion; + } + + /** Set the assertion in the response **/ + public void setAssertion(final Assertion nAssertion) { + this.assertion = nAssertion; + } + + public void setAssertions(List newAssert) { + this.assertions = newAssert; + } + + public List getAssertions() { + return assertions; + } + + /** + * Getter for the toal pal value. + * + * @return The total pal value. + * + * @see PersonalAttributeList + */ + public IPersonalAttributeList getTotalPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) totalAttributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the total Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setTotalPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.totalAttributeList = attrList; + } + } + + /** + * Getter for personal attribute lists + * + * @return The lists + * + * @see PersonalAttributeList + */ + public List getPersonalAttributeLists() { + return attributeLists; + } + + /** + * Setter for the Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setPersonalAttributeLists(final List attrLists) { + if (attrLists != null) { + this.attributeLists = attrLists; + } + } + } diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java index aa98974f6..84fadd023 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKAuthnResponse.java @@ -13,8 +13,11 @@ */ package eu.stork.peps.auth.commons; +import java.util.List; + import org.apache.log4j.Logger; import org.joda.time.DateTime; +import org.opensaml.saml2.core.Assertion; /** * This class is a bean used to store the information relative to the @@ -62,7 +65,16 @@ public final class STORKAuthnResponse { /** Citizen's personal attribute list. */ private transient IPersonalAttributeList attributeList = new PersonalAttributeList(); - + + /** List of all assertions in response **/ + private List assertions; + + /** The complete list from all assertions **/ + private transient IPersonalAttributeList totalAttributeList = new PersonalAttributeList(); + + /** All personal attribute lists **/ + private List attributeLists; + /** * Logger object. */ @@ -306,4 +318,66 @@ public final class STORKAuthnResponse { this.notBefore = nBefore; } + public void setAssertions(List newAssert) { + this.assertions = newAssert; + } + + public List getAssertions() { + return assertions; + } + + /** + * Getter for the toal pal value. + * + * @return The total pal value. + * + * @see PersonalAttributeList + */ + public IPersonalAttributeList getTotalPersonalAttributeList() { + IPersonalAttributeList personnalAttributeList = null; + try { + personnalAttributeList = (IPersonalAttributeList) totalAttributeList.clone(); + } catch (CloneNotSupportedException e1) { + LOG.trace("[PersonalAttribute] Nothing to do."); + } + return personnalAttributeList; + } + + /** + * Setter for the total Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setTotalPersonalAttributeList(final IPersonalAttributeList attrList) { + if (attrList != null) { + this.totalAttributeList = attrList; + } + } + + /** + * Getter for personal attribute lists + * + * @return The lists + * + * @see PersonalAttributeList + */ + public List getPersonalAttributeLists() { + return attributeLists; + } + + /** + * Setter for the Personal Attribute List value. + * + * @param attrList the new value. + * + * @see PersonalAttributeList + */ + public void setPersonalAttributeLists(final List attrLists) { + if (attrLists != null) { + this.attributeLists = attrLists; + } + } + } diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutRequest.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutRequest.java new file mode 100644 index 000000000..44811aee2 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutRequest.java @@ -0,0 +1,197 @@ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +public class STORKLogoutRequest implements Serializable, Cloneable { + private static final long serialVersionUID = 4778480781609392750L; + + /** The samlId. */ + private String samlId; + + /** The destination. */ + private String destination; + + /** The distinguished name. */ + private String distinguishedName; + + /** The qaa. */ + private int qaa; + + /** The token saml. */ + private byte[] tokenSaml = new byte[0]; + + /** The issuer. */ + private String issuer; + + /** The country. */ + private String country; + + /** The Alias used at the keystore for saving this certificate. */ + private String alias; + + /** The ID of principal as known to SP **/ + private String spProvidedId; + + /** + * Gets the SP's Certificate Alias. + * + * @return alias The SP's Certificate Alias. + */ + public String getAlias() { + return alias; + } + + /** + * Sets the SP's Certificate Alias. + * + * @param nAlias The SP's Certificate Alias. + */ + public void setAlias(final String nAlias) { + this.alias = nAlias; + } + + /** + * Gets the issuer. + * + * @return The issuer value. + */ + public String getIssuer() { + return issuer; + } + + /** + * Sets the issuer. + * + * @param samlIssuer the new issuer value. + */ + public void setIssuer(final String samlIssuer) { + this.issuer = samlIssuer; + } + + /** + * Gets the SAML Token. + * + * @return The SAML Token value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Sets the SAML Token. + * + * @param samlToken The new SAML Token value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Gets the country. + * + * @return The country value. + */ + public String getCountry() { + return country; + } + + /** + * Sets the country. + * + * @param nCountry the new country value. + */ + public void setCountry(final String nCountry) { + this.country = nCountry; + } + + /** + * Getter for the qaa value. + * + * @return The qaa value value. + */ + public int getQaa() { + return qaa; + } + + /** + * Setter for the qaa value. + * + * @param qaaLevel The new qaa value. + */ + public void setQaa(final int qaaLevel) { + this.qaa = qaaLevel; + } + + /** + * Getter for the destination value. + * + * @return The destination value. + */ + public String getDestination() { + return destination; + } + + /** + * Setter for the destination value. + * + * @param detination the new destination value. + */ + public void setDestination(final String detination) { + this.destination = detination; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param newSamlId the new samlId value. + */ + public void setSamlId(final String newSamlId) { + this.samlId = newSamlId; + } + + /** + * Getter for the distinguishedName value. + * + * @return The distinguishedName value. + */ + public String getDistinguishedName() { + return distinguishedName; + } + + /** + * Setter for the distinguishedName value. + * + * @param certDN the distinguished name value. + */ + public void setDistinguishedName(final String certDN) { + this.distinguishedName = certDN; + } + + /** Getter for spProvidedId **/ + public String getSpProvidedId() { + return spProvidedId; + } + + public void setSpProvidedId(final String nSpProvidedId) { + this.spProvidedId = nSpProvidedId; + } + + @Override + public Object clone() throws CloneNotSupportedException{ + STORKLogoutRequest storkLogoutRequest = null; + storkLogoutRequest = (STORKLogoutRequest) super.clone(); + storkLogoutRequest.setTokenSaml(getTokenSaml()); + return storkLogoutRequest; + } +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutResponse.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutResponse.java new file mode 100644 index 000000000..21b53a652 --- /dev/null +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/STORKLogoutResponse.java @@ -0,0 +1,250 @@ +package eu.stork.peps.auth.commons; + +import java.io.Serializable; + +public class STORKLogoutResponse implements Serializable, Cloneable { + private static final long serialVersionUID = 4778480781609392750L; + + /** The samlId. */ + private String samlId; + + /** The destination. */ + private String destination; + + /** The distinguished name. */ + private String distinguishedName; + + /** The token saml. */ + private byte[] tokenSaml = new byte[0]; + + /** The issuer. */ + private String issuer; + + /** The country. */ + private String country; + + /** The Alias used at the keystore for saving this certificate. */ + private String alias; + + /** Status code. */ + private String statusCode; + + /** Secondary status code. */ + private String subStatusCode; + + /** Status message. */ + private String statusMessage; + + /** Logout failed? */ + private boolean fail; + + /** + * Gets the SP's Certificate Alias. + * + * @return alias The SP's Certificate Alias. + */ + public String getAlias() { + return alias; + } + + /** + * Sets the SP's Certificate Alias. + * + * @param nAlias The SP's Certificate Alias. + */ + public void setAlias(final String nAlias) { + this.alias = nAlias; + } + + /** + * Gets the issuer. + * + * @return The issuer value. + */ + public String getIssuer() { + return issuer; + } + + /** + * Sets the issuer. + * + * @param samlIssuer the new issuer value. + */ + public void setIssuer(final String samlIssuer) { + this.issuer = samlIssuer; + } + + /** + * Gets the SAML Token. + * + * @return The SAML Token value. + */ + public byte[] getTokenSaml() { + return tokenSaml.clone(); + } + + /** + * Sets the SAML Token. + * + * @param samlToken The new SAML Token value. + */ + public void setTokenSaml(final byte[] samlToken) { + if (samlToken != null) { + this.tokenSaml = samlToken.clone(); + } + } + + /** + * Gets the country. + * + * @return The country value. + */ + public String getCountry() { + return country; + } + + /** + * Sets the country. + * + * @param nCountry the new country value. + */ + public void setCountry(final String nCountry) { + this.country = nCountry; + } + + /** + * Getter for the destination value. + * + * @return The destination value. + */ + public String getDestination() { + return destination; + } + + /** + * Setter for the destination value. + * + * @param detination the new destination value. + */ + public void setDestination(final String detination) { + this.destination = detination; + } + + /** + * Getter for the samlId value. + * + * @return The samlId value. + */ + public String getSamlId() { + return samlId; + } + + /** + * Setter for the samlId value. + * + * @param newSamlId the new samlId value. + */ + public void setSamlId(final String newSamlId) { + this.samlId = newSamlId; + } + + /** + * Getter for the distinguishedName value. + * + * @return The distinguishedName value. + */ + public String getDistinguishedName() { + return distinguishedName; + } + + /** + * Setter for the distinguishedName value. + * + * @param certDN the distinguished name value. + */ + public void setDistinguishedName(final String certDN) { + this.distinguishedName = certDN; + } + + + /** + * Getter for the fail value. + * + * @return The fail value. + */ + public boolean isFail() { + return fail; + } + + /** + * Setter for the fail value. + * + * @param failVal the new fail value. + */ + public void setFail(final boolean failVal) { + this.fail = failVal; + } + + /** + * Getter for the statusCode value. + * + * @return The statusCode value. + */ + public String getStatusCode() { + return statusCode; + } + + /** + * Getter for the subStatusCode. + * + * @return The subStatusCode value. + */ + public String getSubStatusCode() { + return subStatusCode; + } + + /** + * Setter for the subStatusCode. + * + * @param samlSubStatusCode the new subStatusCode value. + */ + public void setSubStatusCode(final String samlSubStatusCode) { + this.subStatusCode = samlSubStatusCode; + } + + /** + * Setter for the statusMessage value. + * + * @param status the new statusMessage value. + */ + public void setStatusMessage(final String status) { + this.statusMessage = status; + } + + /** + * Getter for the statusMessage value. + * + * @return The statusMessage value. + */ + public String getStatusMessage() { + return statusMessage; + } + + /** + * Setter for the statusCode value. + * + * @param status the new statusCode value. + */ + public void setStatusCode(final String status) { + this.statusCode = status; + } + + @Override + public Object clone() throws CloneNotSupportedException{ + STORKLogoutResponse storkLogoutResponse = null; + storkLogoutResponse = (STORKLogoutResponse) super.clone(); + storkLogoutResponse.setTokenSaml(getTokenSaml()); + return storkLogoutResponse; + } + +} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops deleted file mode 100644 index 14f05b17c..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/all-wcprops +++ /dev/null @@ -1,53 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 96 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions -END -InvalidParameterPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 131 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidParameterPEPSException.java -END -SecurityPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 123 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/SecurityPEPSException.java -END -InvalidSessionPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 129 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InvalidSessionPEPSException.java -END -package-info.java -K 25 -svn:wc:ra_dav:version-url -V 114 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/package-info.java -END -CPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 116 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/CPEPSException.java -END -StorkPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 120 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/StorkPEPSException.java -END -AbstractPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 123 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/AbstractPEPSException.java -END -InternalErrorPEPSException.java -K 25 -svn:wc:ra_dav:version-url -V 128 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions/InternalErrorPEPSException.java -END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries deleted file mode 100644 index c2ced14f4..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/entries +++ /dev/null @@ -1,300 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth/commons/exceptions -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -CPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -5d3cb4a7303baeaf2104aaa7da301b21 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -3570 - -StorkPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -fea01f750728ea5f15b449acb517f4b2 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1690 - -AbstractPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -c9aedb030e6dbc9f002c7cd3d52cf03f -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -4422 - -InternalErrorPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -36d8f6310e84c550f65bef78d5dc4238 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -2471 - -InvalidParameterPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -c6ad53378b03a346ca0fc48a381ed771 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1800 - -SecurityPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -78d50b78a69cb0c630e4e14420e3b7be -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -2199 - -InvalidSessionPEPSException.java -file - - - - -2013-12-20T12:27:56.626475Z -5fd7f04ad6f6cc121084e682b2a4e678 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1555 - -package-info.java -file - - - - -2013-12-20T12:27:56.626475Z -7055c01b74382c525c7fcf110646d8fc -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -129 - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base deleted file mode 100644 index e9a96d7c2..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/AbstractPEPSException.java.svn-base +++ /dev/null @@ -1,173 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -import java.io.Serializable; - -/** - * Abstract class to represent the various PEPS exceptions. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ - */ -public abstract class AbstractPEPSException extends RuntimeException implements - Serializable { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = -1884417567740138022L; - - /** - * Error code. - */ - private String errorCode; - - /** - * Error message. - */ - private String errorMessage; - - /** - * SAML token. - */ - private String samlTokenFail; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param code The error code value. - * @param message The error message value. - */ - public AbstractPEPSException(final String code, final String message) { - - super(message); - this.errorCode = code; - this.errorMessage = message; - } - - /** - * Exception Constructor with the errorMessage as parameters and the Throwable - * cause. - * - * @param message The error message value. - * @param cause The throwable object. - */ - public AbstractPEPSException(final String message, final Throwable cause) { - - super(message, cause); - this.errorMessage = message; - } - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters and the Throwable cause. - * - * @param code The error code value. - * @param message The error message value. - * @param cause The throwable object. - */ - public AbstractPEPSException(final String code, final String message, - final Throwable cause) { - - super(message, cause); - this.errorCode = code; - this.errorMessage = message; - } - - /** - * Exception Constructor with three Strings representing the errorCode, - * errorMessage and encoded samlToken as parameters. - * - * @param code The error code value. - * @param message The error message value. - * @param samlToken The error SAML Token. - */ - public AbstractPEPSException(final String code, final String message, - final String samlToken) { - - super(message); - this.errorCode = code; - this.errorMessage = message; - this.samlTokenFail = samlToken; - } - - /** - * Constructor with SAML Token as argument. Error message and error code are - * embedded in the SAML. - * - * @param samlToken The error SAML Token. - */ - public AbstractPEPSException(final String samlToken) { - super(); - this.samlTokenFail = samlToken; - } - - /** - * Getter for errorCode. - * - * @return The errorCode value. - */ - public final String getErrorCode() { - return errorCode; - } - - /** - * Setter for errorCode. - * - * @param code The error code value. - */ - public final void setErrorCode(final String code) { - this.errorCode = code; - } - - /** - * Getter for errorMessage. - * - * @return The error Message value. - */ - public final String getErrorMessage() { - return errorMessage; - } - - /** - * Setter for errorMessage. - * - * @param message The error message value. - */ - public final void setErrorMessage(final String message) { - this.errorMessage = message; - } - - /** - * Getter for SAMLTokenFail. - * - * @return The error SAML Token. - */ - public final String getSamlTokenFail() { - return samlTokenFail; - } - - /** - * Setter for SAMLTokenFail. - * - * @param samlToken The error SAML token. - */ - public final void setSamlTokenFail(final String samlToken) { - this.samlTokenFail = samlToken; - } -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base deleted file mode 100644 index 69cb20fdd..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/CPEPSException.java.svn-base +++ /dev/null @@ -1,143 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -/** - * This exception is thrown by the C-PEPS service and holds the relative - * information to present to the citizen. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.9 $, $Date: 2010-11-17 05:15:28 $ - */ -public final class CPEPSException extends RuntimeException { - - /** - * Serial id. - */ - private static final long serialVersionUID = -4012295047127999362L; - - /** - * Error code. - */ - private String errorCode; - - /** - * Error message. - */ - private String errorMessage; - - /** - * SAML token. - */ - private String samlTokenFail; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param samlToken The SAML Token. - * @param code The error code value. - * @param message The error message value. - */ - public CPEPSException(final String samlToken, final String code, - final String message) { - - super(message); - this.setErrorCode(code); - this.setErrorMessage(message); - this.setSamlTokenFail(samlToken); - } - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param samlToken The SAML Token. - * @param code The error code value. - * @param message The error message value. - * @param cause The original exception; - */ - public CPEPSException(final String samlToken, final String code, - final String message, final Throwable cause) { - - super(message, cause); - this.setErrorCode(code); - this.setErrorMessage(message); - this.setSamlTokenFail(samlToken); - } - - /** - * {@inheritDoc} - */ - public String getMessage() { - return this.getErrorMessage() + " (" + this.getErrorCode() + ")"; - } - - /** - * Getter for the error code. - * - * @return The errorCode value. - */ - public String getErrorCode() { - return errorCode; - } - - /** - * Setter for the error code. - * - * @param code The error code. - */ - public void setErrorCode(final String code) { - this.errorCode = code; - } - - /** - * Getter for the error message. - * - * @return The errorMessage value. - */ - public String getErrorMessage() { - return errorMessage; - } - - /** - * Setter for the error message. - * - * @param message The error message. - */ - public void setErrorMessage(final String message) { - this.errorMessage = message; - } - - /** - * Getter for the samlTokenFail. - * - * @return The samlTokenFail value. - */ - public String getSamlTokenFail() { - return samlTokenFail; - } - - /** - * Setter for the samlTokenFail. - * - * @param samlToken The error Saml Token. - */ - public void setSamlTokenFail(final String samlToken) { - this.samlTokenFail = samlToken; - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base deleted file mode 100644 index 67514d4fe..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InternalErrorPEPSException.java.svn-base +++ /dev/null @@ -1,74 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -/** - * Internal Error Exception class. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.13 $, $Date: 2010-11-17 05:15:28 $ - * - * @see AbstractPEPSException - */ -public final class InternalErrorPEPSException extends AbstractPEPSException { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 1193001455410319795L; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters and the Throwable cause. - * - * @param errorCode The error code value. - * @param errorMessage The error message value. - * @param cause The throwable object. - */ - public InternalErrorPEPSException(final String errorCode, - final String errorMessage, final Throwable cause) { - - super(errorCode, errorMessage, cause); - } - - /** - * Exception Constructor with three strings representing the errorCode, - * errorMessage and encoded samlToken as parameters. - * - * @param errorCode The error code value. - * @param errorMessage The error message value. - * @param samlTokenFail The error SAML Token. - */ - public InternalErrorPEPSException(final String errorCode, - final String errorMessage, final String samlTokenFail) { - - super(errorCode, errorMessage, samlTokenFail); - } - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param errorCode The error code value. - * @param errorMessage The error message value. - */ - public InternalErrorPEPSException(final String errorCode, - final String errorMessage) { - - super(errorCode, errorMessage); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base deleted file mode 100644 index 12c83b589..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidParameterPEPSException.java.svn-base +++ /dev/null @@ -1,54 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -/** - * Invalid Parameter Exception class. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.11 $, $Date: 2010-11-17 05:15:28 $ - * - * @see InvalidParameterPEPSException - */ -public class InvalidParameterPEPSException extends AbstractPEPSException { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 2046282148740524875L; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param errorCode The error code value. - * @param errorMessage The error code message value. - */ - public InvalidParameterPEPSException(final String errorCode, - final String errorMessage) { - super(errorCode, errorMessage); - } - - /** - * Exception Constructor with one String representing the encoded samlToken. - * - * @param samlTokenFail The error SAML Token. - */ - public InvalidParameterPEPSException(final String samlTokenFail) { - super(samlTokenFail); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base deleted file mode 100644 index 800525eee..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/InvalidSessionPEPSException.java.svn-base +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -/** - * Invalid session Exception class. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.14 $, $Date: 2010-11-17 05:15:28 $ - * - * @see InvalidParameterPEPSException - */ -public class InvalidSessionPEPSException extends InvalidParameterPEPSException { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 7147090160978319016L; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param errorCode The error code value. - * @param errorMessage The error message value. - */ - public InvalidSessionPEPSException(final String errorCode, - final String errorMessage) { - - super(errorCode, errorMessage); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base deleted file mode 100644 index fc27371d2..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/SecurityPEPSException.java.svn-base +++ /dev/null @@ -1,67 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -/** - * Security PEPS Exception class. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.18 $, $Date: 2010-11-17 05:15:28 $ - * - * @see AbstractPEPSException - */ -public final class SecurityPEPSException extends AbstractPEPSException { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 5605743302478554967L; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param errorCode The error code value. - * @param errorMsg The error message value. - */ - public SecurityPEPSException(final String errorCode, final String errorMsg) { - super(errorCode, errorMsg); - } - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters and the Throwable cause. - * - * @param errorCode The error code value. - * @param errorMessage The error message value. - * @param cause The throwable object. - */ - public SecurityPEPSException(final String errorCode, - final String errorMessage, final Throwable cause) { - - super(errorCode, errorMessage, cause); - } - - /** - * Exception Constructor with one String representing the encoded samlToken. - * - * @param samlTokenFail The error SAML Token. - */ - public SecurityPEPSException(final String samlTokenFail) { - super(samlTokenFail); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base deleted file mode 100644 index a2da61a02..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/StorkPEPSException.java.svn-base +++ /dev/null @@ -1,53 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.commons.exceptions; - -/** - * Security PEPS Exception class. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com, - * paulo.ribeiro@multicert.com - * @version $Revision: 1.15 $, $Date: 2010-11-17 05:15:28 $ - * - * @see AbstractPEPSException - */ -public final class StorkPEPSException extends AbstractPEPSException { - - /** - * Unique identifier. - */ - private static final long serialVersionUID = 8048033129798427574L; - - /** - * Exception Constructor with two Strings representing the errorCode and - * errorMessage as parameters. - * - * @param errorCode The error code value. - * @param errorMsg The error message value. - */ - public StorkPEPSException(final String errorCode, final String errorMsg) { - super(errorCode, errorMsg); - } - - /** - * {@inheritDoc} - */ - public String getMessage() { - - return "Security Error (" + this.getErrorCode() + ") processing request : " - + this.getErrorMessage(); - } - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base deleted file mode 100644 index d83068beb..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/commons/exceptions/.svn/text-base/package-info.java.svn-base +++ /dev/null @@ -1,7 +0,0 @@ -/** - * Package for the PEPS’ Exceptions handling. - * - * @since 1.0 - */ -package eu.stork.peps.auth.commons.exceptions; - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops deleted file mode 100644 index d23abebd4..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/all-wcprops +++ /dev/null @@ -1,41 +0,0 @@ -K 25 -svn:wc:ra_dav:version-url -V 86 -/CITnet/svn/STORK2/!svn/ver/73/trunk/Commons/src/main/java/eu/stork/peps/auth/specific -END -ICheckAttributeValue.java -K 25 -svn:wc:ra_dav:version-url -V 112 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/ICheckAttributeValue.java -END -IDeriveAttribute.java -K 25 -svn:wc:ra_dav:version-url -V 108 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/IDeriveAttribute.java -END -IAUService.java -K 25 -svn:wc:ra_dav:version-url -V 102 -/CITnet/svn/STORK2/!svn/ver/73/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java -END -INormaliseValue.java -K 25 -svn:wc:ra_dav:version-url -V 107 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/INormaliseValue.java -END -ITranslatorService.java -K 25 -svn:wc:ra_dav:version-url -V 110 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java -END -package-info.java -K 25 -svn:wc:ra_dav:version-url -V 104 -/CITnet/svn/STORK2/!svn/ver/19/trunk/Commons/src/main/java/eu/stork/peps/auth/specific/package-info.java -END diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries deleted file mode 100644 index a23f672b5..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/entries +++ /dev/null @@ -1,232 +0,0 @@ -10 - -dir -357 -https://webgate.ec.europa.eu/CITnet/svn/STORK2/trunk/Commons/src/main/java/eu/stork/peps/auth/specific -https://webgate.ec.europa.eu/CITnet/svn/STORK2 - - - -2013-10-28T11:11:01.095477Z -73 -emlelisst - - - - - - - - - - - - - - -aa842e49-f825-43fc-93ba-11ee9fd5a035 - -ITranslatorService.java -file - - - - -2013-12-20T12:27:56.654475Z -e36bd20ddfb7e165262a4a7891440fc9 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -3144 - -package-info.java -file - - - - -2013-12-20T12:27:56.654475Z -eef7721d55c2edb02a432fc08ae9e487 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -164 - -ICheckAttributeValue.java -file - - - - -2013-12-20T12:27:56.654475Z -b0472ff15d1c86f175da134b0f0eda71 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1321 - -IDeriveAttribute.java -file - - - - -2013-12-20T12:27:56.654475Z -dce3856a97583f739cdf50ca78491277 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1504 - -IAUService.java -file - - - - -2013-12-20T12:27:56.654475Z -254f57923746e205391672afffc04313 -2013-10-28T11:11:01.095477Z -73 -emlelisst - - - - - - - - - - - - - - - - - - - - - -6011 - -INormaliseValue.java -file - - - - -2013-12-20T12:27:56.654475Z -09f6e376875762fca294be4dfecb71f1 -2013-07-25T08:54:09.995385Z -7 -emsomavmi - - - - - - - - - - - - - - - - - - - - - -1237 - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base deleted file mode 100644 index 157c8f7b6..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IAUService.java.svn-base +++ /dev/null @@ -1,183 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.specific; - -import java.util.Map; - -import eu.stork.peps.auth.commons.IPersonalAttributeList; -import eu.stork.peps.auth.commons.IStorkSession; -import eu.stork.peps.auth.commons.STORKAttrQueryResponse; -import eu.stork.peps.auth.commons.STORKAuthnResponse; - -/** - * Interface for Specific Authentication methods. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com - */ -public interface IAUService { - - /** - * Prepares the citizen to be redirected to the IdP. - * - * @param personalList The Personal Attribute List. - * @param parameters The parameters. - * @param session The session object. - * @param requestAttributes The Requested attributes. - * - * @return byte[] containing a SAML Request. - * - * @see IPersonalAttributeList - * @see IStorkSession - */ - byte[] prepareCitizenAuthentication(IPersonalAttributeList personalList, - Map parameters, Map requestAttributes, - IStorkSession session); - - /** - * Authenticates a citizen. - * - * @param personalList The Personal Attribute List. - * @param parameters The parameters. - * @param requestAttributes The requested attributes. - * - * @return The updated Personal Attribute List. - * - * @see IPersonalAttributeList - */ - IPersonalAttributeList authenticateCitizen( - IPersonalAttributeList personalList, Map parameters, - Map requestAttributes); - - /** - * Prepares the Citizen browser to be redirected to the AP. - * - * @param personalList The Personal Attribute List. - * @param parameters The parameters. - * @param session The session object. - * @param requestAttributes The requested attributes. - * - * @return true in case of no error. - * - * @see IPersonalAttributeList - * @see IStorkSession - */ - boolean prepareAPRedirect(IPersonalAttributeList personalList, - Map parameters, Map requestAttributes, - IStorkSession session); - - /** - * Returns the attributes values from the AP. - * - * @param personalList The Personal Attribute List. - * @param parameters The parameters. - * @param requestAttributes The request attributes. - * - * @return The updated Personal Attribute List. - * - * @see IPersonalAttributeList - */ - IPersonalAttributeList getAttributesFromAttributeProviders( - IPersonalAttributeList personalList, Map parameters, - Map requestAttributes); - - /** - * Get the attributes from the AP with verification. - * - * @param personalList The Personal Attribute List. - * @param parameters The HTTP Parameters. - * @param requestAttributes The requested Attributes. - * @param session The session object. - * @param auProcessId The SAML identifier. - * - * @return true if the attributes were correctly verified. - * - * @see IPersonalAttributeList - * @see IStorkSession - */ - boolean getAttributesWithVerification(IPersonalAttributeList personalList, - Map parameters, Map requestAttributes, - IStorkSession session, String auProcessId); - - /** - * Validates a SAML Response. - * - * @param samlToken The SAML Token. - * @param session The session object. - * - * @return the STORKAuthnResponse associated with the validated response. - * - * @see IStorkSession - */ - STORKAuthnResponse processAuthenticationResponse(byte[] samlToken, - IStorkSession session); - - /** - * Generates a SAML Response in case of error. - * - * @param inResponseTo The SAML's identifier to response. - * @param issuer The issuer value. - * @param assertionURL The assertion URL. - * @param code The error code. - * @param subcode The sub error code. - * @param message The error message. - * @param ipUserAddress The user IP address. - * - * @return byte[] containing the SAML Response. - */ - byte[] generateErrorAuthenticationResponse(String inResponseTo, - String issuer, String assertionURL, String code, String subcode, - String message, String ipUserAddress); - - /** - * Compares two given personal attribute lists. - * - * @param original The original Personal Attribute List. - * @param modified The modified Personal Attribute List. - * @return true if the original list contains the modified one. False - * otherwise. - * - * @see IPersonalAttributeList - */ - boolean comparePersonalAttributeLists(IPersonalAttributeList original, - IPersonalAttributeList modified); - - /** - * Prepares the citizen to be redirected to the AtP. - * - * @param personalList The Personal Attribute List. - * @param parameters The parameters. - * @param session The session object. - * - * @return byte[] containing a SAML Request. - * - * @see IPersonalAttributeList - * @see IStorkSession - */ - byte[] prepareAttributeRequest(IPersonalAttributeList personalList, - Map parameters, IStorkSession session); - - /** - * Validates a SAML Response. - * - * @param samlToken The SAML Token. - * @param session The session object. - * - * @return the STORKAttrQueryResponse associated with the validated response. - * - * @see IStorkSession - */ - STORKAttrQueryResponse processAttributeResponse(byte[] samlToken, - IStorkSession session); -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base deleted file mode 100644 index 31a8d78ff..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ICheckAttributeValue.java.svn-base +++ /dev/null @@ -1,37 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.specific; - -import java.util.List; - -/** - * Interface that defines the methods to work with the validation of attributes. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com - */ -public interface ICheckAttributeValue { - - /** - * Checks if the list of values contains the expected value. - * - * @param values The List of values. - * @param expectedValue The value to check if it exists on the list. - * - * @return boolean true, if the value is present in the list. False, - * otherwise. - */ - boolean checkValue(List values, String expectedValue); - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base deleted file mode 100644 index 78eb53004..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/IDeriveAttribute.java.svn-base +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.specific; - -import eu.stork.peps.auth.commons.IStorkSession; -import eu.stork.peps.auth.commons.PersonalAttribute; - -/** - * Interface that defines the methods to work with derivation of attributes. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com - */ -public interface IDeriveAttribute { - - /** - * Derives the attribute value. Set the Personal Attribute value to null if - * the value in session or the value of age are invalid (non-numeric or null). - * - * @param personalAttrList The Personal Attribute List. - * @param session The session object. - * - * @see PersonalAttribute The personal Attribute - * @see IStorkSession The session object. - */ - void deriveAttributeToData(PersonalAttribute personalAttrList, - IStorkSession session); - -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base deleted file mode 100644 index ca2114e32..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/INormaliseValue.java.svn-base +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.specific; - -import eu.stork.peps.auth.commons.PersonalAttribute; - -/** - * Interface for attribute's value normalisation. - * - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com - */ -public interface INormaliseValue { - - /** - * Translates the attribute's value from local format to STORK format. - * - * @param personalAttribute The Personal Attribute to normalise the value. - * - * @see PersonalAttribute - */ - void normaliseAttributeValueToStork(PersonalAttribute personalAttribute); -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base deleted file mode 100644 index d4c152614..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/ITranslatorService.java.svn-base +++ /dev/null @@ -1,100 +0,0 @@ -/* - * This work is Open Source and licensed by the European Commission under the - * conditions of the European Public License v1.1 - * - * (http://www.osor.eu/eupl/european-union-public-licence-eupl-v.1.1); - * - * any use of this file implies acceptance of the conditions of this license. - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT - * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the - * License for the specific language governing permissions and limitations - * under the License. - */ -package eu.stork.peps.auth.specific; - -import eu.stork.peps.auth.commons.IPersonalAttributeList; -import eu.stork.peps.auth.commons.IStorkSession; -import eu.stork.peps.auth.commons.STORKAuthnRequest; - -/** - * Interface for attributes normalization. - * - * @author ricardo.ferreira@multicert.com, renato.portela@multicert.com, - * luis.felix@multicert.com, hugo.magalhaes@multicert.com - */ -public interface ITranslatorService { - - /** - * Translates the attributes from local format to STORK format. - * - * @param personalList The Personal Attribute List. - * - * @return The Personal Attribute List with normalised attributes. - * - * @see IPersonalAttributeList - */ - IPersonalAttributeList normaliseAttributeNamesToStork( - IPersonalAttributeList personalList); - - /** - * Translates the attributes values from local format to STORK format. - * - * @param personalList The Personal Attribute List. - * - * @return The PersonalAttributeList with normalised values. - * - * @see IPersonalAttributeList - */ - IPersonalAttributeList normaliseAttributeValuesToStork( - IPersonalAttributeList personalList); - - /** - * Translates the attributes from STORK format to local format. - * - * @param personalList The Personal Attribute List. - * - * @return The PersonalAttributeList with normalised attributes. - * - * @see IPersonalAttributeList - */ - IPersonalAttributeList normaliseAttributeNamesFromStork( - IPersonalAttributeList personalList); - - /** - * Derive Attribute Names To Stork format. - * - * @param personalList The Personal Attribute List, - * - * @return The PersonalAttributeList with derived attributes. - * - * @see IPersonalAttributeList - */ - IPersonalAttributeList deriveAttributeFromStork( - IPersonalAttributeList personalList); - - /** - * Derive Attribute Names from Stork format. - * - * @param session The session object. - * @param modifiedList The Personal Attribute List. - * - * @return The PersonalAttributeList with derived attributes. - * - * @see IStorkSession - * @see IPersonalAttributeList - */ - IPersonalAttributeList deriveAttributeToStork(IStorkSession session, - IPersonalAttributeList modifiedList); - - /** - * Validate the values of the attributes. - * - * @param authData The SAML's STORKAuthnRequest object. - * - * @return True, if all the attributes have values. False, otherwise. - * - * @see STORKAuthnRequest - */ - boolean checkAttributeValues(STORKAuthnRequest authData); -} diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base deleted file mode 100644 index a25c52311..000000000 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/.svn/text-base/package-info.java.svn-base +++ /dev/null @@ -1,8 +0,0 @@ -/** - * Specific PEPS Interfaces that implements functionality of the Authentication - * Service. - * - * @since 1.0 - */ -package eu.stork.peps.auth.specific; - diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java index 157c8f7b6..5c24cc5a8 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/IAUService.java @@ -45,6 +45,23 @@ public interface IAUService { Map parameters, Map requestAttributes, IStorkSession session); + /** + * Prepares the citizen to be redirected to the PV. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param session The session object. + * @param requestAttributes The Requested attributes. + * + * @return byte[] containing a SAML Request. + * + * @see IPersonalAttributeList + * @see IStorkSession + */ + byte[] preparePVRequest(IPersonalAttributeList personalList, + Map parameters, Map requestAttributes, + IStorkSession session); + /** * Authenticates a citizen. * @@ -60,6 +77,21 @@ public interface IAUService { IPersonalAttributeList personalList, Map parameters, Map requestAttributes); + /** + * Validates a power. + * + * @param personalList The Personal Attribute List. + * @param parameters The parameters. + * @param requestAttributes The requested attributes. + * + * @return The updated Personal Attribute List (power validated). + * + * @see IPersonalAttributeList + */ + IPersonalAttributeList powerValidation( + IPersonalAttributeList personalList, Map parameters, + Map requestAttributes); + /** * Prepares the Citizen browser to be redirected to the AP. * diff --git a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java index d4c152614..8a33897d8 100644 --- a/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java +++ b/id/server/stork2-commons/src/main/java/eu/stork/peps/auth/specific/ITranslatorService.java @@ -90,11 +90,11 @@ public interface ITranslatorService { /** * Validate the values of the attributes. * - * @param authData The SAML's STORKAuthnRequest object. + * @param pal The attribute list * * @return True, if all the attributes have values. False, otherwise. * * @see STORKAuthnRequest */ - boolean checkAttributeValues(STORKAuthnRequest authData); + boolean checkAttributeValues(IPersonalAttributeList pa); } -- cgit v1.2.3