Package net.shibboleth.idp.cas.service

# Class DefaultServiceComparator

java.lang.Object
net.shibboleth.idp.cas.service.DefaultServiceComparator

All Implemented Interfaces:
  `Comparator<String>`

public class DefaultServiceComparator extends Object implements Comparator<String>
Default comparator implementation for comparing CAS service URLs. URL comparison is case-insensitive by default and supports ignoring predefined URL path parameters. The common session marker ;jessionid=value is ignored by default.

A future version MAY change the default to case-sensitive.

## Field Summary

Fields
Modifier and Type
Field
Description
`private boolean`
`caseSensitive`
Whether the check should be case-sensitive.
`private final Pattern[]`
`ignoredPatterns`
Ignored patterns in path part of URL.
`private final org.slf4j.Logger`
`log`
Class logger.

## Constructor Summary

Constructors
Constructor
Description
`DefaultServiceComparator()`
Creates a new instance that ignores ;jsessionid=value.
`DefaultServiceComparator(String... parameterNames)`
Creates a new instance that ignores the given path parameter names (and any associated values).

## Method Summary

Modifier and Type
Method
Description
`int`
`compare(String a, String b)`
`void`
`setCaseSensitive(boolean flag)`
Sets whether the eventual comparison is case-sensitive.
`private String`
`stripPathParameters(String uriString)`
Strips any of the named path parameters (and any associated values) from the given URI.

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

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

### Methods inherited from interface java.util.Comparator

`equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### ignoredPatterns

@Nonnull private final Pattern[] ignoredPatterns
Ignored patterns in path part of URL.

### caseSensitive

private boolean caseSensitive
Whether the check should be case-sensitive.

## Constructor Details

### DefaultServiceComparator

public DefaultServiceComparator()
Creates a new instance that ignores ;jsessionid=value.

### DefaultServiceComparator

public DefaultServiceComparator(@Nonnull String... parameterNames)
Creates a new instance that ignores the given path parameter names (and any associated values).

Parameters:
  `parameterNames` - List of path parameter names to ignore.

## Method Details

### setCaseSensitive

public void setCaseSensitive(boolean flag)
Sets whether the eventual comparison is case-sensitive.

Defaults to false.

Parameters:
  `flag` -

### compare

public int compare(String a, String b)

Specified by:
  `compare` in interface `Comparator<String>`

### stripPathParameters

private String stripPathParameters(@Nonnull String uriString)
Strips any of the named path parameters (and any associated values) from the given URI.

Parameters:
  `uriString` - String form of URI from which to strip named path parameters.
Returns:
  URI with named path parameters and any associated values removed.