Package net.shibboleth.shared.net

# Class SimpleURLCanonicalizer

java.lang.Object
net.shibboleth.shared.net.SimpleURLCanonicalizer

public final class SimpleURLCanonicalizer extends Object
This class performs simple canonicalization of a URL as follows:

- The scheme is lower-cased.
- The hostname is lower-cased
- The port is removed if it is the default port registered for the scheme

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final Map<String,Integer>`
`SCHEME_PORT_MAP`
The scheme-to-port mapping data.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`SimpleURLCanonicalizer()`
Constructor to prevent instantiation.

## Method Summary

Modifier and Type
Method
Description
`static String`
`canonicalize(String url)`
Canonicalize the supplied URL.
`private static void`
`canonicalize(URLBuilder url)`
Canonicalize the supplied URLBuilder data.
`static void`
`deregisterSchemePortMapping(String scheme)`
Deregister a scheme-to-port mapping.
`static Integer`
`getRegisteredPort(String scheme)`
Obtain the default port registered for a scheme.
`static void`
`registerSchemePortMapping(String scheme, Integer port)`
Register a new scheme-to-port mapping.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### SCHEME_PORT_MAP

@Nonnull private static final Map<String,Integer> SCHEME_PORT_MAP
The scheme-to-port mapping data.

## Constructor Details

### SimpleURLCanonicalizer

private SimpleURLCanonicalizer()
Constructor to prevent instantiation.

## Method Details

### registerSchemePortMapping

public static void registerSchemePortMapping(@Nonnull @NotEmpty String scheme, @Nonnull Integer port)
Register a new scheme-to-port mapping.

Parameters:
  `scheme` - the scheme to register
  `port` - the default port for that scheme

### deregisterSchemePortMapping

public static void deregisterSchemePortMapping(@Nonnull String scheme)
Deregister a scheme-to-port mapping.

Parameters:
  `scheme` - the scheme to deregister

### getRegisteredPort

@Nullable public static Integer getRegisteredPort(@Nonnull @NotEmpty String scheme)
Obtain the default port registered for a scheme.

Parameters:
  `scheme` - the scheme to look up
Returns:
  the default port registered for the scheme, or null if none registered

### canonicalize

@Nonnull @NotEmpty public static String canonicalize(@Nonnull @NotEmpty String url) throws MalformedURLException
Canonicalize the supplied URL.

Parameters:
  `url` - the URL to canonicalize
Returns:
  the canonicalized URL
Throws:
  `MalformedURLException` - if the URL is not a valid URL

### canonicalize

private static void canonicalize(@Nonnull URLBuilder url)
Canonicalize the supplied URLBuilder data.

Parameters:
  `url` - the URLBuilder to canonicalize