[Dive4elements-commits] [PATCH 06 of 21] Add NamespaceContext for SAML handling

Wald Commits scm-commit at wald.intevation.org
Wed May 8 18:08:16 CEST 2013


# HG changeset patch
# User Bernhard Herzog <bh at intevation.de>
# Date 1368028573 -7200
# Node ID 231a834d4e28dbe65a0f284070b69104d71051f8
# Parent  302b3497677c9a7ade6114f9a10aa5060d99f813
Add NamespaceContext for SAML handling.

diff -r 302b3497677c -r 231a834d4e28 gwt-client/src/main/java/org/dive4elements/river/client/server/auth/saml/SamlNamespaceContext.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/gwt-client/src/main/java/org/dive4elements/river/client/server/auth/saml/SamlNamespaceContext.java	Wed May 08 17:56:13 2013 +0200
@@ -0,0 +1,106 @@
+/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde
+ * Software engineering by Intevation GmbH
+ *
+ * This file is Free Software under the GNU AGPL (>=v3)
+ * and comes with ABSOLUTELY NO WARRANTY! Check out the
+ * documentation coming with Dive4Elements River for details.
+ */
+
+package org.dive4elements.river.client.server.auth.saml;
+
+import java.util.Iterator;
+
+import javax.xml.XMLConstants;
+import javax.xml.namespace.NamespaceContext;
+
+
+/**
+ * The namespace context for SAML documents.
+ */
+public class SamlNamespaceContext implements NamespaceContext
+{
+    /**
+     * The URI of the namespace of SAML assertions.
+     */
+    public static final String SAML_NS_ASSERT =
+        "urn:oasis:names:tc:SAML:1.0:assertion";
+
+    /**
+     * The URI of the namespace of the SAML protocol.
+     */
+    public static final String SAML_NS_PROTO =
+        "urn:oasis:names:tc:SAML:1.0:protocol";
+
+    /**
+     * The URI of the namespace for XML signatures.
+     */
+    public static final String XML_SIG_NS =
+        "http://www.w3.org/2000/09/xmldsig#";
+
+    /**
+     * Final instance to be easily used to avoid creation
+     * of instances.
+     */
+    public static final SamlNamespaceContext INSTANCE =
+        new SamlNamespaceContext();
+
+
+    /**
+     * The default constructor.
+     */
+    public SamlNamespaceContext() {
+    }
+
+
+    /**
+     * @see javax.xml.namespace.NamespaceContext#getNamespaceURI(String)
+     * @param prefix The prefix
+     * @return The corresponing URI
+     */
+    public String getNamespaceURI(String prefix) {
+
+        if (prefix == null) {
+            throw new NullPointerException("Null prefix");
+        }
+
+        if ("saml".equals(prefix)) {
+            return SAML_NS_ASSERT;
+        }
+
+        if ("samlp".equals(prefix)) {
+            return SAML_NS_PROTO;
+        }
+
+        if ("ds".equals(prefix)) {
+            return XML_SIG_NS;
+        }
+
+        if ("xml".equals(prefix)) {
+            return XMLConstants.XML_NS_URI;
+        }
+
+        return XMLConstants.NULL_NS_URI;
+    }
+
+
+    /**
+     * @see javax.xml.namespace.NamespaceContext#getPrefix(String)
+     * @param uri The URI
+     * @return nothing.
+     * @throws java.lang.UnsupportedOperationException
+     */
+    public String getPrefix(String uri) {
+        throw new UnsupportedOperationException();
+    }
+
+
+    /**
+     * @see javax.xml.namespace.NamespaceContext#getPrefixes(java.lang.String)
+     * @param uri The URI
+     * @return nothing
+     * @throws java.lang.UnsupportedOperationException
+     */
+    public Iterator getPrefixes(String uri) {
+        throw new UnsupportedOperationException();
+    }
+}


More information about the Dive4elements-commits mailing list