001/* 002 * Copyright (c) 2003-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: welker $' 006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 007 * '$Revision: 24234 $' 008 * 009 * Permission is hereby granted, without written agreement and without 010 * license or royalty fees, to use, copy, modify, and distribute this 011 * software and its documentation for any purpose, provided that the above 012 * copyright notice and the following two paragraphs appear in all copies 013 * of this software. 014 * 015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 019 * SUCH DAMAGE. 020 * 021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 026 * ENHANCEMENTS, OR MODIFICATIONS. 027 * 028 */ 029 030package org.kepler.authentication; 031 032import java.io.IOException; 033import java.util.List; 034import java.util.Vector; 035 036import org.kepler.configuration.ConfigurationManager; 037import org.kepler.configuration.ConfigurationProperty; 038 039/** 040 * The DomainList is used to store all of the domain info included in Kepler 041 * authentication framework. Currently we only have two domains: GEON and SEEK. 042 * In the future, with more domains added into the authentication framework, all 043 * the domain info would be stored in a XML configuration file. This class needs 044 * to parse that file and read the domain info into the system. 045 * 046 * @author Zhijie Guan guan@sdsc.edu 047 * 048 */ 049 050public class DomainList { 051 private String AUTHSERVICESBUNDLE = "ptolemy/configs/kepler/authServicesBundle"; 052 private Vector domainVector = new Vector(); 053 private static DomainList dlist = null; // singleton member 054 055 /** 056 * The constructor is used to set/read domain info 057 * 058 */ 059 private DomainList() throws IOException 060 { 061 List propList = ConfigurationManager.getInstance().getProperties( 062 ConfigurationManager.getModule("authentication"), "config.service"); 063 for(int i=0; i<propList.size(); i++) 064 { 065 ConfigurationProperty serviceProp = (ConfigurationProperty)propList.get(i); 066 Domain d = new Domain(); 067 d.setDomain(serviceProp.getProperty("domain").getValue()); 068 d.setServiceOperation(serviceProp.getProperty("serviceOperation").getValue()); 069 d.setServiceURL(serviceProp.getProperty("serviceURL").getValue()); 070 d.setServiceClass(serviceProp.getProperty("serviceClass").getValue()); 071 d.setUsername(serviceProp.getProperty("username").getValue()); 072 d.setPassword(serviceProp.getProperty("password").getValue()); 073 domainVector.add(d); 074 } 075 } 076 077 public static DomainList getInstance() throws IOException { 078 if (dlist == null) { 079 dlist = new DomainList(); 080 } 081 return dlist; 082 } 083 084 /** 085 * @return a Vector of Domains 086 */ 087 public Vector getDomainList() { 088 return domainVector; 089 } 090 091 public void addDomain(Domain d) { 092 Domain existingDomain = this.searchDomainList(d.getDomain()); 093 if (existingDomain == null) { 094 this.domainVector.add(d); 095 } 096 } 097 098 /** 099 * Search the domain list for a specific domain. return the domain if it's 100 * found, if not, return null; 101 */ 102 public Domain searchDomainList(String domainName) { 103 for (int i = 0; i < domainVector.size(); i++) { 104 Domain d = (Domain) domainVector.elementAt(i); 105 if (d.getDomain().equals(domainName)) { 106 return d; 107 } 108 } 109 return null; 110 } 111}