com.infoengine.util
Class Url

java.lang.Object
  extended bycom.infoengine.util.Url
All Implemented Interfaces:
Serializable

public class Url
extends Object
implements Serializable

Parses an LDAP URL into it's parts.

The url can be modified using setters turned back into a complete URL retrieved using the toString() method. Copies can be made using the clone() method.

 from rfc 2255:
ldapurl = scheme "://" [hostport] ["/" [dn ["?" [attributes] ["?" [scope] ["?" [filter] ["?" extensions]]]]]] scheme = "ldap" attributes = attrdesc *("," attrdesc) scope = "base" / "one" / "sub" dn = distinguishedName from Section 3 of [1] hostport = hostport from Section 5 of RFC 1738 [5] attrdesc = AttributeDescription from Section 4.1.5 of [2] filter = filter from Section 4 of [4] extensions = extension *("," extension) extension = ["!"] extype ["=" exvalue] extype = token / xtoken exvalue = LDAPString from section 4.1.2 of [2] token = oid from section 4.1 of [3] xtoken = ("X-" / "x-") token

See Also:
Serialized Form

Field Summary
private  String attributes
           
private  int[] defaultPorts
           
private  String dn
           
private  String extensions
           
private  String filter
           
private  String host
           
private  int port
           
private  String principal
           
private  String scheme
           
private  String[] schemes
           
private  String scope
           
private  String secret
           
 
Constructor Summary
Url()
          Creates an empty url.
Url(String url)
          Creates a new url from a string url.
 
Method Summary
 Object clone()
          Makes a copy of this Url.
static String decodeUrl(String encoded)
          Decodes a URL-encoded string.
 String getAttributes()
          Gets the current attributes portion of this url.
 String getDn()
          Gets the dn.
 String getExtensions()
          Gets the extensions.
 String getFilter()
          Gets the search filter.
 String getHost()
          Gets the host.
 int getPort()
          Gets the current port.
 String getPrincipal()
          Gets the current principal.
 String getProviderUrl()
          Convenience method get url up to hostport.
 String getScheme()
          Gets the current scheme.
 String getScope()
          Gets search scope.
 String getSecret()
          Gets the current secret.
 boolean isDefaultPort()
          Based on scheme returns true if the current port is the default port.
 void setAttributes(String attributes)
          Sets attributes portion of this url.
 void setDn(String dn)
          Sets the dn.
 void setExtensions(String extensions)
          Sets the extensions.
 void setFilter(String filter)
          Sets the search filter.
 void setHost(String host)
          Sets the host.
 void setPort(int port)
          Sets the port.
 void setPrincipal(String principal)
          Sets the current principal.
 void setScheme(String scheme)
          Sets the current scheme.
 void setScope(String scope)
          Sets search scope.
 void setSecret(String secret)
          Sets the current secret (password for principal).
 String toDisplayString()
          Turns Url into a displayable string (without principal and secret).
 String toString()
          Turns this Url into a string.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

scheme

private String scheme

principal

private String principal

secret

private String secret

attributes

private String attributes

host

private String host

port

private int port

scope

private String scope

filter

private String filter

extensions

private String extensions

dn

private String dn

schemes

private String[] schemes

defaultPorts

private int[] defaultPorts
Constructor Detail

Url

public Url()
Creates an empty url.


Url

public Url(String url)
Creates a new url from a string url. For example "ldap://cn=Manager:admin@localhost/o=PTC"

Parameters:
url - The url to initialize from.
Method Detail

toString

public String toString()
Turns this Url into a string.

Returns:
The complete string representation.

toDisplayString

public String toDisplayString()
Turns Url into a displayable string (without principal and secret).

Returns:
The string representation minus credentials.

clone

public Object clone()
Makes a copy of this Url.

Returns:
A new instance of Url that is a copy of this one.

setScheme

public void setScheme(String scheme)
Sets the current scheme. For example; 'http' | 'ldap' (for now should only use 'ldap')

Parameters:
scheme - The new scheme

getScheme

public String getScheme()
Gets the current scheme.

Returns:
The current scheme.

setPrincipal

public void setPrincipal(String principal)
Sets the current principal.

Parameters:
principal - The dn of the new principal.
See Also:
setSecret(String)

getPrincipal

public String getPrincipal()
Gets the current principal.

Returns:
The current principal or null if none.

setSecret

public void setSecret(String secret)
Sets the current secret (password for principal).

Parameters:
secret - The new password.
See Also:
setPrincipal(String)

getSecret

public String getSecret()
Gets the current secret.

Returns:
The current secret or null if none.

setAttributes

public void setAttributes(String attributes)
Sets attributes portion of this url.

Parameters:
attributes - The new attribute list (comma delimited list).

getAttributes

public String getAttributes()
Gets the current attributes portion of this url.

Returns:
The current attribute list.

setHost

public void setHost(String host)
Sets the host.

Parameters:
host - The new host.
See Also:
setPort(int)

getHost

public String getHost()
Gets the host.

Returns:
The host.

setPort

public void setPort(int port)
Sets the port. Value must be in range 0-65535 inclusive.

Parameters:
port - The new port.
See Also:
setHost(String)

getPort

public int getPort()
Gets the current port.

Returns:
The current port.

setScope

public void setScope(String scope)
Sets search scope. Value must be one of 'base','one','sub', or null.

Parameters:
scope - The new search scope.
See Also:
setAttributes(String), setFilter(String)

getScope

public String getScope()
Gets search scope.

Returns:
Ghe current search scope or null if none.

setFilter

public void setFilter(String filter)
Sets the search filter. For example '(objectClass=*)'

Parameters:
filter - The new search filter.
See Also:
setScope(String), setAttributes(String)

getFilter

public String getFilter()
Gets the search filter.

Returns:
The current filter or null if none.

setExtensions

public void setExtensions(String extensions)
Sets the extensions.

Parameters:
extensions - The new extensions.

getExtensions

public String getExtensions()
Gets the extensions.

Returns:
The current extensions or null if none.

setDn

public void setDn(String dn)
Sets the dn. For example "ou=Application Services,l=Arden Hills,o=PTC"

Parameters:
dn - The new dn.

getDn

public String getDn()
Gets the dn.

Returns:
The current dn or null if none.

isDefaultPort

public boolean isDefaultPort()
Based on scheme returns true if the current port is the default port. For example http == 80, ldap == 389, etc.

Returns:
True if the current port is the default for the current scheme.

getProviderUrl

public String getProviderUrl()
Convenience method get url up to hostport. Without principal and secret, for example "ldap://localhost/"

Returns:
The provider url minus credentials.

decodeUrl

public static String decodeUrl(String encoded)
Decodes a URL-encoded string.

Parameters:
encoded - URL-encoded string
Returns:
The decoded result