svn commit: r580989 - in /lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache: lenya/ac/saml/ lenya/ac/saml/impl/ lenya/ac/shibboleth/ shibboleth/ shibboleth/impl/ shibboleth/util/ shibboleth/util/impl/

[email protected]
Newsgroups gmane.comp.cms.lenya.cvs
Message-ID <[email protected]>
Author: andreas
Date: Mon Oct  1 08:17:19 2007
New Revision: 580989

URL: http://svn.apache.org/viewvc?rev=580989&view=rev
Log:
[Refactoring] move attribute translation from shibboleth packages to Lenya packages

Added:
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/AttributeTranslator.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapper.java
      - copied, changed from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapper.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapping.java
      - copied, changed from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapping.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/AttributeTranslatorImpl.java
      - copied, changed from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/AttributeTranslatorImpl.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/UserFieldsMappingImpl.java
      - copied, changed from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/UserFieldsMappingImpl.java
Removed:
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/AttributeTranslator.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapper.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapping.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/AttributeTranslatorImpl.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/UserFieldsMappingImpl.java
Modified:
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAttributeDefinition.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java
    lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java

Added: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/AttributeTranslator.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/AttributeTranslator.java?rev=580989&view=auto
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/AttributeTranslator.java (added)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/AttributeTranslator.java Mon Oct  1 08:17:19 2007
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+package org.apache.lenya.ac.saml;
+
+import java.util.Map;
+
+/**
+ * The attribute translator translates user attributes into a simpler form. The multi-value
+ * attributes can either be translated into comma-separated values, or into string arrays.
+ */
+public interface AttributeTranslator {
+
+    /**
+     * The service role.
+     */
+    String ROLE = AttributeTranslator.class.getName();
+
+    /**
+     * This is the same as <code>translateAttributes(map, true)</code>.
+     * @param attributes The original attributes, the values are {@link org.opensaml.SAMLAttribute}
+     *        objects.
+     * @return AttributesMap containing all values of a given key as a comma-separated String.
+     */
+    Map translateAttributes(Map attributes);
+
+    /**
+     * @param attributes The original attributes, the values are {@link org.opensaml.SAMLAttribute}
+     *        objects.
+     * @param joinValues If the values should be joined to a comma-separated string.
+     * @return AttributesMap containing all values of a given key as a String array or
+     *         comma-separated String, depending on the <code>joinValues</code> parameter.
+     */
+    Map translateAttributes(Map attributes, boolean joinValues);
+
+    /**
+     * @return All possible result names.
+     */
+    String[] getSupportedResultNames();
+
+}

Copied: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapper.java (from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapper.java)
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapper.java?p2=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapper.java&p1=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapper.java&r1=580896&r2=580989&rev=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapper.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapper.java Mon Oct  1 08:17:19 2007
@@ -15,7 +15,7 @@
  *  limitations under the License.
  *
  */
-package org.apache.shibboleth.util;
+package org.apache.lenya.ac.saml;
 
 import java.util.Iterator;
 import java.util.Map;

Copied: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapping.java (from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapping.java)
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapping.java?p2=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapping.java&p1=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapping.java&r1=580896&r2=580989&rev=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/UserFieldsMapping.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/UserFieldsMapping.java Mon Oct  1 08:17:19 2007
@@ -15,7 +15,7 @@
  *  limitations under the License.
  *
  */
-package org.apache.shibboleth.util;
+package org.apache.lenya.ac.saml;
 
 /**
  * Mapping from SAML attributes to user fields.

Copied: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/AttributeTranslatorImpl.java (from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/AttributeTranslatorImpl.java)
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/AttributeTranslatorImpl.java?p2=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/AttributeTranslatorImpl.java&p1=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/AttributeTranslatorImpl.java&r1=580896&r2=580989&rev=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/AttributeTranslatorImpl.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/AttributeTranslatorImpl.java Mon Oct  1 08:17:19 2007
@@ -15,7 +15,7 @@
  *  limitations under the License.
  *
  */
-package org.apache.shibboleth.util.impl;
+package org.apache.lenya.ac.saml.impl;
 
 import java.util.ArrayList;
 import java.util.Collection;
@@ -28,8 +28,7 @@
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
-import org.apache.shibboleth.impl.ShibbolethModuleImpl;
-import org.apache.shibboleth.util.AttributeTranslator;
+import org.apache.lenya.ac.saml.AttributeTranslator;
 import org.opensaml.SAMLAttribute;
 
 /**
@@ -42,6 +41,11 @@
     private static final String CONF_ATTRIBUTE_OUTNAME = "outName";
     private static final String CONF_ATTRIBUTE_INNAME = "inName";
 
+    /**
+     * Separator for multiple values.
+     */
+    public static final String MULTIVALUE_SEPARATOR = ";";
+    
     private Map attributeTranslations;
 
     public void configure(Configuration attrTransConfig) throws ConfigurationException {
@@ -60,8 +64,8 @@
         }
     }
 
-    public Map translateSamlAttributes(Map samlAttributesMap) {
-        return translateSamlAttributes(samlAttributesMap, true);
+    public Map translateAttributes(Map attributesMap) {
+        return translateAttributes(attributesMap, true);
     }
 
     /**
@@ -75,11 +79,11 @@
         return outName != null ? outName : inName;
     }
 
-    public Map translateSamlAttributes(Map samlAttributesMap, boolean joinValues) {
-        Map convertedMap = new HashMap(samlAttributesMap.size());
-        Iterator keys = samlAttributesMap.keySet().iterator();
+    public Map translateAttributes(Map attributesMap, boolean joinValues) {
+        Map convertedMap = new HashMap(attributesMap.size());
+        Iterator keys = attributesMap.keySet().iterator();
         while (keys.hasNext()) {
-            SAMLAttribute attribute = (SAMLAttribute) samlAttributesMap.get(keys.next());
+            SAMLAttribute attribute = (SAMLAttribute) attributesMap.get(keys.next());
             String translatedKey = translateAttribute(attribute.getName());
             Object values;
             if (joinValues) {
@@ -89,7 +93,7 @@
                     buffer.append((String) iter.next());
                 }
                 while (iter.hasNext()) {
-                    buffer.append(ShibbolethModuleImpl.MULTIVALUE_SEPARATOR);
+                    buffer.append(MULTIVALUE_SEPARATOR);
                     buffer.append((String) iter.next());
                 }
                 values = buffer.toString();

Copied: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/UserFieldsMappingImpl.java (from r580896, lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/UserFieldsMappingImpl.java)
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/UserFieldsMappingImpl.java?p2=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/UserFieldsMappingImpl.java&p1=lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/UserFieldsMappingImpl.java&r1=580896&r2=580989&rev=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/util/impl/UserFieldsMappingImpl.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/saml/impl/UserFieldsMappingImpl.java Mon Oct  1 08:17:19 2007
@@ -15,14 +15,14 @@
  *  limitations under the License.
  *
  */
-package org.apache.shibboleth.util.impl;
+package org.apache.lenya.ac.saml.impl;
 
 import org.apache.avalon.framework.configuration.Configurable;
 import org.apache.avalon.framework.configuration.Configuration;
 import org.apache.avalon.framework.configuration.ConfigurationException;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.thread.ThreadSafe;
-import org.apache.shibboleth.util.UserFieldsMapping;
+import org.apache.lenya.ac.saml.UserFieldsMapping;
 
 /**
  * User fields mapping implementation.

Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAttributeDefinition.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAttributeDefinition.java?rev=580989&r1=580988&r2=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAttributeDefinition.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAttributeDefinition.java Mon Oct  1 08:17:19 2007
@@ -23,7 +23,7 @@
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.avalon.framework.thread.ThreadSafe;
 import org.apache.lenya.ac.AttributeDefinition;
-import org.apache.shibboleth.util.AttributeTranslator;
+import org.apache.lenya.ac.saml.AttributeTranslator;
 
 /**
  * Shibboleth-based attribute definition. The attribute names are the possible

Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java?rev=580989&r1=580988&r2=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/lenya/ac/shibboleth/ShibbolethAuthenticator.java Mon Oct  1 08:17:19 2007
@@ -45,12 +45,12 @@
 import org.apache.lenya.ac.impl.DefaultAccessController;
 import org.apache.lenya.ac.impl.TransientUser;
 import org.apache.lenya.ac.impl.UserAuthenticator;
+import org.apache.lenya.ac.saml.AttributeTranslator;
+import org.apache.lenya.ac.saml.UserFieldsMapper;
 import org.apache.lenya.cms.cocoon.components.context.ContextUtility;
 import org.apache.lenya.util.ServletHelper;
 import org.apache.shibboleth.AssertionConsumerService;
 import org.apache.shibboleth.AttributeRequestService;
-import org.apache.shibboleth.util.AttributeTranslator;
-import org.apache.shibboleth.util.UserFieldsMapper;
 import org.opensaml.SAMLBrowserProfile.BrowserProfileResponse;
 
 /**
@@ -175,7 +175,7 @@
         AttributeTranslator translator = null;
         try {
             translator = (AttributeTranslator) this.manager.lookup(AttributeTranslator.ROLE);
-            translatedAttributes = translator.translateSamlAttributes(samlAttributes, false);
+            translatedAttributes = translator.translateAttributes(samlAttributes, false);
         } catch (ServiceException e) {
             throw new RuntimeException(e);
         } finally {

Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java?rev=580989&r1=580988&r2=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/ShibbolethModule.java Mon Oct  1 08:17:19 2007
@@ -17,7 +17,6 @@
  */
 package org.apache.shibboleth;
 
-import org.apache.shibboleth.util.AttributeTranslator;
 import org.apache.shibboleth.util.CredentialsManager;
 import org.apache.shibboleth.util.UniqueIdentifierMapper;
 import org.opensaml.ReplayCache;
@@ -27,7 +26,7 @@
 import edu.internet2.middleware.shibboleth.metadata.Metadata;
 
 /**
- * Facade to Shibboleth funcationality.
+ * Facade to Shibboleth functionality.
  */
 public interface ShibbolethModule {
 
@@ -45,11 +44,6 @@
      * @return The artifact mapper.
      */
     ArtifactMapper getArtifactMapper();
-
-    /**
-     * @return The attribute translator.
-     */
-    AttributeTranslator getAttributeTranslator();
 
     /**
      * @return The credentials manager.

Modified: lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java
URL: http://svn.apache.org/viewvc/lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java?rev=580989&r1=580988&r2=580989&view=diff
==============================================================================
--- lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java (original)
+++ lenya/branches/branch_1_2_x_shibboleth/src/java/org/apache/shibboleth/impl/ShibbolethModuleImpl.java Mon Oct  1 08:17:19 2007
@@ -34,7 +34,6 @@
 import org.apache.lenya.cms.cocoon.source.SourceUtil;
 import org.apache.shibboleth.ShibbolethModule;
 import org.apache.shibboleth.saml.ArtifactMapperImpl;
-import org.apache.shibboleth.util.AttributeTranslator;
 import org.apache.shibboleth.util.CredentialsManager;
 import org.apache.shibboleth.util.UniqueIdentifierMapper;
 import org.opensaml.MalformedException;
@@ -79,7 +78,6 @@
     private XMLAAP aap;
     private ReplayCache replayCache;
     private ArtifactMapper artifactMapper;
-    private AttributeTranslator attributeTranslator;
     private UniqueIdentifierMapper uidMapper;
     private CredentialsManager credentialsManager;
     private String wayfServerUrl;
@@ -88,11 +86,6 @@
 
     private static String languageParamName;
 
-    /**
-     * Separator for multiple values.
-     */
-    public static final String MULTIVALUE_SEPARATOR = ";";
-    
     private ServiceManager manager;
 
     public UniqueIdentifierMapper getUidMapper() {
@@ -116,18 +109,6 @@
             }
         }
         return this.artifactMapper;
-    }
-
-    public AttributeTranslator getAttributeTranslator() {
-        if (this.attributeTranslator == null) {
-            try {
-                this.attributeTranslator = (AttributeTranslator) this.manager
-                        .lookup(AttributeTranslator.ROLE);
-            } catch (ServiceException e) {
-                throw new RuntimeException(e);
-            }
-        }
-        return this.attributeTranslator;
     }
 
     public CredentialsManager getCredentialsManager() {
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.