FQDNUtils.java revision 56ed5bbb263838f338eb8afc978091c01a4f2a2b
/**
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
* Copyright (c) 2005 Sun Microsystems Inc. All Rights Reserved
*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
* See the License for the specific language governing
* permission and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at opensso/legal/CDDLv1.0.txt.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* $Id: FQDNUtils.java,v 1.6 2008/08/19 19:08:59 veiming Exp $
*
*/
/**
* This class provides utility methods to check if a host name is valid; and to
* get fully qualified host name from a partial (virtual) host name.
*/
public class FQDNUtils {
private String defaultHostName;
private Set validHostNames;
/**
* Constructs a <code>FQDNUtils</code> object by reading default host name
* and <code>FQDN</code> map information from
* <code>AMConfig.properties</code> file.
*/
private FQDNUtils() {
init();
}
public static FQDNUtils getInstance() {
return instance;
}
public void init() {
}
/**
* Constructs a <code>FQDNUtils</code> object with a <code>FQDN</code>
* map and a default host name.
*
* @param fqdnMap
* <code>FQDN</code> map.
* @param defaultHostName
* default host name.
*/
this.defaultHostName = defaultHostName;
}
private Map getFQDNMapFromAMConfig() {
while (e.hasMoreElements()) {
if (idx != -1) {
}
}
}
}
return map;
}
}
return set;
}
/**
* Returns true if a host name is valid. <code>hostname</code> is valid if
* it is contained in the list of fully qualified host names. Or, it is the
* default host name where OpenSSO is installed.
*
* @param hostname
* host name
* @return true if a host name is valid.
*/
}
/**
* Returns null if a given host name is valid. Otherwises, this method looks
* up the fully qualified <code>DN</code> map for matching entry. Default
* host name is returned if there is no matching entry.
*
* @param hostname
* host name.
* @return fully qualified host name of <code>hostname</code>
*/
if (!isHostnameValid(hostname)) {
}
}
return fqHostName;
}
}