Home » geronimo-2.2-source-release » org.apache.geronimo.security.deployment » [javadoc | source]

    1   /*
    2    * Licensed to the Apache Software Foundation (ASF) under one
    3    * or more contributor license agreements.  See the NOTICE file
    4    * distributed with this work for additional information
    5    * regarding copyright ownership.  The ASF licenses this file
    6    * to you under the Apache License, Version 2.0 (the
    7    * "License"); you may not use this file except in compliance
    8    * with the License.  You may obtain a copy of the License at
    9    *
   10    *  http://www.apache.org/licenses/LICENSE-2.0
   11    *
   12    * Unless required by applicable law or agreed to in writing,
   13    * software distributed under the License is distributed on an
   14    * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   15    * KIND, either express or implied.  See the License for the
   16    * specific language governing permissions and limitations
   17    * under the License.
   18    */
   19   
   20   
   21   package org.apache.geronimo.security.deployment;
   22   
   23   import java.util.HashMap;
   24   import java.util.Map;
   25   
   26   import org.apache.geronimo.common.DeploymentException;
   27   import org.apache.geronimo.deployment.service.XmlAttributeBuilder;
   28   import org.apache.geronimo.gbean.GBeanInfo;
   29   import org.apache.geronimo.gbean.GBeanInfoBuilder;
   30   import org.apache.geronimo.xbeans.geronimo.credentialstore.CredentialStoreDocument;
   31   import org.apache.geronimo.xbeans.geronimo.credentialstore.CredentialStoreType;
   32   import org.apache.geronimo.xbeans.geronimo.credentialstore.CredentialType;
   33   import org.apache.geronimo.xbeans.geronimo.credentialstore.RealmType;
   34   import org.apache.geronimo.xbeans.geronimo.credentialstore.SubjectType;
   35   import org.apache.xmlbeans.XmlObject;
   36   
   37   /**
   38    * @version $Rev: 698441 $ $Date: 2008-09-24 00:10:08 -0700 (Wed, 24 Sep 2008) $
   39    */
   40   public class CredentialStoreBuilder implements XmlAttributeBuilder {
   41   
   42       private static final String NAMESPACE = CredentialStoreDocument.type.getDocumentElementName().getNamespaceURI();
   43   
   44       public String getNamespace() {
   45           return NAMESPACE;
   46       }
   47   
   48       public Object getValue(XmlObject xmlObject, String type, ClassLoader cl) throws DeploymentException {
   49           Map<String, Map<String, Map<String, String>>> credentialStore = new HashMap<String, Map<String, Map<String, String>>>();
   50           CredentialStoreType cst = (CredentialStoreType) xmlObject.copy().changeType(CredentialStoreType.type);
   51           for (RealmType realmType: cst.getRealmArray()) {
   52               String realmName = realmType.getName().trim();
   53               Map<String, Map<String, String>> realm = new HashMap<String, Map<String, String>>();
   54               credentialStore.put(realmName, realm);
   55               for (SubjectType subjectType: realmType.getSubjectArray()) {
   56                   String id = subjectType.getId().trim();
   57                   Map<String, String> subject = new HashMap<String, String>();
   58                   realm.put(id, subject);
   59                   for (CredentialType credentialType: subjectType.getCredentialArray()) {
   60                       String handlerType = credentialType.getType().trim();
   61                       String value = credentialType.getValue().trim();
   62                       subject.put(handlerType, value);
   63                   }
   64   
   65               }
   66           }
   67           return credentialStore;
   68       }
   69   
   70   
   71       public static final GBeanInfo GBEAN_INFO;
   72   
   73       static {
   74           GBeanInfoBuilder infoBuilder = GBeanInfoBuilder.createStatic(CredentialStoreBuilder.class, "XmlAttributeBuilder");
   75           GBEAN_INFO = infoBuilder.getBeanInfo();
   76       }
   77   
   78       public static GBeanInfo getGBeanInfo() {
   79           return GBEAN_INFO;
   80       }
   81   }

Home » geronimo-2.2-source-release » org.apache.geronimo.security.deployment » [javadoc | source]