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 032/** 033 * Domain is used to represent the organization which the user belongs to. Users 034 * can setup their domain and subdomain, which represent the organization and 035 * department/group they belong to, respectively. 036 * 037 * @author Zhijie Guan guan@sdsc.edu 038 * 039 */ 040 041public class Domain { 042 private String domain; 043 private String subdomain; 044 private String serviceURL; 045 private String serviceOperation; 046 private String serviceClass; 047 private String username; 048 private String password; 049 050 /** 051 * @return Returns the domain. 052 */ 053 public String getDomain() { 054 return domain; 055 } 056 057 /** 058 * @param domain 059 * The domain to set. 060 */ 061 public void setDomain(String domain) { 062 this.domain = domain; 063 } 064 065 /** 066 * @return Returns the subdomain. 067 */ 068 public String getSubdomain() { 069 return subdomain; 070 } 071 072 /** 073 * @param subdomain 074 * The subdomain to set. 075 */ 076 public void setSubdomain(String subdomain) { 077 this.subdomain = subdomain; 078 } 079 080 /** 081 * @param fullDomain 082 * The fullDomain to set. 083 */ 084 public void setFullDomain(String fullDomain) { 085 int slashPosition = fullDomain.indexOf('/'); 086 087 if (slashPosition == -1) { 088 // Only domain exists 089 this.domain = fullDomain; 090 } else { 091 // Subdomain exists 092 this.domain = fullDomain.substring(0, slashPosition); 093 this.subdomain = fullDomain.substring(slashPosition + 1); 094 } 095 } 096 097 /** 098 * @return Returns the fullDomain 099 */ 100 public String getFullDomain() { 101 if (this.subdomain != null) { 102 return this.domain + '/' + this.subdomain; 103 } else { 104 return this.domain; 105 } 106 } 107 108 /** 109 * Compare to another domain to see if they are equal 110 * 111 * @param d 112 * Another domain 113 * @return True if equal, False otherwise 114 */ 115 public boolean equalTo(Domain d) { 116 if ((this.domain == d.getDomain()) 117 && (this.subdomain == d.getSubdomain())) { 118 return true; 119 } else { 120 return false; 121 } 122 } 123 124 /** 125 * @return Returns the serviceOperation. 126 */ 127 public String getServiceOperation() { 128 return serviceOperation; 129 } 130 131 /** 132 * @param serviceOperation 133 * The serviceOperation to set. 134 */ 135 public void setServiceOperation(String serviceOperation) { 136 this.serviceOperation = serviceOperation; 137 } 138 139 /** 140 * @return Returns the serviceURL. 141 */ 142 public String getServiceURL() { 143 return serviceURL; 144 } 145 146 /** 147 * @param serviceURL 148 * The serviceURL to set. 149 */ 150 public void setServiceURL(String serviceURL) { 151 this.serviceURL = serviceURL; 152 } 153 154 /** 155 * @return Returns the serviceURL. 156 */ 157 public String getServiceClass() { 158 return serviceClass; 159 } 160 161 /** 162 * @param serviceURL 163 * The serviceURL to set. 164 */ 165 public void setServiceClass(String serviceClass) { 166 this.serviceClass = serviceClass; 167 } 168 169 public String getUsername() { 170 return username; 171 } 172 173 public void setUsername(String username) { 174 this.username = username; 175 } 176 177 public String getPassword() { 178 return password; 179 } 180 181 public void setPassword(String password) { 182 this.password = password; 183 } 184 185 public String toString() { 186 return "[name: " + domain + ", serviceURL: " + serviceURL 187 + ", serviceOperation: " + serviceOperation + "]"; 188 } 189}