LDAPURL.java revision ae67ee5dbb90734d441ef90cf65e138f58eb31c2
/*
* 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 legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at 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 copyright [year] [name of copyright owner]".
*
* Copyright 2013 ForgeRock AS.
*/
/**
* A simple domain object to represent a simple LDAP URL, the URL can have two main formats:
* <ul>
* <li>scheme://host:port</li>
* <li>host:port</li>
* </ul>
*
* @author Peter Major
*/
private static final int DEFAULT_PORT = 389;
private static final char SEPARATOR = ':';
private final int port;
}
public int getPort() {
return port;
}
return host;
}
/**
* Returns a Boolean instance that tells whether SSL is enabled. The return value can have 3 values:
* <ul>
* <li>null - no protocol scheme has been provided when creating the LDAPURL instance</li>
* <li>TRUE - protocol scheme was provided and it was "ldaps"</li>
* <li>FALSE - protocol scheme was provided and it was "ldap"</li>
* </ul>
* Due to the possible null value, auto-boxing MUST NOT be used when retrieving this value.
*
* @return Returns a Boolean instance - which may be null -, that tells whether this LDAPURL is SSL enabled.
*/
return isSSL;
}
/**
* Parses an LDAP URL string and constructs an LDAPURL instance. The following two formats are supported currently:
* <ul>
* <li>scheme://host:port</li>
* <li>host:port</li>
* </ul
*
* @param url An LDAP URL that needs to be parsed.
* @return An LDAPURL instance that represents the passed in URL.
*/
int port;
if (firstIdx != -1) {
isSSL = true;
} else {
isSSL = false;
}
}
if (lastIdx != -1) {
try {
} catch (NumberFormatException nfe) {
port = DEFAULT_PORT;
}
} else {
port = DEFAULT_PORT;
}
port = DEFAULT_PORT;
}
}
/**
* Creates a new LDAPURL instance based on the provided host and port values.
*
* @param host The LDAP host.
* @param port The LDAP port.
*/
}
/**
* Creates a new LDAPURL instances based on the provided parameters.
*
* @param host The LDAP host.
* @param port The LDAP port.
* @param isSSL Whether SSL is enabled or not for this LDAP server, may be null.
* @return An LDAPURL instance that represetns the provided parameters.
*/
}
public int hashCode() {
int hash = 7;
return hash;
}
return false;
}
return false;
}
return false;
}
return false;
}
return false;
}
return true;
}
/**
* Returns a String representation of this LDAPURL instance. If the scheme has been provided it will be part of
* the representation as well, otherwise just the simple host:port format will be returned.
*
* @return String representation of this LDAPURL instance.
*/
} else {
}
}
}
}