QpidConfig.java
001 package org.apache.qpid;
002 /*
003  
004  * Licensed to the Apache Software Foundation (ASF) under one
005  * or more contributor license agreements.  See the NOTICE file
006  * distributed with this work for additional information
007  * regarding copyright ownership.  The ASF licenses this file
008  * to you under the Apache License, Version 2.0 (the
009  * "License"); you may not use this file except in compliance
010  * with the License.  You may obtain a copy of the License at
011  
012  *   http://www.apache.org/licenses/LICENSE-2.0
013  
014  * Unless required by applicable law or agreed to in writing,
015  * software distributed under the License is distributed on an
016  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017  * KIND, either express or implied.  See the License for the
018  * specific language governing permissions and limitations
019  * under the License.
020  
021  */
022 
023 
024 /**
025  * API to configure the Security parameters of the client.
026  * The user can choose to pick the config from any source 
027  * and set it using this class.
028  *
029  */
030 public class QpidConfig
031 {
032     private static QpidConfig _instance = new QpidConfig();
033     
034     private SecurityMechanism[] securityMechanisms = 
035         new SecurityMechanism[]{new SecurityMechanism("PLAIN","org.apache.qpid.security.UsernamePasswordCallbackHandler"),
036                                 new SecurityMechanism("CRAM_MD5","org.apache.qpid.security.UsernamePasswordCallbackHandler")};
037 
038     private SaslClientFactory[] saslClientFactories =
039         new SaslClientFactory[]{new SaslClientFactory("AMQPLAIN","org.apache.qpid.security.amqplain.AmqPlainSaslClientFactory")};       
040     
041    private  QpidConfig(){}
042     
043    public static QpidConfig get()
044    {
045        return _instance;
046    }
047     
048    public void setSecurityMechanisms(SecurityMechanism... securityMechanisms)
049    {
050        this.securityMechanisms = securityMechanisms;
051    }   
052    
053    public SecurityMechanism[] getSecurityMechanisms()
054    {
055        return securityMechanisms;
056    }
057        
058    public void setSaslClientFactories(SaslClientFactory... saslClientFactories)
059    {
060        this.saslClientFactories = saslClientFactories;
061    }   
062    
063    public SaslClientFactory[] getSaslClientFactories()
064    {
065        return saslClientFactories;
066    }
067    
068    public class SecurityMechanism
069    {
070         String type;
071         String handler;
072         
073         SecurityMechanism(String type,String handler)
074         {
075             this.type = type;
076             this.handler = handler;
077         }
078 
079         public String getHandler()
080         {
081             return handler;
082         }
083 
084         public String getType()
085         {
086             return type;
087         }
088    }
089    
090    public class SaslClientFactory
091    {
092         String type;
093         String factoryClass;
094         
095         SaslClientFactory(String type,String factoryClass)
096         {
097             this.type = type;
098             this.factoryClass = factoryClass;
099         }
100 
101         public String getFactoryClass()
102         {
103             return factoryClass;
104         }
105 
106         public String getType()
107         {
108             return type;
109         }
110    }
111 }