From f71531346c6be197957311712ba093e024545e37 Mon Sep 17 00:00:00 2001 From: Florian Reimair Date: Fri, 7 Aug 2015 13:24:09 +0200 Subject: preparing the old code for the merge --- .../auth/engine/core/AuthenticationAttributes.java | 46 +- .../peps/auth/engine/core/CitizenCountryCode.java | 45 +- .../auth/engine/core/CustomAttributeQuery.java | 72 +- .../engine/core/CustomRequestAbstractType.java | 327 ++++---- .../peps/auth/engine/core/EIDCrossBorderShare.java | 56 +- .../peps/auth/engine/core/EIDCrossSectorShare.java | 54 +- .../peps/auth/engine/core/EIDSectorShare.java | 55 +- .../stork/peps/auth/engine/core/QAAAttribute.java | 67 +- .../peps/auth/engine/core/RequestedAttribute.java | 215 ++--- .../peps/auth/engine/core/RequestedAttributes.java | 38 +- .../eu/stork/peps/auth/engine/core/SAMLCore.java | 145 ++-- .../peps/auth/engine/core/SAMLEngineSignI.java | 105 +-- .../stork/peps/auth/engine/core/SPApplication.java | 53 +- .../eu/stork/peps/auth/engine/core/SPCountry.java | 53 +- .../java/eu/stork/peps/auth/engine/core/SPID.java | 45 +- .../stork/peps/auth/engine/core/SPInformation.java | 45 +- .../stork/peps/auth/engine/core/SPInstitution.java | 53 +- .../eu/stork/peps/auth/engine/core/SPSector.java | 53 +- .../stork/peps/auth/engine/core/STORKSAMLCore.java | 888 ++++++++++----------- .../engine/core/VIDPAuthenticationAttributes.java | 75 +- .../core/impl/AuthenticationAttributesBuilder.java | 54 +- .../core/impl/AuthenticationAttributesImpl.java | 145 ++-- .../impl/AuthenticationAttributesUnmarshaller.java | 15 +- .../core/impl/CitizenCountryCodeBuilder.java | 42 +- .../engine/core/impl/CitizenCountryCodeImpl.java | 91 ++- .../core/impl/CitizenCountryCodeMarshaller.java | 26 +- .../core/impl/CitizenCountryCodeUnmarshaller.java | 23 +- .../core/impl/CustomAttributeQueryBuilder.java | 25 +- .../engine/core/impl/CustomAttributeQueryImpl.java | 62 +- .../core/impl/CustomAttributeQueryMarshaller.java | 69 +- .../impl/CustomAttributeQueryUnmarshaller.java | 165 ++-- .../core/impl/EIDCrossBorderShareBuilder.java | 16 +- .../engine/core/impl/EIDCrossBorderShareImpl.java | 96 ++- .../core/impl/EIDCrossBorderShareMarshaller.java | 14 +- .../core/impl/EIDCrossBorderShareUnmarshaller.java | 13 +- .../core/impl/EIDCrossSectorShareBuilder.java | 46 +- .../engine/core/impl/EIDCrossSectorShareImpl.java | 95 ++- .../core/impl/EIDCrossSectorShareMarshaller.java | 13 +- .../core/impl/EIDCrossSectorShareUnmarshaller.java | 15 +- .../engine/core/impl/EIDSectorShareBuilder.java | 45 +- .../auth/engine/core/impl/EIDSectorShareImpl.java | 100 +-- .../engine/core/impl/EIDSectorShareMarshaller.java | 12 +- .../core/impl/EIDSectorShareUnmarshaller.java | 14 +- .../auth/engine/core/impl/QAAAttributeBuilder.java | 46 +- .../auth/engine/core/impl/QAAAttributeImpl.java | 93 +-- .../engine/core/impl/QAAAttributeMarshaller.java | 26 +- .../engine/core/impl/QAAAttributeUnmarshaller.java | 23 +- .../core/impl/RequestedAttributeBuilder.java | 51 +- .../engine/core/impl/RequestedAttributeImpl.java | 365 ++++----- .../core/impl/RequestedAttributeMarshaller.java | 76 +- .../core/impl/RequestedAttributeUnmarshaller.java | 98 ++- .../core/impl/RequestedAttributesBuilder.java | 51 +- .../engine/core/impl/RequestedAttributesImpl.java | 121 ++- .../core/impl/RequestedAttributesMarshaller.java | 12 +- .../core/impl/RequestedAttributesUnmarshaller.java | 37 +- .../engine/core/impl/SPApplicationBuilder.java | 45 +- .../auth/engine/core/impl/SPApplicationImpl.java | 93 +-- .../engine/core/impl/SPApplicationMarshaller.java | 27 +- .../core/impl/SPApplicationUnmarshaller.java | 24 +- .../auth/engine/core/impl/SPCountryBuilder.java | 44 +- .../peps/auth/engine/core/impl/SPCountryImpl.java | 89 ++- .../auth/engine/core/impl/SPCountryMarshaller.java | 26 +- .../engine/core/impl/SPCountryUnmarshaller.java | 24 +- .../peps/auth/engine/core/impl/SPIDBuilder.java | 42 +- .../stork/peps/auth/engine/core/impl/SPIDImpl.java | 91 ++- .../peps/auth/engine/core/impl/SPIDMarshaller.java | 26 +- .../auth/engine/core/impl/SPIDUnmarshaller.java | 23 +- .../engine/core/impl/SPInformationBuilder.java | 19 +- .../auth/engine/core/impl/SPInformationImpl.java | 145 ++-- .../engine/core/impl/SPInformationMarshaller.java | 12 +- .../core/impl/SPInformationUnmarshaller.java | 41 +- .../engine/core/impl/SPInstitutionBuilder.java | 45 +- .../auth/engine/core/impl/SPInstitutionImpl.java | 95 +-- .../engine/core/impl/SPInstitutionMarshaller.java | 27 +- .../core/impl/SPInstitutionUnmarshaller.java | 23 +- .../auth/engine/core/impl/SPSectorBuilder.java | 42 +- .../peps/auth/engine/core/impl/SPSectorImpl.java | 93 ++- .../auth/engine/core/impl/SPSectorMarshaller.java | 26 +- .../engine/core/impl/SPSectorUnmarshaller.java | 24 +- .../stork/peps/auth/engine/core/impl/SignHW.java | 717 ++++++++--------- .../auth/engine/core/impl/SignModuleFactory.java | 54 +- .../stork/peps/auth/engine/core/impl/SignP12.java | 300 +++---- .../stork/peps/auth/engine/core/impl/SignSW.java | 866 ++++++++++---------- .../impl/VIDPAuthenticationAttributesBuilder.java | 19 +- .../impl/VIDPAuthenticationAttributesImpl.java | 174 ++-- .../VIDPAuthenticationAttributesMarshaller.java | 12 +- .../VIDPAuthenticationAttributesUnmarshaller.java | 45 +- .../validator/CustomAttributeQueryValidator.java | 65 +- .../core/validator/ExtensionsSchemaValidator.java | 46 +- .../MultipleAssertionResponseValidator.java | 85 +- .../validator/QAAAttributeSchemaValidator.java | 20 +- 91 files changed, 4045 insertions(+), 4189 deletions(-) (limited to 'id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core') diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/AuthenticationAttributes.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/AuthenticationAttributes.java index a9efe6362..3821f3c06 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/AuthenticationAttributes.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/AuthenticationAttributes.java @@ -21,37 +21,35 @@ import org.opensaml.common.SAMLObject; /** * The Interface AuthenticationAttributes. + * * @author fjquevedo */ public interface AuthenticationAttributes extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "AuthenticationAttributes"; - - /** Default element name. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "AuthenticationAttributes"; - /** Local name of the XSI type. */ - String TYPE_LOCAL_NAME = "AuthenticationAttributesType"; + /** Default element name. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - /** QName of the XSI type. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** Local name of the XSI type. */ + String TYPE_LOCAL_NAME = "AuthenticationAttributesType"; + /** QName of the XSI type. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - /** - * Gets the citizen country code. - * - * @return the citizen country code - */ - VIDPAuthenticationAttributes getVIDPAuthenticationAttributes(); - + /** + * Gets the citizen country code. + * + * @return the citizen country code + */ + VIDPAuthenticationAttributes getVIDPAuthenticationAttributes(); - /** - * Sets the vIDP authentication attributes. - * - * @param newVIDPAuthenticationAttr the new vIDP authentication attributes - */ - void setVIDPAuthenticationAttributes(VIDPAuthenticationAttributes newVIDPAuthenticationAttr); + /** + * Sets the vIDP authentication attributes. + * + * @param newVIDPAuthenticationAttr + * the new vIDP authentication attributes + */ + void setVIDPAuthenticationAttributes(VIDPAuthenticationAttributes newVIDPAuthenticationAttr); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CitizenCountryCode.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CitizenCountryCode.java index 4af7524ea..95994695d 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CitizenCountryCode.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CitizenCountryCode.java @@ -21,36 +21,35 @@ import org.opensaml.common.SAMLObject; /** * The Interface EIDCrossBorderShare. + * * @author fjquevedo */ public interface CitizenCountryCode extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "CitizenCountryCode"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "CitizenCountryCode"; - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "CitizenCountryCodeType"; + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "CitizenCountryCodeType"; - /** - * Gets the SP country. - * - * @return the sP country - */ - String getCitizenCountryCode(); + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + /** + * Gets the SP country. + * + * @return the sP country + */ + String getCitizenCountryCode(); - /** - * Sets the citizen country code. - * - * @param citizenCountryCode the new citizen country code - */ - void setCitizenCountryCode(String citizenCountryCode); + /** + * Sets the citizen country code. + * + * @param citizenCountryCode + * the new citizen country code + */ + void setCitizenCountryCode(String citizenCountryCode); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomAttributeQuery.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomAttributeQuery.java index b558fc19d..d603c2293 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomAttributeQuery.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomAttributeQuery.java @@ -10,42 +10,40 @@ import org.opensaml.saml2.core.SubjectQuery; public interface CustomAttributeQuery extends CustomRequestAbstractType { /** Element local name. */ - public static final String DEFAULT_ELEMENT_LOCAL_NAME = "AttributeQuery"; - - /** Default element name. */ - public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20P_NS, DEFAULT_ELEMENT_LOCAL_NAME, - SAMLConstants.SAML20P_PREFIX); - - /** Local name of the XSI type. */ - public static final String TYPE_LOCAL_NAME = "CustomAttributeQueryType"; - - /** QName of the XSI type. */ - public static final QName TYPE_NAME = new QName(SAMLConstants.SAML20P_NS, TYPE_LOCAL_NAME, - SAMLConstants.SAML20P_PREFIX); - - /** AssertionConsumerServiceURL attribute name. */ - public static final String ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME - = "AssertionConsumerServiceURL"; - - /** - * Gets the Attributes of this query. - * - * @return the list of Attributes of this query - */ - public List getAttributes(); - - /** - * Gets the Subject of this request. - * - * @return the Subject of this request - */ - public Subject getSubject(); - - /** - * Sets the Subject of this request. - * - * @param newSubject the Subject of this request - */ - public void setSubject(Subject newSubject); + public static final String DEFAULT_ELEMENT_LOCAL_NAME = "AttributeQuery"; + + /** Default element name. */ + public static final QName DEFAULT_ELEMENT_NAME = new QName(SAMLConstants.SAML20P_NS, DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + + /** Local name of the XSI type. */ + public static final String TYPE_LOCAL_NAME = "CustomAttributeQueryType"; + + /** QName of the XSI type. */ + public static final QName TYPE_NAME = new QName(SAMLConstants.SAML20P_NS, TYPE_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + + /** AssertionConsumerServiceURL attribute name. */ + public static final String ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME = "AssertionConsumerServiceURL"; + + /** + * Gets the Attributes of this query. + * + * @return the list of Attributes of this query + */ + public List getAttributes(); + + /** + * Gets the Subject of this request. + * + * @return the Subject of this request + */ + public Subject getSubject(); + + /** + * Sets the Subject of this request. + * + * @param newSubject + * the Subject of this request + */ + public void setSubject(Subject newSubject); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomRequestAbstractType.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomRequestAbstractType.java index 77dd8c4a5..2dd36a4d9 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomRequestAbstractType.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/CustomRequestAbstractType.java @@ -10,167 +10,172 @@ import org.opensaml.saml2.common.Extensions; import org.opensaml.saml2.core.Issuer; public interface CustomRequestAbstractType extends SignableSAMLObject { - + /** Local name of the XSI type. */ - public static final String TYPE_LOCAL_NAME = "RequestAbstractType"; - - /** QName of the XSI type. */ - public static final QName TYPE_NAME = new QName(SAMLConstants.SAML20P_NS, TYPE_LOCAL_NAME, - SAMLConstants.SAML20P_PREFIX); - - /** ID attribute name. */ - public static final String ID_ATTRIB_NAME = "ID"; - - /** Version attribute name. */ - public static final String VERSION_ATTRIB_NAME = "Version"; - - /** IssueInstant attribute name. */ - public static final String ISSUE_INSTANT_ATTRIB_NAME = "IssueInstant"; - - /** Destination attribute name. */ - public static final String DESTINATION_ATTRIB_NAME = "Destination"; - - /** Destination attribute name. */ - public static final String ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME = "AssertionConsumerServiceURL"; - - /** Consent attribute name. */ - public static final String CONSENT_ATTRIB_NAME = "Consent"; - - /** Unspecified consent URI. */ - public static final String UNSPECIFIED_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:unspecified"; - - /** Obtained consent URI. */ - public static final String OBTAINED_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:obtained"; - - /** Prior consent URI. */ - public static final String PRIOR_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:prior"; - - /** Implicit consent URI. */ - public static final String IMPLICIT_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:current-implicit"; - - /** Explicit consent URI. */ - public static final String EXPLICIT_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:current-explicit"; - - /** Unavailable consent URI. */ - public static final String UNAVAILABLE_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:unavailable"; - - /** Inapplicable consent URI. */ - public static final String INAPPLICABLE_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:inapplicable"; - - /** - * Gets the SAML Version of this request. - * - * @return the SAML Version of this request. - */ - public SAMLVersion getVersion(); - - /** - * Sets the SAML Version of this request. - * - * @param newVersion the SAML Version of this request - */ - public void setVersion(SAMLVersion newVersion); - - /** - * Gets the unique identifier of the request. - * - * @return the unique identifier of the request - */ - public String getID(); - - /** - * Sets the unique identifier of the request. - * - * @param newID the unique identifier of the request - */ - - public void setID(String newID); - - /** - * Gets the date/time the request was issued. - * - * @return the date/time the request was issued - */ - - public DateTime getIssueInstant(); - - /** - * Sets the date/time the request was issued. - * - * @param newIssueInstant the date/time the request was issued - */ - public void setIssueInstant(DateTime newIssueInstant); - - /** - * Gets the URI of the destination of the request. - * - * @return the URI of the destination of the request - */ - public String getDestination(); - - /** - * Sets the URI of the destination of the request. - * - * @param newDestination the URI of the destination of the request - */ - public void setDestination(String newDestination); - - /** - * Sets the index of the particular Assertion Consumer Service to which the response to this request should be - * delivered. - * - * @param newAssertionConsumerServiceIndex the new value of the AssertionConsumerServiceIndex attribute - */ - public void setAssertionConsumerServiceURL(String newServiceUrl); - - /** - * Gets the URL of the particular Assertion Consumer Service to which the response to this request should be - * delivered. - * - * @return the value of the AssertionConsumerServiceURL attribute - */ - public String getAssertionConsumerServiceURL(); - - /** - * Gets the consent obtained from the principal for sending this request. - * - * @return the consent obtained from the principal for sending this request - */ - public String getConsent(); - - /** - * Sets the consent obtained from the principal for sending this request. - * - * @param newConsent the new consent obtained from the principal for sending this request - */ - public void setConsent(String newConsent); - - /** - * Gets the issuer of this request. - * - * @return the issuer of this request - */ - public Issuer getIssuer(); - - /** - * Sets the issuer of this request. - * - * @param newIssuer the issuer of this request - */ - public void setIssuer(Issuer newIssuer); - - /** - * Gets the Extensions of this request. - * - * @return the Status of this request - */ - public Extensions getExtensions(); - - /** - * Sets the Extensions of this request. - * - * @param newExtensions the Extensions of this request - */ - public void setExtensions(Extensions newExtensions); + public static final String TYPE_LOCAL_NAME = "RequestAbstractType"; + + /** QName of the XSI type. */ + public static final QName TYPE_NAME = new QName(SAMLConstants.SAML20P_NS, TYPE_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + + /** ID attribute name. */ + public static final String ID_ATTRIB_NAME = "ID"; + + /** Version attribute name. */ + public static final String VERSION_ATTRIB_NAME = "Version"; + + /** IssueInstant attribute name. */ + public static final String ISSUE_INSTANT_ATTRIB_NAME = "IssueInstant"; + + /** Destination attribute name. */ + public static final String DESTINATION_ATTRIB_NAME = "Destination"; + + /** Destination attribute name. */ + public static final String ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME = "AssertionConsumerServiceURL"; + + /** Consent attribute name. */ + public static final String CONSENT_ATTRIB_NAME = "Consent"; + + /** Unspecified consent URI. */ + public static final String UNSPECIFIED_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:unspecified"; + + /** Obtained consent URI. */ + public static final String OBTAINED_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:obtained"; + + /** Prior consent URI. */ + public static final String PRIOR_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:prior"; + + /** Implicit consent URI. */ + public static final String IMPLICIT_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:current-implicit"; + + /** Explicit consent URI. */ + public static final String EXPLICIT_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:current-explicit"; + + /** Unavailable consent URI. */ + public static final String UNAVAILABLE_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:unavailable"; + + /** Inapplicable consent URI. */ + public static final String INAPPLICABLE_CONSENT = "urn:oasis:names:tc:SAML:2.0:consent:inapplicable"; + + /** + * Gets the SAML Version of this request. + * + * @return the SAML Version of this request. + */ + public SAMLVersion getVersion(); + + /** + * Sets the SAML Version of this request. + * + * @param newVersion + * the SAML Version of this request + */ + public void setVersion(SAMLVersion newVersion); + + /** + * Gets the unique identifier of the request. + * + * @return the unique identifier of the request + */ + public String getID(); + + /** + * Sets the unique identifier of the request. + * + * @param newID + * the unique identifier of the request + */ + + public void setID(String newID); + + /** + * Gets the date/time the request was issued. + * + * @return the date/time the request was issued + */ + + public DateTime getIssueInstant(); + + /** + * Sets the date/time the request was issued. + * + * @param newIssueInstant + * the date/time the request was issued + */ + public void setIssueInstant(DateTime newIssueInstant); + + /** + * Gets the URI of the destination of the request. + * + * @return the URI of the destination of the request + */ + public String getDestination(); + + /** + * Sets the URI of the destination of the request. + * + * @param newDestination + * the URI of the destination of the request + */ + public void setDestination(String newDestination); + + /** + * Sets the index of the particular Assertion Consumer Service to which the response to this request should be delivered. + * + * @param newAssertionConsumerServiceIndex + * the new value of the AssertionConsumerServiceIndex attribute + */ + public void setAssertionConsumerServiceURL(String newServiceUrl); + + /** + * Gets the URL of the particular Assertion Consumer Service to which the response to this request should be delivered. + * + * @return the value of the AssertionConsumerServiceURL attribute + */ + public String getAssertionConsumerServiceURL(); + + /** + * Gets the consent obtained from the principal for sending this request. + * + * @return the consent obtained from the principal for sending this request + */ + public String getConsent(); + + /** + * Sets the consent obtained from the principal for sending this request. + * + * @param newConsent + * the new consent obtained from the principal for sending this request + */ + public void setConsent(String newConsent); + + /** + * Gets the issuer of this request. + * + * @return the issuer of this request + */ + public Issuer getIssuer(); + + /** + * Sets the issuer of this request. + * + * @param newIssuer + * the issuer of this request + */ + public void setIssuer(Issuer newIssuer); + + /** + * Gets the Extensions of this request. + * + * @return the Status of this request + */ + public Extensions getExtensions(); + + /** + * Sets the Extensions of this request. + * + * @param newExtensions + * the Extensions of this request + */ + public void setExtensions(Extensions newExtensions); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossBorderShare.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossBorderShare.java index 03541ece1..423f0f342 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossBorderShare.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossBorderShare.java @@ -21,38 +21,36 @@ import org.opensaml.common.SAMLObject; /** * The Interface EIDCrossBorderShare. + * * @author fjquevedo */ public interface EIDCrossBorderShare extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "eIDCrossBorderShare"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "eIDCrossBorderShareType"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - - /** - * Gets the eID cross border share. - * - * @return the eID cross border share - */ - String getEIDCrossBorderShare(); - - - /** - * Sets the eID cross border share. - * - * @param eIDCrossBorderShare the new eID cross border share - */ - void setEIDCrossBorderShare(String eIDCrossBorderShare); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "eIDCrossBorderShare"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "eIDCrossBorderShareType"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** + * Gets the eID cross border share. + * + * @return the eID cross border share + */ + String getEIDCrossBorderShare(); + + /** + * Sets the eID cross border share. + * + * @param eIDCrossBorderShare + * the new eID cross border share + */ + void setEIDCrossBorderShare(String eIDCrossBorderShare); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossSectorShare.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossSectorShare.java index 14c504510..260f91046 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossSectorShare.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDCrossSectorShare.java @@ -21,36 +21,36 @@ import org.opensaml.common.SAMLObject; /** * The Interface EIDCrossSectorShare. + * * @author fjquevedo */ public interface EIDCrossSectorShare extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String ELEM_LOCAL_NAME = "eIDCrossSectorShare"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), ELEM_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "eIDCrossSectorShareType"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - /** - * Gets the eID cross sector share. - * - * @return the eID cross sector share - */ - String getEIDCrossSectorShare(); - - /** - * Sets the eID cross sector share. - * - * @param eIDCrossSectorShare the new eID cross sector share - */ - void setEIDCrossSectorShare(String eIDCrossSectorShare); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String ELEM_LOCAL_NAME = "eIDCrossSectorShare"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), ELEM_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "eIDCrossSectorShareType"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** + * Gets the eID cross sector share. + * + * @return the eID cross sector share + */ + String getEIDCrossSectorShare(); + + /** + * Sets the eID cross sector share. + * + * @param eIDCrossSectorShare + * the new eID cross sector share + */ + void setEIDCrossSectorShare(String eIDCrossSectorShare); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDSectorShare.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDSectorShare.java index 0202f000c..a5748d5f1 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDSectorShare.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/EIDSectorShare.java @@ -21,37 +21,36 @@ import org.opensaml.common.SAMLObject; /** * The Interface EIDSectorShare. + * * @author fjquevedo */ public interface EIDSectorShare extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "eIDSectorShare"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "eIDSectorShare"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - - /** - * Gets the eID sector share. - * - * @return the eID sector share - */ - String getEIDSectorShare(); - - /** - * Sets the eID sector share. - * - * @param eIDSectorShare the new eID sector share - */ - void setEIDSectorShare(String eIDSectorShare); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "eIDSectorShare"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "eIDSectorShare"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** + * Gets the eID sector share. + * + * @return the eID sector share + */ + String getEIDSectorShare(); + + /** + * Sets the eID sector share. + * + * @param eIDSectorShare + * the new eID sector share + */ + void setEIDSectorShare(String eIDSectorShare); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/QAAAttribute.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/QAAAttribute.java index d99d23896..22d472be9 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/QAAAttribute.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/QAAAttribute.java @@ -26,38 +26,37 @@ import org.opensaml.common.SAMLObject; */ public interface QAAAttribute extends SAMLObject { - /** Element local name. */ - String DEF_LOCAL_NAME = "QualityAuthenticationAssuranceLevel"; - - /** Default element name. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** Local name of the XSI type. */ - String TYPE_LOCAL_NAME = "QualityAuthenticationAssuranceLevelAbstractType"; - - /** QName of the XSI type. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** The minimum value allowed. */ - int MIN_VALUE = 1; - - /** The Max value allowed. */ - int MAX_VALUE = 4; - - /** - * Gets the qAA level. - * - * @return the qAA level - */ - String getQaaLevel(); - - /** - * Sets the qAA level. - * - * @param qaaLevel the new qAA level - * - */ - void setQaaLevel(String qaaLevel); + /** Element local name. */ + String DEF_LOCAL_NAME = "QualityAuthenticationAssuranceLevel"; + + /** Default element name. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** Local name of the XSI type. */ + String TYPE_LOCAL_NAME = "QualityAuthenticationAssuranceLevelAbstractType"; + + /** QName of the XSI type. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** The minimum value allowed. */ + int MIN_VALUE = 1; + + /** The Max value allowed. */ + int MAX_VALUE = 4; + + /** + * Gets the qAA level. + * + * @return the qAA level + */ + String getQaaLevel(); + + /** + * Sets the qAA level. + * + * @param qaaLevel + * the new qAA level + * + */ + void setQaaLevel(String qaaLevel); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttribute.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttribute.java index ffd32b3cf..955f6bef9 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttribute.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttribute.java @@ -29,112 +29,113 @@ import org.opensaml.xml.XMLObject; * * @author fjquevedo */ -public interface RequestedAttribute extends SAMLObject, - AttributeExtensibleXMLObject { - - /** Element local name. */ - String DEF_LOCAL_NAME = "RequestedAttribute"; - - /** Default element name. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** Local name of the XSI type. */ - String TYPE_LOCAL_NAME = "RequestedAttributeAbstractType"; - - /** QName of the XSI type. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** NAME_ATTRIB_NAME attribute name. */ - String NAME_ATTRIB_NAME = "Name"; - - /** NAME_FORMAT_ATTRIB_NAME attribute name. */ - String NAME_FORMAT_ATTR = "NameFormat"; - - /** IS_REQUIRED_ATTRIB_NAME attribute name. */ - String IS_REQUIRED_ATTR = "isRequired"; - - /** FRIENDLY_NAME_ATTRIB_NAME attribute name. */ - String FRIENDLY_NAME_ATT = "FriendlyName"; - - /** Unspecified attribute format ID. */ - String UNSPECIFIED = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"; - - /** URI reference attribute format ID. */ - String URI_REFERENCE = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"; - - /** Basic attribute format ID. */ - String BASIC = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"; - - /** - * Gets the name. - * - * @return the name - */ - String getName(); - - /** - * Sets the name. - * - * @param name the new name - */ - void setName(String name); - - /** - * Gets the name format. - * - * @return the name format - */ - String getNameFormat(); - - /** - * Sets the name format. - * - * @param nameFormat the new name format - */ - void setNameFormat(String nameFormat); - - /** - * Gets the friendly name. - * - * @return the friendly name - */ - String getFriendlyName(); - - /** - * Sets the friendly name. - * - * @param friendlyName the new friendly name - */ - void setFriendlyName(String friendlyName); - - /** - * Gets the checks if is required. - * - * @return the checks if is required - */ - String isRequired(); - - /** - * Gets the checks if is required xs boolean. - * - * @return the checks if is required xs boolean - */ - String getIsRequiredXSBoolean(); - - /** - * Sets the checks if is required. - * - * @param newIsRequired the new checks if is required - */ - void setIsRequired(String newIsRequired); - - /** - * Gets the attribute values. - * - * @return the attribute values - */ - List getAttributeValues(); +public interface RequestedAttribute extends SAMLObject, AttributeExtensibleXMLObject { + + /** Element local name. */ + String DEF_LOCAL_NAME = "RequestedAttribute"; + + /** Default element name. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** Local name of the XSI type. */ + String TYPE_LOCAL_NAME = "RequestedAttributeAbstractType"; + + /** QName of the XSI type. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** NAME_ATTRIB_NAME attribute name. */ + String NAME_ATTRIB_NAME = "Name"; + + /** NAME_FORMAT_ATTRIB_NAME attribute name. */ + String NAME_FORMAT_ATTR = "NameFormat"; + + /** IS_REQUIRED_ATTRIB_NAME attribute name. */ + String IS_REQUIRED_ATTR = "isRequired"; + + /** FRIENDLY_NAME_ATTRIB_NAME attribute name. */ + String FRIENDLY_NAME_ATT = "FriendlyName"; + + /** Unspecified attribute format ID. */ + String UNSPECIFIED = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"; + + /** URI reference attribute format ID. */ + String URI_REFERENCE = "urn:oasis:names:tc:SAML:2.0:attrname-format:uri"; + + /** Basic attribute format ID. */ + String BASIC = "urn:oasis:names:tc:SAML:2.0:attrname-format:basic"; + + /** + * Gets the name. + * + * @return the name + */ + String getName(); + + /** + * Sets the name. + * + * @param name + * the new name + */ + void setName(String name); + + /** + * Gets the name format. + * + * @return the name format + */ + String getNameFormat(); + + /** + * Sets the name format. + * + * @param nameFormat + * the new name format + */ + void setNameFormat(String nameFormat); + + /** + * Gets the friendly name. + * + * @return the friendly name + */ + String getFriendlyName(); + + /** + * Sets the friendly name. + * + * @param friendlyName + * the new friendly name + */ + void setFriendlyName(String friendlyName); + + /** + * Gets the checks if is required. + * + * @return the checks if is required + */ + String isRequired(); + + /** + * Gets the checks if is required xs boolean. + * + * @return the checks if is required xs boolean + */ + String getIsRequiredXSBoolean(); + + /** + * Sets the checks if is required. + * + * @param newIsRequired + * the new checks if is required + */ + void setIsRequired(String newIsRequired); + + /** + * Gets the attribute values. + * + * @return the attribute values + */ + List getAttributeValues(); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttributes.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttributes.java index 6e3da28c3..4527bfdb6 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttributes.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/RequestedAttributes.java @@ -28,24 +28,22 @@ import org.opensaml.common.SAMLObject; */ public interface RequestedAttributes extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "RequestedAttributes"; - - /** Default element name. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - /** Local name of the XSI type. */ - String TYPE_LOCAL_NAME = "RequestedAttributesType"; - - /** QName of the XSI type. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); - - /** - * Gets the attributes. - * - * @return the attributes - */ - List getAttributes(); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "RequestedAttributes"; + + /** Default element name. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** Local name of the XSI type. */ + String TYPE_LOCAL_NAME = "RequestedAttributesType"; + + /** QName of the XSI type. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + + /** + * Gets the attributes. + * + * @return the attributes + */ + List getAttributes(); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLCore.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLCore.java index cbedcf7d9..922e7e61e 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLCore.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLCore.java @@ -22,77 +22,78 @@ package eu.stork.peps.auth.engine.core; */ public enum SAMLCore { - - /** The consent authentication request. */ - CONSENT_AUTHN_REQ("consentAuthnRequest"), - - /** The consent authentication response. */ - CONSENT_AUTHN_RES("consentAuthnResponse"), - - /** The FORC e_ auth n_ tag. */ - FORCE_AUTHN_TAG("forceAuthN"), - - /** The I s_ passiv e_ tag. */ - IS_PASSIVE_TAG("isPassive"), - - /** The FORMA t_ entity. */ - FORMAT_ENTITY("formatEntity"), - - /** The FRIENDLY name. */ - FRIENDLY_NAME("friendlyName"), - - /** The IS_REQUIRED AN ATTRIBUTE */ - IS_REQUIRED("isRequired"), - - /** The PRO t_ bindin g_ tag. */ - PROT_BINDING_TAG("protocolBinding"), - - /** The ASSER t_ con s_ tag. */ - ASSERT_CONS_TAG("assertionConsumerServiceURL"), - - /** The REQUESTE r_ tag. */ - REQUESTER_TAG("requester"), - - /** The RESPONDE r_ tag. */ - RESPONDER_TAG("responder"), - - /** The STOR k10_ ns. */ - STORK10_NS("urn:eu:stork:names:tc:STORK:1.0:assertion"), - - /** The STOR k10 p_ ns. */ - STORK10P_NS("urn:eu:stork:names:tc:STORK:1.0:protocol"), - - /** The STOR k10_ prefix. */ - STORK10_PREFIX("stork"), - - /** The STOR k10 p_ prefix. */ - STORK10P_PREFIX("storkp"), - - /** The STOR k10_ bas e_ uri. */ - STORK10_BASE_URI("http://www.stork.gov.eu/1.0/"), - - /** The ON e_ tim e_ use. */ - ONE_TIME_USE("oneTimeUse"); - - /** The value. */ - private String value; - - /** - * Instantiates a new sAML core. - * - * @param fullName the full name - */ - private SAMLCore(final String fullName) { - this.value = fullName; - } - - /** - * Gets the value. - * - * @return the value - */ - public String getValue() { - return value; - } + + /** The consent authentication request. */ + CONSENT_AUTHN_REQ("consentAuthnRequest"), + + /** The consent authentication response. */ + CONSENT_AUTHN_RES("consentAuthnResponse"), + + /** The FORC e_ auth n_ tag. */ + FORCE_AUTHN_TAG("forceAuthN"), + + /** The I s_ passiv e_ tag. */ + IS_PASSIVE_TAG("isPassive"), + + /** The FORMA t_ entity. */ + FORMAT_ENTITY("formatEntity"), + + /** The FRIENDLY name. */ + FRIENDLY_NAME("friendlyName"), + + /** The IS_REQUIRED AN ATTRIBUTE */ + IS_REQUIRED("isRequired"), + + /** The PRO t_ bindin g_ tag. */ + PROT_BINDING_TAG("protocolBinding"), + + /** The ASSER t_ con s_ tag. */ + ASSERT_CONS_TAG("assertionConsumerServiceURL"), + + /** The REQUESTE r_ tag. */ + REQUESTER_TAG("requester"), + + /** The RESPONDE r_ tag. */ + RESPONDER_TAG("responder"), + + /** The STOR k10_ ns. */ + STORK10_NS("urn:eu:stork:names:tc:STORK:1.0:assertion"), + + /** The STOR k10 p_ ns. */ + STORK10P_NS("urn:eu:stork:names:tc:STORK:1.0:protocol"), + + /** The STOR k10_ prefix. */ + STORK10_PREFIX("stork"), + + /** The STOR k10 p_ prefix. */ + STORK10P_PREFIX("storkp"), + + /** The STOR k10_ bas e_ uri. */ + STORK10_BASE_URI("http://www.stork.gov.eu/1.0/"), + + /** The ON e_ tim e_ use. */ + ONE_TIME_USE("oneTimeUse"); + + /** The value. */ + private String value; + + /** + * Instantiates a new sAML core. + * + * @param fullName + * the full name + */ + private SAMLCore(final String fullName) { + this.value = fullName; + } + + /** + * Gets the value. + * + * @return the value + */ + public String getValue() { + return value; + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLEngineSignI.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLEngineSignI.java index e846983d8..8474eeedc 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLEngineSignI.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SAMLEngineSignI.java @@ -30,59 +30,64 @@ import eu.stork.peps.exceptions.SAMLEngineException; */ public interface SAMLEngineSignI { - /** - * Sign. - * - * @param tokenSaml the token SAML - * - * @return the sAML object - * - * @throws SAMLEngineException the SAML engine exception - */ - SAMLObject sign(SignableSAMLObject tokenSaml) throws SAMLEngineException; + /** + * Sign. + * + * @param tokenSaml + * the token SAML + * + * @return the sAML object + * + * @throws SAMLEngineException + * the SAML engine exception + */ + SAMLObject sign(SignableSAMLObject tokenSaml) throws SAMLEngineException; - /** - * Gets the certificate. - * - * @return the certificate - */ - X509Certificate getCertificate(); + /** + * Gets the certificate. + * + * @return the certificate + */ + X509Certificate getCertificate(); - /** - * Gets the trustStore used when validating SAMLTokens - * - * @return the trustStore - * - */ + /** + * Gets the trustStore used when validating SAMLTokens + * + * @return the trustStore + * + */ KeyStore getTrustStore(); - - /** - * Validate signature. - * - * @param tokenSaml the token SAML - * - * @return the sAML object - * - * @throws SAMLEngineException the SAML engine exception - */ - SAMLObject validateSignature(SignableSAMLObject tokenSaml) - throws SAMLEngineException; - /** - * Initialize the signature module. - * - * @param fileConf the configuration file. - * - * @throws SAMLEngineException the STORKSAML engine runtime - * exception - */ - void init(String fileConf) throws SAMLEngineException; + /** + * Validate signature. + * + * @param tokenSaml + * the token SAML + * + * @return the sAML object + * + * @throws SAMLEngineException + * the SAML engine exception + */ + SAMLObject validateSignature(SignableSAMLObject tokenSaml) throws SAMLEngineException; + + /** + * Initialize the signature module. + * + * @param fileConf + * the configuration file. + * + * @throws SAMLEngineException + * the STORKSAML engine runtime exception + */ + void init(String fileConf) throws SAMLEngineException; + + /** + * Load cryptographic service provider. + * + * @throws SAMLEngineException + * the SAML engine exception + */ + void loadCryptServiceProvider() throws SAMLEngineException; - /** - * Load cryptographic service provider. - * - * @throws SAMLEngineException the SAML engine exception - */ - void loadCryptServiceProvider() throws SAMLEngineException; - } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPApplication.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPApplication.java index 9510bf790..82753b61f 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPApplication.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPApplication.java @@ -26,31 +26,30 @@ import org.opensaml.common.SAMLObject; */ public interface SPApplication extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "spApplication"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "spApplicationType"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** - * Gets the service provider application. - * - * @return the service provider application - */ - String getSPApplication(); - - /** - * Sets the service provider application. - * - * @param spApplication the new service provider application - */ - void setSPApplication(String spApplication); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "spApplication"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "spApplicationType"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** + * Gets the service provider application. + * + * @return the service provider application + */ + String getSPApplication(); + + /** + * Sets the service provider application. + * + * @param spApplication + * the new service provider application + */ + void setSPApplication(String spApplication); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPCountry.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPCountry.java index 829ace878..e04d817ca 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPCountry.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPCountry.java @@ -26,31 +26,30 @@ import org.opensaml.common.SAMLObject; */ public interface SPCountry extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "spCountry"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "spCountryType"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** - * Gets the service provider country. - * - * @return the service provider country - */ - String getSPCountry(); - - /** - * Sets the service provider country. - * - * @param spCountry the new service provider country - */ - void setSPCountry(String spCountry); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "spCountry"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "spCountryType"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** + * Gets the service provider country. + * + * @return the service provider country + */ + String getSPCountry(); + + /** + * Sets the service provider country. + * + * @param spCountry + * the new service provider country + */ + void setSPCountry(String spCountry); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPID.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPID.java index bd13f6dbf..8dad4d968 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPID.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPID.java @@ -21,36 +21,35 @@ import org.opensaml.common.SAMLObject; /** * The Interface EIDCrossBorderShare. + * * @author iinigo */ public interface SPID extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "SPID"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "SPID"; - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "SPIDType"; + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "SPIDType"; - /** - * Gets the SP ID. - * - * @return the SP ID - */ - String getSPID(); + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + /** + * Gets the SP ID. + * + * @return the SP ID + */ + String getSPID(); - /** - * Sets the SP ID. - * - * @param SPID the new SP ID - */ - void setSPID(String newSPID); + /** + * Sets the SP ID. + * + * @param SPID + * the new SP ID + */ + void setSPID(String newSPID); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInformation.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInformation.java index bc870c2cc..8ad5b6eef 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInformation.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInformation.java @@ -21,36 +21,35 @@ import org.opensaml.common.SAMLObject; /** * The Interface EIDCrossBorderShare. + * * @author iinigo */ public interface SPInformation extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "SPInformation"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "SPInformation"; - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "SPInformationType"; + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "SPInformationType"; - /** - * Gets the SP Id. - * - * @return the SP Id - */ - SPID getSPID(); + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + /** + * Gets the SP Id. + * + * @return the SP Id + */ + SPID getSPID(); - /** - * Sets the SP Id. - * - * @param newSPId the new SP Id - */ - void setSPID(SPID newSPID); + /** + * Sets the SP Id. + * + * @param newSPId + * the new SP Id + */ + void setSPID(SPID newSPID); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInstitution.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInstitution.java index add45023c..8a34a94ff 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInstitution.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPInstitution.java @@ -26,31 +26,30 @@ import org.opensaml.common.SAMLObject; */ public interface SPInstitution extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "spInstitution"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "spInstitutionType"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** - * Gets the service provider institution. - * - * @return the service provider institution - */ - String getSPInstitution(); - - /** - * Sets the service provider institution. - * - * @param spInstitution the new service provider institution - */ - void setSPInstitution(String spInstitution); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "spInstitution"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "spInstitutionType"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** + * Gets the service provider institution. + * + * @return the service provider institution + */ + String getSPInstitution(); + + /** + * Sets the service provider institution. + * + * @param spInstitution + * the new service provider institution + */ + void setSPInstitution(String spInstitution); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPSector.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPSector.java index 8322a0d47..4b8af10cf 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPSector.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/SPSector.java @@ -26,31 +26,30 @@ import org.opensaml.common.SAMLObject; */ public interface SPSector extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "spSector"; - - /** The Constant DEFAULT_ELEMENT_NAME. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** The Constant TYPE_LOCAL_NAME. */ - String TYPE_LOCAL_NAME = "spSectorType"; - - /** The Constant TYPE_NAME. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10_PREFIX.getValue()); - - /** - * Gets the service provider sector. - * - * @return the service provider sector - */ - String getSPSector(); - - /** - * Sets the service provider sector. - * - * @param spSector the new service provider sector - */ - void setSPSector(String spSector); + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "spSector"; + + /** The Constant DEFAULT_ELEMENT_NAME. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** The Constant TYPE_LOCAL_NAME. */ + String TYPE_LOCAL_NAME = "spSectorType"; + + /** The Constant TYPE_NAME. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10_PREFIX.getValue()); + + /** + * Gets the service provider sector. + * + * @return the service provider sector + */ + String getSPSector(); + + /** + * Sets the service provider sector. + * + * @param spSector + * the new service provider sector + */ + void setSPSector(String spSector); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/STORKSAMLCore.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/STORKSAMLCore.java index 4c314ae68..13d2f0af4 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/STORKSAMLCore.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/STORKSAMLCore.java @@ -34,475 +34,471 @@ import eu.stork.peps.exceptions.STORKSAMLEngineRuntimeException; */ public final class STORKSAMLCore { - /** The Constant LOGGER. */ - private static final Logger LOGGER = LoggerFactory - .getLogger(STORKSAMLCore.class.getName()); + /** The Constant LOGGER. */ + private static final Logger LOGGER = LoggerFactory.getLogger(STORKSAMLCore.class.getName()); - /** The consent authentication request. */ - private String consentAuthnReq = null; + /** The consent authentication request. */ + private String consentAuthnReq = null; - /** The consent authentication response. */ - private String consentAuthnResp = null; + /** The consent authentication response. */ + private String consentAuthnResp = null; - /** The id cross border share. */ - private String eIDCrossBordShare = null; + /** The id cross border share. */ + private String eIDCrossBordShare = null; - /** The e id cross sect share. */ - private String eIDCrossSectShare = null; + /** The e id cross sect share. */ + private String eIDCrossSectShare = null; - /** The e id sector share. */ - private String eIDSectorShare = null; + /** The e id sector share. */ + private String eIDSectorShare = null; - /** The format entity. */ - private String formatEntity = null; + /** The format entity. */ + private String formatEntity = null; - /** The friendly name. */ - private boolean friendlyName = false; + /** The friendly name. */ + private boolean friendlyName = false; - /** The IP validation. */ - private boolean ipValidation = false; + /** The IP validation. */ + private boolean ipValidation = false; - /** The one time use. */ - private boolean oneTimeUse = true; + /** The one time use. */ + private boolean oneTimeUse = true; - /** The protocol binding. */ - private String protocolBinding = null; + /** The protocol binding. */ + private String protocolBinding = null; - /** The requester. */ - private String requester = null; + /** The requester. */ + private String requester = null; + /** The responder. */ + private String responder = null; - /** The responder. */ - private String responder = null; + /** The SAML core properties. */ + private Properties samlCoreProp = null; - /** The SAML core properties. */ - private Properties samlCoreProp = null; + /** The time not on or after. */ + private Integer timeNotOnOrAfter = null; - /** The time not on or after. */ - private Integer timeNotOnOrAfter = null; + /** The is required parameter. */ + private boolean isRequired = true; - /** The is required parameter. */ - private boolean isRequired = true; + private static final String SAML_ENGINE_LITERAL = "SamlEngine.xml: "; - private static final String SAML_ENGINE_LITERAL = "SamlEngine.xml: "; - - /** - * Gets the isRequired. - * - * @return the isRequired - */ - public boolean isRequired() { - return isRequired; + /** + * Gets the isRequired. + * + * @return the isRequired + */ + public boolean isRequired() { + return isRequired; } - /** - * Sets the isRequired. - * - * @param isRequired the required. - */ + /** + * Sets the isRequired. + * + * @param isRequired + * the required. + */ public void setRequired(boolean isRequired) { this.isRequired = isRequired; } /** - * Instantiates a new sAML core. - * - * @param instance the instance - */ - public STORKSAMLCore(final Properties instance) { - loadConfiguration(instance); - } - - /** - * Gets the consent. - * - * @return the consent - */ - public String getConsentAuthnRequest() { - return consentAuthnReq; - } - - /** - * Gets the consent authentication response. - * - * @return the consent authentication response. - */ - public String getConsentAuthnResp() { - return consentAuthnResp; - } - - /** - * Gets the consent authentication response. - * - * @return the consent authentication response - */ - public String getConsentAuthnResponse() { - return consentAuthnResp; - } - - /** - * Gets the format entity. - * - * @return the format entity - */ - public String getFormatEntity() { - return formatEntity; - } - - /** - * Gets the property. - * - * @param key the key - * - * @return the property - */ - public String getProperty(final String key) { - return samlCoreProp.getProperty(key); - } - - /** - * Gets the protocol binding. - * - * @return the protocol binding - */ - public String getProtocolBinding() { - return protocolBinding; - } - - /** - * Gets the requester. - * - * @return the requester - */ - public String getRequester() { - return requester; - } - - /** - * Gets the responder. - * - * @return the responder - */ - public String getResponder() { - return responder; - } - - /** - * Gets the time not on or after. - * - * @return the time not on or after - */ - public Integer getTimeNotOnOrAfter() { - return timeNotOnOrAfter; - } - - /** - * Checks if is e id cross border share. - * - * @return true, if is e id cross border share - */ - public String iseIDCrossBorderShare() { - return eIDCrossBordShare; - } - - /** - * Checks if is e id cross border share. - * - * @return true, if is e id cross border share - */ - public String iseIDCrossBordShare() { - return eIDCrossBordShare; - } - - /** - * Checks if is e id cross sector share. - * - * @return true, if is e id cross sector share - */ - public String iseIDCrossSectorShare() { - return eIDCrossSectShare; - } - - /** - * Checks if is e id cross sect share. - * - * @return true, if is e id cross sect share - */ - public String iseIDCrossSectShare() { - return eIDCrossSectShare; - } - - /** - * Checks if is e id sector share. - * - * @return true, if is e id sector share - */ - public String iseIDSectorShare() { - return eIDSectorShare; - } - - /** - * Checks if is friendly name. - * - * @return true, if checks if is friendly name - */ - public boolean isFriendlyName() { - return friendlyName; - } - - /** - * Checks if is IP validation. - * - * @return true, if is IP validation - */ - public boolean isIpValidation() { - return ipValidation; - } - - /** - * Checks if is one time use. - * - * @return true, if is one time use - */ - public boolean isOneTimeUse() { - return oneTimeUse; - } - - /** - * Method that loads the configuration file for the SAML Engine. - * - * @param instance the instance of the Engine properties. - */ - private void loadConfiguration(final Properties instance) { - - try { - LOGGER.info("SAMLCore: Loading SAMLEngine properties."); - - samlCoreProp = instance; - - final String parameter = samlCoreProp - .getProperty(SAMLCore.FORMAT_ENTITY.getValue()); - - if ("entity".equalsIgnoreCase(parameter)) { - formatEntity = NameIDType.ENTITY; - } - - friendlyName = Boolean.valueOf(samlCoreProp - .getProperty(SAMLCore.FRIENDLY_NAME.getValue())); - - String isRequiredValue = samlCoreProp. - getProperty(SAMLCore.IS_REQUIRED.getValue()); - if (isRequiredValue != null) { - isRequired = Boolean.valueOf(isRequiredValue); - } - - eIDSectorShare = samlCoreProp - .getProperty("eIDSectorShare"); - eIDCrossSectShare = samlCoreProp - .getProperty("eIDCrossSectorShare"); - eIDCrossBordShare = samlCoreProp - .getProperty("eIDCrossBorderShare"); - - ipValidation = Boolean.valueOf(samlCoreProp - .getProperty("ipAddrValidation")); - - final String oneTimeUseProp = samlCoreProp - .getProperty(SAMLCore.ONE_TIME_USE.getValue()); - - if (StringUtils.isNotBlank(oneTimeUseProp)) { - oneTimeUse = Boolean.valueOf(oneTimeUseProp); - } - - // Protocol Binding - loadProtocolBiding(); - - // Consent Authentication Request - consentAuthnReq = samlCoreProp - .getProperty(SAMLCore.CONSENT_AUTHN_REQ.getValue()); - - if ("unspecified".equalsIgnoreCase(consentAuthnReq)) { - consentAuthnReq = RequestAbstractType.UNSPECIFIED_CONSENT; - } - - loadConsentAuthResp(); - - timeNotOnOrAfter = Integer.valueOf(samlCoreProp - .getProperty("timeNotOnOrAfter")); - - if (timeNotOnOrAfter.intValue() < 0) { - LOGGER.error(SAML_ENGINE_LITERAL + "timeNotOnOrAfter" - + " is negative number."); - - throw new SAMLEngineException(SAML_ENGINE_LITERAL - + "timeNotOnOrAfter" + " is negative number."); - } - - requester = samlCoreProp.getProperty(SAMLCore.REQUESTER_TAG.getValue()); - responder = samlCoreProp.getProperty(SAMLCore.RESPONDER_TAG.getValue()); - - } catch (SAMLEngineException e) { - LOGGER.error("SAMLCore: error loadConfiguration. ", e); - throw new STORKSAMLEngineRuntimeException(e); - } catch (RuntimeException e) { - LOGGER.error("SAMLCore: error loadConfiguration. ", e); - throw new STORKSAMLEngineRuntimeException(e); - } - } - - /** - * Load consent authentication response. - */ - private void loadConsentAuthResp() { - // Consent Authentication Response - consentAuthnResp = samlCoreProp - .getProperty(SAMLCore.CONSENT_AUTHN_RES.getValue()); - - if ("obtained".equalsIgnoreCase(consentAuthnResp)) { - consentAuthnResp = RequestAbstractType.OBTAINED_CONSENT; - } else if ("prior".equalsIgnoreCase(consentAuthnResp)) { - consentAuthnResp = RequestAbstractType.PRIOR_CONSENT; - } else if ("curent-implicit".equalsIgnoreCase(consentAuthnResp)) { - consentAuthnResp = - "urn:oasis:names:tc:SAML:2.0:consent:current-implicit"; - } else if ("curent-explicit".equalsIgnoreCase(consentAuthnResp)) { - consentAuthnResp = - "urn:oasis:names:tc:SAML:2.0:consent:current-explicit"; - } else if ("unspecified".equalsIgnoreCase(consentAuthnResp)) { - consentAuthnResp = RequestAbstractType.UNSPECIFIED_CONSENT; - } - } - - /** - * Load protocol biding. - * - * @throws SAMLEngineException the SAML engine exception - */ - private void loadProtocolBiding() throws SAMLEngineException { - // Protocol Binding - protocolBinding = samlCoreProp.getProperty(SAMLCore.PROT_BINDING_TAG.getValue()); - - if (StringUtils.isBlank(protocolBinding)) { - LOGGER.error(SAML_ENGINE_LITERAL + SAMLCore.PROT_BINDING_TAG - + " it's mandatory."); - throw new SAMLEngineException(SAML_ENGINE_LITERAL - + SAMLCore.PROT_BINDING_TAG + " it's mandatory."); - } else if (protocolBinding.equalsIgnoreCase("HTTP-POST")) { - protocolBinding = SAMLConstants.SAML2_POST_BINDING_URI; - } else { - LOGGER.error(SAML_ENGINE_LITERAL + SAMLCore.PROT_BINDING_TAG - + " it's not supporting."); - - throw new SAMLEngineException(SAML_ENGINE_LITERAL - + SAMLCore.PROT_BINDING_TAG + " it's not supporting."); - } - } - - /** - * Sets the consent authentication response. - * - * @param newConsAuthnResp the new consent authentication response - */ - public void setConsentAuthnResp(final String newConsAuthnResp) { - this.consentAuthnResp = newConsAuthnResp; - } - - /** - * Sets an eID that can be shared outside of the Service Provider’s member state. - * - * @param newEIDCrossBord the new eid cross border share - */ - public void setEIDCrossBordShare(final String newEIDCrossBord) { - this.eIDCrossBordShare = newEIDCrossBord; - } - - /** - * Sets an eID that can be shared outside of the Service Provider’s sector. - * - * @param newEIDCrossSect the new eid cross sect share - */ - public void setEIDCrossSectShare(final String newEIDCrossSect) { - this.eIDCrossSectShare = newEIDCrossSect; - } - - /** - * Sets an eID that can be shared within the Service Provider’s sector. - * - * @param newEIDSectorShare the new eid sector share - */ - public void seteIDSectorShare(final String newEIDSectorShare) { - this.eIDSectorShare = newEIDSectorShare; - } - - /** - * Sets the format entity. - * - * @param newFormatEntity the new format entity - */ - public void setFormatEntity(final String newFormatEntity) { - this.formatEntity = newFormatEntity; - } - - /** - * Sets the friendly name. - * - * @param newFriendlyName the new friendly name - */ - public void setFriendlyName(final boolean newFriendlyName) { - this.friendlyName = newFriendlyName; - } - - /** - * Sets the IP validation. - * - * @param newIpValidation the new IP validation - */ - public void setIpValidation(final boolean newIpValidation) { - this.ipValidation = newIpValidation; - } - - /** - * Sets the one time use. - * - * @param newOneTimeUse the new one time use - */ - public void setOneTimeUse(final boolean newOneTimeUse) { - this.oneTimeUse = newOneTimeUse; - } - - /** - * Sets the protocol binding. - * - * @param newProtBinding the new protocol binding - */ - public void setProtocolBinding(final String newProtBinding) { - this.protocolBinding = newProtBinding; - } - - /** - * Sets the requester. - * - * @param newRequester the new requester - */ - public void setRequester(final String newRequester) { - this.requester = newRequester; - } - - /** - * Sets the responder. - * - * @param newResponder the new responder - */ - public void setResponder(final String newResponder) { - this.responder = newResponder; - } - - /** - * Sets the time not on or after. - * - * @param newTimeNotOnOrAft the new time not on or after - */ - public void setTimeNotOnOrAfter(final Integer newTimeNotOnOrAft) { - this.timeNotOnOrAfter = newTimeNotOnOrAft; - } + * Instantiates a new sAML core. + * + * @param instance + * the instance + */ + public STORKSAMLCore(final Properties instance) { + loadConfiguration(instance); + } + + /** + * Gets the consent. + * + * @return the consent + */ + public String getConsentAuthnRequest() { + return consentAuthnReq; + } + + /** + * Gets the consent authentication response. + * + * @return the consent authentication response. + */ + public String getConsentAuthnResp() { + return consentAuthnResp; + } + + /** + * Gets the consent authentication response. + * + * @return the consent authentication response + */ + public String getConsentAuthnResponse() { + return consentAuthnResp; + } + + /** + * Gets the format entity. + * + * @return the format entity + */ + public String getFormatEntity() { + return formatEntity; + } + + /** + * Gets the property. + * + * @param key + * the key + * + * @return the property + */ + public String getProperty(final String key) { + return samlCoreProp.getProperty(key); + } + + /** + * Gets the protocol binding. + * + * @return the protocol binding + */ + public String getProtocolBinding() { + return protocolBinding; + } + + /** + * Gets the requester. + * + * @return the requester + */ + public String getRequester() { + return requester; + } + + /** + * Gets the responder. + * + * @return the responder + */ + public String getResponder() { + return responder; + } + + /** + * Gets the time not on or after. + * + * @return the time not on or after + */ + public Integer getTimeNotOnOrAfter() { + return timeNotOnOrAfter; + } + + /** + * Checks if is e id cross border share. + * + * @return true, if is e id cross border share + */ + public String iseIDCrossBorderShare() { + return eIDCrossBordShare; + } + + /** + * Checks if is e id cross border share. + * + * @return true, if is e id cross border share + */ + public String iseIDCrossBordShare() { + return eIDCrossBordShare; + } + + /** + * Checks if is e id cross sector share. + * + * @return true, if is e id cross sector share + */ + public String iseIDCrossSectorShare() { + return eIDCrossSectShare; + } + + /** + * Checks if is e id cross sect share. + * + * @return true, if is e id cross sect share + */ + public String iseIDCrossSectShare() { + return eIDCrossSectShare; + } + + /** + * Checks if is e id sector share. + * + * @return true, if is e id sector share + */ + public String iseIDSectorShare() { + return eIDSectorShare; + } + + /** + * Checks if is friendly name. + * + * @return true, if checks if is friendly name + */ + public boolean isFriendlyName() { + return friendlyName; + } + + /** + * Checks if is IP validation. + * + * @return true, if is IP validation + */ + public boolean isIpValidation() { + return ipValidation; + } + + /** + * Checks if is one time use. + * + * @return true, if is one time use + */ + public boolean isOneTimeUse() { + return oneTimeUse; + } + + /** + * Method that loads the configuration file for the SAML Engine. + * + * @param instance + * the instance of the Engine properties. + */ + private void loadConfiguration(final Properties instance) { + + try { + LOGGER.info("SAMLCore: Loading SAMLEngine properties."); + + samlCoreProp = instance; + + final String parameter = samlCoreProp.getProperty(SAMLCore.FORMAT_ENTITY.getValue()); + + if ("entity".equalsIgnoreCase(parameter)) { + formatEntity = NameIDType.ENTITY; + } + + friendlyName = Boolean.valueOf(samlCoreProp.getProperty(SAMLCore.FRIENDLY_NAME.getValue())); + + String isRequiredValue = samlCoreProp.getProperty(SAMLCore.IS_REQUIRED.getValue()); + if (isRequiredValue != null) { + isRequired = Boolean.valueOf(isRequiredValue); + } + + eIDSectorShare = samlCoreProp.getProperty("eIDSectorShare"); + eIDCrossSectShare = samlCoreProp.getProperty("eIDCrossSectorShare"); + eIDCrossBordShare = samlCoreProp.getProperty("eIDCrossBorderShare"); + + ipValidation = Boolean.valueOf(samlCoreProp.getProperty("ipAddrValidation")); + + final String oneTimeUseProp = samlCoreProp.getProperty(SAMLCore.ONE_TIME_USE.getValue()); + + if (StringUtils.isNotBlank(oneTimeUseProp)) { + oneTimeUse = Boolean.valueOf(oneTimeUseProp); + } + + // Protocol Binding + loadProtocolBiding(); + + // Consent Authentication Request + consentAuthnReq = samlCoreProp.getProperty(SAMLCore.CONSENT_AUTHN_REQ.getValue()); + + if ("unspecified".equalsIgnoreCase(consentAuthnReq)) { + consentAuthnReq = RequestAbstractType.UNSPECIFIED_CONSENT; + } + + loadConsentAuthResp(); + + timeNotOnOrAfter = Integer.valueOf(samlCoreProp.getProperty("timeNotOnOrAfter")); + + if (timeNotOnOrAfter.intValue() < 0) { + LOGGER.error(SAML_ENGINE_LITERAL + "timeNotOnOrAfter" + " is negative number."); + + throw new SAMLEngineException(SAML_ENGINE_LITERAL + "timeNotOnOrAfter" + " is negative number."); + } + + requester = samlCoreProp.getProperty(SAMLCore.REQUESTER_TAG.getValue()); + responder = samlCoreProp.getProperty(SAMLCore.RESPONDER_TAG.getValue()); + + } catch (SAMLEngineException e) { + LOGGER.error("SAMLCore: error loadConfiguration. ", e); + throw new STORKSAMLEngineRuntimeException(e); + } catch (RuntimeException e) { + LOGGER.error("SAMLCore: error loadConfiguration. ", e); + throw new STORKSAMLEngineRuntimeException(e); + } + } + + /** + * Load consent authentication response. + */ + private void loadConsentAuthResp() { + // Consent Authentication Response + consentAuthnResp = samlCoreProp.getProperty(SAMLCore.CONSENT_AUTHN_RES.getValue()); + + if ("obtained".equalsIgnoreCase(consentAuthnResp)) { + consentAuthnResp = RequestAbstractType.OBTAINED_CONSENT; + } else if ("prior".equalsIgnoreCase(consentAuthnResp)) { + consentAuthnResp = RequestAbstractType.PRIOR_CONSENT; + } else if ("curent-implicit".equalsIgnoreCase(consentAuthnResp)) { + consentAuthnResp = "urn:oasis:names:tc:SAML:2.0:consent:current-implicit"; + } else if ("curent-explicit".equalsIgnoreCase(consentAuthnResp)) { + consentAuthnResp = "urn:oasis:names:tc:SAML:2.0:consent:current-explicit"; + } else if ("unspecified".equalsIgnoreCase(consentAuthnResp)) { + consentAuthnResp = RequestAbstractType.UNSPECIFIED_CONSENT; + } + } + + /** + * Load protocol biding. + * + * @throws SAMLEngineException + * the SAML engine exception + */ + private void loadProtocolBiding() throws SAMLEngineException { + // Protocol Binding + protocolBinding = samlCoreProp.getProperty(SAMLCore.PROT_BINDING_TAG.getValue()); + + if (StringUtils.isBlank(protocolBinding)) { + LOGGER.error(SAML_ENGINE_LITERAL + SAMLCore.PROT_BINDING_TAG + " it's mandatory."); + throw new SAMLEngineException(SAML_ENGINE_LITERAL + SAMLCore.PROT_BINDING_TAG + " it's mandatory."); + } else if (protocolBinding.equalsIgnoreCase("HTTP-POST")) { + protocolBinding = SAMLConstants.SAML2_POST_BINDING_URI; + } else { + LOGGER.error(SAML_ENGINE_LITERAL + SAMLCore.PROT_BINDING_TAG + " it's not supporting."); + + throw new SAMLEngineException(SAML_ENGINE_LITERAL + SAMLCore.PROT_BINDING_TAG + " it's not supporting."); + } + } + + /** + * Sets the consent authentication response. + * + * @param newConsAuthnResp + * the new consent authentication response + */ + public void setConsentAuthnResp(final String newConsAuthnResp) { + this.consentAuthnResp = newConsAuthnResp; + } + + /** + * Sets an eID that can be shared outside of the Service Provider’s member state. + * + * @param newEIDCrossBord + * the new eid cross border share + */ + public void setEIDCrossBordShare(final String newEIDCrossBord) { + this.eIDCrossBordShare = newEIDCrossBord; + } + + /** + * Sets an eID that can be shared outside of the Service Provider’s sector. + * + * @param newEIDCrossSect + * the new eid cross sect share + */ + public void setEIDCrossSectShare(final String newEIDCrossSect) { + this.eIDCrossSectShare = newEIDCrossSect; + } + + /** + * Sets an eID that can be shared within the Service Provider’s sector. + * + * @param newEIDSectorShare + * the new eid sector share + */ + public void seteIDSectorShare(final String newEIDSectorShare) { + this.eIDSectorShare = newEIDSectorShare; + } + + /** + * Sets the format entity. + * + * @param newFormatEntity + * the new format entity + */ + public void setFormatEntity(final String newFormatEntity) { + this.formatEntity = newFormatEntity; + } + + /** + * Sets the friendly name. + * + * @param newFriendlyName + * the new friendly name + */ + public void setFriendlyName(final boolean newFriendlyName) { + this.friendlyName = newFriendlyName; + } + + /** + * Sets the IP validation. + * + * @param newIpValidation + * the new IP validation + */ + public void setIpValidation(final boolean newIpValidation) { + this.ipValidation = newIpValidation; + } + + /** + * Sets the one time use. + * + * @param newOneTimeUse + * the new one time use + */ + public void setOneTimeUse(final boolean newOneTimeUse) { + this.oneTimeUse = newOneTimeUse; + } + + /** + * Sets the protocol binding. + * + * @param newProtBinding + * the new protocol binding + */ + public void setProtocolBinding(final String newProtBinding) { + this.protocolBinding = newProtBinding; + } + + /** + * Sets the requester. + * + * @param newRequester + * the new requester + */ + public void setRequester(final String newRequester) { + this.requester = newRequester; + } + + /** + * Sets the responder. + * + * @param newResponder + * the new responder + */ + public void setResponder(final String newResponder) { + this.responder = newResponder; + } + + /** + * Sets the time not on or after. + * + * @param newTimeNotOnOrAft + * the new time not on or after + */ + public void setTimeNotOnOrAfter(final Integer newTimeNotOnOrAft) { + this.timeNotOnOrAfter = newTimeNotOnOrAft; + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/VIDPAuthenticationAttributes.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/VIDPAuthenticationAttributes.java index 6ee9e0e1b..c4c1ec845 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/VIDPAuthenticationAttributes.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/VIDPAuthenticationAttributes.java @@ -26,47 +26,46 @@ import org.opensaml.common.SAMLObject; */ public interface VIDPAuthenticationAttributes extends SAMLObject { - /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ - String DEF_LOCAL_NAME = "VIDPAuthenticationAttributes"; + /** The Constant DEFAULT_ELEMENT_LOCAL_NAME. */ + String DEF_LOCAL_NAME = "VIDPAuthenticationAttributes"; - /** Default element name. */ - QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** Default element name. */ + QName DEF_ELEMENT_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - /** Local name of the XSI type. */ - String TYPE_LOCAL_NAME = "VIDPAuthenticationAttributesType"; + /** Local name of the XSI type. */ + String TYPE_LOCAL_NAME = "VIDPAuthenticationAttributesType"; - /** QName of the XSI type. */ - QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, - SAMLCore.STORK10P_PREFIX.getValue()); + /** QName of the XSI type. */ + QName TYPE_NAME = new QName(SAMLCore.STORK10P_NS.getValue(), TYPE_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + /** + * Gets the citizen country code. + * + * @return the citizen country code + */ + CitizenCountryCode getCitizenCountryCode(); + + /** + * Sets the citizen country code. + * + * @param newCitizenCountryCode + * the new citizen country code + */ + void setCitizenCountryCode(CitizenCountryCode newCitizenCountryCode); + + /** + * Gets the SP information + * + * @return the SP information + */ + SPInformation getSPInformation(); + + /** + * Sets the SP information + * + * @param newSPInformation + * the new SPInformation + */ + void setSPInformation(SPInformation newSPInformation); - /** - * Gets the citizen country code. - * - * @return the citizen country code - */ - CitizenCountryCode getCitizenCountryCode(); - - /** - * Sets the citizen country code. - * - * @param newCitizenCountryCode the new citizen country code - */ - void setCitizenCountryCode(CitizenCountryCode newCitizenCountryCode); - - /** - * Gets the SP information - * - * @return the SP information - */ - SPInformation getSPInformation(); - - /** - * Sets the SP information - * - * @param newSPInformation the new SPInformation - */ - void setSPInformation(SPInformation newSPInformation); - } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesBuilder.java index 2d9039d4c..f34adfcb4 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesBuilder.java @@ -24,33 +24,31 @@ import eu.stork.peps.auth.engine.core.AuthenticationAttributes; * * @author fjquevedo */ -public class AuthenticationAttributesBuilder extends - AbstractSAMLObjectBuilder { - - - - /** - * Builds the object. - * - * @return the authentication attributes - */ - public final AuthenticationAttributes buildObject() { - return buildObject(AuthenticationAttributes.DEF_ELEMENT_NAME); - } - - /** - * Builds the object. - * - * @param namespaceURI the namespace URI - * @param localName the local name - * @param namespacePrefix the namespace prefix - * - * @return the authentication attributes - */ - public final AuthenticationAttributes buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new AuthenticationAttributesImpl(namespaceURI, localName, - namespacePrefix); - } +public class AuthenticationAttributesBuilder extends AbstractSAMLObjectBuilder { + + /** + * Builds the object. + * + * @return the authentication attributes + */ + public final AuthenticationAttributes buildObject() { + return buildObject(AuthenticationAttributes.DEF_ELEMENT_NAME); + } + + /** + * Builds the object. + * + * @param namespaceURI + * the namespace URI + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * + * @return the authentication attributes + */ + public final AuthenticationAttributes buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new AuthenticationAttributesImpl(namespaceURI, localName, namespacePrefix); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesImpl.java index e0de20f7d..907b9bf68 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesImpl.java @@ -32,78 +32,79 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public final class AuthenticationAttributesImpl extends AbstractSignableSAMLObject implements -AuthenticationAttributes { - - private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticationAttributesImpl.class.getName()); - - /** The indexed children. */ - private VIDPAuthenticationAttributes vIDPAuthenAttr; - - /** - * Instantiates a new authentication attributes implementation. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected AuthenticationAttributesImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } - - /** - * Gets the ordered children. - * - * @return the ordered children - * - */ - public List getOrderedChildren() { - final ArrayList children = new ArrayList(); - - children.add(vIDPAuthenAttr); - - if (getSignature() != null) { - children.add(getSignature()); +public final class AuthenticationAttributesImpl extends AbstractSignableSAMLObject implements AuthenticationAttributes { + + private static final Logger LOGGER = LoggerFactory.getLogger(AuthenticationAttributesImpl.class.getName()); + + /** The indexed children. */ + private VIDPAuthenticationAttributes vIDPAuthenAttr; + + /** + * Instantiates a new authentication attributes implementation. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected AuthenticationAttributesImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); } - return Collections.unmodifiableList(children); - } - - /** - * Gets the signature reference id. - * - * @return the signature reference id - * - */ - public String getSignatureReferenceID() { - return null; - } - - /** - * Gets the vidp authentication attributes. - * - * @return the VIDP authentication attributes - * - */ - public VIDPAuthenticationAttributes getVIDPAuthenticationAttributes() { - return vIDPAuthenAttr; - } - - /** - * Sets the vidp authentication attributes. - * - * @param newVIDPAuthenAttr the new vidp authen attr - * - */ - public void setVIDPAuthenticationAttributes( - final VIDPAuthenticationAttributes newVIDPAuthenAttr) { - vIDPAuthenAttr = prepareForAssignment(this.vIDPAuthenAttr, newVIDPAuthenAttr); - } - - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + /** + * Gets the ordered children. + * + * @return the ordered children + * + */ + public List getOrderedChildren() { + final ArrayList children = new ArrayList(); + + children.add(vIDPAuthenAttr); + + if (getSignature() != null) { + children.add(getSignature()); + } + + return Collections.unmodifiableList(children); + } + + /** + * Gets the signature reference id. + * + * @return the signature reference id + * + */ + public String getSignatureReferenceID() { + return null; + } + + /** + * Gets the vidp authentication attributes. + * + * @return the VIDP authentication attributes + * + */ + public VIDPAuthenticationAttributes getVIDPAuthenticationAttributes() { + return vIDPAuthenAttr; + } + + /** + * Sets the vidp authentication attributes. + * + * @param newVIDPAuthenAttr + * the new vidp authen attr + * + */ + public void setVIDPAuthenticationAttributes(final VIDPAuthenticationAttributes newVIDPAuthenAttr) { + vIDPAuthenAttr = prepareForAssignment(this.vIDPAuthenAttr, newVIDPAuthenAttr); + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesUnmarshaller.java index 113214712..7e1b6bbe2 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/AuthenticationAttributesUnmarshaller.java @@ -28,20 +28,21 @@ import eu.stork.peps.auth.engine.core.AuthenticationAttributes; * * @author fjquevedo */ -public class AuthenticationAttributesUnmarshaller extends -AbstractSAMLObjectUnmarshaller { +public class AuthenticationAttributesUnmarshaller extends AbstractSAMLObjectUnmarshaller { /** * Process child element. * - * @param parentObject the parent object - * @param childObject the child object + * @param parentObject + * the parent object + * @param childObject + * the child object * - * @throws UnmarshallingException the unmarshalling exception + * @throws UnmarshallingException + * the unmarshalling exception * */ - protected final void processChildElement(final XMLObject parentObject, - final XMLObject childObject) throws UnmarshallingException { + protected final void processChildElement(final XMLObject parentObject, final XMLObject childObject) throws UnmarshallingException { final AuthenticationAttributes attrStatement = (AuthenticationAttributes) parentObject; if (childObject instanceof VIDPAuthenticationAttributes) { diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeBuilder.java index 64651691f..49ed66d88 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeBuilder.java @@ -26,25 +26,27 @@ import eu.stork.peps.auth.engine.core.CitizenCountryCode; */ public class CitizenCountryCodeBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the citizen country code - */ - public final CitizenCountryCode buildObject() { - return buildObject(CitizenCountryCode.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the citizen country code + */ + public final CitizenCountryCode buildObject() { + return buildObject(CitizenCountryCode.DEF_ELEMENT_NAME); + } - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the citizen country code - */ - public final CitizenCountryCode buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new CitizenCountryCodeImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the citizen country code + */ + public final CitizenCountryCode buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new CitizenCountryCodeImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeImpl.java index 374398cf1..003d56b46 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeImpl.java @@ -31,52 +31,55 @@ import org.slf4j.LoggerFactory; */ public class CitizenCountryCodeImpl extends AbstractSAMLObject implements CitizenCountryCode { - private static final Logger LOGGER = LoggerFactory.getLogger(CitizenCountryCodeImpl.class.getName()); - /** The citizen country code. */ - private String citizenCountryCode; - - /** - * Instantiates a new sP country impl. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected CitizenCountryCodeImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + private static final Logger LOGGER = LoggerFactory.getLogger(CitizenCountryCodeImpl.class.getName()); + /** The citizen country code. */ + private String citizenCountryCode; - /** - * Gets the citizen country code. - * - * @return the citizen country code - */ - public final String getCitizenCountryCode() { - return citizenCountryCode; - } + /** + * Instantiates a new sP country impl. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected CitizenCountryCodeImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Sets the citizen country code. - * - * @param newCitizenCountryCode the new citizen country code - */ - public final void setCitizenCountryCode(final String newCitizenCountryCode) { - this.citizenCountryCode = prepareForAssignment(this.citizenCountryCode, newCitizenCountryCode); - } + /** + * Gets the citizen country code. + * + * @return the citizen country code + */ + public final String getCitizenCountryCode() { + return citizenCountryCode; + } - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Sets the citizen country code. + * + * @param newCitizenCountryCode + * the new citizen country code + */ + public final void setCitizenCountryCode(final String newCitizenCountryCode) { + this.citizenCountryCode = prepareForAssignment(this.citizenCountryCode, newCitizenCountryCode); + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeMarshaller.java index decae04c5..e04323f06 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeMarshaller.java @@ -30,16 +30,18 @@ import eu.stork.peps.auth.engine.core.CitizenCountryCode; */ public class CitizenCountryCodeMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final CitizenCountryCode citizenCountryCode = (CitizenCountryCode) samlObject; - XMLHelper.appendTextContent(domElement, citizenCountryCode.getCitizenCountryCode()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final CitizenCountryCode citizenCountryCode = (CitizenCountryCode) samlObject; + XMLHelper.appendTextContent(domElement, citizenCountryCode.getCitizenCountryCode()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeUnmarshaller.java index 93132b508..eca6d69b9 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CitizenCountryCodeUnmarshaller.java @@ -27,15 +27,16 @@ import eu.stork.peps.auth.engine.core.CitizenCountryCode; */ public class CitizenCountryCodeUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final CitizenCountryCode citizenCountryCode = (CitizenCountryCode) samlObject; - citizenCountryCode.setCitizenCountryCode(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final CitizenCountryCode citizenCountryCode = (CitizenCountryCode) samlObject; + citizenCountryCode.setCitizenCountryCode(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryBuilder.java index 48da2a24b..f2d2fe7fb 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryBuilder.java @@ -6,21 +6,20 @@ import eu.stork.peps.auth.engine.core.CustomAttributeQuery; public class CustomAttributeQueryBuilder extends AbstractSAMLObjectBuilder { /** - * Constructor. - */ - public CustomAttributeQueryBuilder() { + * Constructor. + */ + public CustomAttributeQueryBuilder() { - } + } - /** {@inheritDoc} */ - public CustomAttributeQuery buildObject() { - return buildObject(SAMLConstants.SAML20P_NS, CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME, - SAMLConstants.SAML20P_PREFIX); - } + /** {@inheritDoc} */ + public CustomAttributeQuery buildObject() { + return buildObject(SAMLConstants.SAML20P_NS, CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + } - /** {@inheritDoc} */ - public CustomAttributeQuery buildObject(String namespaceURI, String localName, String namespacePrefix) { - return new CustomAttributeQueryImpl(namespaceURI, localName, namespacePrefix); - } + /** {@inheritDoc} */ + public CustomAttributeQuery buildObject(String namespaceURI, String localName, String namespacePrefix) { + return new CustomAttributeQueryImpl(namespaceURI, localName, namespacePrefix); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryImpl.java index cbf9221eb..d88ede1a3 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryImpl.java @@ -11,44 +11,46 @@ import org.opensaml.xml.util.XMLObjectChildrenList; import eu.stork.peps.auth.engine.core.CustomAttributeQuery; - public class CustomAttributeQueryImpl extends SubjectQueryImpl implements CustomAttributeQuery { /** Attribute child elements. */ - private final XMLObjectChildrenList attributes; - private String serviceURL; + private final XMLObjectChildrenList attributes; + private String serviceURL; - /** - * Constructor. - * - * @param namespaceURI the namespace the element is in - * @param elementLocalName the local name of the XML element this Object represents - * @param namespacePrefix the prefix for the given namespace - */ - protected CustomAttributeQueryImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - attributes = new XMLObjectChildrenList(this); - } + /** + * Constructor. + * + * @param namespaceURI + * the namespace the element is in + * @param elementLocalName + * the local name of the XML element this Object represents + * @param namespacePrefix + * the prefix for the given namespace + */ + protected CustomAttributeQueryImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + attributes = new XMLObjectChildrenList(this); + } - /** {@inheritDoc} */ - public List getAttributes() { - return attributes; - } + /** {@inheritDoc} */ + public List getAttributes() { + return attributes; + } - /** {@inheritDoc} */ - public List getOrderedChildren() { - ArrayList children = new ArrayList(); + /** {@inheritDoc} */ + public List getOrderedChildren() { + ArrayList children = new ArrayList(); - if (super.getOrderedChildren() != null) { - children.addAll(super.getOrderedChildren()); - } - children.addAll(attributes); + if (super.getOrderedChildren() != null) { + children.addAll(super.getOrderedChildren()); + } + children.addAll(attributes); - if (children.size() == 0) { - return null; - } + if (children.size() == 0) { + return null; + } - return Collections.unmodifiableList(children); - } + return Collections.unmodifiableList(children); + } @Override public String getAssertionConsumerServiceURL() { diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryMarshaller.java index 7f2013ca8..5e0cf55b3 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryMarshaller.java @@ -10,41 +10,40 @@ import org.w3c.dom.Element; import eu.stork.peps.auth.engine.core.CustomRequestAbstractType; public class CustomAttributeQueryMarshaller extends SubjectQueryMarshaller { - - /** {@inheritDoc} */ - protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { - CustomRequestAbstractType req = (CustomRequestAbstractType) samlObject; - - if (req.getVersion() != null) { - domElement.setAttributeNS(null, RequestAbstractType.VERSION_ATTRIB_NAME, req.getVersion().toString()); - } - - if (req.getID() != null) { - domElement.setAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, req.getID()); - domElement.setIdAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, true); - } - - if (req.getVersion() != null) { - domElement.setAttributeNS(null, RequestAbstractType.VERSION_ATTRIB_NAME, req.getVersion().toString()); - } - - if (req.getIssueInstant() != null) { - String iiStr = Configuration.getSAMLDateFormatter().print(req.getIssueInstant()); - domElement.setAttributeNS(null, RequestAbstractType.ISSUE_INSTANT_ATTRIB_NAME, iiStr); - } - - if (req.getDestination() != null) { - domElement.setAttributeNS(null, RequestAbstractType.DESTINATION_ATTRIB_NAME, req.getDestination()); - } - - if (req.getAssertionConsumerServiceURL() != null) { - domElement.setAttributeNS(null, CustomRequestAbstractType.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME, req.getAssertionConsumerServiceURL()); - } - - if (req.getConsent() != null) { - domElement.setAttributeNS(null, RequestAbstractType.CONSENT_ATTRIB_NAME, req.getConsent()); - } - } + /** {@inheritDoc} */ + protected void marshallAttributes(XMLObject samlObject, Element domElement) throws MarshallingException { + CustomRequestAbstractType req = (CustomRequestAbstractType) samlObject; + + if (req.getVersion() != null) { + domElement.setAttributeNS(null, RequestAbstractType.VERSION_ATTRIB_NAME, req.getVersion().toString()); + } + + if (req.getID() != null) { + domElement.setAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, req.getID()); + domElement.setIdAttributeNS(null, RequestAbstractType.ID_ATTRIB_NAME, true); + } + + if (req.getVersion() != null) { + domElement.setAttributeNS(null, RequestAbstractType.VERSION_ATTRIB_NAME, req.getVersion().toString()); + } + + if (req.getIssueInstant() != null) { + String iiStr = Configuration.getSAMLDateFormatter().print(req.getIssueInstant()); + domElement.setAttributeNS(null, RequestAbstractType.ISSUE_INSTANT_ATTRIB_NAME, iiStr); + } + + if (req.getDestination() != null) { + domElement.setAttributeNS(null, RequestAbstractType.DESTINATION_ATTRIB_NAME, req.getDestination()); + } + + if (req.getAssertionConsumerServiceURL() != null) { + domElement.setAttributeNS(null, CustomRequestAbstractType.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME, req.getAssertionConsumerServiceURL()); + } + + if (req.getConsent() != null) { + domElement.setAttributeNS(null, RequestAbstractType.CONSENT_ATTRIB_NAME, req.getConsent()); + } + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryUnmarshaller.java index e351b65b0..485d6656b 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/CustomAttributeQueryUnmarshaller.java @@ -24,91 +24,88 @@ import eu.stork.peps.auth.engine.core.CustomAttributeQuery; import eu.stork.peps.auth.engine.core.CustomRequestAbstractType; public class CustomAttributeQueryUnmarshaller extends SubjectQueryUnmarshaller { - + private final Logger log = LoggerFactory.getLogger(AbstractXMLObjectUnmarshaller.class); + + /** {@inheritDoc} */ + protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) throws UnmarshallingException { + CustomAttributeQuery query = (CustomAttributeQuery) parentSAMLObject; + + if (childSAMLObject instanceof Attribute) { + query.getAttributes().add((Attribute) childSAMLObject); + } else { + super.processChildElement(parentSAMLObject, childSAMLObject); + } + } + + /** {@inheritDoc} */ + public XMLObject unmarshall(Element domElement) throws UnmarshallingException { + if (log.isTraceEnabled()) { + log.trace("Starting to unmarshall DOM element {}", XMLHelper.getNodeQName(domElement)); + } + + checkElementIsTarget(domElement); + + // String namespaceURI, String elementLocalName, String namespacePrefix + XMLObject xmlObject = new CustomAttributeQueryImpl(SAMLConstants.SAML20P_NS, CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + + if (log.isTraceEnabled()) { + log.trace("Unmarshalling attributes of DOM Element {}", XMLHelper.getNodeQName(domElement)); + } + + NamedNodeMap attributes = domElement.getAttributes(); + Node attribute; + for (int i = 0; i < attributes.getLength(); i++) { + attribute = attributes.item(i); + + // These should allows be attribute nodes, but just in case... + if (attribute.getNodeType() == Node.ATTRIBUTE_NODE) { + unmarshallAttribute(xmlObject, (Attr) attribute); + } + } + + if (log.isTraceEnabled()) { + log.trace("Unmarshalling other child nodes of DOM Element {}", XMLHelper.getNodeQName(domElement)); + } + + Node childNode = domElement.getFirstChild(); + while (childNode != null) { + + if (childNode.getNodeType() == Node.ATTRIBUTE_NODE) { + unmarshallAttribute(xmlObject, (Attr) childNode); + } else if (childNode.getNodeType() == Node.ELEMENT_NODE) { + unmarshallChildElement(xmlObject, (Element) childNode); + } else if (childNode.getNodeType() == Node.TEXT_NODE || childNode.getNodeType() == Node.CDATA_SECTION_NODE) { + unmarshallTextContent(xmlObject, (Text) childNode); + } + + childNode = childNode.getNextSibling(); + } + + xmlObject.setDOM(domElement); + return xmlObject; + } + /** {@inheritDoc} */ - protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) - throws UnmarshallingException { - CustomAttributeQuery query = (CustomAttributeQuery) parentSAMLObject; - - if (childSAMLObject instanceof Attribute) { - query.getAttributes().add((Attribute) childSAMLObject); - } else { - super.processChildElement(parentSAMLObject, childSAMLObject); - } - } - - /** {@inheritDoc} */ - public XMLObject unmarshall(Element domElement) throws UnmarshallingException { - if (log.isTraceEnabled()) { - log.trace("Starting to unmarshall DOM element {}", XMLHelper.getNodeQName(domElement)); - } - - checkElementIsTarget(domElement); - - //String namespaceURI, String elementLocalName, String namespacePrefix - XMLObject xmlObject = new CustomAttributeQueryImpl(SAMLConstants.SAML20P_NS, CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME, - SAMLConstants.SAML20P_PREFIX); - - if (log.isTraceEnabled()) { - log.trace("Unmarshalling attributes of DOM Element {}", XMLHelper.getNodeQName(domElement)); - } - - NamedNodeMap attributes = domElement.getAttributes(); - Node attribute; - for (int i = 0; i < attributes.getLength(); i++) { - attribute = attributes.item(i); - - // These should allows be attribute nodes, but just in case... - if (attribute.getNodeType() == Node.ATTRIBUTE_NODE) { - unmarshallAttribute(xmlObject, (Attr) attribute); - } - } - - if (log.isTraceEnabled()) { - log.trace("Unmarshalling other child nodes of DOM Element {}", XMLHelper.getNodeQName(domElement)); - } - - Node childNode = domElement.getFirstChild(); - while (childNode != null) { - - if (childNode.getNodeType() == Node.ATTRIBUTE_NODE) { - unmarshallAttribute(xmlObject, (Attr) childNode); - } else if (childNode.getNodeType() == Node.ELEMENT_NODE) { - unmarshallChildElement(xmlObject, (Element) childNode); - } else if (childNode.getNodeType() == Node.TEXT_NODE - || childNode.getNodeType() == Node.CDATA_SECTION_NODE) { - unmarshallTextContent(xmlObject, (Text) childNode); - } - - childNode = childNode.getNextSibling(); - } - - xmlObject.setDOM(domElement); - return xmlObject; - } - - /** {@inheritDoc} */ - protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { - CustomRequestAbstractType req = (CustomRequestAbstractType) samlObject; - - if (attribute.getLocalName().equals(RequestAbstractType.VERSION_ATTRIB_NAME)) { - req.setVersion(SAMLVersion.valueOf(attribute.getValue())); - } else if (attribute.getLocalName().equals(RequestAbstractType.ID_ATTRIB_NAME)) { - req.setID(attribute.getValue()); - attribute.getOwnerElement().setIdAttributeNode(attribute, true); - } else if (attribute.getLocalName().equals(RequestAbstractType.ISSUE_INSTANT_ATTRIB_NAME) - && !DatatypeHelper.isEmpty(attribute.getValue())) { - req.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC())); - } else if (attribute.getLocalName().equals(RequestAbstractType.DESTINATION_ATTRIB_NAME)) { - req.setDestination(attribute.getValue()); - } else if (attribute.getLocalName().equals(RequestAbstractType.CONSENT_ATTRIB_NAME)) { - req.setConsent(attribute.getValue()); - } else if (attribute.getLocalName().equals(CustomRequestAbstractType.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME)) { - req.setAssertionConsumerServiceURL(attribute.getValue()); - }else { - super.processAttribute(samlObject, attribute); - } - } + protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { + CustomRequestAbstractType req = (CustomRequestAbstractType) samlObject; + + if (attribute.getLocalName().equals(RequestAbstractType.VERSION_ATTRIB_NAME)) { + req.setVersion(SAMLVersion.valueOf(attribute.getValue())); + } else if (attribute.getLocalName().equals(RequestAbstractType.ID_ATTRIB_NAME)) { + req.setID(attribute.getValue()); + attribute.getOwnerElement().setIdAttributeNode(attribute, true); + } else if (attribute.getLocalName().equals(RequestAbstractType.ISSUE_INSTANT_ATTRIB_NAME) && !DatatypeHelper.isEmpty(attribute.getValue())) { + req.setIssueInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC())); + } else if (attribute.getLocalName().equals(RequestAbstractType.DESTINATION_ATTRIB_NAME)) { + req.setDestination(attribute.getValue()); + } else if (attribute.getLocalName().equals(RequestAbstractType.CONSENT_ATTRIB_NAME)) { + req.setConsent(attribute.getValue()); + } else if (attribute.getLocalName().equals(CustomRequestAbstractType.ASSERTION_CONSUMER_SERVICE_URL_ATTRIB_NAME)) { + req.setAssertionConsumerServiceURL(attribute.getValue()); + } else { + super.processAttribute(samlObject, attribute); + } + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareBuilder.java index 3f4fc633d..7c7a88b89 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareBuilder.java @@ -24,8 +24,7 @@ import eu.stork.peps.auth.engine.core.EIDCrossBorderShare; * * @author fjquevedo */ -public class EIDCrossBorderShareBuilder extends AbstractSAMLObjectBuilder { - +public class EIDCrossBorderShareBuilder extends AbstractSAMLObjectBuilder { /** * Builds the object. @@ -36,17 +35,18 @@ public class EIDCrossBorderShareBuilder extends AbstractSAMLObjectBuilder getOrderedChildren() { - return null; - } + /** + * Sets the eID cross border share. + * + * @param newEIDCrossBorderShare + * the new eID cross border share + */ + public final void setEIDCrossBorderShare(String newEIDCrossBorderShare) { + this.eIDCrossBorderShare = prepareForAssignment(this.eIDCrossBorderShare, newEIDCrossBorderShare); + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + /** + * Gets the ordered children. + * + * @return the ordered children {@inheritDoc} + */ + public final List getOrderedChildren() { + return null; + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareMarshaller.java index c5e113013..2e8868ac1 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareMarshaller.java @@ -23,7 +23,6 @@ import org.w3c.dom.Element; import eu.stork.peps.auth.engine.core.EIDCrossBorderShare; - /** * The Class EIDCrossBorderShareMarshaller. * @@ -31,16 +30,17 @@ import eu.stork.peps.auth.engine.core.EIDCrossBorderShare; */ public class EIDCrossBorderShareMarshaller extends AbstractSAMLObjectMarshaller { - /** * Marshall element content. * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { final EIDCrossBorderShare crossBorderShare = (EIDCrossBorderShare) samlObject; XMLHelper.appendTextContent(domElement, crossBorderShare.getEIDCrossBorderShare()); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareUnmarshaller.java index e74bee6ca..013b5b78b 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossBorderShareUnmarshaller.java @@ -25,18 +25,17 @@ import eu.stork.peps.auth.engine.core.EIDCrossBorderShare; * * @author fjquevedo */ -public class EIDCrossBorderShareUnmarshaller extends - AbstractSAMLObjectUnmarshaller { - +public class EIDCrossBorderShareUnmarshaller extends AbstractSAMLObjectUnmarshaller { /** * Process element content. * - * @param samlObject the SAML object - * @param elementContent the element content + * @param samlObject + * the SAML object + * @param elementContent + * the element content */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { final EIDCrossBorderShare crossBorderShare = (EIDCrossBorderShare) samlObject; crossBorderShare.setEIDCrossBorderShare(elementContent); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareBuilder.java index 5e91e18fd..398815719 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareBuilder.java @@ -24,29 +24,29 @@ import eu.stork.peps.auth.engine.core.EIDCrossSectorShare; * * @author fjquevedo */ -public class EIDCrossSectorShareBuilder extends - AbstractSAMLObjectBuilder { +public class EIDCrossSectorShareBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the eID cross sector share - */ - public final EIDCrossSectorShare buildObject() { - return buildObject(EIDCrossSectorShare.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the eID cross sector share + */ + public final EIDCrossSectorShare buildObject() { + return buildObject(EIDCrossSectorShare.DEF_ELEMENT_NAME); + } - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the eID cross sector share implementation - */ - public final EIDCrossSectorShareImpl buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new EIDCrossSectorShareImpl(namespaceURI, localName, - namespacePrefix); - } + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the eID cross sector share implementation + */ + public final EIDCrossSectorShareImpl buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new EIDCrossSectorShareImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareImpl.java index 7b2ad3dbd..f2762e327 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareImpl.java @@ -25,65 +25,62 @@ import eu.stork.peps.auth.engine.core.EIDCrossSectorShare; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class EIDCrossSectorShareImpl. * * @author fjquevedo */ -public class EIDCrossSectorShareImpl extends AbstractSAMLObject implements - EIDCrossSectorShare { +public class EIDCrossSectorShareImpl extends AbstractSAMLObject implements EIDCrossSectorShare { - private static final Logger LOGGER = LoggerFactory.getLogger(EIDCrossSectorShareImpl.class.getName()); + private static final Logger LOGGER = LoggerFactory.getLogger(EIDCrossSectorShareImpl.class.getName()); /** The citizen country code. */ - private String eIDCrossSectorShare; + private String eIDCrossSectorShare; + /** + * Instantiates a new eID cross sector share implementation. + * + * @param namespaceURI + * the namespace URI + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected EIDCrossSectorShareImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Instantiates a new eID cross sector share implementation. - * - * @param namespaceURI the namespace URI - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected EIDCrossSectorShareImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } - - - - /** - * Gets the eID cross sector share. - * - * @return the eID cross sector share - */ - public final String getEIDCrossSectorShare() { - return eIDCrossSectorShare; - } + /** + * Gets the eID cross sector share. + * + * @return the eID cross sector share + */ + public final String getEIDCrossSectorShare() { + return eIDCrossSectorShare; + } + /** + * Sets the eID cross sector share. + * + * @param newEIDCrossSectorShare + * the new eID cross sector share + */ + public final void setEIDCrossSectorShare(String newEIDCrossSectorShare) { + this.eIDCrossSectorShare = prepareForAssignment(this.eIDCrossSectorShare, newEIDCrossSectorShare); + } - /** - * Sets the eID cross sector share. - * - * @param newEIDCrossSectorShare the new eID cross sector share - */ - public final void setEIDCrossSectorShare(String newEIDCrossSectorShare) { - this.eIDCrossSectorShare = prepareForAssignment(this.eIDCrossSectorShare, newEIDCrossSectorShare); - } - - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareMarshaller.java index 3ee9df698..caa2df56a 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareMarshaller.java @@ -23,7 +23,6 @@ import org.w3c.dom.Element; import eu.stork.peps.auth.engine.core.EIDCrossSectorShare; - /** * The Class EIDCrossSectorShareMarshaller. * @@ -34,12 +33,14 @@ public class EIDCrossSectorShareMarshaller extends AbstractSAMLObjectMarshaller /** * Marshall element content. * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { final EIDCrossSectorShare crossSectorShare = (EIDCrossSectorShare) samlObject; XMLHelper.appendTextContent(domElement, crossSectorShare.getEIDCrossSectorShare()); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareUnmarshaller.java index 94c7689be..ebf80e700 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDCrossSectorShareUnmarshaller.java @@ -28,18 +28,19 @@ import eu.stork.peps.auth.engine.core.EIDCrossSectorShare; * * @author fjquevedo */ -public class EIDCrossSectorShareUnmarshaller extends - AbstractSAMLObjectUnmarshaller { +public class EIDCrossSectorShareUnmarshaller extends AbstractSAMLObjectUnmarshaller { /** * Process element content. * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception */ - protected final void processElementContent(final XMLObject samlObject, - final String domElement) { + protected final void processElementContent(final XMLObject samlObject, final String domElement) { final EIDCrossSectorShare crossSectorShare = (EIDCrossSectorShare) samlObject; crossSectorShare.setEIDCrossSectorShare(domElement); diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareBuilder.java index 230ff3ca4..670b6f33a 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareBuilder.java @@ -24,28 +24,29 @@ import eu.stork.peps.auth.engine.core.EIDSectorShare; * * @author fjquevedo */ -public class EIDSectorShareBuilder extends - AbstractSAMLObjectBuilder { +public class EIDSectorShareBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the eID sector share - */ - public final EIDSectorShare buildObject() { - return buildObject(EIDSectorShare.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the eID sector share + */ + public final EIDSectorShare buildObject() { + return buildObject(EIDSectorShare.DEF_ELEMENT_NAME); + } - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the eID sector share - */ - public final EIDSectorShare buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new EIDSectorShareImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the eID sector share + */ + public final EIDSectorShare buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new EIDSectorShareImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareImpl.java index 9ed726a32..f7c514722 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareImpl.java @@ -30,56 +30,58 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public class EIDSectorShareImpl extends AbstractSAMLObject implements - EIDSectorShare { +public class EIDSectorShareImpl extends AbstractSAMLObject implements EIDSectorShare { - private static final Logger LOGGER = LoggerFactory.getLogger(EIDSectorShareImpl.class.getName()); - - /** The e id sector share. */ - private String eIDSectorShare; - /** - * Instantiates a new eID sector share implementation. - * - * @param namespaceURI the namespace URI - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected EIDSectorShareImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } - - - /** - * Gets the eID sector share. - * - * @return the eID sector share - */ - public final String getEIDSectorShare() { - return eIDSectorShare; - } + private static final Logger LOGGER = LoggerFactory.getLogger(EIDSectorShareImpl.class.getName()); - /** - * Sets the eID sector share. - * - * @param newEIDSectorShare the new eID sector share - */ - public final void setEIDSectorShare(String newEIDSectorShare) { - this.eIDSectorShare = prepareForAssignment(this.eIDSectorShare, newEIDSectorShare); - } - - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** The e id sector share. */ + private String eIDSectorShare; - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + /** + * Instantiates a new eID sector share implementation. + * + * @param namespaceURI + * the namespace URI + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected EIDSectorShareImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } + + /** + * Gets the eID sector share. + * + * @return the eID sector share + */ + public final String getEIDSectorShare() { + return eIDSectorShare; + } + + /** + * Sets the eID sector share. + * + * @param newEIDSectorShare + * the new eID sector share + */ + public final void setEIDSectorShare(String newEIDSectorShare) { + this.eIDSectorShare = prepareForAssignment(this.eIDSectorShare, newEIDSectorShare); + } + + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareMarshaller.java index 0ce449cd1..509503af0 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareMarshaller.java @@ -34,12 +34,14 @@ public class EIDSectorShareMarshaller extends AbstractSAMLObjectMarshaller { /** * Marshall element content. * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { final EIDSectorShare sectorShare = (EIDSectorShare) samlObject; XMLHelper.appendTextContent(domElement, sectorShare.getEIDSectorShare()); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareUnmarshaller.java index f7f00adb9..8e2f327c6 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/EIDSectorShareUnmarshaller.java @@ -23,7 +23,6 @@ import org.w3c.dom.Element; import eu.stork.peps.auth.engine.core.EIDSectorShare; - /** * The Class EIDSectorShareUnmarshaller. * @@ -31,16 +30,17 @@ import eu.stork.peps.auth.engine.core.EIDSectorShare; */ public class EIDSectorShareUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** * Process element content. * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception */ - protected final void processElementContent(final XMLObject samlObject, - final String domElement) { + protected final void processElementContent(final XMLObject samlObject, final String domElement) { final EIDSectorShare sectorShare = (EIDSectorShare) samlObject; sectorShare.setEIDSectorShare(domElement); } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeBuilder.java index 41676931b..deeb2ae56 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeBuilder.java @@ -24,29 +24,29 @@ import eu.stork.peps.auth.engine.core.QAAAttribute; * * @author fjquevedo */ -public class QAAAttributeBuilder extends - AbstractSAMLObjectBuilder { +public class QAAAttributeBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the quality authentication assurance object - */ - public final QAAAttribute buildObject() { - return buildObject(QAAAttribute.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the quality authentication assurance object + */ + public final QAAAttribute buildObject() { + return buildObject(QAAAttribute.DEF_ELEMENT_NAME); + } - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the quality authentication assurance object - - */ - public final QAAAttribute buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new QAAAttributeImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the quality authentication assurance object + */ + public final QAAAttribute buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new QAAAttributeImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeImpl.java index 46f3bb402..423cf8b25 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeImpl.java @@ -29,56 +29,57 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public class QAAAttributeImpl extends AbstractSAMLObject implements - QAAAttribute { +public class QAAAttributeImpl extends AbstractSAMLObject implements QAAAttribute { - private static final Logger LOGGER = LoggerFactory.getLogger(QAAAttributeImpl.class.getName()); - /** The quality authentication assurance level. */ - private String qaaLevel; + private static final Logger LOGGER = LoggerFactory.getLogger(QAAAttributeImpl.class.getName()); + /** The quality authentication assurance level. */ + private String qaaLevel; - /** - * Constructor. - * - * @param namespaceURI the namespace the element is in - * @param elementLocalName the local name of the XML element this Object - * represents - * @param namespacePrefix the prefix for the given namespace - */ - protected QAAAttributeImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + /** + * Constructor. + * + * @param namespaceURI + * the namespace the element is in + * @param elementLocalName + * the local name of the XML element this Object represents + * @param namespacePrefix + * the prefix for the given namespace + */ + protected QAAAttributeImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Gets the quality authentication assurance level. - * - * @return the quality authentication assurance level - */ - public final String getQaaLevel() { - return qaaLevel; - } + /** + * Gets the quality authentication assurance level. + * + * @return the quality authentication assurance level + */ + public final String getQaaLevel() { + return qaaLevel; + } - /** - * Sets the quality authentication assurance level. - * - * @param newQaaLevel the new quality authentication assurance level - */ - public final void setQaaLevel(final String newQaaLevel) { - this.qaaLevel = prepareForAssignment(this.qaaLevel, newQaaLevel); - } + /** + * Sets the quality authentication assurance level. + * + * @param newQaaLevel + * the new quality authentication assurance level + */ + public final void setQaaLevel(final String newQaaLevel) { + this.qaaLevel = prepareForAssignment(this.qaaLevel, newQaaLevel); + } - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeMarshaller.java index 000879368..03a7a758a 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeMarshaller.java @@ -30,16 +30,18 @@ import eu.stork.peps.auth.engine.core.QAAAttribute; */ public class QAAAttributeMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final QAAAttribute qaaAttribute = (QAAAttribute) samlObject; - XMLHelper.appendTextContent(domElement, qaaAttribute.getQaaLevel()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final QAAAttribute qaaAttribute = (QAAAttribute) samlObject; + XMLHelper.appendTextContent(domElement, qaaAttribute.getQaaLevel()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeUnmarshaller.java index 8445e4eeb..1b9e813f0 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/QAAAttributeUnmarshaller.java @@ -27,15 +27,16 @@ import eu.stork.peps.auth.engine.core.QAAAttribute; */ public class QAAAttributeUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final QAAAttribute qaaLevel = (QAAAttribute) samlObject; - qaaLevel.setQaaLevel(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final QAAAttribute qaaLevel = (QAAAttribute) samlObject; + qaaLevel.setQaaLevel(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeBuilder.java index c9881c439..4367c4ecf 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeBuilder.java @@ -24,31 +24,30 @@ import eu.stork.peps.auth.engine.core.RequestedAttribute; * * @author fjquevedo */ -public class RequestedAttributeBuilder extends - AbstractSAMLObjectBuilder { - - - /** - * Builds the object. - * - * @return the requested attribute - */ - public final RequestedAttribute buildObject() { - return buildObject(RequestedAttribute.DEF_ELEMENT_NAME); - } - - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the requested attribute - */ - public final RequestedAttribute buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new RequestedAttributeImpl(namespaceURI, localName, - namespacePrefix); - } +public class RequestedAttributeBuilder extends AbstractSAMLObjectBuilder { + + /** + * Builds the object. + * + * @return the requested attribute + */ + public final RequestedAttribute buildObject() { + return buildObject(RequestedAttribute.DEF_ELEMENT_NAME); + } + + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the requested attribute + */ + public final RequestedAttribute buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new RequestedAttributeImpl(namespaceURI, localName, namespacePrefix); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeImpl.java index ac2e8a3ee..e7ac7213b 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeImpl.java @@ -35,186 +35,187 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public class RequestedAttributeImpl extends AbstractSAMLObject implements - RequestedAttribute { - - private static final Logger LOGGER = LoggerFactory.getLogger(RequestedAttributeImpl.class.getName()); - /** - * The attribute values. - */ - private final XMLObjectChildrenList attributeValues; - - /** - * The friendly name. - * - */ - private String friendlyName; - - /** - * The is required. - */ - private String isRequired; - - /** - * The name. - * - */ - private String name; - - /** - * The name format. - * - */ - private String nameFormat; - - /** - * The unknown attributes. - * - */ - private AttributeMap unknownAttributes; - - /** - * Instantiates a new requested attribute impl. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected RequestedAttributeImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - unknownAttributes = new AttributeMap(this); - attributeValues = new XMLObjectChildrenList(this); - } - - - /** - * Gets the attribute values. - * - * @return the attribute values - */ - public final List getAttributeValues() { - return attributeValues; - } - - /** - * Gets the friendly name. - * - * @return the friendly name. - */ - public final String getFriendlyName() { - return friendlyName; - } - - - /** - * Gets the checks if is required. - * - * @return the boolean if it's required. - */ - public final String isRequired() { - return isRequired; - } - - - /** - * Gets the is required xs boolean. - * - * @return the XSBoolean if it's required. - */ - public final String getIsRequiredXSBoolean() { - return isRequired; - } - - - /** - * Gets the name. - * - * @return the name - */ - public final String getName() { - return name; - } - - - /** - * Gets the name format. - * - * @return the name format. - */ - public final String getNameFormat() { - return nameFormat; - } - - /** - * Gets the ordered children. - * - * @return the list of XMLObject. - */ - public final List getOrderedChildren() { - final ArrayList children = new ArrayList(); - children.addAll(attributeValues); - return Collections.unmodifiableList(children); - } - - /** - * Gets the unknown attributes. - * - * @return the attribute map - */ - public final AttributeMap getUnknownAttributes() { - return unknownAttributes; - } - - /** - * Sets the friendly name. - * - * @param newFriendlyName the new friendly name format - */ - public final void setFriendlyName(final String newFriendlyName) { - this.friendlyName = prepareForAssignment(this.friendlyName, - newFriendlyName); - } - - /** - * Set new boolean value isRequired. - * @param newIsRequired then new value - */ - public final void setIsRequired(final String newIsRequired) { - isRequired = prepareForAssignment(this.isRequired, newIsRequired); - - } - - /** - * Sets the name. - * - * @param newName the new name - */ - public final void setName(final String newName) { - this.name = prepareForAssignment(this.name, newName); - } - - /** - * Sets the name format. - * - * @param newNameFormat the new name format - */ - public final void setNameFormat(final String newNameFormat) { - this.nameFormat = prepareForAssignment(this.nameFormat, newNameFormat); - } - - /** - * Sets the unknown attributes. - * - * @param newUnknownAttr the new unknown attributes - */ - public final void setUnknownAttributes(final AttributeMap newUnknownAttr) { - this.unknownAttributes = newUnknownAttr; - } - - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } +public class RequestedAttributeImpl extends AbstractSAMLObject implements RequestedAttribute { + + private static final Logger LOGGER = LoggerFactory.getLogger(RequestedAttributeImpl.class.getName()); + /** + * The attribute values. + */ + private final XMLObjectChildrenList attributeValues; + + /** + * The friendly name. + * + */ + private String friendlyName; + + /** + * The is required. + */ + private String isRequired; + + /** + * The name. + * + */ + private String name; + + /** + * The name format. + * + */ + private String nameFormat; + + /** + * The unknown attributes. + * + */ + private AttributeMap unknownAttributes; + + /** + * Instantiates a new requested attribute impl. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected RequestedAttributeImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + unknownAttributes = new AttributeMap(this); + attributeValues = new XMLObjectChildrenList(this); + } + + /** + * Gets the attribute values. + * + * @return the attribute values + */ + public final List getAttributeValues() { + return attributeValues; + } + + /** + * Gets the friendly name. + * + * @return the friendly name. + */ + public final String getFriendlyName() { + return friendlyName; + } + + /** + * Gets the checks if is required. + * + * @return the boolean if it's required. + */ + public final String isRequired() { + return isRequired; + } + + /** + * Gets the is required xs boolean. + * + * @return the XSBoolean if it's required. + */ + public final String getIsRequiredXSBoolean() { + return isRequired; + } + + /** + * Gets the name. + * + * @return the name + */ + public final String getName() { + return name; + } + + /** + * Gets the name format. + * + * @return the name format. + */ + public final String getNameFormat() { + return nameFormat; + } + + /** + * Gets the ordered children. + * + * @return the list of XMLObject. + */ + public final List getOrderedChildren() { + final ArrayList children = new ArrayList(); + children.addAll(attributeValues); + return Collections.unmodifiableList(children); + } + + /** + * Gets the unknown attributes. + * + * @return the attribute map + */ + public final AttributeMap getUnknownAttributes() { + return unknownAttributes; + } + + /** + * Sets the friendly name. + * + * @param newFriendlyName + * the new friendly name format + */ + public final void setFriendlyName(final String newFriendlyName) { + this.friendlyName = prepareForAssignment(this.friendlyName, newFriendlyName); + } + + /** + * Set new boolean value isRequired. + * + * @param newIsRequired + * then new value + */ + public final void setIsRequired(final String newIsRequired) { + isRequired = prepareForAssignment(this.isRequired, newIsRequired); + + } + + /** + * Sets the name. + * + * @param newName + * the new name + */ + public final void setName(final String newName) { + this.name = prepareForAssignment(this.name, newName); + } + + /** + * Sets the name format. + * + * @param newNameFormat + * the new name format + */ + public final void setNameFormat(final String newNameFormat) { + this.nameFormat = prepareForAssignment(this.nameFormat, newNameFormat); + } + + /** + * Sets the unknown attributes. + * + * @param newUnknownAttr + * the new unknown attributes + */ + public final void setUnknownAttributes(final AttributeMap newUnknownAttr) { + this.unknownAttributes = newUnknownAttr; + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeMarshaller.java index 1a14a118a..4a9ec94b1 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeMarshaller.java @@ -36,54 +36,44 @@ import eu.stork.peps.auth.engine.core.RequestedAttribute; */ public class RequestedAttributeMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall attributes. - * - * @param samlElement the SAML element - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallAttributes(final XMLObject samlElement, - final Element domElement) throws MarshallingException { - final RequestedAttribute requestedAttr = (RequestedAttribute) samlElement; + /** + * Marshall attributes. + * + * @param samlElement + * the SAML element + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallAttributes(final XMLObject samlElement, final Element domElement) throws MarshallingException { + final RequestedAttribute requestedAttr = (RequestedAttribute) samlElement; - if (requestedAttr.getName() != null) { - domElement.setAttributeNS(null, - RequestedAttribute.NAME_ATTRIB_NAME, requestedAttr - .getName()); - } + if (requestedAttr.getName() != null) { + domElement.setAttributeNS(null, RequestedAttribute.NAME_ATTRIB_NAME, requestedAttr.getName()); + } - if (requestedAttr.getNameFormat() != null) { - domElement.setAttributeNS(null, - RequestedAttribute.NAME_FORMAT_ATTR, requestedAttr - .getNameFormat()); - } + if (requestedAttr.getNameFormat() != null) { + domElement.setAttributeNS(null, RequestedAttribute.NAME_FORMAT_ATTR, requestedAttr.getNameFormat()); + } - if (requestedAttr.getFriendlyName() != null) { - domElement.setAttributeNS(null, - RequestedAttribute.FRIENDLY_NAME_ATT, requestedAttr - .getFriendlyName()); - } + if (requestedAttr.getFriendlyName() != null) { + domElement.setAttributeNS(null, RequestedAttribute.FRIENDLY_NAME_ATT, requestedAttr.getFriendlyName()); + } - if (requestedAttr.getIsRequiredXSBoolean() != null) { - domElement.setAttributeNS(null, - RequestedAttribute.IS_REQUIRED_ATTR, requestedAttr - .getIsRequiredXSBoolean().toString()); - } + if (requestedAttr.getIsRequiredXSBoolean() != null) { + domElement.setAttributeNS(null, RequestedAttribute.IS_REQUIRED_ATTR, requestedAttr.getIsRequiredXSBoolean().toString()); + } - Attr attr; - for (Entry entry : requestedAttr.getUnknownAttributes() - .entrySet()) { - attr = XMLHelper.constructAttribute(domElement.getOwnerDocument(), - entry.getKey()); - attr.setValue(entry.getValue()); - domElement.setAttributeNodeNS(attr); - if (Configuration.isIDAttribute(entry.getKey()) - || requestedAttr.getUnknownAttributes().isIDAttribute( - entry.getKey())) { - attr.getOwnerElement().setIdAttributeNode(attr, true); - } + Attr attr; + for (Entry entry : requestedAttr.getUnknownAttributes().entrySet()) { + attr = XMLHelper.constructAttribute(domElement.getOwnerDocument(), entry.getKey()); + attr.setValue(entry.getValue()); + domElement.setAttributeNodeNS(attr); + if (Configuration.isIDAttribute(entry.getKey()) || requestedAttr.getUnknownAttributes().isIDAttribute(entry.getKey())) { + attr.getOwnerElement().setIdAttributeNode(attr, true); + } + } } - } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeUnmarshaller.java index c07f852d9..098ece427 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributeUnmarshaller.java @@ -33,64 +33,60 @@ import eu.stork.peps.auth.engine.core.SAMLCore; * * @author fjquevedo */ -public class RequestedAttributeUnmarshaller extends - AbstractSAMLObjectUnmarshaller { +public class RequestedAttributeUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process child element. - * - * @param parentSAMLObject parent SAMLObject - * @param childSAMLObject child SAMLObject - * - * @throws UnmarshallingException error at unmarshall XML object - */ - protected final void processChildElement(final XMLObject parentSAMLObject, - final XMLObject childSAMLObject) throws UnmarshallingException { + /** + * Process child element. + * + * @param parentSAMLObject + * parent SAMLObject + * @param childSAMLObject + * child SAMLObject + * + * @throws UnmarshallingException + * error at unmarshall XML object + */ + protected final void processChildElement(final XMLObject parentSAMLObject, final XMLObject childSAMLObject) throws UnmarshallingException { - final RequestedAttribute requestedAttr = (RequestedAttribute) parentSAMLObject; + final RequestedAttribute requestedAttr = (RequestedAttribute) parentSAMLObject; - final QName childQName = childSAMLObject.getElementQName(); - if (childQName.getLocalPart().equals("AttributeValue") - && childQName.getNamespaceURI().equals(SAMLCore.STORK10_NS.getValue())) { - requestedAttr.getAttributeValues().add(childSAMLObject); - } else { - super.processChildElement(parentSAMLObject, childSAMLObject); + final QName childQName = childSAMLObject.getElementQName(); + if (childQName.getLocalPart().equals("AttributeValue") && childQName.getNamespaceURI().equals(SAMLCore.STORK10_NS.getValue())) { + requestedAttr.getAttributeValues().add(childSAMLObject); + } else { + super.processChildElement(parentSAMLObject, childSAMLObject); + } } - } - /** - * Process attribute. - * - * @param samlObject the SAML object - * @param attribute the attribute - * @throws UnmarshallingException the unmarshalling exception - */ - protected final void processAttribute(final XMLObject samlObject, - final Attr attribute) throws UnmarshallingException { + /** + * Process attribute. + * + * @param samlObject + * the SAML object + * @param attribute + * the attribute + * @throws UnmarshallingException + * the unmarshalling exception + */ + protected final void processAttribute(final XMLObject samlObject, final Attr attribute) throws UnmarshallingException { - final RequestedAttribute requestedAttr = (RequestedAttribute) samlObject; + final RequestedAttribute requestedAttr = (RequestedAttribute) samlObject; - if (attribute.getLocalName() - .equals(RequestedAttribute.NAME_ATTRIB_NAME)) { - requestedAttr.setName(attribute.getValue()); - } else if (attribute.getLocalName().equals( - RequestedAttribute.NAME_FORMAT_ATTR)) { - requestedAttr.setNameFormat(attribute.getValue()); - } else if (attribute.getLocalName().equals( - RequestedAttribute.FRIENDLY_NAME_ATT)) { - requestedAttr.setFriendlyName(attribute.getValue()); - } else if (attribute.getLocalName().equals( - RequestedAttribute.IS_REQUIRED_ATTR)) { - requestedAttr.setIsRequired(attribute - .getValue()); + if (attribute.getLocalName().equals(RequestedAttribute.NAME_ATTRIB_NAME)) { + requestedAttr.setName(attribute.getValue()); + } else if (attribute.getLocalName().equals(RequestedAttribute.NAME_FORMAT_ATTR)) { + requestedAttr.setNameFormat(attribute.getValue()); + } else if (attribute.getLocalName().equals(RequestedAttribute.FRIENDLY_NAME_ATT)) { + requestedAttr.setFriendlyName(attribute.getValue()); + } else if (attribute.getLocalName().equals(RequestedAttribute.IS_REQUIRED_ATTR)) { + requestedAttr.setIsRequired(attribute.getValue()); - } else { - final QName attribQName = XMLHelper.getNodeQName(attribute); - if (attribute.isId()) { - requestedAttr.getUnknownAttributes().registerID(attribQName); - } - requestedAttr.getUnknownAttributes().put(attribQName, - attribute.getValue()); + } else { + final QName attribQName = XMLHelper.getNodeQName(attribute); + if (attribute.isId()) { + requestedAttr.getUnknownAttributes().registerID(attribQName); + } + requestedAttr.getUnknownAttributes().put(attribQName, attribute.getValue()); + } } - } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesBuilder.java index d421c53d2..c9643d7ae 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesBuilder.java @@ -24,31 +24,30 @@ import eu.stork.peps.auth.engine.core.RequestedAttributes; * * @author fjquevedo */ -public class RequestedAttributesBuilder extends - AbstractSAMLObjectBuilder { - - - /** - * Builds the object. - * - * @return the requested attributes - */ - public final RequestedAttributes buildObject() { - return buildObject(RequestedAttributes.DEF_ELEMENT_NAME); - } - - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the requested attributes - */ - public final RequestedAttributes buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new RequestedAttributesImpl(namespaceURI, localName, - namespacePrefix); - } +public class RequestedAttributesBuilder extends AbstractSAMLObjectBuilder { + + /** + * Builds the object. + * + * @return the requested attributes + */ + public final RequestedAttributes buildObject() { + return buildObject(RequestedAttributes.DEF_ELEMENT_NAME); + } + + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the requested attributes + */ + public final RequestedAttributes buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new RequestedAttributesImpl(namespaceURI, localName, namespacePrefix); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesImpl.java index 0a5b37add..ad81e4846 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesImpl.java @@ -31,65 +31,64 @@ import eu.stork.peps.auth.engine.core.RequestedAttributes; * * @author fjquevedo */ -public class RequestedAttributesImpl extends AbstractSAMLObject implements - RequestedAttributes { - - /** - * Instantiates a new requested attributes implement. - * - * @param namespaceURI the namespace URI - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected RequestedAttributesImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - indexedChildren = new IndexedXMLObjectChildrenList(this); - } - - /** The indexed children. */ - private final IndexedXMLObjectChildrenList indexedChildren; - - /** - * Gets the indexed children. - * - * @return the indexed children - */ - public final IndexedXMLObjectChildrenList getIndexedChildren() { - return indexedChildren; - } - - - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - - final ArrayList children = new ArrayList(); - - children.addAll(indexedChildren); - - return Collections.unmodifiableList(children); - - } - - /** - * Gets the attributes. - * - * @return the attributes - * - * @see eu.stork.peps.auth.engine.core.RequestedAttributes#getAttributes() - */ - @SuppressWarnings("unchecked") - public final List getAttributes() { - return (List) indexedChildren - .subList(RequestedAttribute.DEF_ELEMENT_NAME); - } - - @Override - public int hashCode() { - throw new UnsupportedOperationException("hashCode method not implemented"); - } +public class RequestedAttributesImpl extends AbstractSAMLObject implements RequestedAttributes { + + /** + * Instantiates a new requested attributes implement. + * + * @param namespaceURI + * the namespace URI + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected RequestedAttributesImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + indexedChildren = new IndexedXMLObjectChildrenList(this); + } + + /** The indexed children. */ + private final IndexedXMLObjectChildrenList indexedChildren; + + /** + * Gets the indexed children. + * + * @return the indexed children + */ + public final IndexedXMLObjectChildrenList getIndexedChildren() { + return indexedChildren; + } + + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + + final ArrayList children = new ArrayList(); + + children.addAll(indexedChildren); + + return Collections.unmodifiableList(children); + + } + + /** + * Gets the attributes. + * + * @return the attributes + * + * @see eu.stork.peps.auth.engine.core.RequestedAttributes#getAttributes() + */ + @SuppressWarnings("unchecked") + public final List getAttributes() { + return (List) indexedChildren.subList(RequestedAttribute.DEF_ELEMENT_NAME); + } + + @Override + public int hashCode() { + throw new UnsupportedOperationException("hashCode method not implemented"); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesMarshaller.java index dfc42adf3..e1b15015e 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesMarshaller.java @@ -24,10 +24,10 @@ import org.opensaml.common.impl.AbstractSAMLObjectMarshaller; */ public class RequestedAttributesMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Instantiates a new requested attributes marshaller. - */ - public RequestedAttributesMarshaller() { - super(); - } + /** + * Instantiates a new requested attributes marshaller. + */ + public RequestedAttributesMarshaller() { + super(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesUnmarshaller.java index 41b3afa40..69990ebe5 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/RequestedAttributesUnmarshaller.java @@ -27,26 +27,27 @@ import eu.stork.peps.auth.engine.core.RequestedAttributes; * * @author fjquevedo */ -public class RequestedAttributesUnmarshaller extends - AbstractSAMLObjectUnmarshaller { +public class RequestedAttributesUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process child element. - * - * @param parentObject the parent object - * @param childObject the child object - * - * @throws UnmarshallingException error in unmarshall - */ - protected final void processChildElement(final XMLObject parentObject, - final XMLObject childObject) throws UnmarshallingException { - final RequestedAttributes attrStatement = (RequestedAttributes) parentObject; + /** + * Process child element. + * + * @param parentObject + * the parent object + * @param childObject + * the child object + * + * @throws UnmarshallingException + * error in unmarshall + */ + protected final void processChildElement(final XMLObject parentObject, final XMLObject childObject) throws UnmarshallingException { + final RequestedAttributes attrStatement = (RequestedAttributes) parentObject; - if (childObject instanceof RequestedAttribute) { - attrStatement.getAttributes().add((RequestedAttribute) childObject); - } else { - super.processChildElement(parentObject, childObject); + if (childObject instanceof RequestedAttribute) { + attrStatement.getAttributes().add((RequestedAttribute) childObject); + } else { + super.processChildElement(parentObject, childObject); + } } - } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationBuilder.java index a35c77936..6d9f9bf1e 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationBuilder.java @@ -24,28 +24,29 @@ import eu.stork.peps.auth.engine.core.SPApplication; * * @author fjquevedo */ -public class SPApplicationBuilder extends - AbstractSAMLObjectBuilder { +public class SPApplicationBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the service provider application - */ - public final SPApplication buildObject() { - return buildObject(SPApplication.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the service provider application + */ + public final SPApplication buildObject() { + return buildObject(SPApplication.DEF_ELEMENT_NAME); + } - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the service provider application - */ - public final SPApplication buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new SPApplicationImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the service provider application + */ + public final SPApplication buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new SPApplicationImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationImpl.java index 0a428a521..276697d6a 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationImpl.java @@ -29,56 +29,57 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public class SPApplicationImpl extends AbstractSAMLObject implements - SPApplication { +public class SPApplicationImpl extends AbstractSAMLObject implements SPApplication { - private static final Logger LOGGER = LoggerFactory.getLogger(SPApplicationImpl.class.getName()); - /** The service provider application. */ - private String spApplication; + private static final Logger LOGGER = LoggerFactory.getLogger(SPApplicationImpl.class.getName()); + /** The service provider application. */ + private String spApplication; - /** - * Instantiates a new service provider application. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected SPApplicationImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + /** + * Instantiates a new service provider application. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected SPApplicationImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Gets the service provider application. - * - * @return the service provider application - */ - public final String getSPApplication() { - return spApplication; - } + /** + * Gets the service provider application. + * + * @return the service provider application + */ + public final String getSPApplication() { + return spApplication; + } - /** - * Sets the service provider application. - * - * @param newSpApplication the new service provider application - */ - public final void setSPApplication(final String newSpApplication) { - this.spApplication = prepareForAssignment(this.spApplication, - newSpApplication); - } + /** + * Sets the service provider application. + * + * @param newSpApplication + * the new service provider application + */ + public final void setSPApplication(final String newSpApplication) { + this.spApplication = prepareForAssignment(this.spApplication, newSpApplication); + } - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationMarshaller.java index 4866c3535..d9268c550 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationMarshaller.java @@ -30,17 +30,18 @@ import eu.stork.peps.auth.engine.core.SPApplication; */ public class SPApplicationMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final SPApplication spApplication = (SPApplication) samlObject; - XMLHelper.appendTextContent(domElement, spApplication - .getSPApplication()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final SPApplication spApplication = (SPApplication) samlObject; + XMLHelper.appendTextContent(domElement, spApplication.getSPApplication()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationUnmarshaller.java index a28432a13..9fb514cf0 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPApplicationUnmarshaller.java @@ -20,7 +20,6 @@ import org.opensaml.xml.XMLObject; import eu.stork.peps.auth.engine.core.SPApplication; - /** * The Class SPApplicationUnmarshaller. * @@ -28,15 +27,16 @@ import eu.stork.peps.auth.engine.core.SPApplication; */ public class SPApplicationUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final SPApplication spApplication = (SPApplication) samlObject; - spApplication.setSPApplication(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final SPApplication spApplication = (SPApplication) samlObject; + spApplication.setSPApplication(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryBuilder.java index 48ec92f49..2c6c124e3 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryBuilder.java @@ -26,27 +26,27 @@ import eu.stork.peps.auth.engine.core.SPCountry; */ public class SPCountryBuilder extends AbstractSAMLObjectBuilder { - - /** - * Builds the object SPCountry. - * - * @return the service provider country - */ - public final SPCountry buildObject() { - return buildObject(SPCountry.DEF_ELEMENT_NAME); - } + /** + * Builds the object SPCountry. + * + * @return the service provider country + */ + public final SPCountry buildObject() { + return buildObject(SPCountry.DEF_ELEMENT_NAME); + } - - /** - * Builds the object SPCountry. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the service provider country - */ - public final SPCountry buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new SPCountryImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object SPCountry. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the service provider country + */ + public final SPCountry buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new SPCountryImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryImpl.java index 40a1ac86a..404a90079 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryImpl.java @@ -31,52 +31,55 @@ import org.slf4j.LoggerFactory; */ public class SPCountryImpl extends AbstractSAMLObject implements SPCountry { - private static final Logger LOGGER = LoggerFactory.getLogger(SPCountryImpl.class.getName()); - /** The service provider country. */ - private String spCountry; + private static final Logger LOGGER = LoggerFactory.getLogger(SPCountryImpl.class.getName()); + /** The service provider country. */ + private String spCountry; - /** - * Instantiates a new service provider country. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected SPCountryImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + /** + * Instantiates a new service provider country. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected SPCountryImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Gets the service provider country. - * - * @return the service provider country - */ - public final String getSPCountry() { - return spCountry; - } + /** + * Gets the service provider country. + * + * @return the service provider country + */ + public final String getSPCountry() { + return spCountry; + } - /** - * Sets the service provider country. - * - * @param newSpCountry the new service provider country - */ - public final void setSPCountry(final String newSpCountry) { - this.spCountry = prepareForAssignment(this.spCountry, newSpCountry); - } + /** + * Sets the service provider country. + * + * @param newSpCountry + * the new service provider country + */ + public final void setSPCountry(final String newSpCountry) { + this.spCountry = prepareForAssignment(this.spCountry, newSpCountry); + } - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryMarshaller.java index e82634749..1bd7121f0 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryMarshaller.java @@ -30,16 +30,18 @@ import eu.stork.peps.auth.engine.core.SPCountry; */ public class SPCountryMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final SPCountry spCountry = (SPCountry) samlObject; - XMLHelper.appendTextContent(domElement, spCountry.getSPCountry()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final SPCountry spCountry = (SPCountry) samlObject; + XMLHelper.appendTextContent(domElement, spCountry.getSPCountry()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryUnmarshaller.java index deb695ac6..c9ac243f1 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPCountryUnmarshaller.java @@ -20,7 +20,6 @@ import org.opensaml.xml.XMLObject; import eu.stork.peps.auth.engine.core.SPCountry; - /** * The Class SPCountryUnmarshaller. * @@ -28,15 +27,16 @@ import eu.stork.peps.auth.engine.core.SPCountry; */ public class SPCountryUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final SPCountry spCountry = (SPCountry) samlObject; - spCountry.setSPCountry(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final SPCountry spCountry = (SPCountry) samlObject; + spCountry.setSPCountry(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDBuilder.java index b3640947b..2cee08268 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDBuilder.java @@ -26,25 +26,27 @@ import eu.stork.peps.auth.engine.core.SPID; */ public class SPIDBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the SP ID - */ - public final SPID buildObject() { - return buildObject(SPID.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the SP ID + */ + public final SPID buildObject() { + return buildObject(SPID.DEF_ELEMENT_NAME); + } - /** - * Builds the object. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the citizen country code - */ - public final SPID buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new SPIDImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the citizen country code + */ + public final SPID buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new SPIDImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDImpl.java index 68611997b..cea51a5a8 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDImpl.java @@ -31,52 +31,55 @@ import org.slf4j.LoggerFactory; */ public class SPIDImpl extends AbstractSAMLObject implements SPID { - private static final Logger LOGGER = LoggerFactory.getLogger(SPIDImpl.class.getName()); - /** The citizen country code. */ - private String spId; - - /** - * Instantiates a new sP country impl. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected SPIDImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + private static final Logger LOGGER = LoggerFactory.getLogger(SPIDImpl.class.getName()); + /** The citizen country code. */ + private String spId; - /** - * Gets the SP ID. - * - * @return the SP ID - */ - public final String getSPID() { - return spId; - } + /** + * Instantiates a new sP country impl. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected SPIDImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Sets the SP ID. - * - * @param newSPID the new SP ID - */ - public final void setSPID(final String newSPID) { - this.spId = prepareForAssignment(this.spId, newSPID); - } + /** + * Gets the SP ID. + * + * @return the SP ID + */ + public final String getSPID() { + return spId; + } - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Sets the SP ID. + * + * @param newSPID + * the new SP ID + */ + public final void setSPID(final String newSPID) { + this.spId = prepareForAssignment(this.spId, newSPID); + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDMarshaller.java index 24389522e..d8cac34fc 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDMarshaller.java @@ -30,16 +30,18 @@ import eu.stork.peps.auth.engine.core.SPID; */ public class SPIDMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final SPID spid = (SPID) samlObject; - XMLHelper.appendTextContent(domElement, spid.getSPID()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final SPID spid = (SPID) samlObject; + XMLHelper.appendTextContent(domElement, spid.getSPID()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDUnmarshaller.java index e4d230b94..ab3aef878 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPIDUnmarshaller.java @@ -27,15 +27,16 @@ import eu.stork.peps.auth.engine.core.SPID; */ public class SPIDUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final SPID spid = (SPID) samlObject; - spid.setSPID(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final SPID spid = (SPID) samlObject; + spid.setSPID(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationBuilder.java index a6e1fe686..af7c97d19 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationBuilder.java @@ -26,16 +26,15 @@ import eu.stork.peps.auth.engine.core.SPInformation; * @author iinigo */ public final class SPInformationBuilder extends AbstractSAMLObjectBuilder { - - /** {@inheritDoc} */ - public SPInformation buildObject() { - return buildObject(SAMLCore.STORK10P_NS.getValue(), SPInformation.DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - } + /** {@inheritDoc} */ + public SPInformation buildObject() { + return buildObject(SAMLCore.STORK10P_NS.getValue(), SPInformation.DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + } + + /** {@inheritDoc} */ + public SPInformation buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new SPInformationImpl(namespaceURI, localName, namespacePrefix); + } - /** {@inheritDoc} */ - public SPInformation buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { - return new SPInformationImpl(namespaceURI, localName, namespacePrefix); - } - } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationImpl.java index ff6e90999..4089f0862 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationImpl.java @@ -27,84 +27,83 @@ import eu.stork.peps.auth.engine.core.SPInformation; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - /** * The Class SPInformationImpl. * * @author iinigo */ -public final class SPInformationImpl extends AbstractSignableSAMLObject implements -SPInformation { - - private static final Logger LOGGER = LoggerFactory.getLogger(SPInformationImpl.class.getName()); - /** The citizen country code. */ - private SPID spId; - - +public final class SPInformationImpl extends AbstractSignableSAMLObject implements SPInformation { + + private static final Logger LOGGER = LoggerFactory.getLogger(SPInformationImpl.class.getName()); + /** The citizen country code. */ + private SPID spId; + + /** + * Instantiates a new requested attributes implement. + * + * @param namespaceURI + * the namespace URI + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected SPInformationImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } + /** - * Instantiates a new requested attributes implement. - * - * @param namespaceURI the namespace URI - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected SPInformationImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } - - - /** - * getSPId. - * - * @return the SP ID - */ - public SPID getSPID() { - return spId; - } - - /** - * Gets the ordered children. - * - * @return the ordered children - * - */ - public List getOrderedChildren() { - final ArrayList children = new ArrayList(); - - children.add(spId); - - if (getSignature() != null) { - children.add(getSignature()); + * getSPId. + * + * @return the SP ID + */ + public SPID getSPID() { + return spId; + } + + /** + * Gets the ordered children. + * + * @return the ordered children + * + */ + public List getOrderedChildren() { + final ArrayList children = new ArrayList(); + + children.add(spId); + + if (getSignature() != null) { + children.add(getSignature()); + } + + return Collections.unmodifiableList(children); + + } + + /** + * Gets the signature reference id. + * + * @return the signature reference id + * + */ + public String getSignatureReferenceID() { + return null; + } + + /** + * Sets the SP Id. + * + * @param newSPId + * the new SP Id + * + */ + public void setSPID(SPID newSPId) { + this.spId = prepareForAssignment(this.spId, newSPId); + } + + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); } - - return Collections.unmodifiableList(children); - - } - - /** - * Gets the signature reference id. - * - * @return the signature reference id - * - */ - public String getSignatureReferenceID() { - return null; - } - - /** - * Sets the SP Id. - * - * @param newSPId the new SP Id - * - */ - public void setSPID(SPID newSPId) { - this.spId = prepareForAssignment(this.spId, newSPId); - } - - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationMarshaller.java index 44845948c..027e49e9d 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationMarshaller.java @@ -24,10 +24,10 @@ import org.opensaml.common.impl.AbstractSAMLObjectMarshaller; */ public class SPInformationMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Instantiates a new SP Information marshaller. - */ - public SPInformationMarshaller() { - super(); - } + /** + * Instantiates a new SP Information marshaller. + */ + public SPInformationMarshaller() { + super(); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationUnmarshaller.java index 414b93386..ecf69e2c7 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInformationUnmarshaller.java @@ -27,26 +27,27 @@ import eu.stork.peps.auth.engine.core.SPInformation; * * @author iinigo */ -public class SPInformationUnmarshaller extends - AbstractSAMLObjectUnmarshaller { +public class SPInformationUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process child element. - * - * @param parentObject the parent object - * @param childObject the child object - * - * @throws UnmarshallingException the unmarshalling exception - * - */ - protected final void processChildElement(final XMLObject parentObject, - final XMLObject childObject) throws UnmarshallingException { - final SPInformation spInformation = (SPInformation) parentObject; + /** + * Process child element. + * + * @param parentObject + * the parent object + * @param childObject + * the child object + * + * @throws UnmarshallingException + * the unmarshalling exception + * + */ + protected final void processChildElement(final XMLObject parentObject, final XMLObject childObject) throws UnmarshallingException { + final SPInformation spInformation = (SPInformation) parentObject; - if (childObject instanceof SPID) { - spInformation.setSPID((SPID) childObject); - } else { - super.processChildElement(parentObject, childObject); - } - } + if (childObject instanceof SPID) { + spInformation.setSPID((SPID) childObject); + } else { + super.processChildElement(parentObject, childObject); + } + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionBuilder.java index fe47cf99c..d26b15a1e 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionBuilder.java @@ -24,28 +24,29 @@ import eu.stork.peps.auth.engine.core.SPInstitution; * * @author fjquevedo */ -public class SPInstitutionBuilder extends - AbstractSAMLObjectBuilder { +public class SPInstitutionBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object. - * - * @return the service provider institution - */ - public final SPInstitution buildObject() { - return buildObject(SPInstitution.DEF_ELEMENT_NAME); - } + /** + * Builds the object. + * + * @return the service provider institution + */ + public final SPInstitution buildObject() { + return buildObject(SPInstitution.DEF_ELEMENT_NAME); + } - /** - * Builds the object SPInstitution. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the service provider institution - */ - public final SPInstitution buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new SPInstitutionImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object SPInstitution. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the service provider institution + */ + public final SPInstitution buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new SPInstitutionImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionImpl.java index 38438613a..054481744 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionImpl.java @@ -29,56 +29,57 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public class SPInstitutionImpl extends AbstractSAMLObject implements - SPInstitution { +public class SPInstitutionImpl extends AbstractSAMLObject implements SPInstitution { - private static final Logger LOGGER = LoggerFactory.getLogger(SPInstitutionImpl.class.getName()); - /** The service provider institution. */ - private String spInstitution; + private static final Logger LOGGER = LoggerFactory.getLogger(SPInstitutionImpl.class.getName()); + /** The service provider institution. */ + private String spInstitution; - /** - * Instantiates a new service provider institution. - * - * @param namespaceURI the namespace uri - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected SPInstitutionImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + /** + * Instantiates a new service provider institution. + * + * @param namespaceURI + * the namespace uri + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected SPInstitutionImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - /** - * Gets the service provider institution. - * - * @return the service provider institution - */ - public final String getSPInstitution() { - return spInstitution; - } + /** + * Gets the service provider institution. + * + * @return the service provider institution + */ + public final String getSPInstitution() { + return spInstitution; + } - /** - * Sets the service provider institution. - * - * @param newSpInstitution the new service provider institution - */ - public final void setSPInstitution(final String newSpInstitution) { - this.spInstitution = prepareForAssignment(this.spInstitution, - newSpInstitution); - } + /** + * Sets the service provider institution. + * + * @param newSpInstitution + * the new service provider institution + */ + public final void setSPInstitution(final String newSpInstitution) { + this.spInstitution = prepareForAssignment(this.spInstitution, newSpInstitution); + } - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } - } + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } +} diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionMarshaller.java index 504a1f035..48bb3fec5 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionMarshaller.java @@ -30,17 +30,18 @@ import eu.stork.peps.auth.engine.core.SPInstitution; */ public class SPInstitutionMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final SPInstitution spInstitution = (SPInstitution) samlObject; - XMLHelper.appendTextContent(domElement, spInstitution - .getSPInstitution()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final SPInstitution spInstitution = (SPInstitution) samlObject; + XMLHelper.appendTextContent(domElement, spInstitution.getSPInstitution()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionUnmarshaller.java index 103d5f2b2..f7b1f440e 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPInstitutionUnmarshaller.java @@ -27,15 +27,16 @@ import eu.stork.peps.auth.engine.core.SPInstitution; */ public class SPInstitutionUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final SPInstitution spInstitution = (SPInstitution) samlObject; - spInstitution.setSPInstitution(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final SPInstitution spInstitution = (SPInstitution) samlObject; + spInstitution.setSPInstitution(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorBuilder.java index a691b9008..b97e91b36 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorBuilder.java @@ -26,25 +26,27 @@ import eu.stork.peps.auth.engine.core.SPSector; */ public class SPSectorBuilder extends AbstractSAMLObjectBuilder { - /** - * Builds the object SPSector. - * - * @return the service provider sector. - */ - public final SPSector buildObject() { - return buildObject(SPSector.DEF_ELEMENT_NAME); - } + /** + * Builds the object SPSector. + * + * @return the service provider sector. + */ + public final SPSector buildObject() { + return buildObject(SPSector.DEF_ELEMENT_NAME); + } - /** - * Builds the object SPSector. - * - * @param namespaceURI the namespace uri - * @param localName the local name - * @param namespacePrefix the namespace prefix - * @return the service provider sector - */ - public final SPSector buildObject(final String namespaceURI, - final String localName, final String namespacePrefix) { - return new SPSectorImpl(namespaceURI, localName, namespacePrefix); - } + /** + * Builds the object SPSector. + * + * @param namespaceURI + * the namespace uri + * @param localName + * the local name + * @param namespacePrefix + * the namespace prefix + * @return the service provider sector + */ + public final SPSector buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new SPSectorImpl(namespaceURI, localName, namespacePrefix); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorImpl.java index 4ac822876..670198e67 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorImpl.java @@ -22,7 +22,6 @@ import org.opensaml.xml.XMLObject; import eu.stork.peps.auth.engine.core.SPSector; - /** * The Class SPSectorImpl. * @@ -30,55 +29,55 @@ import eu.stork.peps.auth.engine.core.SPSector; */ public class SPSectorImpl extends AbstractSAMLObject implements SPSector { - /** The service provider sector. */ - private String spSector; + /** The service provider sector. */ + private String spSector; - /** - * Instantiates a new Service provider sector implementation. - * - * @param namespaceURI the namespace URI - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected SPSectorImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } + /** + * Instantiates a new Service provider sector implementation. + * + * @param namespaceURI + * the namespace URI + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected SPSectorImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } - - /** - * Gets the service provider sector. - * - * @return the SP sector - * - * @see eu.stork.peps.auth.engine.core.SPSector#getSPSector() - */ - public final String getSPSector() { - return spSector; - } + /** + * Gets the service provider sector. + * + * @return the SP sector + * + * @see eu.stork.peps.auth.engine.core.SPSector#getSPSector() + */ + public final String getSPSector() { + return spSector; + } - - /** - * Sets the service provider sector. - * - * @param newSpSector the new service provider sector - */ - public final void setSPSector(final String newSpSector) { - this.spSector = prepareForAssignment(this.spSector, newSpSector); - } + /** + * Sets the service provider sector. + * + * @param newSpSector + * the new service provider sector + */ + public final void setSPSector(final String newSpSector) { + this.spSector = prepareForAssignment(this.spSector, newSpSector); + } - - /** - * Gets the ordered children. - * - * @return the ordered children - */ - public final List getOrderedChildren() { - return null; - } + /** + * Gets the ordered children. + * + * @return the ordered children + */ + public final List getOrderedChildren() { + return null; + } - @Override - public int hashCode() { - throw new UnsupportedOperationException("hashCode method not implemented"); - } + @Override + public int hashCode() { + throw new UnsupportedOperationException("hashCode method not implemented"); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorMarshaller.java index c5331e8f4..59e349f9f 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorMarshaller.java @@ -30,16 +30,18 @@ import eu.stork.peps.auth.engine.core.SPSector; */ public class SPSectorMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Marshall element content. - * - * @param samlObject the SAML object - * @param domElement the DOM element - * @throws MarshallingException the marshalling exception - */ - protected final void marshallElementContent(final XMLObject samlObject, - final Element domElement) throws MarshallingException { - final SPSector spSector = (SPSector) samlObject; - XMLHelper.appendTextContent(domElement, spSector.getSPSector()); - } + /** + * Marshall element content. + * + * @param samlObject + * the SAML object + * @param domElement + * the DOM element + * @throws MarshallingException + * the marshalling exception + */ + protected final void marshallElementContent(final XMLObject samlObject, final Element domElement) throws MarshallingException { + final SPSector spSector = (SPSector) samlObject; + XMLHelper.appendTextContent(domElement, spSector.getSPSector()); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorUnmarshaller.java index cbb05c6e5..e671cee03 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SPSectorUnmarshaller.java @@ -27,16 +27,16 @@ import eu.stork.peps.auth.engine.core.SPSector; */ public class SPSectorUnmarshaller extends AbstractSAMLObjectUnmarshaller { - - /** - * Process element content. - * - * @param samlObject the SAML object - * @param elementContent the element content - */ - protected final void processElementContent(final XMLObject samlObject, - final String elementContent) { - final SPSector spSector = (SPSector) samlObject; - spSector.setSPSector(elementContent); - } + /** + * Process element content. + * + * @param samlObject + * the SAML object + * @param elementContent + * the element content + */ + protected final void processElementContent(final XMLObject samlObject, final String elementContent) { + final SPSector spSector = (SPSector) samlObject; + spSector.setSPSector(elementContent); + } } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignHW.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignHW.java index 80796ea86..6e23d7f24 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignHW.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignHW.java @@ -64,8 +64,6 @@ import org.opensaml.xml.validation.ValidationException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; - - import eu.stork.peps.auth.engine.core.CustomAttributeQuery; import eu.stork.peps.auth.engine.core.SAMLEngineSignI; import eu.stork.peps.exceptions.SAMLEngineException; @@ -77,392 +75,345 @@ import eu.stork.peps.exceptions.SAMLEngineException; */ public final class SignHW implements SAMLEngineSignI { - /** The Constant CONFIGURATION_FILE. */ - private static final String CONF_FILE = "configurationFile"; - - /** The Constant KEYSTORE_TYPE. - private static final String KEYSTORE_TYPE = "keystoreType" */ - - /** The logger. */ - private static final Logger LOG = LoggerFactory.getLogger(SignHW.class - .getName()); - - /** The stork own key store. */ - private KeyStore storkOwnKeyStore = null; - - /** - * Gets the stork own key store. - * - * @return the stork own key store - */ - public KeyStore getStorkOwnKeyStore() { - return storkOwnKeyStore; - } - - /** - * Gets the stork trustStore. - * - * @return the stork own key store - */ - public KeyStore getTrustStore() { - return storkOwnKeyStore; - } - - /** - * Sets the stork own key store. - * - * @param newkOwnKeyStore the new stork own key store - */ - public void setStorkOwnKeyStore(final KeyStore newkOwnKeyStore) { - this.storkOwnKeyStore = newkOwnKeyStore; - } - - /** - * Gets the properties. - * - * @return the properties - */ - public Properties getProperties() { - return properties; - } - - /** - * Sets the properties. - * - * @param newProperties the new properties - */ - public void setProperties(final Properties newProperties) { - this.properties = newProperties; - } - - /** The HW sign prop. */ - private Properties properties = null; - - /** - * @see - * eu.stork.peps.auth.engine.core.SAMLEngineSignI#init(java.lang.String) - * @param fileConf file of configuration - * @throws SAMLEngineException error in read file - */ - public void init(final String fileConf) - throws SAMLEngineException { - InputStream inputStr = null; - try { - inputStr = SignHW.class.getResourceAsStream("/" - + fileConf); - properties = new Properties(); - - properties.loadFromXML(inputStr); - } catch (final InvalidPropertiesFormatException e) { - LOG.info("Exception: invalid properties format."); - throw new SAMLEngineException(e); - } catch (IOException e) { - LOG.info("Exception: invalid file: " + fileConf); - throw new SAMLEngineException(e); - } finally { - IOUtils.closeQuietly(inputStr); + /** The Constant CONFIGURATION_FILE. */ + private static final String CONF_FILE = "configurationFile"; + + /** + * The Constant KEYSTORE_TYPE. private static final String KEYSTORE_TYPE = "keystoreType" + */ + + /** The logger. */ + private static final Logger LOG = LoggerFactory.getLogger(SignHW.class.getName()); + + /** The stork own key store. */ + private KeyStore storkOwnKeyStore = null; + + /** + * Gets the stork own key store. + * + * @return the stork own key store + */ + public KeyStore getStorkOwnKeyStore() { + return storkOwnKeyStore; + } + + /** + * Gets the stork trustStore. + * + * @return the stork own key store + */ + public KeyStore getTrustStore() { + return storkOwnKeyStore; + } + + /** + * Sets the stork own key store. + * + * @param newkOwnKeyStore + * the new stork own key store + */ + public void setStorkOwnKeyStore(final KeyStore newkOwnKeyStore) { + this.storkOwnKeyStore = newkOwnKeyStore; + } + + /** + * Gets the properties. + * + * @return the properties + */ + public Properties getProperties() { + return properties; } - } - - - /** - * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#getCertificate() - * @return the X509Certificate. - */ - public X509Certificate getCertificate() { - throw new NotImplementedException(); - } - - /** - * @see - * eu.stork.peps.auth.engine.core.SAMLEngineSignI#sign(SignableSAMLObject tokenSaml) - * @param tokenSaml signable SAML Object - * @return the SAMLObject signed. - * @throws SAMLEngineException error in sign token saml - */ - public SAMLObject sign(final SignableSAMLObject tokenSaml) throws SAMLEngineException { - - try { - LOG.info("Star procces of sign"); - final char[] pin = properties.getProperty("keyPassword") - .toCharArray(); - - storkOwnKeyStore.load(null, pin); - - final String serialNumber = properties.getProperty("serialNumber"); - final String issuer = properties.getProperty("issuer"); - - String alias = null; - String aliasCert; - X509Certificate certificate; - - boolean find = false; - for (final Enumeration e = storkOwnKeyStore.aliases(); e - .hasMoreElements() && !find;) { - aliasCert = e.nextElement(); - certificate = (X509Certificate) storkOwnKeyStore - .getCertificate(aliasCert); - // Verified serial number, issuer - - final String serialNum = certificate.getSerialNumber() - .toString(16); - X509Principal issuerDN = new X509Principal(certificate.getIssuerDN().getName()); - X509Principal issuerDNConf = new X509Principal(issuer); - - if(serialNum.equalsIgnoreCase(serialNumber) - && X509PrincipalUtil.equals(issuerDN, issuerDNConf)){ - alias = aliasCert; - find = true; + + /** + * Sets the properties. + * + * @param newProperties + * the new properties + */ + public void setProperties(final Properties newProperties) { + this.properties = newProperties; + } + + /** The HW sign prop. */ + private Properties properties = null; + + /** + * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#init(java.lang.String) + * @param fileConf + * file of configuration + * @throws SAMLEngineException + * error in read file + */ + public void init(final String fileConf) throws SAMLEngineException { + InputStream inputStr = null; + try { + inputStr = SignHW.class.getResourceAsStream("/" + fileConf); + properties = new Properties(); + + properties.loadFromXML(inputStr); + } catch (final InvalidPropertiesFormatException e) { + LOG.info("Exception: invalid properties format."); + throw new SAMLEngineException(e); + } catch (IOException e) { + LOG.info("Exception: invalid file: " + fileConf); + throw new SAMLEngineException(e); + } finally { + IOUtils.closeQuietly(inputStr); + } + } + + /** + * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#getCertificate() + * @return the X509Certificate. + */ + public X509Certificate getCertificate() { + throw new NotImplementedException(); + } + + /** + * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#sign(SignableSAMLObject tokenSaml) + * @param tokenSaml + * signable SAML Object + * @return the SAMLObject signed. + * @throws SAMLEngineException + * error in sign token saml + */ + public SAMLObject sign(final SignableSAMLObject tokenSaml) throws SAMLEngineException { + + try { + LOG.info("Star procces of sign"); + final char[] pin = properties.getProperty("keyPassword").toCharArray(); + + storkOwnKeyStore.load(null, pin); + + final String serialNumber = properties.getProperty("serialNumber"); + final String issuer = properties.getProperty("issuer"); + + String alias = null; + String aliasCert; + X509Certificate certificate; + + boolean find = false; + for (final Enumeration e = storkOwnKeyStore.aliases(); e.hasMoreElements() && !find;) { + aliasCert = e.nextElement(); + certificate = (X509Certificate) storkOwnKeyStore.getCertificate(aliasCert); + // Verified serial number, issuer + + final String serialNum = certificate.getSerialNumber().toString(16); + X509Principal issuerDN = new X509Principal(certificate.getIssuerDN().getName()); + X509Principal issuerDNConf = new X509Principal(issuer); + + if (serialNum.equalsIgnoreCase(serialNumber) && X509PrincipalUtil.equals(issuerDN, issuerDNConf)) { + alias = aliasCert; + find = true; + } + + } + + if (!find) { + throw new SAMLEngineException("Certificate cannot be found in keystore "); + } + certificate = (X509Certificate) storkOwnKeyStore.getCertificate(alias); + final PrivateKey privateKey = (PrivateKey) storkOwnKeyStore.getKey(alias, pin); + + LOG.info("Recover BasicX509Credential."); + final BasicX509Credential credential = new BasicX509Credential(); + + LOG.debug("Load certificate"); + credential.setEntityCertificate(certificate); + + LOG.debug("Load privateKey"); + credential.setPrivateKey(privateKey); + + LOG.info("Star procces of sign"); + final Signature signature = (Signature) org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME).buildObject(Signature.DEFAULT_ELEMENT_NAME); + + LOG.debug("Begin signature with openSaml"); + signature.setSigningCredential(credential); + + /* + * signature.setSignatureAlgorithm( SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1); + */ + signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); + + final SecurityConfiguration securityConf = org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(); + final NamedKeyInfoGeneratorManager keyInfoManager = securityConf.getKeyInfoGeneratorManager(); + final KeyInfoGeneratorManager keyInfoGenManager = keyInfoManager.getDefaultManager(); + final KeyInfoGeneratorFactory keyInfoGenFac = keyInfoGenManager.getFactory(credential); + final KeyInfoGenerator keyInfoGenerator = keyInfoGenFac.newInstance(); + + final KeyInfo keyInfo = keyInfoGenerator.generate(credential); + + signature.setKeyInfo(keyInfo); + + LOG.debug("Set Canonicalization Algorithm"); + signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); + + // Create a second signature which will be used when signing assertion and response + final Signature signature2 = (Signature) Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME).buildObject(Signature.DEFAULT_ELEMENT_NAME); + final SecurityConfiguration secConfiguration2 = Configuration.getGlobalSecurityConfiguration(); + final NamedKeyInfoGeneratorManager keyInfoManager2 = secConfiguration2.getKeyInfoGeneratorManager(); + final KeyInfoGeneratorManager keyInfoGenManager2 = keyInfoManager2.getDefaultManager(); + final KeyInfoGeneratorFactory keyInfoGenFac2 = keyInfoGenManager2.getFactory(credential); + final KeyInfoGenerator keyInfoGenerator2 = keyInfoGenFac2.newInstance(); + + KeyInfo keyInfo2 = keyInfoGenerator2.generate(credential); + signature2.setSigningCredential(credential); + signature2.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); + signature2.setKeyInfo(keyInfo2); + signature2.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); + + LOG.info("Marshall samlToken."); + String qn = tokenSaml.getElementQName().toString(); + + if (qn.endsWith(CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME)) { + tokenSaml.setSignature(signature); + CustomAttributeQueryMarshaller mars = new CustomAttributeQueryMarshaller(); + mars.marshall(tokenSaml); + Signer.signObject(signature); + } else if (qn.endsWith(Response.DEFAULT_ELEMENT_LOCAL_NAME) && !qn.contains(LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME)) { + Response res = (Response) tokenSaml; + List asserts = res.getAssertions(); + // If multiple assertions we just sign the response and not the assertion + if (asserts.size() > 1) { + tokenSaml.setSignature(signature); + Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); + LOG.info("Sign samlToken."); + Signer.signObject(signature); + } + // If single assertion we sign the assertion and response + else { + Assertion assertion = (Assertion) asserts.get(0); + assertion.setSignature(signature); + tokenSaml.setSignature(signature2); + Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); + LOG.info("Sign samlToken."); + Signer.signObject(signature); + Signer.signObject(signature2); + } + } + // Normally we just sign the total saml response + else { + tokenSaml.setSignature(signature); + Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); + LOG.info("Sign samlToken."); + Signer.signObject(signature); + } + + } catch (final MarshallingException e) { + LOG.error("MarshallingException"); + throw new SAMLEngineException(e); + } catch (final NoSuchAlgorithmException e) { + LOG.error("A 'xmldsig#rsa-sha1' cryptographic algorithm is requested but is not available in the environment."); + throw new SAMLEngineException(e); + } catch (final KeyStoreException e) { + LOG.error("Generic KeyStore exception."); + throw new SAMLEngineException(e); + } catch (final SignatureException e) { + LOG.error("Signature exception."); + throw new SAMLEngineException(e); + } catch (final SecurityException e) { + LOG.error("Security exception."); + throw new SAMLEngineException(e); + } catch (final CertificateException e) { + LOG.error("Certificate exception."); + throw new SAMLEngineException(e); + } catch (final IOException e) { + LOG.error("IO exception."); + throw new SAMLEngineException(e); + } catch (final UnrecoverableKeyException e) { + LOG.error("UnrecoverableKeyException exception."); + throw new SAMLEngineException(e); } - - } - - if (!find) { - throw new SAMLEngineException("Certificate cannot be found in keystore "); - } - certificate = (X509Certificate) storkOwnKeyStore.getCertificate(alias); - final PrivateKey privateKey = (PrivateKey) storkOwnKeyStore.getKey( - alias, pin); - - LOG.info("Recover BasicX509Credential."); - final BasicX509Credential credential = new BasicX509Credential(); - - LOG.debug("Load certificate"); - credential.setEntityCertificate(certificate); - - LOG.debug("Load privateKey"); - credential.setPrivateKey(privateKey); - - LOG.info("Star procces of sign"); - final Signature signature = (Signature) org.opensaml.xml.Configuration - .getBuilderFactory().getBuilder( - Signature.DEFAULT_ELEMENT_NAME).buildObject( - Signature.DEFAULT_ELEMENT_NAME); - - LOG.debug("Begin signature with openSaml"); - signature.setSigningCredential(credential); - - /*signature.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1);*/ - signature.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); - - - - final SecurityConfiguration securityConf = - org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(); - final NamedKeyInfoGeneratorManager keyInfoManager = securityConf - .getKeyInfoGeneratorManager(); - final KeyInfoGeneratorManager keyInfoGenManager = keyInfoManager - .getDefaultManager(); - final KeyInfoGeneratorFactory keyInfoGenFac = keyInfoGenManager - .getFactory(credential); - final KeyInfoGenerator keyInfoGenerator = keyInfoGenFac - .newInstance(); - - final KeyInfo keyInfo = keyInfoGenerator.generate(credential); - - signature.setKeyInfo(keyInfo); - - LOG.debug("Set Canonicalization Algorithm"); - signature.setCanonicalizationAlgorithm( - SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); - - //Create a second signature which will be used when signing assertion and response - final Signature signature2 = (Signature) Configuration - .getBuilderFactory().getBuilder( - Signature.DEFAULT_ELEMENT_NAME).buildObject( - Signature.DEFAULT_ELEMENT_NAME); - final SecurityConfiguration secConfiguration2 = Configuration - .getGlobalSecurityConfiguration(); - final NamedKeyInfoGeneratorManager keyInfoManager2 = secConfiguration2 - .getKeyInfoGeneratorManager(); - final KeyInfoGeneratorManager keyInfoGenManager2 = keyInfoManager2 - .getDefaultManager(); - final KeyInfoGeneratorFactory keyInfoGenFac2 = keyInfoGenManager2 - .getFactory(credential); - final KeyInfoGenerator keyInfoGenerator2 = keyInfoGenFac2 - .newInstance(); - - KeyInfo keyInfo2 = keyInfoGenerator2.generate(credential); - signature2.setSigningCredential(credential); - signature2.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); - signature2.setKeyInfo(keyInfo2); - signature2.setCanonicalizationAlgorithm( - SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); - - - LOG.info("Marshall samlToken."); - String qn = tokenSaml.getElementQName().toString(); - - if (qn.endsWith(CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME)) - { - tokenSaml.setSignature(signature); - CustomAttributeQueryMarshaller mars = new CustomAttributeQueryMarshaller(); - mars.marshall(tokenSaml); - Signer.signObject(signature); - } - else if (qn.endsWith(Response.DEFAULT_ELEMENT_LOCAL_NAME) && !qn.contains(LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME)) - { - Response res = (Response)tokenSaml; - List asserts = res.getAssertions(); - //If multiple assertions we just sign the response and not the assertion - if (asserts.size() > 1) - { - tokenSaml.setSignature(signature); - Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); - LOG.info("Sign samlToken."); - Signer.signObject(signature); - } - //If single assertion we sign the assertion and response - else - { - Assertion assertion = (Assertion)asserts.get(0); - assertion.setSignature(signature); - tokenSaml.setSignature(signature2); - Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); - LOG.info("Sign samlToken."); - Signer.signObject(signature); - Signer.signObject(signature2); - } - } - //Normally we just sign the total saml response - else - { - tokenSaml.setSignature(signature); - Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); - LOG.info("Sign samlToken."); - Signer.signObject(signature); - } - - } catch (final MarshallingException e) { - LOG.error("MarshallingException"); - throw new SAMLEngineException(e); - } catch (final NoSuchAlgorithmException e) { - LOG.error("A 'xmldsig#rsa-sha1' cryptographic algorithm is requested but is not available in the environment."); - throw new SAMLEngineException(e); - } catch (final KeyStoreException e) { - LOG.error("Generic KeyStore exception."); - throw new SAMLEngineException(e); - } catch (final SignatureException e) { - LOG.error("Signature exception."); - throw new SAMLEngineException(e); - } catch (final SecurityException e) { - LOG.error("Security exception."); - throw new SAMLEngineException(e); - } catch (final CertificateException e) { - LOG.error("Certificate exception."); - throw new SAMLEngineException(e); - } catch (final IOException e) { - LOG.error("IO exception."); - throw new SAMLEngineException(e); - } catch (final UnrecoverableKeyException e) { - LOG.error("UnrecoverableKeyException exception."); - throw new SAMLEngineException(e); + + return tokenSaml; } - return tokenSaml; - } - - /** - * @see - * eu.stork.peps.auth.engine.core.SAMLEngineSignI#validateSignature(SignableSAMLObject) - * @param tokenSaml the token saml - * @return the SAMLObject validated. - * @throws SAMLEngineException exception in validate signature - */ - public SAMLObject validateSignature(final SignableSAMLObject tokenSaml) - throws SAMLEngineException { - LOG.info("Start signature validation."); - try { - - // Validate structure signature - final SAMLSignatureProfileValidator signProfValidator = - new SAMLSignatureProfileValidator(); - - // Indicates signature id conform to SAML Signature profile - signProfValidator.validate(tokenSaml.getSignature()); - - String aliasCert; - X509Certificate certificate; - - final List trustedCred = new ArrayList(); - - for (final Enumeration e = storkOwnKeyStore.aliases(); e - .hasMoreElements();) { - aliasCert = e.nextElement(); - final BasicX509Credential credential = new BasicX509Credential(); - certificate = (X509Certificate) storkOwnKeyStore - .getCertificate(aliasCert); - credential.setEntityCertificate(certificate); - trustedCred.add(credential); - } - - final KeyInfo keyInfo = tokenSaml.getSignature().getKeyInfo(); - final List listCertificates = KeyInfoHelper - .getCertificates(keyInfo); - - if (listCertificates.size() != 1) { - throw new SAMLEngineException("Only must be one certificate"); - } - - // Exist only one certificate - final BasicX509Credential entityX509Cred = new BasicX509Credential(); - entityX509Cred.setEntityCertificate(listCertificates.get(0)); - - final ExplicitKeyTrustEvaluator keyTrustEvaluator = - new ExplicitKeyTrustEvaluator(); - if (!keyTrustEvaluator.validate(entityX509Cred, trustedCred)) { - throw new SAMLEngineException("Certificate it is not trusted."); - } - - final SignatureValidator sigValidator = new SignatureValidator( - entityX509Cred); - - sigValidator.validate(tokenSaml.getSignature()); - - } catch (final ValidationException e) { - LOG.error("ValidationException.", e); - throw new SAMLEngineException(e); - } catch (final KeyStoreException e) { - LOG.error("ValidationException.", e); - throw new SAMLEngineException(e); - } catch (final CertificateException e) { - LOG.error("CertificateException.", e); - throw new SAMLEngineException(e); + /** + * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#validateSignature(SignableSAMLObject) + * @param tokenSaml + * the token saml + * @return the SAMLObject validated. + * @throws SAMLEngineException + * exception in validate signature + */ + public SAMLObject validateSignature(final SignableSAMLObject tokenSaml) throws SAMLEngineException { + LOG.info("Start signature validation."); + try { + + // Validate structure signature + final SAMLSignatureProfileValidator signProfValidator = new SAMLSignatureProfileValidator(); + + // Indicates signature id conform to SAML Signature profile + signProfValidator.validate(tokenSaml.getSignature()); + + String aliasCert; + X509Certificate certificate; + + final List trustedCred = new ArrayList(); + + for (final Enumeration e = storkOwnKeyStore.aliases(); e.hasMoreElements();) { + aliasCert = e.nextElement(); + final BasicX509Credential credential = new BasicX509Credential(); + certificate = (X509Certificate) storkOwnKeyStore.getCertificate(aliasCert); + credential.setEntityCertificate(certificate); + trustedCred.add(credential); + } + + final KeyInfo keyInfo = tokenSaml.getSignature().getKeyInfo(); + final List listCertificates = KeyInfoHelper.getCertificates(keyInfo); + + if (listCertificates.size() != 1) { + throw new SAMLEngineException("Only must be one certificate"); + } + + // Exist only one certificate + final BasicX509Credential entityX509Cred = new BasicX509Credential(); + entityX509Cred.setEntityCertificate(listCertificates.get(0)); + + final ExplicitKeyTrustEvaluator keyTrustEvaluator = new ExplicitKeyTrustEvaluator(); + if (!keyTrustEvaluator.validate(entityX509Cred, trustedCred)) { + throw new SAMLEngineException("Certificate it is not trusted."); + } + + final SignatureValidator sigValidator = new SignatureValidator(entityX509Cred); + + sigValidator.validate(tokenSaml.getSignature()); + + } catch (final ValidationException e) { + LOG.error("ValidationException.", e); + throw new SAMLEngineException(e); + } catch (final KeyStoreException e) { + LOG.error("ValidationException.", e); + throw new SAMLEngineException(e); + } catch (final CertificateException e) { + LOG.error("CertificateException.", e); + throw new SAMLEngineException(e); + } + return tokenSaml; } - return tokenSaml; - } - - /** - * load cryptographic service provider. - * - * @throws SAMLEngineException the SAML engine exception - * Note this class was using pkcs11Provider - * final Provider pkcs11Provider = new sun.security.pkcs11.SunPKCS11(inputStream) - * if (Security.getProperty(pkcs11Provider.getName()) == null) { - * Security.insertProviderAt(pkcs11Provider, Security .getProviders().length) - * } - * storkOwnKeyStore = KeyStore.getInstance(properties.getProperty(KEYSTORE_TYPE)) - */ - public void loadCryptServiceProvider() throws SAMLEngineException { - LOG.info("Load Cryptographic Service Provider"); - InputStream inputStream = null; - - try { - inputStream = SignHW.class.getResourceAsStream("/" - + properties.getProperty(CONF_FILE)); - - } catch (final Exception e) { - throw new SAMLEngineException( - "Error loading CryptographicServiceProvider", e); - } finally { - IOUtils.closeQuietly(inputStream); + + /** + * load cryptographic service provider. + * + * @throws SAMLEngineException + * the SAML engine exception Note this class was using pkcs11Provider final Provider pkcs11Provider = new sun.security.pkcs11.SunPKCS11(inputStream) if + * (Security.getProperty(pkcs11Provider.getName()) == null) { Security.insertProviderAt(pkcs11Provider, Security .getProviders().length) } storkOwnKeyStore = + * KeyStore.getInstance(properties.getProperty(KEYSTORE_TYPE)) + */ + public void loadCryptServiceProvider() throws SAMLEngineException { + LOG.info("Load Cryptographic Service Provider"); + InputStream inputStream = null; + + try { + inputStream = SignHW.class.getResourceAsStream("/" + properties.getProperty(CONF_FILE)); + + } catch (final Exception e) { + throw new SAMLEngineException("Error loading CryptographicServiceProvider", e); + } finally { + IOUtils.closeQuietly(inputStream); + } } - } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignModuleFactory.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignModuleFactory.java index c37074eab..66d0201d5 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignModuleFactory.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignModuleFactory.java @@ -30,35 +30,35 @@ import eu.stork.peps.exceptions.STORKSAMLEngineException; public final class SignModuleFactory { - /** The Constant LOG. */ - private static final Logger LOG = LoggerFactory - .getLogger(SignModuleFactory.class.getName()); + /** The Constant LOG. */ + private static final Logger LOG = LoggerFactory.getLogger(SignModuleFactory.class.getName()); - /** - * Instantiates a new module sign factory. - */ - private SignModuleFactory() { + /** + * Instantiates a new module sign factory. + */ + private SignModuleFactory() { - } - - /** - * Gets the single instance of SignModuleFactory. - * - * @param className the class name - * - * @return single instance of SignModuleFactory - * - * @throws STORKSAMLEngineException the STORKSAML engine exception - */ - public static SAMLEngineSignI getInstance(final String className) - throws STORKSAMLEngineException { - LOG.info("[START]SignModuleFactory static"); - try { - final Class cls = Class.forName(className); - return (SAMLEngineSignI) cls.newInstance(); - } catch (Exception e) { - throw new STORKSAMLEngineException(e); } - } + /** + * Gets the single instance of SignModuleFactory. + * + * @param className + * the class name + * + * @return single instance of SignModuleFactory + * + * @throws STORKSAMLEngineException + * the STORKSAML engine exception + */ + public static SAMLEngineSignI getInstance(final String className) throws STORKSAMLEngineException { + LOG.info("[START]SignModuleFactory static"); + try { + final Class cls = Class.forName(className); + return (SAMLEngineSignI) cls.newInstance(); + } catch (Exception e) { + throw new STORKSAMLEngineException(e); + } + + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignP12.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignP12.java index 06e80dc14..c91f11444 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignP12.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignP12.java @@ -74,26 +74,21 @@ import eu.stork.peps.auth.engine.core.SAMLEngineSignI; import eu.stork.peps.exceptions.SAMLEngineException; /** - * The Class SWSign. Class responsible for signing and validating of messages - * SAML with a certificate store software. + * The Class SWSign. Class responsible for signing and validating of messages SAML with a certificate store software. * * @author fjquevedo */ public final class SignP12 implements SAMLEngineSignI { /** The logger. */ - private static final Logger LOG = LoggerFactory.getLogger(SignP12.class - .getName()); - + private static final Logger LOG = LoggerFactory.getLogger(SignP12.class.getName()); /** The p12 store. */ private KeyStore p12Store = null; - /** The trust store. */ private KeyStore trustStore = null; - /** * Gets the trust store. * @@ -107,7 +102,8 @@ public final class SignP12 implements SAMLEngineSignI { /** * Sets the trust store. * - * @param newTrustStore the new trust store + * @param newTrustStore + * the new trust store */ public void setTrustStore(final KeyStore newTrustStore) { this.trustStore = newTrustStore; @@ -123,8 +119,6 @@ public final class SignP12 implements SAMLEngineSignI { return properties; } - - /** * Gets the p12 store. * @@ -134,23 +128,21 @@ public final class SignP12 implements SAMLEngineSignI { return p12Store; } - - /** * Sets the p12 store. * - * @param newP12Store the new p12 store + * @param newP12Store + * the new p12 store */ public void setP12Store(final KeyStore newP12Store) { this.p12Store = newP12Store; } - - /** * Sets the properties. * - * @param newProperties the new properties + * @param newProperties + * the new properties */ public void setProperties(final Properties newProperties) { this.properties = newProperties; @@ -159,13 +151,14 @@ public final class SignP12 implements SAMLEngineSignI { /** The SW sign prop. */ private Properties properties = null; - /** * Initialize the file configuration. * - * @param fileConf name of the file configuration + * @param fileConf + * name of the file configuration * - * @throws SAMLEngineException error at the load from file configuration + * @throws SAMLEngineException + * error at the load from file configuration */ @Override public void init(final String fileConf) throws SAMLEngineException { @@ -209,7 +202,7 @@ public final class SignP12 implements SAMLEngineSignI { * Gets the certificate. * * @return the X509Certificate - * + * */ @Override public X509Certificate getCertificate() { @@ -219,16 +212,17 @@ public final class SignP12 implements SAMLEngineSignI { /** * Sign the token SAML. * - * @param tokenSaml token SAML + * @param tokenSaml + * token SAML * * @return the X509Certificate signed. * - * @throws SAMLEngineException error at sign SAML token + * @throws SAMLEngineException + * error at sign SAML token * */ @Override - public SAMLObject sign(final SignableSAMLObject tokenSaml) - throws SAMLEngineException { + public SAMLObject sign(final SignableSAMLObject tokenSaml) throws SAMLEngineException { LOG.info("Start Sign process"); try { @@ -240,30 +234,24 @@ public final class SignP12 implements SAMLEngineSignI { X509Certificate certificate; boolean find = false; - for (final Enumeration e = p12Store.aliases(); e - .hasMoreElements() && !find;) { + for (final Enumeration e = p12Store.aliases(); e.hasMoreElements() && !find;) { aliasCert = e.nextElement(); - certificate = (X509Certificate) p12Store - .getCertificate(aliasCert); + certificate = (X509Certificate) p12Store.getCertificate(aliasCert); - final String serialNum = certificate.getSerialNumber() - .toString(16); + final String serialNum = certificate.getSerialNumber().toString(16); X509Principal issuerDN = new X509Principal(certificate.getIssuerDN().getName()); X509Principal issuerDNConf = new X509Principal(issuer); - if(serialNum.equalsIgnoreCase(serialNumber) - && X509PrincipalUtil.equals(issuerDN, issuerDNConf)){ + if (serialNum.equalsIgnoreCase(serialNumber) && X509PrincipalUtil.equals(issuerDN, issuerDNConf)) { alias = aliasCert; find = true; } } - certificate = (X509Certificate) p12Store - .getCertificate(alias); - final PrivateKey privateKey = (PrivateKey) p12Store.getKey( - alias, properties.getProperty("keyPassword").toCharArray()); + certificate = (X509Certificate) p12Store.getCertificate(alias); + final PrivateKey privateKey = (PrivateKey) p12Store.getKey(alias, properties.getProperty("keyPassword").toCharArray()); LOG.info("Recover BasicX509Credential."); final BasicX509Credential credential = new BasicX509Credential(); @@ -275,102 +263,73 @@ public final class SignP12 implements SAMLEngineSignI { credential.setPrivateKey(privateKey); LOG.debug("Begin signature with openSaml"); - final Signature signature = (Signature) org.opensaml.xml.Configuration - .getBuilderFactory().getBuilder( - Signature.DEFAULT_ELEMENT_NAME).buildObject( - Signature.DEFAULT_ELEMENT_NAME); + final Signature signature = (Signature) org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME).buildObject(Signature.DEFAULT_ELEMENT_NAME); signature.setSigningCredential(credential); - /*signature.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1);*/ - signature.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); - - final SecurityConfiguration secConfiguration = org.opensaml.xml.Configuration - .getGlobalSecurityConfiguration(); - final NamedKeyInfoGeneratorManager keyInfoManager = secConfiguration - .getKeyInfoGeneratorManager(); - final KeyInfoGeneratorManager keyInfoGenManager = keyInfoManager - .getDefaultManager(); - final KeyInfoGeneratorFactory keyInfoGenFac = keyInfoGenManager - .getFactory(credential); - final KeyInfoGenerator keyInfoGenerator = keyInfoGenFac - .newInstance(); + /* + * signature.setSignatureAlgorithm( SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1); + */ + signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); + + final SecurityConfiguration secConfiguration = org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(); + final NamedKeyInfoGeneratorManager keyInfoManager = secConfiguration.getKeyInfoGeneratorManager(); + final KeyInfoGeneratorManager keyInfoGenManager = keyInfoManager.getDefaultManager(); + final KeyInfoGeneratorFactory keyInfoGenFac = keyInfoGenManager.getFactory(credential); + final KeyInfoGenerator keyInfoGenerator = keyInfoGenFac.newInstance(); final KeyInfo keyInfo = keyInfoGenerator.generate(credential); signature.setKeyInfo(keyInfo); - signature.setCanonicalizationAlgorithm( - SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); - - //Create a second signature which will be used when signing assertion and response - final Signature signature2 = (Signature) org.opensaml.xml.Configuration - .getBuilderFactory().getBuilder( - Signature.DEFAULT_ELEMENT_NAME).buildObject( - Signature.DEFAULT_ELEMENT_NAME); - final SecurityConfiguration secConfiguration2 = org.opensaml.xml.Configuration - .getGlobalSecurityConfiguration(); - final NamedKeyInfoGeneratorManager keyInfoManager2 = secConfiguration2 - .getKeyInfoGeneratorManager(); - final KeyInfoGeneratorManager keyInfoGenManager2 = keyInfoManager2 - .getDefaultManager(); - final KeyInfoGeneratorFactory keyInfoGenFac2 = keyInfoGenManager2 - .getFactory(credential); - final KeyInfoGenerator keyInfoGenerator2 = keyInfoGenFac2 - .newInstance(); + signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); + + // Create a second signature which will be used when signing assertion and response + final Signature signature2 = (Signature) org.opensaml.xml.Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME).buildObject(Signature.DEFAULT_ELEMENT_NAME); + final SecurityConfiguration secConfiguration2 = org.opensaml.xml.Configuration.getGlobalSecurityConfiguration(); + final NamedKeyInfoGeneratorManager keyInfoManager2 = secConfiguration2.getKeyInfoGeneratorManager(); + final KeyInfoGeneratorManager keyInfoGenManager2 = keyInfoManager2.getDefaultManager(); + final KeyInfoGeneratorFactory keyInfoGenFac2 = keyInfoGenManager2.getFactory(credential); + final KeyInfoGenerator keyInfoGenerator2 = keyInfoGenFac2.newInstance(); KeyInfo keyInfo2 = keyInfoGenerator2.generate(credential); signature2.setSigningCredential(credential); - signature2.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); + signature2.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); signature2.setKeyInfo(keyInfo2); - signature2.setCanonicalizationAlgorithm( - SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); - + signature2.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); LOG.info("Marshall samlToken."); String qn = tokenSaml.getElementQName().toString(); - if (qn.endsWith(CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME)) - { + if (qn.endsWith(CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME)) { tokenSaml.setSignature(signature); CustomAttributeQueryMarshaller mars = new CustomAttributeQueryMarshaller(); mars.marshall(tokenSaml); Signer.signObject(signature); - } - else if (qn.endsWith(Response.DEFAULT_ELEMENT_LOCAL_NAME) && !qn.contains(LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME)) - { - Response res = (Response)tokenSaml; + } else if (qn.endsWith(Response.DEFAULT_ELEMENT_LOCAL_NAME) && !qn.contains(LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME)) { + Response res = (Response) tokenSaml; List asserts = res.getAssertions(); - //If multiple assertions we just sign the response and not the assertion - if (asserts.size() > 1) - { + // If multiple assertions we just sign the response and not the assertion + if (asserts.size() > 1) { tokenSaml.setSignature(signature); - org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); + org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); LOG.info("Sign samlToken."); Signer.signObject(signature); } - //If single assertion we sign the assertion and response - else - { + // If single assertion we sign the assertion and response + else { Assertion assertion = asserts.get(0); - assertion.setSignature(signature); + assertion.setSignature(signature); tokenSaml.setSignature(signature2); - org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); + org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); LOG.info("Sign samlToken."); Signer.signObject(signature); Signer.signObject(signature2); } } - //Normally we just sign the total saml response - else - { + // Normally we just sign the total saml response + else { tokenSaml.setSignature(signature); - org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); + org.opensaml.xml.Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); LOG.info("Sign samlToken."); Signer.signObject(signature); } @@ -401,22 +360,22 @@ public final class SignP12 implements SAMLEngineSignI { /** * Validate signature. * - * @param tokenSaml token SAML + * @param tokenSaml + * token SAML * * @return the SAMLObject validated. * - * @throws SAMLEngineException error validate signature + * @throws SAMLEngineException + * error validate signature * */ @Override - public SAMLObject validateSignature(final SignableSAMLObject tokenSaml) - throws SAMLEngineException { + public SAMLObject validateSignature(final SignableSAMLObject tokenSaml) throws SAMLEngineException { LOG.info("Start signature validation."); try { // Validate structure signature - final SAMLSignatureProfileValidator sigProfValidator = - new SAMLSignatureProfileValidator(); + final SAMLSignatureProfileValidator sigProfValidator = new SAMLSignatureProfileValidator(); try { // Indicates signature id conform to SAML Signature profile sigProfValidator.validate(tokenSaml.getSignature()); @@ -430,64 +389,43 @@ public final class SignP12 implements SAMLEngineSignI { final List trustCred = new ArrayList(); - for (final Enumeration e = trustStore.aliases(); e - .hasMoreElements();) - { + for (final Enumeration e = trustStore.aliases(); e.hasMoreElements();) { aliasCert = e.nextElement(); final BasicX509Credential credential = new BasicX509Credential(); - certificate = (X509Certificate) trustStore - .getCertificate(aliasCert); + certificate = (X509Certificate) trustStore.getCertificate(aliasCert); credential.setEntityCertificate(certificate); trustCred.add(credential); } final KeyInfo keyInfo = tokenSaml.getSignature().getKeyInfo(); - final org.opensaml.xml.signature.X509Certificate xmlCert = keyInfo - .getX509Datas().get(0).getX509Certificates().get(0); + final org.opensaml.xml.signature.X509Certificate xmlCert = keyInfo.getX509Datas().get(0).getX509Certificates().get(0); - final CertificateFactory certFact = CertificateFactory - .getInstance("X.509"); - final ByteArrayInputStream bis = new ByteArrayInputStream(Base64 - .decode(xmlCert.getValue())); - final X509Certificate cert = (X509Certificate) certFact - .generateCertificate(bis); + final CertificateFactory certFact = CertificateFactory.getInstance("X.509"); + final ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(xmlCert.getValue())); + final X509Certificate cert = (X509Certificate) certFact.generateCertificate(bis); // Exist only one certificate final BasicX509Credential entityX509Cred = new BasicX509Credential(); entityX509Cred.setEntityCertificate(cert); - /* A better use of PKI based validation but not wanted for STORK... - boolean trusted = false; - - for (final Enumeration e = trustStore.aliases(); e.hasMoreElements();) - { - aliasCert = e.nextElement(); - certificate = (X509Certificate) trustStore.getCertificate(aliasCert); - try { - cert.verify(certificate.getPublicKey()); - trusted = true; - break; - } - catch (Exception ex) { - //Do nothing - cert not trusted yet - } - } - - if (!trusted) - throw new SAMLEngineException("Certificate is not trusted.");*/ + /* + * A better use of PKI based validation but not wanted for STORK... boolean trusted = false; + * + * for (final Enumeration e = trustStore.aliases(); e.hasMoreElements();) { aliasCert = e.nextElement(); certificate = (X509Certificate) trustStore.getCertificate(aliasCert); try { + * cert.verify(certificate.getPublicKey()); trusted = true; break; } catch (Exception ex) { //Do nothing - cert not trusted yet } } + * + * if (!trusted) throw new SAMLEngineException("Certificate is not trusted."); + */ // Validate trust certificates - final ExplicitKeyTrustEvaluator keyTrustEvaluator = - new ExplicitKeyTrustEvaluator(); - if (!keyTrustEvaluator.validate(entityX509Cred, trustCred)) - { + final ExplicitKeyTrustEvaluator keyTrustEvaluator = new ExplicitKeyTrustEvaluator(); + if (!keyTrustEvaluator.validate(entityX509Cred, trustCred)) { throw new SAMLEngineException("Certificate it is not trusted."); } // Validate signature - final SignatureValidator sigValidator = new SignatureValidator( - entityX509Cred); + final SignatureValidator sigValidator = new SignatureValidator(entityX509Cred); sigValidator.validate(tokenSaml.getSignature()); } catch (ValidationException e) { @@ -503,11 +441,11 @@ public final class SignP12 implements SAMLEngineSignI { return tokenSaml; } - /** * Load cryptographic service provider. * - * @throws SAMLEngineException the SAML engine exception + * @throws SAMLEngineException + * the SAML engine exception */ @Override public void loadCryptServiceProvider() throws SAMLEngineException { @@ -517,48 +455,40 @@ public final class SignP12 implements SAMLEngineSignI { FileInputStream fisTrustStore = null; try { -// // Dynamically register Bouncy Castle provider. -// boolean found = false; -// // Check if BouncyCastle is already registered as a provider -// final Provider[] providers = Security.getProviders(); -// for (int i = 0; i < providers.length; i++) { -// if (providers[i].getName().equals( -// BouncyCastleProvider.PROVIDER_NAME)) { -// found = true; -// } -// } -// -// // Register only if the provider has not been previously registered -// if (!found) { -// LOG.debug("SAMLCore: Register Bouncy Castle provider."); -// Security.insertProviderAt(new BouncyCastleProvider(), Security -// .getProviders().length); -// } - - p12Store = KeyStore.getInstance(properties - .getProperty("keystoreType")); - - fis = new FileInputStream(properties - .getProperty("keystorePath")); - - p12Store.load(fis, properties.getProperty( - "keyStorePassword").toCharArray()); - - - trustStore = KeyStore.getInstance(properties - .getProperty("trustStoreType")); - - fisTrustStore = new FileInputStream(properties - .getProperty("trustStorePath")); - trustStore.load(fisTrustStore, properties.getProperty( - "trustStorePassword").toCharArray()); + // // Dynamically register Bouncy Castle provider. + // boolean found = false; + // // Check if BouncyCastle is already registered as a provider + // final Provider[] providers = Security.getProviders(); + // for (int i = 0; i < providers.length; i++) { + // if (providers[i].getName().equals( + // BouncyCastleProvider.PROVIDER_NAME)) { + // found = true; + // } + // } + // + // // Register only if the provider has not been previously registered + // if (!found) { + // LOG.debug("SAMLCore: Register Bouncy Castle provider."); + // Security.insertProviderAt(new BouncyCastleProvider(), Security + // .getProviders().length); + // } + + p12Store = KeyStore.getInstance(properties.getProperty("keystoreType")); + + fis = new FileInputStream(properties.getProperty("keystorePath")); + + p12Store.load(fis, properties.getProperty("keyStorePassword").toCharArray()); + + trustStore = KeyStore.getInstance(properties.getProperty("trustStoreType")); + + fisTrustStore = new FileInputStream(properties.getProperty("trustStorePath")); + trustStore.load(fisTrustStore, properties.getProperty("trustStorePassword").toCharArray()); } catch (Exception e) { - throw new SAMLEngineException( - "Error loading CryptographicServiceProvider", e); - } finally { + throw new SAMLEngineException("Error loading CryptographicServiceProvider", e); + } finally { IOUtils.closeQuietly(fis); IOUtils.closeQuietly(fisTrustStore); - } + } } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignSW.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignSW.java index 0984bb9ca..e1ae2b8e2 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignSW.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/SignSW.java @@ -61,471 +61,415 @@ import java.security.cert.CertificateNotYetValidException; import java.security.cert.X509Certificate; import java.util.*; - /** - * The Class SWSign. Class responsible for signing and validating of messages - * SAML with a certificate store software. + * The Class SWSign. Class responsible for signing and validating of messages SAML with a certificate store software. * * @author fjquevedo */ public class SignSW implements SAMLEngineSignI { - /** - * The Constant KEYSTORE_TYPE. - */ - private static final String KEYSTORE_TYPE = "keystoreType"; - - /** - * The Constant KEY_STORE_PASSWORD. - */ - private static final String KEY_STORE_PASS = "keyStorePassword"; - - /** - * The logger. - */ - private static final Logger LOG = LoggerFactory.getLogger(SignSW.class - .getName()); - - /** - * The stork own key store. - */ - private KeyStore storkOwnKeyStore = null; - - /** - * The instance. - * - * @return the properties - */ - - public final Properties getProperties() { - return properties; - } - - /** - * Gets the stork own key store. - * - * @return the stork own key store - */ - public final KeyStore getStorkOwnKeyStore() { - return storkOwnKeyStore; - } - - /** - * Gets the stork trustStore. - * - * @return the stork own key store - */ - public KeyStore getTrustStore() { - return storkOwnKeyStore; - } - - /** - * Sets the stork own key store. - * - * @param newkOwnKeyStore the new stork own key store - */ - public final void setStorkOwnKeyStore(final KeyStore newkOwnKeyStore) { - this.storkOwnKeyStore = newkOwnKeyStore; - } - - /** - * Sets the properties. - * - * @param newProperties the new properties - */ - public final void setProperties(final Properties newProperties) { - this.properties = newProperties; - } - - /** - * The SW sign prop. - */ - private Properties properties = null; - - - /** - * Inits the file configuration. - * - * @param fileConf name of the file configuration - * @throws SAMLEngineException error at the load from file configuration - */ - public final void init(final String fileConf) - throws SAMLEngineException { - InputStream fileProperties = null; - // fetch base from system properties, give a default if there is nothing configured - String base = System.getProperty("eu.stork.samlengine.config.location"); - if (null != base) { - if (!base.endsWith("/")) { - base += "/"; - } - } else { - base = "/"; - } - - try { - if (null != base) - fileProperties = new FileInputStream(base + fileConf); - else - fileProperties = SignSW.class.getResourceAsStream("/" - + fileConf); - properties = new Properties(); - - properties.loadFromXML(fileProperties); - fileProperties.close(); - } catch (InvalidPropertiesFormatException e) { - LOG.info("Exception: invalid properties format."); - throw new SAMLEngineException(e); - } catch (IOException e) { - LOG.info("Exception: invalid file: " + fileConf); - throw new SAMLEngineException(e); - } finally { - IOUtils.closeQuietly(fileProperties); - } - } - - /** - * @return the X509Certificate - * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#getCertificate() - */ - public final X509Certificate getCertificate() { - throw new NotImplementedException(); - } - - - /** - * Sign the token SAML. - * - * @param tokenSaml the token SAML. - * @return the SAML object - * @throws SAMLEngineException the SAML engine exception - */ - public final SAMLObject sign(final SignableSAMLObject tokenSaml) - throws SAMLEngineException { - LOG.info("Start Sign process."); - try { - final String serialNumber = properties.getProperty("serialNumber"); - final String issuer = properties.getProperty("issuer"); - - String alias = null; - String aliasCert; - X509Certificate certificate; - boolean find = false; - - for (final Enumeration e = storkOwnKeyStore.aliases(); e - .hasMoreElements() && !find; ) { - aliasCert = e.nextElement(); - certificate = (X509Certificate) storkOwnKeyStore - .getCertificate(aliasCert); - - final String serialNum = certificate.getSerialNumber() - .toString(16); - - try { - X509Principal issuerDN = new X509Principal(certificate.getIssuerDN().getName()); - X509Principal issuerDNConf = new X509Principal(issuer); - - if (serialNum.equalsIgnoreCase(serialNumber) - && X509PrincipalUtil.equals(issuerDN, issuerDNConf)) { - alias = aliasCert; - find = true; - } - } catch (Exception ex) { - LOG.error("Exception during signing: " + ex.getMessage()); // Added as a workaround for Bouncycastle email error - } - } - if (!find) { - throw new SAMLEngineException("Certificate cannot be found in keystore "); - } - certificate = (X509Certificate) storkOwnKeyStore.getCertificate(alias); - final PrivateKey privateKey = (PrivateKey) storkOwnKeyStore.getKey( - alias, properties.getProperty("keyPassword").toCharArray()); - - LOG.info("Recover BasicX509Credential."); - final BasicX509Credential credential = new BasicX509Credential(); - - LOG.debug("Load certificate"); - credential.setEntityCertificate(certificate); - - LOG.debug("Load privateKey"); - credential.setPrivateKey(privateKey); - - LOG.debug("Begin signature with openSaml"); - final Signature signature = (Signature) Configuration - .getBuilderFactory().getBuilder( - Signature.DEFAULT_ELEMENT_NAME).buildObject( - Signature.DEFAULT_ELEMENT_NAME); - - signature.setSigningCredential(credential); - signature.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); - //signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1); - - - final SecurityConfiguration secConfiguration = Configuration - .getGlobalSecurityConfiguration(); - final NamedKeyInfoGeneratorManager keyInfoManager = secConfiguration - .getKeyInfoGeneratorManager(); - final KeyInfoGeneratorManager keyInfoGenManager = keyInfoManager - .getDefaultManager(); - final KeyInfoGeneratorFactory keyInfoGenFac = keyInfoGenManager - .getFactory(credential); - final KeyInfoGenerator keyInfoGenerator = keyInfoGenFac - .newInstance(); - - KeyInfo keyInfo = keyInfoGenerator.generate(credential); - - signature.setKeyInfo(keyInfo); - signature.setCanonicalizationAlgorithm( - SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); - - //Create a second signature which will be used when signing assertion and response - final Signature signature2 = (Signature) Configuration - .getBuilderFactory().getBuilder( - Signature.DEFAULT_ELEMENT_NAME).buildObject( - Signature.DEFAULT_ELEMENT_NAME); - final SecurityConfiguration secConfiguration2 = Configuration - .getGlobalSecurityConfiguration(); - final NamedKeyInfoGeneratorManager keyInfoManager2 = secConfiguration2 - .getKeyInfoGeneratorManager(); - final KeyInfoGeneratorManager keyInfoGenManager2 = keyInfoManager2 - .getDefaultManager(); - final KeyInfoGeneratorFactory keyInfoGenFac2 = keyInfoGenManager2 - .getFactory(credential); - final KeyInfoGenerator keyInfoGenerator2 = keyInfoGenFac2 - .newInstance(); - - KeyInfo keyInfo2 = keyInfoGenerator2.generate(credential); - signature2.setSigningCredential(credential); - signature2.setSignatureAlgorithm( - SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); - //signature2.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1); - signature2.setKeyInfo(keyInfo2); - signature2.setCanonicalizationAlgorithm( - SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); - - - LOG.info("Marshall samlToken."); - String qn = tokenSaml.getElementQName().toString(); - - if (qn.endsWith(CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME)) { - tokenSaml.setSignature(signature); - CustomAttributeQueryMarshaller mars = new CustomAttributeQueryMarshaller(); - mars.marshall(tokenSaml); - Signer.signObject(signature); - } else if (qn.endsWith(Response.DEFAULT_ELEMENT_LOCAL_NAME) && !qn.contains(LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME)) { - Response res = (Response) tokenSaml; - List asserts = res.getAssertions(); - //If multiple assertions we just sign the response and not the assertion - if (asserts.size() > 1) { - tokenSaml.setSignature(signature); - Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); - LOG.info("Sign samlToken."); - Signer.signObject(signature); - } - //If single assertion we sign the assertion and response - else { - Assertion assertion = (Assertion) asserts.get(0); - assertion.setSignature(signature); - tokenSaml.setSignature(signature2); - Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); - LOG.info("Sign samlToken."); - Signer.signObject(signature); - Signer.signObject(signature2); - } - } - //Normally we just sign the total saml response - else { - tokenSaml.setSignature(signature); - Configuration.getMarshallerFactory().getMarshaller(tokenSaml) - .marshall(tokenSaml); - LOG.info("Sign samlToken."); - Signer.signObject(signature); - } - - - } catch (MarshallingException e) { - LOG.error("MarshallingException"); - throw new SAMLEngineException(e); - } catch (NoSuchAlgorithmException e) { - LOG.error("A 'xmldsig#rsa-sha1' cryptographic algorithm is requested but is not available in the environment."); - throw new SAMLEngineException(e); - } catch (KeyStoreException e) { - LOG.error("Generic KeyStore exception."); - throw new SAMLEngineException(e); - } catch (SignatureException e) { - LOG.error("Signature exception."); - throw new SAMLEngineException(e); - } catch (SecurityException e) { - LOG.error("Security exception."); - throw new SAMLEngineException(e); - } catch (UnrecoverableKeyException e) { - LOG.error("UnrecoverableKey exception."); - throw new SAMLEngineException(e); - } - - return tokenSaml; - } - - /** - * @param tokenSaml token SAML - * @return the SAMLObject validated. - * @throws SAMLEngineException error validate signature - * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#validateSignature(org.opensaml.common.SignableSAMLObject) - */ - public final SAMLObject validateSignature(final SignableSAMLObject tokenSaml) - throws SAMLEngineException { - LOG.info("Start signature validation."); - try { - - // Validate structure signature - final SAMLSignatureProfileValidator sigProfValidator = - new SAMLSignatureProfileValidator(); - try { - // Indicates signature id conform to SAML Signature profile - sigProfValidator.validate(tokenSaml.getSignature()); - } catch (ValidationException e) { - LOG.error("ValidationException: signature isn't conform to SAML Signature profile."); - throw new SAMLEngineException(e); - } - - String aliasCert = null; - X509Certificate certificate; - - final List trustCred = new ArrayList(); - - for (final Enumeration e = storkOwnKeyStore.aliases(); e - .hasMoreElements(); ) { - aliasCert = e.nextElement(); - final BasicX509Credential credential = new BasicX509Credential(); - certificate = (X509Certificate) storkOwnKeyStore - .getCertificate(aliasCert); - credential.setEntityCertificate(certificate); - trustCred.add(credential); - } - - final KeyInfo keyInfo = tokenSaml.getSignature().getKeyInfo(); - - final org.opensaml.xml.signature.X509Certificate xmlCert = keyInfo - .getX509Datas().get(0).getX509Certificates().get(0); - - final CertificateFactory certFact = CertificateFactory - .getInstance("X.509"); - final ByteArrayInputStream bis = new ByteArrayInputStream(Base64 - .decode(xmlCert.getValue())); - final X509Certificate cert = (X509Certificate) certFact - .generateCertificate(bis); - - // Exist only one certificate - final BasicX509Credential entityX509Cred = new BasicX509Credential(); - entityX509Cred.setEntityCertificate(cert); - - try { - cert.checkValidity(); - } catch (CertificateExpiredException exp) { - throw new SAMLEngineException("Certificate expired."); - } catch (CertificateNotYetValidException exp) { - throw new SAMLEngineException("Certificate not yet valid."); - } - - /* A better use of PKI based validation but not wanted for STORK... - boolean trusted = false; - - for (final Enumeration e = storkOwnKeyStore.aliases(); e.hasMoreElements();) - { - aliasCert = e.nextElement(); - certificate = (X509Certificate) storkOwnKeyStore.getCertificate(aliasCert); - try { - cert.verify(certificate.getPublicKey()); - trusted = true; - break; - } - catch (Exception ex) { - //Do nothing - cert not trusted yet - } - } - - if (!trusted) - throw new SAMLEngineException("Certificate is not trusted.");*/ - - // Validate trust certificates - final ExplicitX509CertificateTrustEvaluator chainTrustEvaluator = new ExplicitX509CertificateTrustEvaluator(); - - if (!chainTrustEvaluator.validate(entityX509Cred, trustCred)) { - throw new SAMLEngineException("Certificate is not trusted."); - } - final ExplicitKeyTrustEvaluator keyTrustEvaluator = - new ExplicitKeyTrustEvaluator(); - - if (!keyTrustEvaluator.validate(entityX509Cred, trustCred)) { - throw new SAMLEngineException("Certificate is not trusted."); - } - - // Validate signature - final SignatureValidator sigValidator = new SignatureValidator( - entityX509Cred); - sigValidator.validate(tokenSaml.getSignature()); - - } catch (ValidationException e) { - LOG.error("ValidationException."); - throw new SAMLEngineException(e); - } catch (KeyStoreException e) { - LOG.error("KeyStoreException.", e); - throw new SAMLEngineException(e); - } catch (GeneralSecurityException e) { - LOG.error("GeneralSecurityException.", e); - throw new SAMLEngineException(e); - } - LOG.info(tokenSaml.getSignatureReferenceID()); - LOG.info("Start signature validation - END."); - return tokenSaml; - } - - - /** - * Load cryptographic service provider. - * - * @throws SAMLEngineException the SAML engine exception - */ - public final void loadCryptServiceProvider() throws SAMLEngineException { - LOG.info("Load Cryptographic Service Provider"); - FileInputStream fis = null; - try { -// // Dynamically register Bouncy Castle provider. -// boolean found = false; -// // Check if BouncyCastle is already registered as a provider -// final Provider[] providers = Security.getProviders(); -// for (int i = 0; i < providers.length; i++) { -// if (providers[i].getName().equals( -// BouncyCastleProvider.PROVIDER_NAME)) { -// found = true; -// } -// } -// -// // Register only if the provider has not been previously registered -// if (!found) { -// LOG.info("SAMLCore: Register Bouncy Castle provider."); -// Security.insertProviderAt(new BouncyCastleProvider(), Security -// .getProviders().length); -// } - - storkOwnKeyStore = KeyStore.getInstance(properties - .getProperty(KEYSTORE_TYPE)); - - LOG.info("Loading KeyInfo from keystore file " + properties.getProperty("keystorePath")); - fis = new FileInputStream(properties - .getProperty("keystorePath")); - - storkOwnKeyStore.load(fis, properties.getProperty( - KEY_STORE_PASS).toCharArray()); - - } catch (Exception e) { - LOG.error("Error loading CryptographicServiceProvider", e); - throw new SAMLEngineException( - "Error loading CryptographicServiceProvider", e); - } finally { - IOUtils.closeQuietly(fis); - } - } + /** + * The Constant KEYSTORE_TYPE. + */ + private static final String KEYSTORE_TYPE = "keystoreType"; + + /** + * The Constant KEY_STORE_PASSWORD. + */ + private static final String KEY_STORE_PASS = "keyStorePassword"; + + /** + * The logger. + */ + private static final Logger LOG = LoggerFactory.getLogger(SignSW.class.getName()); + + /** + * The stork own key store. + */ + private KeyStore storkOwnKeyStore = null; + + /** + * The instance. + * + * @return the properties + */ + + public final Properties getProperties() { + return properties; + } + + /** + * Gets the stork own key store. + * + * @return the stork own key store + */ + public final KeyStore getStorkOwnKeyStore() { + return storkOwnKeyStore; + } + + /** + * Gets the stork trustStore. + * + * @return the stork own key store + */ + public KeyStore getTrustStore() { + return storkOwnKeyStore; + } + + /** + * Sets the stork own key store. + * + * @param newkOwnKeyStore + * the new stork own key store + */ + public final void setStorkOwnKeyStore(final KeyStore newkOwnKeyStore) { + this.storkOwnKeyStore = newkOwnKeyStore; + } + + /** + * Sets the properties. + * + * @param newProperties + * the new properties + */ + public final void setProperties(final Properties newProperties) { + this.properties = newProperties; + } + + /** + * The SW sign prop. + */ + private Properties properties = null; + + /** + * Inits the file configuration. + * + * @param fileConf + * name of the file configuration + * @throws SAMLEngineException + * error at the load from file configuration + */ + public final void init(final String fileConf) throws SAMLEngineException { + InputStream fileProperties = null; + // fetch base from system properties, give a default if there is nothing configured + String base = System.getProperty("eu.stork.samlengine.config.location"); + if (null != base) { + if (!base.endsWith("/")) { + base += "/"; + } + } else { + base = "/"; + } + + try { + if (null != base) + fileProperties = new FileInputStream(base + fileConf); + else + fileProperties = SignSW.class.getResourceAsStream("/" + fileConf); + properties = new Properties(); + + properties.loadFromXML(fileProperties); + fileProperties.close(); + } catch (InvalidPropertiesFormatException e) { + LOG.info("Exception: invalid properties format."); + throw new SAMLEngineException(e); + } catch (IOException e) { + LOG.info("Exception: invalid file: " + fileConf); + throw new SAMLEngineException(e); + } finally { + IOUtils.closeQuietly(fileProperties); + } + } + + /** + * @return the X509Certificate + * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#getCertificate() + */ + public final X509Certificate getCertificate() { + throw new NotImplementedException(); + } + + /** + * Sign the token SAML. + * + * @param tokenSaml + * the token SAML. + * @return the SAML object + * @throws SAMLEngineException + * the SAML engine exception + */ + public final SAMLObject sign(final SignableSAMLObject tokenSaml) throws SAMLEngineException { + LOG.info("Start Sign process."); + try { + final String serialNumber = properties.getProperty("serialNumber"); + final String issuer = properties.getProperty("issuer"); + + String alias = null; + String aliasCert; + X509Certificate certificate; + boolean find = false; + + for (final Enumeration e = storkOwnKeyStore.aliases(); e.hasMoreElements() && !find;) { + aliasCert = e.nextElement(); + certificate = (X509Certificate) storkOwnKeyStore.getCertificate(aliasCert); + + final String serialNum = certificate.getSerialNumber().toString(16); + + try { + X509Principal issuerDN = new X509Principal(certificate.getIssuerDN().getName()); + X509Principal issuerDNConf = new X509Principal(issuer); + + if (serialNum.equalsIgnoreCase(serialNumber) && X509PrincipalUtil.equals(issuerDN, issuerDNConf)) { + alias = aliasCert; + find = true; + } + } catch (Exception ex) { + LOG.error("Exception during signing: " + ex.getMessage()); // Added as a workaround for Bouncycastle email error + } + } + if (!find) { + throw new SAMLEngineException("Certificate cannot be found in keystore "); + } + certificate = (X509Certificate) storkOwnKeyStore.getCertificate(alias); + final PrivateKey privateKey = (PrivateKey) storkOwnKeyStore.getKey(alias, properties.getProperty("keyPassword").toCharArray()); + + LOG.info("Recover BasicX509Credential."); + final BasicX509Credential credential = new BasicX509Credential(); + + LOG.debug("Load certificate"); + credential.setEntityCertificate(certificate); + + LOG.debug("Load privateKey"); + credential.setPrivateKey(privateKey); + + LOG.debug("Begin signature with openSaml"); + final Signature signature = (Signature) Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME).buildObject(Signature.DEFAULT_ELEMENT_NAME); + + signature.setSigningCredential(credential); + signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); + // signature.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1); + + final SecurityConfiguration secConfiguration = Configuration.getGlobalSecurityConfiguration(); + final NamedKeyInfoGeneratorManager keyInfoManager = secConfiguration.getKeyInfoGeneratorManager(); + final KeyInfoGeneratorManager keyInfoGenManager = keyInfoManager.getDefaultManager(); + final KeyInfoGeneratorFactory keyInfoGenFac = keyInfoGenManager.getFactory(credential); + final KeyInfoGenerator keyInfoGenerator = keyInfoGenFac.newInstance(); + + KeyInfo keyInfo = keyInfoGenerator.generate(credential); + + signature.setKeyInfo(keyInfo); + signature.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); + + // Create a second signature which will be used when signing assertion and response + final Signature signature2 = (Signature) Configuration.getBuilderFactory().getBuilder(Signature.DEFAULT_ELEMENT_NAME).buildObject(Signature.DEFAULT_ELEMENT_NAME); + final SecurityConfiguration secConfiguration2 = Configuration.getGlobalSecurityConfiguration(); + final NamedKeyInfoGeneratorManager keyInfoManager2 = secConfiguration2.getKeyInfoGeneratorManager(); + final KeyInfoGeneratorManager keyInfoGenManager2 = keyInfoManager2.getDefaultManager(); + final KeyInfoGeneratorFactory keyInfoGenFac2 = keyInfoGenManager2.getFactory(credential); + final KeyInfoGenerator keyInfoGenerator2 = keyInfoGenFac2.newInstance(); + + KeyInfo keyInfo2 = keyInfoGenerator2.generate(credential); + signature2.setSigningCredential(credential); + signature2.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA256); + // signature2.setSignatureAlgorithm(SignatureConstants.ALGO_ID_SIGNATURE_RSA_SHA1); + signature2.setKeyInfo(keyInfo2); + signature2.setCanonicalizationAlgorithm(SignatureConstants.ALGO_ID_C14N_EXCL_OMIT_COMMENTS); + + LOG.info("Marshall samlToken."); + String qn = tokenSaml.getElementQName().toString(); + + if (qn.endsWith(CustomAttributeQuery.DEFAULT_ELEMENT_LOCAL_NAME)) { + tokenSaml.setSignature(signature); + CustomAttributeQueryMarshaller mars = new CustomAttributeQueryMarshaller(); + mars.marshall(tokenSaml); + Signer.signObject(signature); + } else if (qn.endsWith(Response.DEFAULT_ELEMENT_LOCAL_NAME) && !qn.contains(LogoutResponse.DEFAULT_ELEMENT_LOCAL_NAME)) { + Response res = (Response) tokenSaml; + List asserts = res.getAssertions(); + // If multiple assertions we just sign the response and not the assertion + if (asserts.size() > 1) { + tokenSaml.setSignature(signature); + Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); + LOG.info("Sign samlToken."); + Signer.signObject(signature); + } + // If single assertion we sign the assertion and response + else { + Assertion assertion = (Assertion) asserts.get(0); + assertion.setSignature(signature); + tokenSaml.setSignature(signature2); + Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); + LOG.info("Sign samlToken."); + Signer.signObject(signature); + Signer.signObject(signature2); + } + } + // Normally we just sign the total saml response + else { + tokenSaml.setSignature(signature); + Configuration.getMarshallerFactory().getMarshaller(tokenSaml).marshall(tokenSaml); + LOG.info("Sign samlToken."); + Signer.signObject(signature); + } + + } catch (MarshallingException e) { + LOG.error("MarshallingException"); + throw new SAMLEngineException(e); + } catch (NoSuchAlgorithmException e) { + LOG.error("A 'xmldsig#rsa-sha1' cryptographic algorithm is requested but is not available in the environment."); + throw new SAMLEngineException(e); + } catch (KeyStoreException e) { + LOG.error("Generic KeyStore exception."); + throw new SAMLEngineException(e); + } catch (SignatureException e) { + LOG.error("Signature exception."); + throw new SAMLEngineException(e); + } catch (SecurityException e) { + LOG.error("Security exception."); + throw new SAMLEngineException(e); + } catch (UnrecoverableKeyException e) { + LOG.error("UnrecoverableKey exception."); + throw new SAMLEngineException(e); + } + + return tokenSaml; + } + + /** + * @param tokenSaml + * token SAML + * @return the SAMLObject validated. + * @throws SAMLEngineException + * error validate signature + * @see eu.stork.peps.auth.engine.core.SAMLEngineSignI#validateSignature(org.opensaml.common.SignableSAMLObject) + */ + public final SAMLObject validateSignature(final SignableSAMLObject tokenSaml) throws SAMLEngineException { + LOG.info("Start signature validation."); + try { + + // Validate structure signature + final SAMLSignatureProfileValidator sigProfValidator = new SAMLSignatureProfileValidator(); + try { + // Indicates signature id conform to SAML Signature profile + sigProfValidator.validate(tokenSaml.getSignature()); + } catch (ValidationException e) { + LOG.error("ValidationException: signature isn't conform to SAML Signature profile."); + throw new SAMLEngineException(e); + } + + String aliasCert = null; + X509Certificate certificate; + + final List trustCred = new ArrayList(); + + for (final Enumeration e = storkOwnKeyStore.aliases(); e.hasMoreElements();) { + aliasCert = e.nextElement(); + final BasicX509Credential credential = new BasicX509Credential(); + certificate = (X509Certificate) storkOwnKeyStore.getCertificate(aliasCert); + credential.setEntityCertificate(certificate); + trustCred.add(credential); + } + + final KeyInfo keyInfo = tokenSaml.getSignature().getKeyInfo(); + + final org.opensaml.xml.signature.X509Certificate xmlCert = keyInfo.getX509Datas().get(0).getX509Certificates().get(0); + + final CertificateFactory certFact = CertificateFactory.getInstance("X.509"); + final ByteArrayInputStream bis = new ByteArrayInputStream(Base64.decode(xmlCert.getValue())); + final X509Certificate cert = (X509Certificate) certFact.generateCertificate(bis); + + // Exist only one certificate + final BasicX509Credential entityX509Cred = new BasicX509Credential(); + entityX509Cred.setEntityCertificate(cert); + + try { + cert.checkValidity(); + } catch (CertificateExpiredException exp) { + throw new SAMLEngineException("Certificate expired."); + } catch (CertificateNotYetValidException exp) { + throw new SAMLEngineException("Certificate not yet valid."); + } + + /* + * A better use of PKI based validation but not wanted for STORK... boolean trusted = false; + * + * for (final Enumeration e = storkOwnKeyStore.aliases(); e.hasMoreElements();) { aliasCert = e.nextElement(); certificate = (X509Certificate) + * storkOwnKeyStore.getCertificate(aliasCert); try { cert.verify(certificate.getPublicKey()); trusted = true; break; } catch (Exception ex) { //Do nothing - cert not trusted yet } } + * + * if (!trusted) throw new SAMLEngineException("Certificate is not trusted."); + */ + + // Validate trust certificates + final ExplicitX509CertificateTrustEvaluator chainTrustEvaluator = new ExplicitX509CertificateTrustEvaluator(); + + if (!chainTrustEvaluator.validate(entityX509Cred, trustCred)) { + throw new SAMLEngineException("Certificate is not trusted."); + } + final ExplicitKeyTrustEvaluator keyTrustEvaluator = new ExplicitKeyTrustEvaluator(); + + if (!keyTrustEvaluator.validate(entityX509Cred, trustCred)) { + throw new SAMLEngineException("Certificate is not trusted."); + } + + // Validate signature + final SignatureValidator sigValidator = new SignatureValidator(entityX509Cred); + sigValidator.validate(tokenSaml.getSignature()); + + } catch (ValidationException e) { + LOG.error("ValidationException."); + throw new SAMLEngineException(e); + } catch (KeyStoreException e) { + LOG.error("KeyStoreException.", e); + throw new SAMLEngineException(e); + } catch (GeneralSecurityException e) { + LOG.error("GeneralSecurityException.", e); + throw new SAMLEngineException(e); + } + LOG.info(tokenSaml.getSignatureReferenceID()); + LOG.info("Start signature validation - END."); + return tokenSaml; + } + + /** + * Load cryptographic service provider. + * + * @throws SAMLEngineException + * the SAML engine exception + */ + public final void loadCryptServiceProvider() throws SAMLEngineException { + LOG.info("Load Cryptographic Service Provider"); + FileInputStream fis = null; + try { + // // Dynamically register Bouncy Castle provider. + // boolean found = false; + // // Check if BouncyCastle is already registered as a provider + // final Provider[] providers = Security.getProviders(); + // for (int i = 0; i < providers.length; i++) { + // if (providers[i].getName().equals( + // BouncyCastleProvider.PROVIDER_NAME)) { + // found = true; + // } + // } + // + // // Register only if the provider has not been previously registered + // if (!found) { + // LOG.info("SAMLCore: Register Bouncy Castle provider."); + // Security.insertProviderAt(new BouncyCastleProvider(), Security + // .getProviders().length); + // } + + storkOwnKeyStore = KeyStore.getInstance(properties.getProperty(KEYSTORE_TYPE)); + + LOG.info("Loading KeyInfo from keystore file " + properties.getProperty("keystorePath")); + fis = new FileInputStream(properties.getProperty("keystorePath")); + + storkOwnKeyStore.load(fis, properties.getProperty(KEY_STORE_PASS).toCharArray()); + + } catch (Exception e) { + LOG.error("Error loading CryptographicServiceProvider", e); + throw new SAMLEngineException("Error loading CryptographicServiceProvider", e); + } finally { + IOUtils.closeQuietly(fis); + } + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesBuilder.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesBuilder.java index a60515593..332882a03 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesBuilder.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesBuilder.java @@ -26,16 +26,15 @@ import eu.stork.peps.auth.engine.core.VIDPAuthenticationAttributes; * @author fjquevedo */ public final class VIDPAuthenticationAttributesBuilder extends AbstractSAMLObjectBuilder { - - /** {@inheritDoc} */ - public VIDPAuthenticationAttributes buildObject() { - return buildObject(SAMLCore.STORK10P_NS.getValue(), VIDPAuthenticationAttributes.DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); - } + /** {@inheritDoc} */ + public VIDPAuthenticationAttributes buildObject() { + return buildObject(SAMLCore.STORK10P_NS.getValue(), VIDPAuthenticationAttributes.DEF_LOCAL_NAME, SAMLCore.STORK10P_PREFIX.getValue()); + } + + /** {@inheritDoc} */ + public VIDPAuthenticationAttributes buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { + return new VIDPAuthenticationAttributesImpl(namespaceURI, localName, namespacePrefix); + } - /** {@inheritDoc} */ - public VIDPAuthenticationAttributes buildObject(final String namespaceURI, final String localName, final String namespacePrefix) { - return new VIDPAuthenticationAttributesImpl(namespaceURI, localName, namespacePrefix); - } - } \ No newline at end of file diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesImpl.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesImpl.java index 25737e307..d7d92ea74 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesImpl.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesImpl.java @@ -33,100 +33,102 @@ import org.slf4j.LoggerFactory; * * @author fjquevedo */ -public final class VIDPAuthenticationAttributesImpl extends AbstractSignableSAMLObject implements -VIDPAuthenticationAttributes { +public final class VIDPAuthenticationAttributesImpl extends AbstractSignableSAMLObject implements VIDPAuthenticationAttributes { - private static final Logger LOGGER = LoggerFactory.getLogger(VIDPAuthenticationAttributesImpl.class.getName()); - /** The citizen country code. */ - private CitizenCountryCode citizenCountryCode; - - /** The SP information. */ - private SPInformation spInformation; + private static final Logger LOGGER = LoggerFactory.getLogger(VIDPAuthenticationAttributesImpl.class.getName()); + /** The citizen country code. */ + private CitizenCountryCode citizenCountryCode; + + /** The SP information. */ + private SPInformation spInformation; + + /** + * Instantiates a new requested attributes implement. + * + * @param namespaceURI + * the namespace URI + * @param elementLocalName + * the element local name + * @param namespacePrefix + * the namespace prefix + */ + protected VIDPAuthenticationAttributesImpl(final String namespaceURI, final String elementLocalName, final String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } /** - * Instantiates a new requested attributes implement. - * - * @param namespaceURI the namespace URI - * @param elementLocalName the element local name - * @param namespacePrefix the namespace prefix - */ - protected VIDPAuthenticationAttributesImpl(final String namespaceURI, - final String elementLocalName, final String namespacePrefix) { - super(namespaceURI, elementLocalName, namespacePrefix); - } - - - /** - * getCitizenCountryCode. - * - * @return the citizen country code - */ - public CitizenCountryCode getCitizenCountryCode() { - return citizenCountryCode; - } - - /** - * getSPInformation - * - * @return the SP information - */ - public SPInformation getSPInformation() { + * getCitizenCountryCode. + * + * @return the citizen country code + */ + public CitizenCountryCode getCitizenCountryCode() { + return citizenCountryCode; + } + + /** + * getSPInformation + * + * @return the SP information + */ + public SPInformation getSPInformation() { return spInformation; } - /** - * Gets the ordered children. - * - * @return the ordered children - * - */ - public List getOrderedChildren() { - final ArrayList children = new ArrayList(); - - children.add(citizenCountryCode); - children.add(spInformation); - - if (getSignature() != null) { - children.add(getSignature()); + /** + * Gets the ordered children. + * + * @return the ordered children + * + */ + public List getOrderedChildren() { + final ArrayList children = new ArrayList(); + + children.add(citizenCountryCode); + children.add(spInformation); + + if (getSignature() != null) { + children.add(getSignature()); + } + + return Collections.unmodifiableList(children); + + } + + /** + * Gets the signature reference id. + * + * @return the signature reference id + * + */ + public String getSignatureReferenceID() { + return null; + } + + /** + * Sets the citizen country code. + * + * @param newCitizenCountryCode + * the new citizen country code + * + */ + public void setCitizenCountryCode(CitizenCountryCode newCitizenCountryCode) { + this.citizenCountryCode = prepareForAssignment(this.citizenCountryCode, newCitizenCountryCode); } - - return Collections.unmodifiableList(children); - - } - - /** - * Gets the signature reference id. - * - * @return the signature reference id - * - */ - public String getSignatureReferenceID() { - return null; - } - - /** - * Sets the citizen country code. - * - * @param newCitizenCountryCode the new citizen country code - * - */ - public void setCitizenCountryCode(CitizenCountryCode newCitizenCountryCode) { - this.citizenCountryCode = prepareForAssignment(this.citizenCountryCode, newCitizenCountryCode); - } - - /** - * Sets the SP information. - * - * @param newSPInformation the new SP information - * - */ - public void setSPInformation(SPInformation newSPInformation) { + + /** + * Sets the SP information. + * + * @param newSPInformation + * the new SP information + * + */ + public void setSPInformation(SPInformation newSPInformation) { this.spInformation = prepareForAssignment(this.spInformation, newSPInformation); } - @Override - public int hashCode() { - LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); - return super.hashCode(); - } + @Override + public int hashCode() { + LOGGER.warn("Hashcode has been called, passed to super. Nothing foreseen here"); + return super.hashCode(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesMarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesMarshaller.java index 5635ddd6b..73e0ca6f5 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesMarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesMarshaller.java @@ -24,10 +24,10 @@ import org.opensaml.common.impl.AbstractSAMLObjectMarshaller; */ public class VIDPAuthenticationAttributesMarshaller extends AbstractSAMLObjectMarshaller { - /** - * Instantiates a new vIDP authentication attributes marshaller. - */ - public VIDPAuthenticationAttributesMarshaller() { - super(); - } + /** + * Instantiates a new vIDP authentication attributes marshaller. + */ + public VIDPAuthenticationAttributesMarshaller() { + super(); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesUnmarshaller.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesUnmarshaller.java index ba4a4fe3a..dadf86254 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesUnmarshaller.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/impl/VIDPAuthenticationAttributesUnmarshaller.java @@ -28,28 +28,29 @@ import eu.stork.peps.auth.engine.core.VIDPAuthenticationAttributes; * * @author fjquevedo */ -public class VIDPAuthenticationAttributesUnmarshaller extends - AbstractSAMLObjectUnmarshaller { +public class VIDPAuthenticationAttributesUnmarshaller extends AbstractSAMLObjectUnmarshaller { - /** - * Process child element. - * - * @param parentObject the parent object - * @param childObject the child object - * - * @throws UnmarshallingException the unmarshalling exception - * - */ - protected final void processChildElement(final XMLObject parentObject, - final XMLObject childObject) throws UnmarshallingException { - final VIDPAuthenticationAttributes vIDPAuthenticationAttr = (VIDPAuthenticationAttributes) parentObject; + /** + * Process child element. + * + * @param parentObject + * the parent object + * @param childObject + * the child object + * + * @throws UnmarshallingException + * the unmarshalling exception + * + */ + protected final void processChildElement(final XMLObject parentObject, final XMLObject childObject) throws UnmarshallingException { + final VIDPAuthenticationAttributes vIDPAuthenticationAttr = (VIDPAuthenticationAttributes) parentObject; - if (childObject instanceof CitizenCountryCode) { - vIDPAuthenticationAttr.setCitizenCountryCode((CitizenCountryCode) childObject); - } else if (childObject instanceof SPInformation) { - vIDPAuthenticationAttr.setSPInformation((SPInformation) childObject); - } else { - super.processChildElement(parentObject, childObject); - } - } + if (childObject instanceof CitizenCountryCode) { + vIDPAuthenticationAttr.setCitizenCountryCode((CitizenCountryCode) childObject); + } else if (childObject instanceof SPInformation) { + vIDPAuthenticationAttr.setSPInformation((SPInformation) childObject); + } else { + super.processChildElement(parentObject, childObject); + } + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/CustomAttributeQueryValidator.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/CustomAttributeQueryValidator.java index c602ad38a..be06dcfb4 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/CustomAttributeQueryValidator.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/CustomAttributeQueryValidator.java @@ -7,13 +7,15 @@ import org.opensaml.xml.validation.Validator; import eu.stork.peps.auth.engine.core.CustomAttributeQuery; public class CustomAttributeQueryValidator implements Validator { - + /** * Validate action. * - * @param attrQuery the attribute query to validate + * @param attrQuery + * the attribute query to validate * - * @throws ValidationException the validation exception + * @throws ValidationException + * the validation exception */ public final void validate(final CustomAttributeQuery attrQuery) throws ValidationException { validateAssertion(attrQuery); @@ -21,49 +23,58 @@ public class CustomAttributeQueryValidator implements Validator { + /** + * validate the extensions. + * + * @param extensions + * the extensions + * + * @throws ValidationException + * the validation exception + */ + public final void validate(final Extensions extensions) throws ValidationException { + if (extensions.getUnknownXMLObjects() == null || extensions.getUnknownXMLObjects().size() <= 0) { + throw new ValidationException("Extension element is empty or not exist."); + } + + List qaa = extensions.getUnknownXMLObjects(QAAAttribute.DEF_ELEMENT_NAME); + + if (qaa.size() == 1) { + final Validator validatorQaa = new QAAAttributeSchemaValidator(); + validatorQaa.validate((QAAAttribute) qaa.get(0)); + } else { + throw new ValidationException("Extensions must contain only one element QAALevel."); + } - /** - * validate the extensions. - * - * @param extensions the extensions - * - * @throws ValidationException the validation exception - */ - public final void validate(final Extensions extensions) - throws ValidationException { - if (extensions.getUnknownXMLObjects() == null - || extensions.getUnknownXMLObjects().size() <= 0) { - throw new ValidationException("Extension element is empty or not exist."); } - - List qaa = extensions.getUnknownXMLObjects(QAAAttribute.DEF_ELEMENT_NAME); - - if (qaa.size() == 1) { - final Validator validatorQaa = new QAAAttributeSchemaValidator(); - validatorQaa.validate((QAAAttribute) qaa.get(0)); - } else { - throw new ValidationException( - "Extensions must contain only one element QAALevel."); - } - - } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/MultipleAssertionResponseValidator.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/MultipleAssertionResponseValidator.java index 72639c8ee..0d3dbb5e9 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/MultipleAssertionResponseValidator.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/MultipleAssertionResponseValidator.java @@ -4,77 +4,90 @@ import org.opensaml.saml2.core.Response; import org.opensaml.xml.validation.ValidationException; import org.opensaml.xml.validation.Validator; - public class MultipleAssertionResponseValidator implements Validator { - + /** * Validate action. * - * @param response the response to validate + * @param response + * the response to validate * - * @throws ValidationException the validation exception + * @throws ValidationException + * the validation exception */ public final void validate(final Response response) throws ValidationException { validateAssertion(response); validateConsent(response); - validateDestination(response); + validateDestination(response); validateTime(response); validateId(response); } - /** * Validate assertion. * - * @param response the attribute query + * @param response + * the attribute query * - * @throws ValidationException the validation exception + * @throws ValidationException + * the validation exception */ - protected final void validateAssertion(final Response response) - throws ValidationException { + protected final void validateAssertion(final Response response) throws ValidationException { if (response.getAssertions() == null || response.getAssertions().size() < 2) { throw new ValidationException("Multiple assertions must be specified."); } } - + /** * Validate the Consent - * @param response the response to validate - * @throws ValidationException the validation exception + * + * @param response + * the response to validate + * @throws ValidationException + * the validation exception */ protected void validateConsent(Response response) throws ValidationException { - if (response.getConsent() == null) - throw new ValidationException("Consent is required"); - } - + if (response.getConsent() == null) + throw new ValidationException("Consent is required"); + } + /** * Validate the destination - * @param response the response to validate - * @throws ValidationException the validation exception + * + * @param response + * the response to validate + * @throws ValidationException + * the validation exception */ protected void validateDestination(Response response) throws ValidationException { - if (response.getDestination() == null) - throw new ValidationException("Destination is required"); - } - + if (response.getDestination() == null) + throw new ValidationException("Destination is required"); + } + /** * Validate issue times - * @param response the response to validate - * @throws ValidationException the validation exception + * + * @param response + * the response to validate + * @throws ValidationException + * the validation exception */ - protected void validateTime(Response response) throws ValidationException { - if (response.getIssueInstant().isAfterNow()) - throw new ValidationException("Issue time is in the futue"); - } - + protected void validateTime(Response response) throws ValidationException { + if (response.getIssueInstant().isAfterNow()) + throw new ValidationException("Issue time is in the futue"); + } + /** * Validate ids - * @param response the response to validate - * @throws ValidationException the validation exception + * + * @param response + * the response to validate + * @throws ValidationException + * the validation exception */ - protected void validateId(Response response) throws ValidationException { - if (response.getID() == null || response.getInResponseTo() == null) - throw new ValidationException("Id and response id is required"); - } + protected void validateId(Response response) throws ValidationException { + if (response.getID() == null || response.getInResponseTo() == null) + throw new ValidationException("Id and response id is required"); + } } diff --git a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/QAAAttributeSchemaValidator.java b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/QAAAttributeSchemaValidator.java index 44c9db380..bf7626dc5 100644 --- a/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/QAAAttributeSchemaValidator.java +++ b/id/server/stork2-saml-engine/src/main/java/eu/stork/peps/auth/engine/core/validator/QAAAttributeSchemaValidator.java @@ -28,28 +28,29 @@ import eu.stork.peps.auth.engine.core.QAAAttribute; */ public class QAAAttributeSchemaValidator implements Validator { - /** * Validate action. * - * @param qaa the quality authentication assurance level attribute + * @param qaa + * the quality authentication assurance level attribute * - * @throws ValidationException the validation exception + * @throws ValidationException + * the validation exception */ public final void validate(final QAAAttribute qaa) throws ValidationException { validateAction(qaa); } - /** * Validate action. * - * @param qaaAttribute the quality authentication assurance level attribute. + * @param qaaAttribute + * the quality authentication assurance level attribute. * - * @throws ValidationException the validation exception + * @throws ValidationException + * the validation exception */ - protected final void validateAction(final QAAAttribute qaaAttribute) - throws ValidationException { + protected final void validateAction(final QAAAttribute qaaAttribute) throws ValidationException { if (DatatypeHelper.isEmpty(qaaAttribute.getQaaLevel())) { throw new ValidationException("QAALevel label must be specified."); } @@ -57,8 +58,7 @@ public class QAAAttributeSchemaValidator implements Validator { final int qaa = Integer.valueOf(qaaAttribute.getQaaLevel()); if (qaa < QAAAttribute.MIN_VALUE || qaa > QAAAttribute.MAX_VALUE) { - throw new ValidationException( - "QAALevel label must be greater than 0."); + throw new ValidationException("QAALevel label must be greater than 0."); } } -- cgit v1.2.3