Author: anil.saldhana(a)jboss.com
Date: 2009-04-29 13:45:33 -0400 (Wed, 29 Apr 2009)
New Revision: 466
Added:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataExtractor.java
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/SecurityActions.java
Modified:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataBuilder.java
Log:
JBID-42: saml metadata profile
Modified:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataBuilder.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataBuilder.java 2009-04-29
17:44:23 UTC (rev 465)
+++
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataBuilder.java 2009-04-29
17:45:33 UTC (rev 466)
@@ -172,6 +172,11 @@
return sp;
}
+ /**
+ * Get the marshaller
+ * @return
+ * @throws Exception
+ */
public static Marshaller getMarshaller() throws Exception
{
return JBossSAMLBaseFactory.getMarshaller(pkgName);
Added:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataExtractor.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataExtractor.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/MetaDataExtractor.java 2009-04-29
17:45:33 UTC (rev 466)
@@ -0,0 +1,149 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.federation.api.saml.v2.metadata;
+
+import java.util.List;
+
+import org.jboss.identity.federation.saml.v2.metadata.EndpointType;
+import org.jboss.identity.federation.saml.v2.metadata.EntityDescriptorType;
+import org.jboss.identity.federation.saml.v2.metadata.IDPSSODescriptorType;
+import org.jboss.identity.federation.saml.v2.metadata.IndexedEndpointType;
+import org.jboss.identity.federation.saml.v2.metadata.RoleDescriptorType;
+import org.jboss.identity.federation.saml.v2.metadata.SPSSODescriptorType;
+import org.jboss.identity.federation.saml.v2.metadata.SSODescriptorType;
+
+/**
+ * Extract useful information out of metadata
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Apr 29, 2009
+ */
+public class MetaDataExtractor
+{
+ public static String LINE_SEPARATOR =
SecurityActions.getSystemProperty("line.separator",
+ "\n");
+
+ /**
+ * Generate a string from the information in the metadata
+ * @param edt
+ * @return
+ */
+ public static String toString(EntityDescriptorType edt)
+ {
+ StringBuilder builder = new StringBuilder();
+ List<RoleDescriptorType> rolesD =
edt.getRoleDescriptorOrIDPSSODescriptorOrSPSSODescriptor();
+
+ for(RoleDescriptorType rdt: rolesD)
+ {
+ builder.append("ID=").append(rdt.getID());
+ builder.append(LINE_SEPARATOR);
+
+ if(rdt instanceof IDPSSODescriptorType)
+ {
+ IDPSSODescriptorType idp = (IDPSSODescriptorType) rdt;
+ builder.append(toString(idp));
+ }
+ if(rdt instanceof SPSSODescriptorType)
+ {
+ SPSSODescriptorType sp = (SPSSODescriptorType) rdt;
+ builder.append(toString(sp));
+ }
+ }
+
+ return builder.toString();
+ }
+
+ public static String toString(IDPSSODescriptorType idp)
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append(LINE_SEPARATOR);
+
+ //Get the SSODescriptor tags
+ SSODescriptorType sdt = idp;
+ builder.append(toString(sdt));
+
+ List<EndpointType> ssoServices = idp.getSingleSignOnService();
+ if(ssoServices != null)
+ {
+ builder.append("Single Singon Services are:[");
+
+ for(EndpointType edt: ssoServices)
+ {
+ builder.append(toString(edt));
+ }
+ builder.append("]");
+ builder.append(LINE_SEPARATOR);
+ }
+ return builder.toString();
+ }
+
+ public static String toString(SSODescriptorType sso)
+ {
+ StringBuilder builder = new StringBuilder();
+ List<String> nameIDs = sso.getNameIDFormat();
+ if(nameIDs != null)
+ {
+ for(String nameID: nameIDs)
+ {
+ builder.append("NameID=").append(nameID);
+ builder.append(LINE_SEPARATOR);
+ }
+ }
+
+ List<IndexedEndpointType> attrResServices =
sso.getArtifactResolutionService();
+ if(attrResServices != null)
+ {
+ builder.append("AttributeResolutionServices are:[");
+ builder.append(LINE_SEPARATOR);
+ for(IndexedEndpointType iet : attrResServices)
+ {
+ builder.append(toString(iet));
+ }
+ builder.append("]");
+ }
+
+ List<EndpointType> sloServices = sso.getSingleLogoutService();
+ if(sloServices != null)
+ {
+ builder.append("Single Logout Services are:[");
+ builder.append(LINE_SEPARATOR);
+
+ for(EndpointType edt: sloServices)
+ {
+ builder.append(toString(edt));
+ }
+ builder.append("]");
+ builder.append(LINE_SEPARATOR);
+ }
+ return builder.toString();
+ }
+
+ public static String toString(EndpointType ept)
+ {
+ StringBuilder builder = new StringBuilder();
+ builder.append("[Location=").append(ept.getLocation());
+
+ builder.append(",ResponseLocation=").append(ept.getResponseLocation());
+ builder.append("]");
+ builder.append(LINE_SEPARATOR);
+ return builder.toString();
+ }
+}
\ No newline at end of file
Added:
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/SecurityActions.java
===================================================================
---
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/SecurityActions.java
(rev 0)
+++
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/saml/v2/metadata/SecurityActions.java 2009-04-29
17:45:33 UTC (rev 466)
@@ -0,0 +1,65 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.jboss.identity.federation.api.saml.v2.metadata;
+
+import java.security.AccessController;
+import java.security.PrivilegedAction;
+
+/**
+ * Privileged Blocks
+ * @author Anil.Saldhana(a)redhat.com
+ * @since Dec 9, 2008
+ */
+class SecurityActions
+{
+ /**
+ * Get the Thread Context ClassLoader
+ * @return
+ */
+ static ClassLoader getContextClassLoader()
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>()
+ {
+ public ClassLoader run()
+ {
+ return Thread.currentThread().getContextClassLoader();
+ }
+ });
+ }
+
+ /**
+ * Get the system property
+ * @param key
+ * @param defaultValue
+ * @return
+ */
+ static String getSystemProperty(final String key, final String defaultValue)
+ {
+ return AccessController.doPrivileged(new PrivilegedAction<String>()
+ {
+ public String run()
+ {
+ return System.getProperty(key, defaultValue);
+ }
+ });
+ }
+}