From 1626ac9867cd5406b83e73651080e33c11fb98d1 Mon Sep 17 00:00:00 2001 From: kstranacher_eGovL Date: Thu, 12 Jul 2012 11:27:13 +0000 Subject: Integration of STORK git-svn-id: https://joinup.ec.europa.eu/svn/moa-idspss/trunk@1285 d688527b-c9ab-4aba-bd8d-4036d912da1d --- .../messages/saml/impl/STORKAttributeBuilder.java | 60 ++++++++ .../messages/saml/impl/STORKAttributeImpl.java | 63 ++++++++ .../saml/impl/STORKAttributeMarshaller.java | 56 +++++++ .../saml/impl/STORKAttributeUnmarshaller.java | 58 +++++++ .../saml/impl/STORKAuthnRequestBuilder.java | 48 ++++++ .../messages/saml/impl/STORKAuthnRequestImpl.java | 170 +++++++++++++++++++++ .../saml/impl/STORKAuthnRequestMarshaller.java | 44 ++++++ .../saml/impl/STORKAuthnRequestUnmarshaller.java | 137 +++++++++++++++++ .../messages/saml/impl/STORKExtensionsBuilder.java | 45 ++++++ .../messages/saml/impl/STORKExtensionsImpl.java | 74 +++++++++ .../saml/impl/STORKExtensionsMarshaller.java | 32 ++++ .../saml/impl/STORKExtensionsUnmarshaller.java | 58 +++++++ .../saml/impl/STORKRequestedAttributeBuilder.java | 57 +++++++ .../saml/impl/STORKRequestedAttributeImpl.java | 66 ++++++++ .../impl/STORKRequestedAttributeUnmarshaller.java | 64 ++++++++ .../messages/saml/impl/STORKResponseBuilder.java | 48 ++++++ .../vidp/messages/saml/impl/STORKResponseImpl.java | 59 +++++++ .../saml/impl/STORKResponseMarshaller.java | 44 ++++++ .../saml/impl/STORKResponseUnmarshaller.java | 51 +++++++ 19 files changed, 1234 insertions(+) create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeBuilder.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeImpl.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeMarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeUnmarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestBuilder.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestImpl.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestMarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestUnmarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsBuilder.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsImpl.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsMarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsUnmarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeBuilder.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeImpl.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeUnmarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseBuilder.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseImpl.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseMarshaller.java create mode 100644 id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseUnmarshaller.java (limited to 'id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl') diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeBuilder.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeBuilder.java new file mode 100644 index 000000000..413b5f6d7 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeBuilder.java @@ -0,0 +1,60 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +/** + * + */ +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.Attribute; +import org.opensaml.saml2.core.impl.AttributeBuilder; + +import eu.stork.vidp.messages.saml.STORKAttribute; + +/** + * @author bzwattendorfer + * + */ +public class STORKAttributeBuilder extends AttributeBuilder { + + /** + * Constructor. + */ + public STORKAttributeBuilder() { + + } + + /** {@inheritDoc} */ + public STORKAttribute buildObject() { + return buildObject(SAMLConstants.SAML20_NS, Attribute.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20_PREFIX); + } + + /** {@inheritDoc} */ + public STORKAttribute buildObject(String namespaceURI, String localName, String namespacePrefix) { + return new STORKAttributeImpl(namespaceURI, localName, namespacePrefix); + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeImpl.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeImpl.java new file mode 100644 index 000000000..89ad90eae --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeImpl.java @@ -0,0 +1,63 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +/** + * + */ +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.core.impl.AttributeImpl; + +import eu.stork.vidp.messages.saml.STORKAttribute; + +/** + * @author bzwattendorfer + * + */ +public class STORKAttributeImpl extends AttributeImpl implements STORKAttribute { + + private String attributeStatus; + + protected STORKAttributeImpl(String namespaceURI, String elementLocalName, + String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } + + /* (non-Javadoc) + * @see eu.stork.mw.common.messages.saml.STORKAttribute#getAttributeStatus() + */ + public String getAttributeStatus() { + return attributeStatus; + } + + /* (non-Javadoc) + * @see eu.stork.mw.common.messages.saml.STORKAttribute#setAttributeStatus(java.lang.String) + */ + public void setAttributeStatus(String attributeStatus) { + this.attributeStatus = attributeStatus; + + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeMarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeMarshaller.java new file mode 100644 index 000000000..ba8c2f1a3 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeMarshaller.java @@ -0,0 +1,56 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +/** + * + */ +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.core.impl.AttributeMarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.MarshallingException; +import org.w3c.dom.Element; + +import eu.stork.vidp.messages.common.STORKConstants; +import eu.stork.vidp.messages.saml.STORKAttribute; + +/** + * @author bzwattendorfer + * + */ +public class STORKAttributeMarshaller extends AttributeMarshaller { + + protected void marshallAttributes(XMLObject samlElement, Element domElement) throws MarshallingException { + STORKAttribute attribute = (STORKAttribute) samlElement; + + if (attribute.getAttributeStatus() != null) { + domElement.setAttributeNS(STORKConstants.STORK10_NS, STORKAttribute.STORK_ATTRIBUTE_STATUS_ATTTRIB_NAME, attribute.getName()); + } + + super.marshallAttributes(samlElement, domElement); + + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeUnmarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeUnmarshaller.java new file mode 100644 index 000000000..5a74dab7d --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAttributeUnmarshaller.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + + +package eu.stork.vidp.messages.saml.impl; + +import javax.xml.namespace.QName; + +import org.opensaml.saml2.core.Attribute; +import org.opensaml.saml2.core.impl.AttributeUnmarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.UnmarshallingException; +import org.w3c.dom.Attr; + +import eu.stork.vidp.messages.saml.STORKAttribute; + +/** + * A thread-safe Unmarshaller for {@link org.opensaml.saml2.core.Attribute} objects. + */ +public class STORKAttributeUnmarshaller extends AttributeUnmarshaller { + + + protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException { + + if (samlObject instanceof STORKAttribute) { + STORKAttribute attrib = (STORKAttribute) samlObject; + + if (attribute.getLocalName().equals(STORKAttribute.STORK_ATTRIBUTE_STATUS_ATTTRIB_NAME)) { + attrib.setAttributeStatus(attribute.getValue()); + } + } + + super.processAttribute(samlObject, attribute); + } + +} \ No newline at end of file diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestBuilder.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestBuilder.java new file mode 100644 index 000000000..8836b6c8e --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestBuilder.java @@ -0,0 +1,48 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.AuthnRequest; +import org.opensaml.saml2.core.impl.AuthnRequestBuilder; + +import eu.stork.mw.messages.saml.STORKAuthnRequest; + +public class STORKAuthnRequestBuilder extends AuthnRequestBuilder { + + /** {@inheritDoc} */ + + + public STORKAuthnRequest buildObject() { + return buildObject(SAMLConstants.SAML20P_NS, AuthnRequest.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + } + + /** {@inheritDoc} */ + public STORKAuthnRequest buildObject(String namespaceURI, String localName, String namespacePrefix) { + return new STORKAuthnRequestImpl(namespaceURI, localName, namespacePrefix); + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestImpl.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestImpl.java new file mode 100644 index 000000000..c9375ceb9 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestImpl.java @@ -0,0 +1,170 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import java.security.cert.X509Certificate; +import java.util.List; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.impl.AuthnRequestImpl; +import org.opensaml.saml2.metadata.RequestedAttribute; +import org.opensaml.xml.XMLObject; + +import eu.stork.mw.messages.saml.STORKAuthnRequest; + +public class STORKAuthnRequestImpl extends AuthnRequestImpl implements STORKAuthnRequest { + + private int qaaLevel; + + private String ccc; + + private String finalRedirectURL; + + private String spID; + + private XMLObject originalSPAuthRequest; + + private X509Certificate spCertSig; + + private X509Certificate spCertEnc; + + //private XMLObjectChildrenList requestedAttributes; + private List requestedAttributes; + + protected STORKAuthnRequestImpl(String namespaceURI, String elementLocalName, + String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + //requestedAttributes = new IndexedXMLObjectChildrenList(this); + } + + public STORKAuthnRequestImpl() { + super(SAMLConstants.SAML20P_NS, STORKAuthnRequest.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + } + + + + public int getQAALevel() { + return this.qaaLevel; + } + + public void setQAALevel(int authLevel) { + this.qaaLevel = authLevel; + + } + + public String getCitizenCountryCode() { + return ccc; + } + + public String getFinalRedirectURL() { + return finalRedirectURL; + } + + public XMLObject getOriginalSPAuthRequest() { + return originalSPAuthRequest; + } + + public X509Certificate getSPCertEnc() { + return spCertEnc; + } + + public X509Certificate getSPCertSig() { + return spCertSig; + } + + public String getSPID() { + return spID; + } + + public void setCitizenCountryCode(String citizenCountryCode) { + this.ccc = citizenCountryCode; + } + + public void setFinalRedirectURL(String finalRedirectURL) { + this.finalRedirectURL = finalRedirectURL; + } + + public void setOriginalSPAuthRequest(XMLObject spAuthRequest) { + this.originalSPAuthRequest = spAuthRequest; + } + + public void setSPCertEnc(X509Certificate encryptionCertificate) { + this.spCertEnc = encryptionCertificate; + } + + public void setSPCertSig(X509Certificate signingCertificate) { + this.spCertSig = signingCertificate; + } + + public void setSPID(String spID) { + this.spID = spID; + } + + public List getRequestedAttributes() { +// return (List) requestedAttributes.subList(new QName(STORKMessagesConstants.STORK10_NS, DEFAULT_ELEMENT_LOCAL_NAME, STORKMessagesConstants.STORK10_PREFIX)); + return requestedAttributes; + } + + public void setRequestedAttributes(List requestedAttributesList) { + // this.requestedAttributes = (XMLObjectChildrenList) requestedAttributesList; + this.requestedAttributes = requestedAttributesList; + } + +// public List getOrderedChildren() { +// ArrayList children = new ArrayList(); +// +// if (super.getOrderedChildren() != null) { +// children.addAll(super.getOrderedChildren()); +// } +// +// if (qaaLevel != 0 ) { +// children.add(subject); +// } +// +// if (nameIDPolicy != null) { +// children.add(nameIDPolicy); +// } +// +// if (conditions != null) { +// children.add(conditions); +// } +// +// if (requestedAuthnContext != null) { +// children.add(requestedAuthnContext); +// } +// +// if (scoping != null) { +// children.add(scoping); +// } +// +// if (children.size() == 0) { +// return null; +// } +// +// return Collections.unmodifiableList(children); +// } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestMarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestMarshaller.java new file mode 100644 index 000000000..faad3a835 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestMarshaller.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.core.impl.AuthnRequestMarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.MarshallingException; +import org.w3c.dom.Element; + +import eu.stork.mw.messages.saml.STORKAuthnRequest; + +public class STORKAuthnRequestMarshaller extends AuthnRequestMarshaller { + + protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException { + STORKAuthnRequest req = (STORKAuthnRequest) samlObject; + +// if (sr.getQAA() != -1) { +// //domElement.setAttributeNS(null, StatusResponseType.VERSION_ATTRIB_NAME, sr.getVersion().toString()); +// } + } +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestUnmarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestUnmarshaller.java new file mode 100644 index 000000000..7924400fa --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKAuthnRequestUnmarshaller.java @@ -0,0 +1,137 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; + +import org.opensaml.saml2.core.impl.AuthnRequestUnmarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.UnmarshallingException; +import org.opensaml.xml.signature.X509Data; +import org.opensaml.xml.util.Base64; + +import eu.stork.mw.messages.saml.STORKAuthnRequest; +import eu.stork.vidp.messages.saml.STORKExtensions; +import eu.stork.vidp.messages.stork.SPCertEnc; +import eu.stork.vidp.messages.stork.SPCertSig; +import eu.stork.vidp.messages.stork.SPCertType; +import eu.stork.vidp.messages.stork.SPInformation; +import eu.stork.vidp.messages.stork.VIDPAuthenticationAttributes; + +public class STORKAuthnRequestUnmarshaller extends AuthnRequestUnmarshaller { + + protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) + throws UnmarshallingException { + STORKAuthnRequest req = (STORKAuthnRequest) parentSAMLObject; + + if (childSAMLObject instanceof STORKExtensions) { + STORKExtensions ext = (STORKExtensions) childSAMLObject; + req.setExtensions(ext); + + if (ext.getQAALevel() != null) + req.setQAALevel(ext.getQAALevel().getValue()); + + if (ext.getRequestedAttributes() != null) { + //List reqAttrList = new ArrayList(); +// for (RequestedAttribute reqAtt : ext.getRequestedAttributes().getRequestedAttributes()) { +// req.getRequestedAttributes().add(reqAtt); +// } + req.setRequestedAttributes(ext.getRequestedAttributes().getRequestedAttributes()); + + } + + if (ext.getAuthenticationAttributes() != null) { + VIDPAuthenticationAttributes vidpAuthAttributes = ext.getAuthenticationAttributes().getVIDPAuthenticationAttributes(); + if (vidpAuthAttributes != null) { + if (vidpAuthAttributes.getCitizenCountryCode() != null) + req.setCitizenCountryCode(vidpAuthAttributes.getCitizenCountryCode().getValue()); + + SPInformation spInformation = vidpAuthAttributes.getSPInformation(); + if (spInformation != null) { + if (spInformation.getSPID() != null) + req.setSPID(spInformation.getSPID().getValue()); + + if (spInformation.getSPCertSig() != null) { + SPCertSig spCertSig = spInformation.getSPCertSig(); + try { + req.setSPCertSig(getCertificateFromX509Data(spCertSig)); + } catch (Exception e) { + throw new UnmarshallingException("Error reading SP signing certificate"); + } + } + + if (spInformation.getSPCertEnc() != null) { + SPCertEnc spCertEnc = spInformation.getSPCertEnc(); + try { + req.setSPCertEnc(getCertificateFromX509Data(spCertEnc)); + } catch (Exception e) { + throw new UnmarshallingException("Error reading SP encryption certificate"); + } + } + + if (spInformation.getSPAuthRequest() != null) { + req.setOriginalSPAuthRequest(spInformation.getSPAuthRequest()); + } + + } + } + } + + } else { + super.processChildElement(parentSAMLObject, childSAMLObject); + } + } + + private X509Certificate getCertificateFromX509Data(SPCertType spCert) throws CertificateException { + if (spCert.getKeyInfo() != null) + if (!spCert.getKeyInfo().getX509Datas().isEmpty()) { + X509Data samlX509Data = spCert.getKeyInfo().getX509Datas().get(0); + + if (samlX509Data != null) { + if (!samlX509Data.getX509Certificates().isEmpty()) { + org.opensaml.xml.signature.X509Certificate samlX509Cert = samlX509Data.getX509Certificates().get(0); + if (samlX509Cert != null) { + if (samlX509Cert.getValue() != null && samlX509Cert.getValue().length() != 0) { + InputStream inStream = new ByteArrayInputStream( Base64.decode(samlX509Cert.getValue())); + CertificateFactory cf = CertificateFactory.getInstance("X.509"); + X509Certificate cert = (X509Certificate)cf.generateCertificate(inStream); + return cert; + } + + } + + } + } + } + + return null; + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsBuilder.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsBuilder.java new file mode 100644 index 000000000..96004871c --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsBuilder.java @@ -0,0 +1,45 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.common.impl.ExtensionsBuilder; +import org.opensaml.saml2.core.Response; + +import eu.stork.vidp.messages.saml.STORKExtensions; + +public class STORKExtensionsBuilder extends ExtensionsBuilder { + + public STORKExtensions buildObject() { + return buildObject(SAMLConstants.SAML20P_NS, Response.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + } + + /** {@inheritDoc} */ + public STORKExtensions buildObject(String namespaceURI, String localName, String namespacePrefix) { + return new STORKExtensionsImpl(namespaceURI, localName, namespacePrefix); + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsImpl.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsImpl.java new file mode 100644 index 000000000..5417481c7 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsImpl.java @@ -0,0 +1,74 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.common.impl.ExtensionsImpl; + +import eu.stork.vidp.messages.saml.STORKExtensions; +import eu.stork.vidp.messages.stork.AuthenticationAttributes; +import eu.stork.vidp.messages.stork.QualityAuthenticationAssuranceLevel; +import eu.stork.vidp.messages.stork.RequestedAttributes; + +public class STORKExtensionsImpl extends ExtensionsImpl implements STORKExtensions { + + private QualityAuthenticationAssuranceLevel qaaLevel; + + private RequestedAttributes requestedAttributes; + + private AuthenticationAttributes authenticationAttributes; + + protected STORKExtensionsImpl(String namespaceURI, String elementLocalName, + String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } + + public AuthenticationAttributes getAuthenticationAttributes() { + return authenticationAttributes; + } + + public QualityAuthenticationAssuranceLevel getQAALevel() { + return qaaLevel; + } + + public RequestedAttributes getRequestedAttributes() { + return requestedAttributes; + } + + public void setAuthenticationAttributes( + AuthenticationAttributes authenticationAttributes) { + this.authenticationAttributes = authenticationAttributes; + } + + public void setQAALevel(QualityAuthenticationAssuranceLevel authLevel) { + this.qaaLevel = authLevel; + } + + public void setRequestedAttributes(RequestedAttributes requestedAttributes) { + this.requestedAttributes = requestedAttributes; + } + + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsMarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsMarshaller.java new file mode 100644 index 000000000..7aa86c2ed --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsMarshaller.java @@ -0,0 +1,32 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.common.impl.ExtensionsMarshaller; + +public class STORKExtensionsMarshaller extends ExtensionsMarshaller { + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsUnmarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsUnmarshaller.java new file mode 100644 index 000000000..a701c9e6f --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKExtensionsUnmarshaller.java @@ -0,0 +1,58 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.common.impl.ExtensionsUnmarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.UnmarshallingException; + +import eu.stork.vidp.messages.saml.STORKExtensions; +import eu.stork.vidp.messages.stork.AuthenticationAttributes; +import eu.stork.vidp.messages.stork.QualityAuthenticationAssuranceLevel; +import eu.stork.vidp.messages.stork.RequestedAttributes; + +public class STORKExtensionsUnmarshaller extends ExtensionsUnmarshaller { + + protected void processChildElement(XMLObject parentXMLObject, XMLObject childXMLObject) + throws UnmarshallingException { + STORKExtensions extensions = (STORKExtensions) parentXMLObject; + + if (childXMLObject instanceof QualityAuthenticationAssuranceLevel) { + QualityAuthenticationAssuranceLevel qaa = (QualityAuthenticationAssuranceLevel) childXMLObject; + extensions.setQAALevel(qaa); + } if (childXMLObject instanceof RequestedAttributes) { + RequestedAttributes requestedAttributes = (RequestedAttributes) childXMLObject; + extensions.setRequestedAttributes(requestedAttributes); + } if (childXMLObject instanceof AuthenticationAttributes) { + AuthenticationAttributes authenticationAttributes = (AuthenticationAttributes) childXMLObject; + extensions.setAuthenticationAttributes(authenticationAttributes); + } else { + super.processChildElement(parentXMLObject, childXMLObject); + } + +} + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeBuilder.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeBuilder.java new file mode 100644 index 000000000..1e23a9f2b --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeBuilder.java @@ -0,0 +1,57 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +/** + * + */ + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.common.impl.AbstractSAMLObjectBuilder; +import org.opensaml.saml2.metadata.RequestedAttribute; + +import eu.stork.vidp.messages.common.STORKConstants; +import eu.stork.vidp.messages.saml.STORKRequestedAttribute; + +/** + * Builder for {@link org.opensaml.saml2.metadata.impl.RequestedAttributeImpl}. + */ +public class STORKRequestedAttributeBuilder extends AbstractSAMLObjectBuilder { + + /** Constructor */ + public STORKRequestedAttributeBuilder() { + + } + + /** {@inheritDoc} */ + public STORKRequestedAttribute buildObject() { + return buildObject(STORKConstants.STORK10_NS, STORKRequestedAttribute.DEFAULT_ELEMENT_LOCAL_NAME, STORKConstants.STORK10_PREFIX); + } + + /** {@inheritDoc} */ + public STORKRequestedAttribute buildObject(String namespaceURI, String localName, String namespacePrefix) { + return new STORKRequestedAttributeImpl(namespaceURI, localName, namespacePrefix); + } +} \ No newline at end of file diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeImpl.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeImpl.java new file mode 100644 index 000000000..e3921919a --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeImpl.java @@ -0,0 +1,66 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + + +/** + * + */ + +package eu.stork.vidp.messages.saml.impl; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.opensaml.saml2.metadata.impl.RequestedAttributeImpl; +import org.opensaml.xml.XMLObject; + +import eu.stork.vidp.messages.saml.STORKRequestedAttribute; + +/** + * Concrete implementation of {@link org.opensaml.saml2.metadata.RequestedAttribute} + */ +public class STORKRequestedAttributeImpl extends RequestedAttributeImpl implements STORKRequestedAttribute { + + /** + * Constructor + * + * @param namespaceURI + * @param elementLocalName + * @param namespacePrefix + */ + protected STORKRequestedAttributeImpl(String namespaceURI, String elementLocalName, String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } + + /** {@inheritDoc} */ + public List getOrderedChildren() { + ArrayList children = new ArrayList(); + + children.addAll(getAttributeValues()); + + return Collections.unmodifiableList(children); + } +} \ No newline at end of file diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeUnmarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeUnmarshaller.java new file mode 100644 index 000000000..6b7771c72 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKRequestedAttributeUnmarshaller.java @@ -0,0 +1,64 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + + +/** + * + */ + +package eu.stork.vidp.messages.saml.impl; + +import javax.xml.namespace.QName; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.Attribute; +import org.opensaml.saml2.metadata.impl.RequestedAttributeUnmarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.UnmarshallingException; + +import eu.stork.vidp.messages.common.STORKConstants; + + +/** + * A thread-safe Unmarshaller for {@link org.opensaml.saml2.metadata.RequestedAttribute} objects. + */ +public class STORKRequestedAttributeUnmarshaller extends RequestedAttributeUnmarshaller { + + protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) + throws UnmarshallingException { + + Attribute attribute = (Attribute) parentSAMLObject; + + QName childQName = childSAMLObject.getElementQName(); + if (childQName.getLocalPart().equals("AttributeValue") + && childQName.getNamespaceURI().equals(STORKConstants.STORK10_NS)) { + attribute.getAttributeValues().add(childSAMLObject); + } else { + super.processChildElement(parentSAMLObject, childSAMLObject); + } +} + + +} \ No newline at end of file diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseBuilder.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseBuilder.java new file mode 100644 index 000000000..24cebaef7 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseBuilder.java @@ -0,0 +1,48 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.Response; +import org.opensaml.saml2.core.impl.ResponseBuilder; + +import eu.stork.mw.messages.saml.STORKResponse; + +public class STORKResponseBuilder extends ResponseBuilder { + + /** {@inheritDoc} */ + + + public STORKResponse buildObject() { + return buildObject(SAMLConstants.SAML20P_NS, Response.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + } + + /** {@inheritDoc} */ + public STORKResponse buildObject(String namespaceURI, String localName, String namespacePrefix) { + return new STORKResponseImpl(namespaceURI, localName, namespacePrefix); + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseImpl.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseImpl.java new file mode 100644 index 000000000..08b5dc9bc --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseImpl.java @@ -0,0 +1,59 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.common.xml.SAMLConstants; +import org.opensaml.saml2.core.impl.ResponseImpl; + +import eu.stork.mw.messages.saml.STORKAuthnRequest; +import eu.stork.mw.messages.saml.STORKResponse; + +public class STORKResponseImpl extends ResponseImpl implements STORKResponse { + + private int qaaLevel; + + protected STORKResponseImpl(String namespaceURI, String elementLocalName, + String namespacePrefix) { + super(namespaceURI, elementLocalName, namespacePrefix); + } + + + + public STORKResponseImpl() { + super(SAMLConstants.SAML20P_NS, STORKResponse.DEFAULT_ELEMENT_LOCAL_NAME, SAMLConstants.SAML20P_PREFIX); + } + + + public int getQAALevel() { + return this.qaaLevel; + } + + public void setQAALevel(int authLevel) { + this.qaaLevel = authLevel; + + } + +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseMarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseMarshaller.java new file mode 100644 index 000000000..1a4654d01 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseMarshaller.java @@ -0,0 +1,44 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.core.impl.ResponseMarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.MarshallingException; +import org.w3c.dom.Element; + +import eu.stork.mw.messages.saml.STORKResponse; + +public class STORKResponseMarshaller extends ResponseMarshaller { + + protected void marshallElementContent(XMLObject samlObject, Element domElement) throws MarshallingException { + STORKResponse sr = (STORKResponse) samlObject; + +// if (sr.getQAA() != -1) { +// //domElement.setAttributeNS(null, StatusResponseType.VERSION_ATTRIB_NAME, sr.getVersion().toString()); +// } + } +} diff --git a/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseUnmarshaller.java b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseUnmarshaller.java new file mode 100644 index 000000000..c2a7bcef9 --- /dev/null +++ b/id/server/stork-saml-engine/src/main/java/eu/stork/vidp/messages/saml/impl/STORKResponseUnmarshaller.java @@ -0,0 +1,51 @@ +/* + * Copyright 2011 by Graz University of Technology, Austria + * The Austrian STORK Modules have been developed by the E-Government + * Innovation Center EGIZ, a joint initiative of the Federal Chancellery + * Austria and Graz University of Technology. + * + * Licensed under the EUPL, Version 1.1 or - as soon they will be approved by + * the European Commission - subsequent versions of the EUPL (the "Licence"); + * You may not use this work except in compliance with the Licence. + * You may obtain a copy of the Licence at: + * http://www.osor.eu/eupl/ + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the Licence is distributed on an "AS IS" basis, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the Licence for the specific language governing permissions and + * limitations under the Licence. + * + * This product combines work with different licenses. See the "NOTICE" text + * file for details on the various modules and licenses. + * The "NOTICE" text file is part of the distribution. Any derivative works + * that you distribute must include a readable copy of the "NOTICE" text file. + */ + + +package eu.stork.vidp.messages.saml.impl; + +import org.opensaml.saml2.core.impl.ResponseUnmarshaller; +import org.opensaml.xml.XMLObject; +import org.opensaml.xml.io.UnmarshallingException; + +import eu.stork.mw.messages.saml.STORKResponse; +import eu.stork.vidp.messages.saml.STORKExtensions; + +public class STORKResponseUnmarshaller extends ResponseUnmarshaller { + + protected void processChildElement(XMLObject parentSAMLObject, XMLObject childSAMLObject) + throws UnmarshallingException { + STORKResponse resp = (STORKResponse) parentSAMLObject; + + if (childSAMLObject instanceof STORKExtensions) { + STORKExtensions ext = (STORKExtensions) childSAMLObject; + + if (ext.getQAALevel() != null) + resp.setQAALevel(ext.getQAALevel().getValue()); + } else { + super.processChildElement(parentSAMLObject, childSAMLObject); + } + } + +} -- cgit v1.2.3