From 95b21a826e5d81fdeabcf4673a9e87047edaec9d Mon Sep 17 00:00:00 2001 From: Thomas Date: Wed, 4 Dec 2019 22:54:51 +0100 Subject: to some more code quality tasks --- .../api/IPvpAuthnRequestBuilderConfiguruation.java | 38 +++++++++++----------- .../pvp2/sp/impl/PvpAuthnRequestBuilder.java | 5 +++ .../sp/impl/utils/AssertionAttributeExtractor.java | 17 +++++----- 3 files changed, 32 insertions(+), 28 deletions(-) (limited to 'eaaf_modules/eaaf_module_pvp2_sp/src') diff --git a/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/api/IPvpAuthnRequestBuilderConfiguruation.java b/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/api/IPvpAuthnRequestBuilderConfiguruation.java index d050dd4b..07e9c28d 100644 --- a/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/api/IPvpAuthnRequestBuilderConfiguruation.java +++ b/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/api/IPvpAuthnRequestBuilderConfiguruation.java @@ -39,14 +39,14 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public String getSpNameForLogging(); + String getSpNameForLogging(); /** * If true, the SAML2 isPassive flag is set in the AuthnRequest. * * @return */ - public Boolean isPassivRequest(); + Boolean isPassivRequest(); /** * Define the ID of the AssertionConsumerService, which defines the required attributes in @@ -54,21 +54,21 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public Integer getAssertionConsumerServiceId(); + Integer getAssertionConsumerServiceId(); /** * Define the SAML2 EntityID of the service provider. * * @return */ - public String getSpEntityID(); + String getSpEntityID(); /** * Define the SAML2 NameIDPolicy. * * @return Service-Provider EntityID, but never null */ - public String getNameIdPolicyFormat(); + String getNameIdPolicyFormat(); /** * Define the AuthnContextClassRefernece of this request. @@ -80,14 +80,14 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public String getAuthnContextClassRef(); + String getAuthnContextClassRef(); /** * Define the AuthnContextComparison model, which should be used. * * @return */ - public AuthnContextComparisonTypeEnumeration getAuthnContextComparison(); + AuthnContextComparisonTypeEnumeration getAuthnContextComparison(); /** @@ -95,7 +95,7 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public Credential getAuthnRequestSigningCredential(); + Credential getAuthnRequestSigningCredential(); /** @@ -103,14 +103,14 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return Credential, but never null. */ - public EntityDescriptor getIdpEntityDescriptor(); + EntityDescriptor getIdpEntityDescriptor(); /** * Set the SAML2 NameIDPolicy allow-creation flag. * * @return EntityDescriptor, but never null. */ - public boolean getNameIdPolicyAllowCreation(); + boolean getNameIdPolicyAllowCreation(); /** @@ -118,7 +118,7 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return SubjectNameID, or null if no SubjectNameID should be used */ - public String getSubjectNameID(); + String getSubjectNameID(); /** * Define the qualifier of the SubjectNameID
@@ -127,7 +127,7 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return qualifier, or null if no qualifier should be set */ - public String getSubjectNameIdQualifier(); + String getSubjectNameIdQualifier(); /** * Define the format of the subjectNameID, which is included in authn-request. @@ -135,21 +135,21 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return nameIDFormat, of SAML2 'transient' if nothing is defined */ - public String getSubjectNameIdFormat(); + String getSubjectNameIdFormat(); /** * Define a SP specific SAML2 requestID. * * @return requestID, or null if the requestID should be generated automatically */ - public String getRequestID(); + String getRequestID(); /** * Defines the 'method' attribute in 'SubjectConformation' element. * * @return method, or null if no method should set */ - public String getSubjectConformationMethode(); + String getSubjectConformationMethode(); /** * Define the information, which should be added as 'subjectConformationDate' in @@ -157,7 +157,7 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return subjectConformation information or null if no subjectConformation should be set */ - public Element getSubjectConformationDate(); + Element getSubjectConformationDate(); /** @@ -165,7 +165,7 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public String getScopeRequesterId(); + String getScopeRequesterId(); /** @@ -173,7 +173,7 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public String getProviderName(); + String getProviderName(); /** @@ -182,6 +182,6 @@ public interface IPvpAuthnRequestBuilderConfiguruation { * * @return */ - public List getRequestedAttributes(); + List getRequestedAttributes(); } diff --git a/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/PvpAuthnRequestBuilder.java b/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/PvpAuthnRequestBuilder.java index 36f43cc8..11b1ecad 100644 --- a/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/PvpAuthnRequestBuilder.java +++ b/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/PvpAuthnRequestBuilder.java @@ -253,6 +253,11 @@ public class PvpAuthnRequestBuilder { } else if (endpoint.getBinding().equals(SAMLConstants.SAML2_POST_BINDING_URI)) { binding = springContext.getBean("PVPPOSTBinding", PostBinding.class); + } else { + log.warn("Binding: {} is not supported", endpoint.getBinding()); + throw new AuthnRequestBuildException("sp.pvp2.00", + new Object[] {config.getSpNameForLogging(), idpEntity.getEntityID()}); + } // encode message diff --git a/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/utils/AssertionAttributeExtractor.java b/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/utils/AssertionAttributeExtractor.java index e0cad257..42d1c85e 100644 --- a/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/utils/AssertionAttributeExtractor.java +++ b/eaaf_modules/eaaf_module_pvp2_sp/src/main/java/at/gv/egiz/eaaf/modules/pvp2/sp/impl/utils/AssertionAttributeExtractor.java @@ -285,7 +285,7 @@ public class AssertionAttributeExtractor { && getFullAssertion().getAuthnStatements().size() > 0) { for (final AuthnStatement el : getFullAssertion().getAuthnStatements()) { if (el.getSessionNotOnOrAfter() != null) { - return (el.getSessionNotOnOrAfter().toDate()); + return el.getSessionNotOnOrAfter().toDate(); } } @@ -331,21 +331,20 @@ public class AssertionAttributeExtractor { && assertion.getAttributeStatements().size() > 0) { final AttributeStatement attrStat = assertion.getAttributeStatements().get(0); for (final Attribute attr : attrStat.getAttributes()) { - if (attr.getName().startsWith(PvpConstants.STORK_ATTRIBUTE_PREFIX)) { - final List storkAttrValues = new ArrayList<>(); - for (final XMLObject el : attr.getAttributeValues()) { - storkAttrValues.add(el.getDOM().getTextContent()); - } - +// if (attr.getName().startsWith(PvpConstants.STORK_ATTRIBUTE_PREFIX)) { +// final List storkAttrValues = new ArrayList<>(); +// for (final XMLObject el : attr.getAttributeValues()) { +// storkAttrValues.add(el.getDOM().getTextContent()); +// } // PersonalAttribute storkAttr = new PersonalAttribute(attr.getName(), // false, storkAttrValues , "Available"); // storkAttributes.put(attr.getName(), storkAttr ); - } else { +// } else { final List attrList = new ArrayList<>(); for (final XMLObject el : attr.getAttributeValues()) { attrList.add(el.getDOM().getTextContent()); - } + // } attributs.put(attr.getName(), attrList); -- cgit v1.2.3