add springboot autocfg support
This commit is contained in:
parent
387e7249e0
commit
ca5e5f1f06
114
README.md
114
README.md
|
|
@ -62,7 +62,7 @@ files in the modules (`cas-client-integration-jboss` and `cas-client-support-dis
|
|||
</dependency>
|
||||
```
|
||||
|
||||
- Atlassian integration is provided by this dependency:
|
||||
- Atlassian integration (Deprecated) is provided by this dependency:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
|
|
@ -122,6 +122,16 @@ files in the modules (`cas-client-integration-jboss` and `cas-client-support-dis
|
|||
</dependency>
|
||||
```
|
||||
|
||||
- Spring Boot AutoConfiguration is provided by this dependency:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-support-springboot</artifactId>
|
||||
<version>${java.cas.client.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
<a name="configuration"></a>
|
||||
## Configuration
|
||||
|
||||
|
|
@ -749,6 +759,106 @@ You have been logged out of [APPLICATION NAME GOES HERE].
|
|||
To log out of all applications, click here. (provide link to CAS server's logout)
|
||||
```
|
||||
|
||||
<a name="springboot-autoconfiguration"></a>
|
||||
## Spring Boot AutoConfiguration
|
||||
|
||||
### Usage
|
||||
|
||||
* Define a dependency:
|
||||
|
||||
> Maven:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-support-springboot</artifactId>
|
||||
<version>${java.cas.client.version}</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
> Gradle:
|
||||
|
||||
```groovy
|
||||
dependencies {
|
||||
...
|
||||
compile 'org.jasig.cas.client:cas-client-support-springboot:${java.cas.client.version}'
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
* Add the following required properties in Spring Boot's `application.properties` or `application.yml`:
|
||||
|
||||
```properties
|
||||
cas.server-url-prefix=https://cashost.com/cas
|
||||
cas.server-login-url=https://cashost.com/cas/login
|
||||
cas.client-host-url=https://casclient.com
|
||||
```
|
||||
|
||||
* Annotate Spring Boot application (or any @Configuration class) with `@EnableCasClient` annotation
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@Controller
|
||||
@EnableCasClient
|
||||
public class MyApplication { .. }
|
||||
```
|
||||
|
||||
> For CAS3 protocol (authentication and validation filters) - which is default if nothing is specified
|
||||
|
||||
```properties
|
||||
cas.validation-type=CAS3
|
||||
```
|
||||
|
||||
> For CAS2 protocol (authentication and validation filters)
|
||||
|
||||
```properties
|
||||
cas.validation-type=CAS
|
||||
```
|
||||
|
||||
> For SAML protocol (authentication and validation filters)
|
||||
|
||||
```properties
|
||||
cas.validation-type=SAML
|
||||
```
|
||||
|
||||
### Available optional properties
|
||||
|
||||
* `cas.authentication-url-patterns`
|
||||
* `cas.validation-url-patterns`
|
||||
* `cas.request-wrapper-url-patterns`
|
||||
* `cas.assertion-thread-local-url-patterns`
|
||||
* `cas.gateway`
|
||||
* `cas.use-session`
|
||||
* `cas.redirect-after-validation`
|
||||
* `cas.allowed-proxy-chains`
|
||||
* `cas.proxy-callback-url`
|
||||
* `cas.proxy-receptor-url`
|
||||
* `cas.accept-any-proxy`
|
||||
* `server.context-parameters.renew`
|
||||
|
||||
### Advanced configuration
|
||||
|
||||
This module does not expose ALL the CAS client configuration options via standard Spring property sources, but only most commonly used ones.
|
||||
If there is a need however, to set any number of not exposed, 'exotic' properties, you can implement the `CasClientConfigurer`
|
||||
class in your `@EnableCasClient` annotated class and override appropriate configuration method(s) for CAS client filter(s) in question.
|
||||
For example:
|
||||
|
||||
```java
|
||||
@SpringBootApplication
|
||||
@EnableCasClient
|
||||
class CasProtectedApplication implements CasClientConfigurer {
|
||||
@Override
|
||||
void configureValidationFilter(FilterRegistrationBean validationFilter) {
|
||||
validationFilter.getInitParameters().put("millisBetweenCleanUps", "120000");
|
||||
}
|
||||
@Override
|
||||
void configureAuthenticationFilter(FilterRegistrationBean authenticationFilter) {
|
||||
authenticationFilter.getInitParameters().put("artifactParameterName", "casTicket");
|
||||
authenticationFilter.getInitParameters().put("serviceParameterName", "targetService");
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
<a name="jaas"></a>
|
||||
## JAAS
|
||||
The client supports the Java Authentication and Authorization Service (JAAS) framework, which provides authn facilities to CAS-enabled JEE applications.
|
||||
|
|
@ -870,7 +980,7 @@ If you have any trouble, you can enable the log of cas in `jboss-logging.xml` by
|
|||
<logger category="org.jasig">
|
||||
<level name="DEBUG" />
|
||||
</logger>
|
||||
```
|
||||
```
|
||||
|
||||
<a name="tomcat-678-integration"></a>
|
||||
## Tomcat 6/7/8 Integration
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class AttributePrincipalImpl extends SimplePrincipal implements Attribute
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getProxyTicketFor(String service) {
|
||||
public String getProxyTicketFor(final String service) {
|
||||
if (proxyGrantingTicket != null) {
|
||||
return this.proxyRetriever.getProxyTicketIdFor(this.proxyGrantingTicket, service);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class AuthenticationFilter extends AbstractCasFilter {
|
|||
if (!isIgnoreInitConfiguration()) {
|
||||
super.initInternal(filterConfig);
|
||||
|
||||
String loginUrl = getString(ConfigurationKeys.CAS_SERVER_LOGIN_URL);
|
||||
final String loginUrl = getString(ConfigurationKeys.CAS_SERVER_LOGIN_URL);
|
||||
if (loginUrl != null) {
|
||||
setCasServerLoginUrl(loginUrl);
|
||||
} else {
|
||||
|
|
@ -154,7 +154,7 @@ public class AuthenticationFilter extends AbstractCasFilter {
|
|||
public void init() {
|
||||
super.init();
|
||||
|
||||
String message = String.format(
|
||||
final String message = String.format(
|
||||
"one of %s and %s must not be null.",
|
||||
ConfigurationKeys.CAS_SERVER_LOGIN_URL.getName(),
|
||||
ConfigurationKeys.CAS_SERVER_URL_PREFIX.getName());
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public final class LegacyConfigurationStrategyImpl extends BaseConfigurationStra
|
|||
private final JndiConfigurationStrategyImpl jndiConfigurationStrategy = new JndiConfigurationStrategyImpl();
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig, Class<? extends Filter> filterClazz) {
|
||||
public void init(final FilterConfig filterConfig, final Class<? extends Filter> filterClazz) {
|
||||
this.webXmlConfigurationStrategy.init(filterConfig, filterClazz);
|
||||
this.jndiConfigurationStrategy.init(filterConfig, filterClazz);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,11 +30,11 @@ import javax.servlet.FilterConfig;
|
|||
public class SystemPropertiesConfigurationStrategyImpl extends BaseConfigurationStrategy {
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig, Class<? extends Filter> filterClazz) {
|
||||
public void init(final FilterConfig filterConfig, final Class<? extends Filter> filterClazz) {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String get(ConfigurationKey configurationKey) {
|
||||
protected String get(final ConfigurationKey configurationKey) {
|
||||
return System.getProperty(configurationKey.getName());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public final class TicketCredential implements Principal {
|
|||
return this.ticket;
|
||||
}
|
||||
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ public final class HashMapBackedSessionMappingStorage implements SessionMappingS
|
|||
private final Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Override
|
||||
public synchronized void addSessionById(String mappingId, HttpSession session) {
|
||||
public synchronized void addSessionById(final String mappingId, final HttpSession session) {
|
||||
ID_TO_SESSION_KEY_MAPPING.put(session.getId(), mappingId);
|
||||
MANAGED_SESSIONS.put(mappingId, session);
|
||||
|
||||
|
|
@ -71,7 +71,7 @@ public final class HashMapBackedSessionMappingStorage implements SessionMappingS
|
|||
}
|
||||
|
||||
@Override
|
||||
public synchronized HttpSession removeSessionByMappingId(String mappingId) {
|
||||
public synchronized HttpSession removeSessionByMappingId(final String mappingId) {
|
||||
final HttpSession session = MANAGED_SESSIONS.get(mappingId);
|
||||
|
||||
if (session != null) {
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public final class SingleSignOutFilter extends AbstractConfigurationFilter {
|
|||
HANDLER.setRelayStateParameterName(name);
|
||||
}
|
||||
|
||||
public void setLogoutCallbackPath(String logoutCallbackPath) {
|
||||
public void setLogoutCallbackPath(final String logoutCallbackPath) {
|
||||
HANDLER.setLogoutCallbackPath(logoutCallbackPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -103,7 +103,7 @@ public final class SingleSignOutHandler {
|
|||
/**
|
||||
* @param logoutCallbackPath The logout callback path configured at the CAS server.
|
||||
*/
|
||||
public void setLogoutCallbackPath(String logoutCallbackPath) {
|
||||
public void setLogoutCallbackPath(final String logoutCallbackPath) {
|
||||
this.logoutCallbackPath = logoutCallbackPath;
|
||||
}
|
||||
|
||||
|
|
@ -169,11 +169,11 @@ public final class SingleSignOutHandler {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean pathEligibleForLogout(HttpServletRequest request) {
|
||||
private boolean pathEligibleForLogout(final HttpServletRequest request) {
|
||||
return logoutCallbackPath == null || logoutCallbackPath.equals(getPath(request));
|
||||
}
|
||||
|
||||
private String getPath(HttpServletRequest request) {
|
||||
private String getPath(final HttpServletRequest request) {
|
||||
return request.getServletPath() + CommonUtils.nullToEmpty(request.getPathInfo());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ public final class HttpsURLConnectionFactory implements HttpURLConnectionFactory
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ public abstract class AbstractConfigurationFilter implements Filter {
|
|||
private ConfigurationStrategy configurationStrategy;
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig) throws ServletException {
|
||||
public void init(final FilterConfig filterConfig) throws ServletException {
|
||||
final String configurationStrategyName = filterConfig.getServletContext().getInitParameter(CONFIGURATION_STRATEGY_KEY);
|
||||
this.configurationStrategy = ReflectUtils.newInstance(ConfigurationStrategyName.resolveToConfigurationStrategy(configurationStrategyName));
|
||||
this.configurationStrategy.init(filterConfig, getClass());
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ public final class CommonUtils {
|
|||
|
||||
final URIBuilder builder;
|
||||
if (!serverName.startsWith("https://") && !serverName.startsWith("http://")) {
|
||||
String scheme = request.isSecure() ? "https://" : "http://";
|
||||
final String scheme = request.isSecure() ? "https://" : "http://";
|
||||
builder = new URIBuilder(scheme + serverName, encode);
|
||||
} else {
|
||||
builder = new URIBuilder(serverName, encode);
|
||||
|
|
@ -328,13 +328,13 @@ public final class CommonUtils {
|
|||
final List<String> serviceParameterNames = Arrays.asList(serviceParameterName.split(","));
|
||||
if (!serviceParameterNames.isEmpty() && !originalRequestUrl.getQueryParams().isEmpty()) {
|
||||
for (final URIBuilder.BasicNameValuePair pair : originalRequestUrl.getQueryParams()) {
|
||||
String name = pair.getName();
|
||||
final String name = pair.getName();
|
||||
if (!name.equals(artifactParameterName) && !serviceParameterNames.contains(name)) {
|
||||
if (name.contains("&") || name.contains("=") ){
|
||||
URIBuilder encodedParamBuilder = new URIBuilder();
|
||||
final URIBuilder encodedParamBuilder = new URIBuilder();
|
||||
encodedParamBuilder.setParameters(name);
|
||||
for (final URIBuilder.BasicNameValuePair pair2 :encodedParamBuilder.getQueryParams()){
|
||||
String name2 = pair2.getName();
|
||||
final String name2 = pair2.getName();
|
||||
if (!name2.equals(artifactParameterName) && !serviceParameterNames.contains(name2)) {
|
||||
builder.addParameter(name2, pair2.getValue());
|
||||
}
|
||||
|
|
@ -708,7 +708,7 @@ public final class CommonUtils {
|
|||
* @param string a possibly <code>null</code> string
|
||||
* @return a non-<code>null</code> string
|
||||
*/
|
||||
public static String nullToEmpty(String string) {
|
||||
public static String nullToEmpty(final String string) {
|
||||
return string == null ? "" : string;
|
||||
}
|
||||
|
||||
|
|
@ -718,7 +718,7 @@ public final class CommonUtils {
|
|||
* @param uri a string that may or may not end with a slash
|
||||
* @return the same string, except with a slash suffix (if necessary).
|
||||
*/
|
||||
public static String addTrailingSlash(String uri) {
|
||||
public static String addTrailingSlash(final String uri) {
|
||||
return uri.endsWith("/") ? uri : uri + "/";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ public class PrivateKeyUtils {
|
|||
}
|
||||
|
||||
public static PrivateKey createKey(final String path, final String algorithm) {
|
||||
PrivateKey key = readPemPrivateKey(path);
|
||||
final PrivateKey key = readPemPrivateKey(path);
|
||||
if (key == null) {
|
||||
return readDERPrivateKey(path, algorithm);
|
||||
} else {
|
||||
|
|
@ -70,8 +70,8 @@ public class PrivateKeyUtils {
|
|||
FileInputStream fis = null;
|
||||
try {
|
||||
fis = new FileInputStream(file);
|
||||
long byteLength = file.length();
|
||||
byte[] bytes = new byte[(int) byteLength];
|
||||
final long byteLength = file.length();
|
||||
final byte[] bytes = new byte[(int) byteLength];
|
||||
fis.read(bytes, 0, (int) byteLength);
|
||||
final PKCS8EncodedKeySpec privSpec = new PKCS8EncodedKeySpec(bytes);
|
||||
final KeyFactory factory = KeyFactory.getInstance(algorithm);
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public final class ReflectUtils {
|
|||
do {
|
||||
try {
|
||||
field = clazz.getDeclaredField(fieldName);
|
||||
} catch (NoSuchFieldException e) {
|
||||
} catch (final NoSuchFieldException e) {
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
} while (field == null && clazz != null);
|
||||
|
|
@ -176,7 +176,7 @@ public final class ReflectUtils {
|
|||
field.setAccessible(true);
|
||||
}
|
||||
return field.get(target);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
throw new IllegalArgumentException("Error getting field " + fieldName, e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ public class ThreadLocalXPathExpression extends ThreadLocal<XPathExpression> imp
|
|||
final XPath xPath = XPathFactory.newInstance().newXPath();
|
||||
xPath.setNamespaceContext(context);
|
||||
return xPath.compile(expression);
|
||||
} catch (XPathExpressionException e) {
|
||||
} catch (final XPathExpressionException e) {
|
||||
throw new IllegalArgumentException("Invalid XPath expression");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ public final class URIBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public URIBuilder(final String string, boolean encode) {
|
||||
public URIBuilder(final String string, final boolean encode) {
|
||||
super();
|
||||
try {
|
||||
setEncode(encode);
|
||||
|
|
@ -252,7 +252,7 @@ public final class URIBuilder {
|
|||
return this.encode ? CommonUtils.urlEncode(fragment) : fragment;
|
||||
}
|
||||
|
||||
public URIBuilder setEncode(boolean encode) {
|
||||
public URIBuilder setEncode(final boolean encode) {
|
||||
this.encode = encode;
|
||||
return this;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ public final class XmlUtils {
|
|||
for (final Map.Entry<String, Boolean> entry : features.entrySet()) {
|
||||
try {
|
||||
factory.setFeature(entry.getKey(), entry.getValue());
|
||||
} catch (ParserConfigurationException e) {
|
||||
} catch (final ParserConfigurationException e) {
|
||||
LOGGER.warn("Failed setting XML feature {}: {}", entry.getKey(), e);
|
||||
}
|
||||
}
|
||||
|
|
@ -73,7 +73,7 @@ public final class XmlUtils {
|
|||
factory.setNamespaceAware(true);
|
||||
try {
|
||||
return factory.newDocumentBuilder().parse(new InputSource(new StringReader(xml)));
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException("XML parsing error: " + e);
|
||||
}
|
||||
}
|
||||
|
|
@ -136,7 +136,7 @@ public final class XmlUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
public void characters(final char[] ch, final int start, final int length) throws SAXException {
|
||||
if (this.foundElement) {
|
||||
this.buffer.append(ch, start, length);
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ public final class XmlUtils {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void characters(char[] ch, int start, int length) throws SAXException {
|
||||
public void characters(final char[] ch, final int start, final int length) throws SAXException {
|
||||
if (this.foundElement) {
|
||||
builder.append(ch, start, length);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public abstract class AbstractUrlBasedTicketValidator implements TicketValidator
|
|||
buffer.append(this.casServerUrlPrefix);
|
||||
buffer.append(suffix);
|
||||
|
||||
for (Map.Entry<String, String> entry : urlParameters.entrySet()) {
|
||||
for (final Map.Entry<String, String> entry : urlParameters.entrySet()) {
|
||||
final String key = entry.getKey();
|
||||
final String value = entry.getValue();
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class Cas30ServiceTicketValidator extends Cas20ServiceTicketValidator {
|
|||
* @return - Map of attributes
|
||||
*/
|
||||
@Override
|
||||
protected Map<String, Object> extractCustomAttributes(String xml) {
|
||||
protected Map<String, Object> extractCustomAttributes(final String xml) {
|
||||
final Document document = XmlUtils.newDocument(xml);
|
||||
|
||||
// Check if attributes are inlined. If not return default super method results
|
||||
|
|
|
|||
|
|
@ -48,23 +48,23 @@ public final class PublicTestHttpServer extends Thread {
|
|||
|
||||
private static final Map<Integer, PublicTestHttpServer> serverMap = new HashMap<Integer, PublicTestHttpServer>();
|
||||
|
||||
private PublicTestHttpServer(String data, String encoding, String MIMEType, int port)
|
||||
private PublicTestHttpServer(final String data, final String encoding, final String MIMEType, final int port)
|
||||
throws UnsupportedEncodingException {
|
||||
this(data.getBytes(encoding), encoding, MIMEType, port);
|
||||
}
|
||||
|
||||
private PublicTestHttpServer(byte[] data, String encoding, String MIMEType, int port)
|
||||
private PublicTestHttpServer(final byte[] data, final String encoding, final String MIMEType, final int port)
|
||||
throws UnsupportedEncodingException {
|
||||
this.content = data;
|
||||
this.port = port;
|
||||
this.encoding = encoding;
|
||||
String header = "HTTP/1.0 200 OK\r\n" + "Server: OneFile 1.0\r\n" + "Content-type: " + MIMEType + "\r\n\r\n";
|
||||
final String header = "HTTP/1.0 200 OK\r\n" + "Server: OneFile 1.0\r\n" + "Content-type: " + MIMEType + "\r\n\r\n";
|
||||
this.header = header.getBytes("ASCII");
|
||||
}
|
||||
|
||||
public static synchronized PublicTestHttpServer instance(final int port) {
|
||||
if (serverMap.containsKey(port)) {
|
||||
PublicTestHttpServer server = serverMap.get(port);
|
||||
final PublicTestHttpServer server = serverMap.get(port);
|
||||
server.waitUntilReady();
|
||||
return server;
|
||||
}
|
||||
|
|
@ -75,7 +75,7 @@ public final class PublicTestHttpServer extends Thread {
|
|||
serverMap.put(port, server);
|
||||
server.waitUntilReady();
|
||||
return server;
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
|
@ -83,7 +83,7 @@ public final class PublicTestHttpServer extends Thread {
|
|||
private void waitUntilReady() {
|
||||
try {
|
||||
ready.await(10, TimeUnit.SECONDS);
|
||||
} catch (InterruptedException e) {
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new RuntimeException("interrupted", e);
|
||||
}
|
||||
|
|
@ -117,7 +117,7 @@ public final class PublicTestHttpServer extends Thread {
|
|||
// read the first line only; that's all we need
|
||||
final StringBuffer request = new StringBuffer(80);
|
||||
while (true) {
|
||||
int c = in.read();
|
||||
final int c = in.read();
|
||||
if (c == '\r' || c == '\n' || c == -1)
|
||||
break;
|
||||
request.append((char) c);
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class SerializationTests extends TestCase {
|
|||
final ObjectOutputStream out = new ObjectOutputStream(byteOut);
|
||||
try {
|
||||
out.writeObject(subjects[i]);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
Assert.fail("Serialization failed for " + subjects[i]);
|
||||
} finally {
|
||||
out.close();
|
||||
|
|
@ -59,7 +59,7 @@ public class SerializationTests extends TestCase {
|
|||
final ObjectInputStream in = new ObjectInputStream(byteIn);
|
||||
try {
|
||||
Assert.assertEquals(subjects[i], in.readObject());
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
Assert.fail("Deserialization failed for " + subjects[i]);
|
||||
} finally {
|
||||
in.close();
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public final class AuthenticationFilterTests {
|
|||
final FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
|
|
@ -118,7 +118,7 @@ public final class AuthenticationFilterTests {
|
|||
final FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
|
|
@ -149,7 +149,7 @@ public final class AuthenticationFilterTests {
|
|||
final FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
|
|
@ -169,7 +169,7 @@ public final class AuthenticationFilterTests {
|
|||
final FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
|
|
@ -190,7 +190,7 @@ public final class AuthenticationFilterTests {
|
|||
final FilterChain filterChain = new FilterChain() {
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
// nothing to do
|
||||
}
|
||||
};
|
||||
|
|
@ -273,7 +273,7 @@ public final class AuthenticationFilterTests {
|
|||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -303,7 +303,7 @@ public final class AuthenticationFilterTests {
|
|||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -338,7 +338,7 @@ public final class AuthenticationFilterTests {
|
|||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -368,7 +368,7 @@ public final class AuthenticationFilterTests {
|
|||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ public final class AuthenticationFilterTests {
|
|||
|
||||
final FilterChain filterChain = new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -46,12 +46,12 @@ public final class ConfigurationStrategyNameTests {
|
|||
private class TestClass extends BaseConfigurationStrategy {
|
||||
|
||||
@Override
|
||||
protected String get(ConfigurationKey configurationKey) {
|
||||
protected String get(final ConfigurationKey configurationKey) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(FilterConfig filterConfig, Class<? extends Filter> filterClazz) {
|
||||
public void init(final FilterConfig filterConfig, final Class<? extends Filter> filterClazz) {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class CasLoginModuleTests {
|
|||
try {
|
||||
module.login();
|
||||
fail("Login did not throw FailedLoginException as expected.");
|
||||
} catch (LoginException e) {
|
||||
} catch (final LoginException e) {
|
||||
assertEquals(TicketValidationException.class, e.getCause().getClass());
|
||||
}
|
||||
module.commit();
|
||||
|
|
@ -181,7 +181,7 @@ public class CasLoginModuleTests {
|
|||
module.login();
|
||||
module.commit();
|
||||
Assert.fail("Login should have failed.");
|
||||
} catch (LoginException e) {
|
||||
} catch (final LoginException e) {
|
||||
assertEquals(TicketValidationException.class, e.getCause().getClass());
|
||||
}
|
||||
assertEquals(0, this.subject.getPrincipals().size());
|
||||
|
|
@ -229,7 +229,7 @@ public class CasLoginModuleTests {
|
|||
try {
|
||||
module.login();
|
||||
fail("Should have thrown FailedLoginException.");
|
||||
} catch (LoginException e) {
|
||||
} catch (final LoginException e) {
|
||||
assertEquals(TicketValidationException.class, e.getCause().getClass());
|
||||
}
|
||||
}
|
||||
|
|
@ -237,7 +237,7 @@ public class CasLoginModuleTests {
|
|||
private boolean hasPrincipalName(final Subject subject, final Class<? extends Principal> principalClass,
|
||||
final String name) {
|
||||
final Set<? extends Principal> principals = subject.getPrincipals(principalClass);
|
||||
for (Principal p : principals) {
|
||||
for (final Principal p : principals) {
|
||||
if (p.getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,12 @@ public class CleanUpTimerTaskTest extends TestCase {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String retrieve(String proxyGrantingTicketIou) {
|
||||
public String retrieve(final String proxyGrantingTicketIou) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void save(String proxyGrantingTicketIou, String proxyGrantingTicket) {
|
||||
public void save(final String proxyGrantingTicketIou, final String proxyGrantingTicket) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,9 @@ public class ProxyGrantingTicketStorageImplTest {
|
|||
|
||||
@Test
|
||||
public void cleanUp() throws Exception {
|
||||
String proxyGrantingTicketIou = "proxyGrantingTicketIou";
|
||||
final String proxyGrantingTicketIou = "proxyGrantingTicketIou";
|
||||
|
||||
int timeout = 250;
|
||||
final int timeout = 250;
|
||||
this.storage.save(proxyGrantingTicketIou, "proxyGrantingTicket");
|
||||
|
||||
// sleep long enough for the ticket to timeout
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public final class CasFilterTests {
|
|||
super(Protocol.CAS2);
|
||||
}
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException,
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException,
|
||||
ServletException {
|
||||
// nothing to do
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public final class CommonUtilsTests extends TestCase {
|
|||
CommonUtils.assertNotNull(new Object(), CONST_MESSAGE);
|
||||
try {
|
||||
CommonUtils.assertNotNull(null, CONST_MESSAGE);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (final IllegalArgumentException e) {
|
||||
assertEquals(CONST_MESSAGE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -81,13 +81,13 @@ public final class CommonUtilsTests extends TestCase {
|
|||
CommonUtils.assertNotEmpty(c, CONST_MESSAGE);
|
||||
try {
|
||||
CommonUtils.assertNotEmpty(new ArrayList<Object>(), CONST_MESSAGE);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (final IllegalArgumentException e) {
|
||||
assertEquals(CONST_MESSAGE, e.getMessage());
|
||||
}
|
||||
|
||||
try {
|
||||
CommonUtils.assertNotEmpty(null, CONST_MESSAGE);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (final IllegalArgumentException e) {
|
||||
assertEquals(CONST_MESSAGE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
@ -97,7 +97,7 @@ public final class CommonUtilsTests extends TestCase {
|
|||
CommonUtils.assertTrue(true, CONST_MESSAGE);
|
||||
try {
|
||||
CommonUtils.assertTrue(false, CONST_MESSAGE);
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (final IllegalArgumentException e) {
|
||||
assertEquals(CONST_MESSAGE, e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -120,7 +120,7 @@ public final class HttpServletRequestWrapperFilterTests extends TestCase {
|
|||
private FilterChain createFilterChain() {
|
||||
return new FilterChain() {
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response) throws IOException, ServletException {
|
||||
public void doFilter(final ServletRequest request, final ServletResponse response) throws IOException, ServletException {
|
||||
HttpServletRequestWrapperFilterTests.this.mockRequest = (HttpServletRequest) request;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class ReflectUtilsTests extends TestCase {
|
|||
/**
|
||||
* @param count the count to set
|
||||
*/
|
||||
public void setCount(int count) {
|
||||
public void setCount(final int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
|
|
@ -95,7 +95,7 @@ public class ReflectUtilsTests extends TestCase {
|
|||
/**
|
||||
* @param name the name to set
|
||||
*/
|
||||
public void setName(String name) {
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
|
@ -109,7 +109,7 @@ public class ReflectUtilsTests extends TestCase {
|
|||
/**
|
||||
* @param flag the flag to set
|
||||
*/
|
||||
public void setFlag(boolean flag) {
|
||||
public void setFlag(final boolean flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ public class ReflectUtilsTests extends TestCase {
|
|||
return state;
|
||||
}
|
||||
|
||||
public void setState(String state) {
|
||||
public void setState(final String state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void allPartsUsed() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -65,7 +65,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void noSchemeUsed() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
.setCustomQuery("hello=world")
|
||||
|
|
@ -75,7 +75,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void noAuthorityUsed() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setPath("/shindig")
|
||||
.setCustomQuery("hello=world")
|
||||
|
|
@ -85,7 +85,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void noPathUsed() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setCustomQuery("hello=world")
|
||||
|
|
@ -95,7 +95,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void noQueryUsed() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -105,7 +105,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void noFragmentUsed() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -115,7 +115,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void hostRelativePaths() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setPath("/shindig")
|
||||
.setCustomQuery("hello=world")
|
||||
.setFragment("foo");
|
||||
|
|
@ -124,7 +124,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void relativePaths() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setPath("foo")
|
||||
.setCustomQuery("hello=world")
|
||||
.setFragment("foo");
|
||||
|
|
@ -133,7 +133,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void noPathNoHostNoAuthority() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setCustomQuery("hello=world")
|
||||
.setFragment("foo");
|
||||
assertEquals("?hello=world#foo", builder.toString());
|
||||
|
|
@ -141,7 +141,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void justSchemeAndAuthority() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org");
|
||||
assertEquals("http://apache.org", builder.toString());
|
||||
|
|
@ -149,14 +149,14 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void justPath() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setPath("/shindig");
|
||||
assertEquals("/shindig", builder.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void justAuthorityAndPath() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig");
|
||||
assertEquals("//apache.org/shindig", builder.toString());
|
||||
|
|
@ -164,21 +164,21 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void justQuery() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setCustomQuery("hello=world");
|
||||
assertEquals("?hello=world", builder.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void justFragment() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setFragment("foo");
|
||||
assertEquals("#foo", builder.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addSingleQueryParameter() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -189,7 +189,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void addTwoQueryParameters() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -201,10 +201,10 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void iterableQueryParameters() {
|
||||
List<URIBuilder.BasicNameValuePair> list = new ArrayList<URIBuilder.BasicNameValuePair>();
|
||||
final List<URIBuilder.BasicNameValuePair> list = new ArrayList<URIBuilder.BasicNameValuePair>();
|
||||
list.add(new URIBuilder.BasicNameValuePair("hello", "world"));
|
||||
list.add(new URIBuilder.BasicNameValuePair("hello", "monde"));
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -215,14 +215,14 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void removeQueryParameter() {
|
||||
URIBuilder uri = new URIBuilder("http://www.example.com/foo?bar=baz&quux=baz");
|
||||
final URIBuilder uri = new URIBuilder("http://www.example.com/foo?bar=baz&quux=baz");
|
||||
uri.removeQuery();
|
||||
assertEquals("http://www.example.com/foo", uri.toString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void addIdenticalParameters() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -234,7 +234,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void queryStringIsUnescaped() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -244,7 +244,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void queryParamsAreEscaped() {
|
||||
URIBuilder builder = new URIBuilder(true)
|
||||
final URIBuilder builder = new URIBuilder(true)
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setEncodedPath("/shindig")
|
||||
|
|
@ -256,7 +256,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void addSingleFragmentParameter() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -267,7 +267,7 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void fragmentStringIsUnescaped() {
|
||||
URIBuilder builder = new URIBuilder(true)
|
||||
final URIBuilder builder = new URIBuilder(true)
|
||||
.setScheme("http")
|
||||
.setHost("apache.org")
|
||||
.setPath("/shindig")
|
||||
|
|
@ -278,15 +278,15 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void parse() {
|
||||
URIBuilder builder = new URIBuilder()
|
||||
final URIBuilder builder = new URIBuilder()
|
||||
.digestURI(URI.create("http://apache.org/shindig?foo=bar%26baz&foo=three%3Dbaz#blah"));
|
||||
|
||||
assertEquals("http", builder.getScheme());
|
||||
assertEquals("apache.org", builder.getHost());
|
||||
assertEquals("/shindig", builder.getPath());
|
||||
|
||||
List<URIBuilder.BasicNameValuePair> list = builder.getQueryParams();
|
||||
for (URIBuilder.BasicNameValuePair pair : list) {
|
||||
final List<URIBuilder.BasicNameValuePair> list = builder.getQueryParams();
|
||||
for (final URIBuilder.BasicNameValuePair pair : list) {
|
||||
assertEquals("foo", pair.getName());
|
||||
assertTrue(pair.getValue().equals("three=baz") || pair.getValue().equals("bar&baz"));
|
||||
}
|
||||
|
|
@ -296,16 +296,16 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void constructFromUriAndBack() {
|
||||
URI uri = URI.create("http://apache.org/foo/bar?foo=bar&a=b&c=d&y=z&foo=zoo#foo");
|
||||
URIBuilder builder = new URIBuilder(uri);
|
||||
final URI uri = URI.create("http://apache.org/foo/bar?foo=bar&a=b&c=d&y=z&foo=zoo#foo");
|
||||
final URIBuilder builder = new URIBuilder(uri);
|
||||
|
||||
assertEquals(uri, builder.build());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void constructFromUriAndModify() {
|
||||
URI uri = URI.create("http://apache.org/foo/bar?foo=bar#foo");
|
||||
URIBuilder builder = new URIBuilder(uri);
|
||||
final URI uri = URI.create("http://apache.org/foo/bar?foo=bar#foo");
|
||||
final URIBuilder builder = new URIBuilder(uri);
|
||||
|
||||
builder.setHost("example.org");
|
||||
builder.addParameter("bar", "foo");
|
||||
|
|
@ -315,8 +315,8 @@ public class URIBuilderTests {
|
|||
|
||||
@Test
|
||||
public void equalsAndHashCodeOk() {
|
||||
URIBuilder uri = new URIBuilder().digestURI(URI.create("http://example.org/foo/bar/baz?blah=blah#boo"));
|
||||
URIBuilder uri2 = new URIBuilder(URI.create("http://example.org/foo/bar/baz?blah=blah#boo"));
|
||||
final URIBuilder uri = new URIBuilder().digestURI(URI.create("http://example.org/foo/bar/baz?blah=blah#boo"));
|
||||
final URIBuilder uri2 = new URIBuilder(URI.create("http://example.org/foo/bar/baz?blah=blah#boo"));
|
||||
|
||||
assertEquals(uri, uri2);
|
||||
assertEquals(uri2, uri);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class Cas20ProxyReceivingTicketValidationFilterTests extends TestCase {
|
|||
|
||||
final Timer timer = new Timer(true) {
|
||||
@Override
|
||||
public void schedule(TimerTask task, long delay, long period) {
|
||||
public void schedule(final TimerTask task, final long delay, final long period) {
|
||||
scheduleMethodFlag.setCalled();
|
||||
}
|
||||
};
|
||||
|
|
@ -140,19 +140,19 @@ public class Cas20ProxyReceivingTicketValidationFilterTests extends TestCase {
|
|||
}
|
||||
|
||||
public void testThrowsForNullStorage() throws Exception {
|
||||
Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
filter.setProxyGrantingTicketStorage(null);
|
||||
|
||||
try {
|
||||
filter.init();
|
||||
fail("expected an exception due to null ProxyGrantingTicketStorage");
|
||||
} catch (IllegalArgumentException exception) {
|
||||
} catch (final IllegalArgumentException exception) {
|
||||
// test passes
|
||||
}
|
||||
}
|
||||
|
||||
public void testGetTicketValidator() throws Exception {
|
||||
Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
|
||||
// Test case #1
|
||||
final MockFilterConfig config1 = new MockFilterConfig();
|
||||
|
|
@ -165,7 +165,7 @@ public class Cas20ProxyReceivingTicketValidationFilterTests extends TestCase {
|
|||
|
||||
@Test
|
||||
public void getTicketValidatorWithProxyChains() throws Exception {
|
||||
Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
// Test case #2
|
||||
final MockFilterConfig config2 = new MockFilterConfig();
|
||||
config2.addInitParameter("allowedProxyChains", "https://a.example.com https://b.example.com");
|
||||
|
|
@ -178,7 +178,7 @@ public class Cas20ProxyReceivingTicketValidationFilterTests extends TestCase {
|
|||
|
||||
@Test
|
||||
public void getTIcketValidatorWithProxyChainsAndLineBreak() throws Exception {
|
||||
Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
final Cas20ProxyReceivingTicketValidationFilter filter = newCas20ProxyReceivingTicketValidationFilter();
|
||||
|
||||
// Test case #3
|
||||
final MockFilterConfig config3 = new MockFilterConfig();
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ public final class Cas20ProxyTicketValidatorTests extends AbstractTicketValidato
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String getProxyTicketIdFor(String proxyGrantingTicketId, String targetService) {
|
||||
public String getProxyTicketIdFor(final String proxyGrantingTicketId, final String targetService) {
|
||||
return "test";
|
||||
}
|
||||
};
|
||||
|
|
@ -100,7 +100,7 @@ public final class Cas20ProxyTicketValidatorTests extends AbstractTicketValidato
|
|||
try {
|
||||
this.ticketValidator.validate("test", "test");
|
||||
fail("Invalid proxy chain");
|
||||
} catch (InvalidProxyChainTicketValidationException e) {
|
||||
} catch (final InvalidProxyChainTicketValidationException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
|
@ -131,7 +131,7 @@ public final class Cas20ProxyTicketValidatorTests extends AbstractTicketValidato
|
|||
try {
|
||||
this.ticketValidator.validate("test", "test");
|
||||
fail("Invalid proxy chain");
|
||||
} catch (InvalidProxyChainTicketValidationException e) {
|
||||
} catch (final InvalidProxyChainTicketValidationException e) {
|
||||
// expected
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ public final class Cas20ServiceTicketValidatorTests extends AbstractTicketValida
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String getProxyTicketIdFor(String proxyGrantingTicketId, String targetService) {
|
||||
public String getProxyTicketIdFor(final String proxyGrantingTicketId, final String targetService) {
|
||||
return "test";
|
||||
}
|
||||
};
|
||||
|
|
@ -136,9 +136,9 @@ public final class Cas20ServiceTicketValidatorTests extends AbstractTicketValida
|
|||
assertEquals("id", principal.getAttributes().get("eduPersonId"));
|
||||
assertEquals("test1\n\ntest", principal.getAttributes().get("longAttribute"));
|
||||
try {
|
||||
List<?> multivalued = (List<?>) principal.getAttributes().get("multivaluedAttribute");
|
||||
final List<?> multivalued = (List<?>) principal.getAttributes().get("multivaluedAttribute");
|
||||
assertArrayEquals(new String[] { "value1", "value2" }, multivalued.toArray());
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
fail("'multivaluedAttribute' attribute expected as List<Object> object.");
|
||||
}
|
||||
assertEquals(PGT, proxyGrantingTicketField.get(principal));
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ public final class Cas30ServiceTicketValidatorTests extends AbstractTicketValida
|
|||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Override
|
||||
public String getProxyTicketIdFor(String proxyGrantingTicketId, String targetService) {
|
||||
public String getProxyTicketIdFor(final String proxyGrantingTicketId, final String targetService) {
|
||||
return "test";
|
||||
}
|
||||
};
|
||||
|
|
@ -135,9 +135,9 @@ public final class Cas30ServiceTicketValidatorTests extends AbstractTicketValida
|
|||
assertEquals("id", assertion.getPrincipal().getAttributes().get("eduPersonId"));
|
||||
assertEquals("test1\n\ntest", assertion.getPrincipal().getAttributes().get("longAttribute"));
|
||||
try {
|
||||
List<?> multivalued = (List<?>) assertion.getPrincipal().getAttributes().get("multivaluedAttribute");
|
||||
final List<?> multivalued = (List<?>) assertion.getPrincipal().getAttributes().get("multivaluedAttribute");
|
||||
assertArrayEquals(new String[] { "value1", "value2" }, multivalued.toArray());
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
fail("'multivaluedAttribute' attribute expected as List<Object> object.");
|
||||
}
|
||||
//assertEquals(PGT, assertion.getProxyGrantingTicketId());
|
||||
|
|
@ -160,9 +160,9 @@ public final class Cas30ServiceTicketValidatorTests extends AbstractTicketValida
|
|||
assertEquals("id", assertion.getPrincipal().getAttributes().get("eduPersonId"));
|
||||
assertEquals("test1\n\ntest", assertion.getPrincipal().getAttributes().get("longAttribute"));
|
||||
try {
|
||||
List<?> multivalued = (List<?>) assertion.getPrincipal().getAttributes().get("multivaluedAttribute");
|
||||
final List<?> multivalued = (List<?>) assertion.getPrincipal().getAttributes().get("multivaluedAttribute");
|
||||
assertArrayEquals(new String[] { "value1", "value2" }, multivalued.toArray());
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
fail("'multivaluedAttribute' attribute expected as List<Object> object.");
|
||||
}
|
||||
//assertEquals(PGT, assertion.getProxyGrantingTicketId());
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ public class CasAuthenticator extends AbstractLifeCycle implements Authenticator
|
|||
logger.info("Successfully authenticated {}", assertion.getPrincipal());
|
||||
authentication = new CasAuthentication(this, ticket, assertion);
|
||||
cacheAuthentication(request, authentication);
|
||||
} catch (Exception e) {
|
||||
} catch (final Exception e) {
|
||||
throw new ServerAuthException("CAS ticket validation failed", e);
|
||||
}
|
||||
}
|
||||
|
|
@ -240,7 +240,7 @@ public class CasAuthenticator extends AbstractLifeCycle implements Authenticator
|
|||
casServerLoginUrl, protocol.getServiceParameterName(), serviceUrl(request, response), renew, false, null);
|
||||
logger.debug("Redirecting to {}", redirectUrl);
|
||||
response.sendRedirect(redirectUrl);
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
logger.debug("Redirect to CAS failed with error", e);
|
||||
throw new ServerAuthException("Redirect to CAS failed", e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -200,11 +200,11 @@ public class CasAuthenticatorTest {
|
|||
final HttpURLConnection uc;
|
||||
try {
|
||||
uc = (HttpURLConnection) new URL(url).openConnection();
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new RuntimeException("Invalid URL: " + url, e);
|
||||
}
|
||||
uc.setInstanceFollowRedirects(false);
|
||||
uc.connect();
|
||||
return uc;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public final class AuthenticatorDelegate {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
Principal p = realm.authenticate(assertion.getPrincipal());
|
||||
final Principal p = realm.authenticate(assertion.getPrincipal());
|
||||
if (p == null) {
|
||||
logger.debug("{} failed to authenticate to {}", assertion.getPrincipal().getName(), realm);
|
||||
setUnauthorized(response, null);
|
||||
|
|
@ -192,7 +192,7 @@ public final class AuthenticatorDelegate {
|
|||
} else {
|
||||
response.sendError(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
}
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IllegalStateException("Error setting 403 status.", e);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class SingleSignOutValve extends AbstractLifecycleValve implements Sessio
|
|||
this.handler.setRelayStateParameterName(name);
|
||||
}
|
||||
|
||||
public void setLogoutCallbackPath(String logoutCallbackPath) {
|
||||
public void setLogoutCallbackPath(final String logoutCallbackPath) {
|
||||
this.handler.setLogoutCallbackPath(logoutCallbackPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ public abstract class AbstractAuthenticator extends AuthenticatorBase implements
|
|||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected synchronized void setState(LifecycleState state, Object data) throws LifecycleException {
|
||||
protected synchronized void setState(final LifecycleState state, final Object data) throws LifecycleException {
|
||||
super.setState(state, data);
|
||||
if (LifecycleState.STARTED.equals(state)) {
|
||||
logger.info("{} started.", getName());
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class SingleSignOutValve extends ValveBase implements SessionListener {
|
|||
this.handler.setRelayStateParameterName(name);
|
||||
}
|
||||
|
||||
public void setLogoutCallbackPath(String logoutCallbackPath) {
|
||||
public void setLogoutCallbackPath(final String logoutCallbackPath) {
|
||||
this.handler.setLogoutCallbackPath(logoutCallbackPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class SingleSignOutValve extends ValveBase implements SessionListener {
|
|||
this.handler.setRelayStateParameterName(name);
|
||||
}
|
||||
|
||||
public void setLogoutCallbackPath(String logoutCallbackPath) {
|
||||
public void setLogoutCallbackPath(final String logoutCallbackPath) {
|
||||
this.handler.setLogoutCallbackPath(logoutCallbackPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class SingleSignOutValve extends ValveBase implements SessionListener {
|
|||
this.handler.setRelayStateParameterName(name);
|
||||
}
|
||||
|
||||
public void setLogoutCallbackPath(String logoutCallbackPath) {
|
||||
public void setLogoutCallbackPath(final String logoutCallbackPath) {
|
||||
this.handler.setLogoutCallbackPath(logoutCallbackPath);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@
|
|||
|
||||
<packaging>jar</packaging>
|
||||
<artifactId>cas-client-support-distributed-memcached</artifactId>
|
||||
<name>Jasig CAS Client for Java - Distributed Proxy Storage Support:
|
||||
Memcached
|
||||
</name>
|
||||
<name>Jasig CAS Client for Java - Distributed Proxy Storage Support: Memcached</name>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public final class Saml11TicketValidator extends AbstractUrlBasedTicketValidator
|
|||
try {
|
||||
SAML_REQUEST_TEMPLATE = IOUtils.readString(
|
||||
Saml11TicketValidator.class.getResourceAsStream("/META-INF/cas/samlRequestTemplate.xml"));
|
||||
} catch (IOException e) {
|
||||
} catch (final IOException e) {
|
||||
throw new IllegalStateException("Cannot load SAML request template from classpath", e);
|
||||
}
|
||||
|
||||
|
|
@ -101,7 +101,7 @@ public final class Saml11TicketValidator extends AbstractUrlBasedTicketValidator
|
|||
|
||||
try {
|
||||
random = SecureRandom.getInstance("SHA1PRNG");
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
} catch (final NoSuchAlgorithmException e) {
|
||||
throw new IllegalStateException("Cannot find required SHA1PRNG algorithm");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,30 @@
|
|||
Licensed to Apereo under one or more contributor license
|
||||
agreements. See the NOTICE file distributed with this work
|
||||
for additional information regarding copyright ownership.
|
||||
Apereo licenses this file to you under the Apache License,
|
||||
Version 2.0 (the "License"); you may not use this file
|
||||
except in compliance with the License. You may obtain a
|
||||
copy of the License at the following location:
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
|
||||
This project includes:
|
||||
Jasig CAS Client for Java - Core under Apache License Version 2.0
|
||||
Jasig CAS Client for Java - SAML Protocol Support under Apache License Version 2.0
|
||||
Java Servlet API under CDDL + GPLv2 with classpath exception
|
||||
JCL 1.1.1 implemented over SLF4J under MIT License
|
||||
Joda-Time under Apache 2
|
||||
JUnit under Common Public License Version 1.0
|
||||
SLF4J API Module under MIT License
|
||||
SLF4J Simple Binding under MIT License
|
||||
spring-asm under The Apache Software License, Version 2.0
|
||||
spring-core under The Apache Software License, Version 2.0
|
||||
spring-test under The Apache Software License, Version 2.0
|
||||
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<parent>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<version>3.6.0-SNAPSHOT</version>
|
||||
<artifactId>cas-client</artifactId>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>cas-client-support-springboot</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
<name>Jasig CAS Client for Java - Spring Boot Support</name>
|
||||
<description>Library providing annotation-based configuration support for CAS Java clients.
|
||||
Primarily designed for super easy CASification of Spring Boot apps.
|
||||
</description>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-support-saml</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<version>${springboot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-core</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-context</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Test dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.jasig.cas.client</groupId>
|
||||
<artifactId>cas-client-core</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>test-jar</type>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springframework</groupId>
|
||||
<artifactId>spring-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<springboot.version>2.1.4.RELEASE</springboot.version>
|
||||
</properties>
|
||||
</project>
|
||||
|
|
@ -0,0 +1,184 @@
|
|||
package org.jasig.cas.client.boot.configuration;
|
||||
|
||||
import org.jasig.cas.client.authentication.AuthenticationFilter;
|
||||
import org.jasig.cas.client.authentication.Saml11AuthenticationFilter;
|
||||
import org.jasig.cas.client.util.AssertionThreadLocalFilter;
|
||||
import org.jasig.cas.client.util.HttpServletRequestWrapperFilter;
|
||||
import org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter;
|
||||
import org.jasig.cas.client.validation.Cas30ProxyReceivingTicketValidationFilter;
|
||||
import org.jasig.cas.client.validation.Saml11TicketValidationFilter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.servlet.Filter;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Configuration class providing default CAS client infrastructure filters.
|
||||
* This configuration facility is typically imported into Spring's Application Context via
|
||||
* {@link EnableCasClient} meta annotation.
|
||||
*
|
||||
* @author Dmitriy Kopylenko
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(CasClientConfigurationProperties.class)
|
||||
public class CasClientConfiguration {
|
||||
|
||||
@Autowired
|
||||
CasClientConfigurationProperties configProps;
|
||||
|
||||
private CasClientConfigurer casClientConfigurer;
|
||||
|
||||
private static Map<String, String> constructInitParams(final String casUrlParamName, final String casUrlParamVal, final String clientHostUrlVal) {
|
||||
final Map<String, String> initParams = new HashMap<>(2);
|
||||
initParams.put(casUrlParamName, casUrlParamVal);
|
||||
initParams.put("serverName", clientHostUrlVal);
|
||||
return initParams;
|
||||
}
|
||||
|
||||
private static void initFilter(final FilterRegistrationBean filterRegistrationBean,
|
||||
final Filter targetFilter,
|
||||
final int filterOrder,
|
||||
final Map<String, String> initParams,
|
||||
final List<String> urlPatterns) {
|
||||
|
||||
filterRegistrationBean.setFilter(targetFilter);
|
||||
filterRegistrationBean.setOrder(filterOrder);
|
||||
filterRegistrationBean.setInitParameters(initParams);
|
||||
if (!urlPatterns.isEmpty()) {
|
||||
filterRegistrationBean.setUrlPatterns(urlPatterns);
|
||||
}
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "cas", name = "skipTicketValidation", havingValue = "false", matchIfMissing = true)
|
||||
public FilterRegistrationBean casValidationFilter() {
|
||||
final FilterRegistrationBean validationFilter = new FilterRegistrationBean();
|
||||
final Filter targetCasValidationFilter;
|
||||
switch (this.configProps.getValidationType()) {
|
||||
case CAS:
|
||||
targetCasValidationFilter = new Cas20ProxyReceivingTicketValidationFilter();
|
||||
break;
|
||||
case SAML:
|
||||
targetCasValidationFilter = new Saml11TicketValidationFilter();
|
||||
break;
|
||||
case CAS3:
|
||||
default:
|
||||
targetCasValidationFilter = new Cas30ProxyReceivingTicketValidationFilter();
|
||||
break;
|
||||
}
|
||||
|
||||
initFilter(validationFilter,
|
||||
targetCasValidationFilter,
|
||||
1,
|
||||
constructInitParams("casServerUrlPrefix", this.configProps.getServerUrlPrefix(), this.configProps.getClientHostUrl()),
|
||||
this.configProps.getValidationUrlPatterns());
|
||||
|
||||
if (this.configProps.getUseSession() != null) {
|
||||
validationFilter.getInitParameters().put("useSession", String.valueOf(this.configProps.getUseSession()));
|
||||
}
|
||||
if (this.configProps.getRedirectAfterValidation() != null) {
|
||||
validationFilter.getInitParameters().put("redirectAfterValidation", String.valueOf(this.configProps.getRedirectAfterValidation()));
|
||||
}
|
||||
|
||||
//Proxy tickets validation
|
||||
if (this.configProps.getAcceptAnyProxy() != null) {
|
||||
validationFilter.getInitParameters().put("acceptAnyProxy", String.valueOf(this.configProps.getAcceptAnyProxy()));
|
||||
}
|
||||
if (!this.configProps.getAllowedProxyChains().isEmpty()) {
|
||||
validationFilter.getInitParameters().put("allowedProxyChains",
|
||||
StringUtils.collectionToDelimitedString(this.configProps.getAllowedProxyChains(), " "));
|
||||
}
|
||||
if (this.configProps.getProxyCallbackUrl() != null) {
|
||||
validationFilter.getInitParameters().put("proxyCallbackUrl", this.configProps.getProxyCallbackUrl());
|
||||
}
|
||||
if (this.configProps.getProxyReceptorUrl() != null) {
|
||||
validationFilter.getInitParameters().put("proxyReceptorUrl", this.configProps.getProxyReceptorUrl());
|
||||
}
|
||||
|
||||
if (this.casClientConfigurer != null) {
|
||||
this.casClientConfigurer.configureValidationFilter(validationFilter);
|
||||
}
|
||||
return validationFilter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean casAuthenticationFilter() {
|
||||
final FilterRegistrationBean authnFilter = new FilterRegistrationBean();
|
||||
final Filter targetCasAuthnFilter =
|
||||
this.configProps.getValidationType() == EnableCasClient.ValidationType.CAS
|
||||
|| configProps.getValidationType() == EnableCasClient.ValidationType.CAS3
|
||||
? new AuthenticationFilter()
|
||||
: new Saml11AuthenticationFilter();
|
||||
|
||||
initFilter(authnFilter,
|
||||
targetCasAuthnFilter,
|
||||
2,
|
||||
constructInitParams("casServerLoginUrl", this.configProps.getServerLoginUrl(), this.configProps.getClientHostUrl()),
|
||||
this.configProps.getAuthenticationUrlPatterns());
|
||||
|
||||
if (this.configProps.getGateway() != null) {
|
||||
authnFilter.getInitParameters().put("gateway", String.valueOf(this.configProps.getGateway()));
|
||||
}
|
||||
|
||||
if (this.casClientConfigurer != null) {
|
||||
this.casClientConfigurer.configureAuthenticationFilter(authnFilter);
|
||||
}
|
||||
return authnFilter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean casHttpServletRequestWrapperFilter() {
|
||||
final FilterRegistrationBean reqWrapperFilter = new FilterRegistrationBean();
|
||||
reqWrapperFilter.setFilter(new HttpServletRequestWrapperFilter());
|
||||
if (!this.configProps.getRequestWrapperUrlPatterns().isEmpty()) {
|
||||
reqWrapperFilter.setUrlPatterns(this.configProps.getRequestWrapperUrlPatterns());
|
||||
}
|
||||
reqWrapperFilter.setOrder(3);
|
||||
|
||||
if (this.casClientConfigurer != null) {
|
||||
this.casClientConfigurer.configureHttpServletRequestWrapperFilter(reqWrapperFilter);
|
||||
}
|
||||
return reqWrapperFilter;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public FilterRegistrationBean casAssertionThreadLocalFilter() {
|
||||
final FilterRegistrationBean assertionTLFilter = new FilterRegistrationBean();
|
||||
assertionTLFilter.setFilter(new AssertionThreadLocalFilter());
|
||||
if (!this.configProps.getAssertionThreadLocalUrlPatterns().isEmpty()) {
|
||||
assertionTLFilter.setUrlPatterns(this.configProps.getAssertionThreadLocalUrlPatterns());
|
||||
}
|
||||
assertionTLFilter.setOrder(4);
|
||||
|
||||
if (this.casClientConfigurer != null) {
|
||||
this.casClientConfigurer.configureAssertionThreadLocalFilter(assertionTLFilter);
|
||||
}
|
||||
return assertionTLFilter;
|
||||
}
|
||||
|
||||
@Autowired(required = false)
|
||||
void setConfigurers(final Collection<CasClientConfigurer> configurers) {
|
||||
if (CollectionUtils.isEmpty(configurers)) {
|
||||
return;
|
||||
}
|
||||
if (configurers.size() > 1) {
|
||||
throw new IllegalStateException(configurers.size() + " implementations of " +
|
||||
"CasClientConfigurer were found when only 1 was expected. " +
|
||||
"Refactor the configuration such that CasClientConfigurer is " +
|
||||
"implemented only once or not at all.");
|
||||
}
|
||||
this.casClientConfigurer = configurers.iterator().next();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,227 @@
|
|||
package org.jasig.cas.client.boot.configuration;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.lang.NonNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* {@link ConfigurationProperties} for CAS Java client filters.
|
||||
* <p>
|
||||
* Will be used to customize CAS filters via simple properties or YAML files in standard Spring Boot PropertySources.
|
||||
*
|
||||
* @author Dmitriy Kopylenko
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@ConfigurationProperties(prefix = "cas", ignoreUnknownFields = false)
|
||||
public class CasClientConfigurationProperties {
|
||||
|
||||
/**
|
||||
* CAS server URL E.g. https://example.com/cas or https://cas.example. Required.
|
||||
*/
|
||||
@NonNull
|
||||
private String serverUrlPrefix;
|
||||
|
||||
/**
|
||||
* CAS server login URL E.g. https://example.com/cas/login or https://cas.example/login. Required.
|
||||
*/
|
||||
@NonNull
|
||||
private String serverLoginUrl;
|
||||
|
||||
/**
|
||||
* CAS-protected client application host URL E.g. https://myclient.example.com Required.
|
||||
*/
|
||||
@NonNull
|
||||
private String clientHostUrl;
|
||||
|
||||
/**
|
||||
* List of URL patterns protected by CAS authentication filter.
|
||||
*/
|
||||
private List<String> authenticationUrlPatterns = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* List of URL patterns protected by CAS validation filter.
|
||||
*/
|
||||
private List<String> validationUrlPatterns = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* List of URL patterns protected by CAS request wrapper filter.
|
||||
*/
|
||||
private List<String> requestWrapperUrlPatterns = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* List of URL patterns protected by CAS assertion thread local filter.
|
||||
*/
|
||||
private List<String> assertionThreadLocalUrlPatterns = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Authentication filter gateway parameter.
|
||||
*/
|
||||
private Boolean gateway;
|
||||
|
||||
/**
|
||||
* Validation filter useSession parameter.
|
||||
*/
|
||||
private Boolean useSession;
|
||||
|
||||
/**
|
||||
* Validation filter redirectAfterValidation.
|
||||
*/
|
||||
private Boolean redirectAfterValidation;
|
||||
|
||||
/**
|
||||
* Cas20ProxyReceivingTicketValidationFilter acceptAnyProxy parameter.
|
||||
*/
|
||||
private Boolean acceptAnyProxy;
|
||||
|
||||
/**
|
||||
* Cas20ProxyReceivingTicketValidationFilter allowedProxyChains parameter.
|
||||
*/
|
||||
private List<String> allowedProxyChains = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* Cas20ProxyReceivingTicketValidationFilter proxyCallbackUrl parameter.
|
||||
*/
|
||||
private String proxyCallbackUrl;
|
||||
|
||||
/**
|
||||
* Cas20ProxyReceivingTicketValidationFilter proxyReceptorUrl parameter.
|
||||
*/
|
||||
private String proxyReceptorUrl;
|
||||
|
||||
/**
|
||||
* ValidationType the CAS protocol validation type. Defaults to CAS3 if not explicitly set.
|
||||
*/
|
||||
private EnableCasClient.ValidationType validationType = EnableCasClient.ValidationType.CAS3;
|
||||
|
||||
private Boolean skipTicketValidation = false;
|
||||
|
||||
public String getServerUrlPrefix() {
|
||||
return serverUrlPrefix;
|
||||
}
|
||||
|
||||
public void setServerUrlPrefix(final String serverUrlPrefix) {
|
||||
this.serverUrlPrefix = serverUrlPrefix;
|
||||
}
|
||||
|
||||
public String getServerLoginUrl() {
|
||||
return serverLoginUrl;
|
||||
}
|
||||
|
||||
public void setServerLoginUrl(final String serverLoginUrl) {
|
||||
this.serverLoginUrl = serverLoginUrl;
|
||||
}
|
||||
|
||||
public String getClientHostUrl() {
|
||||
return clientHostUrl;
|
||||
}
|
||||
|
||||
public void setClientHostUrl(final String clientHostUrl) {
|
||||
this.clientHostUrl = clientHostUrl;
|
||||
}
|
||||
|
||||
public Boolean getAcceptAnyProxy() {
|
||||
return acceptAnyProxy;
|
||||
}
|
||||
|
||||
public void setAcceptAnyProxy(final Boolean acceptAnyProxy) {
|
||||
this.acceptAnyProxy = acceptAnyProxy;
|
||||
}
|
||||
|
||||
public List<String> getAllowedProxyChains() {
|
||||
return allowedProxyChains;
|
||||
}
|
||||
|
||||
public void setAllowedProxyChains(final List<String> allowedProxyChains) {
|
||||
this.allowedProxyChains = allowedProxyChains;
|
||||
}
|
||||
|
||||
public String getProxyCallbackUrl() {
|
||||
return proxyCallbackUrl;
|
||||
}
|
||||
|
||||
public void setProxyCallbackUrl(final String proxyCallbackUrl) {
|
||||
this.proxyCallbackUrl = proxyCallbackUrl;
|
||||
}
|
||||
|
||||
public String getProxyReceptorUrl() {
|
||||
return proxyReceptorUrl;
|
||||
}
|
||||
|
||||
public void setProxyReceptorUrl(final String proxyReceptorUrl) {
|
||||
this.proxyReceptorUrl = proxyReceptorUrl;
|
||||
}
|
||||
|
||||
public Boolean getGateway() {
|
||||
return gateway;
|
||||
}
|
||||
|
||||
public void setGateway(final Boolean gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
public Boolean getUseSession() {
|
||||
return useSession;
|
||||
}
|
||||
|
||||
public void setUseSession(final Boolean useSession) {
|
||||
this.useSession = useSession;
|
||||
}
|
||||
|
||||
public Boolean getRedirectAfterValidation() {
|
||||
return redirectAfterValidation;
|
||||
}
|
||||
|
||||
public void setRedirectAfterValidation(final Boolean redirectAfterValidation) {
|
||||
this.redirectAfterValidation = redirectAfterValidation;
|
||||
}
|
||||
|
||||
public List<String> getAssertionThreadLocalUrlPatterns() {
|
||||
return assertionThreadLocalUrlPatterns;
|
||||
}
|
||||
|
||||
public void setAssertionThreadLocalUrlPatterns(final List<String> assertionThreadLocalUrlPatterns) {
|
||||
this.assertionThreadLocalUrlPatterns = assertionThreadLocalUrlPatterns;
|
||||
}
|
||||
|
||||
public List<String> getRequestWrapperUrlPatterns() {
|
||||
return requestWrapperUrlPatterns;
|
||||
}
|
||||
|
||||
public void setRequestWrapperUrlPatterns(final List<String> requestWrapperUrlPatterns) {
|
||||
this.requestWrapperUrlPatterns = requestWrapperUrlPatterns;
|
||||
}
|
||||
|
||||
public List<String> getValidationUrlPatterns() {
|
||||
return validationUrlPatterns;
|
||||
}
|
||||
|
||||
public void setValidationUrlPatterns(final List<String> validationUrlPatterns) {
|
||||
this.validationUrlPatterns = validationUrlPatterns;
|
||||
}
|
||||
|
||||
public List<String> getAuthenticationUrlPatterns() {
|
||||
return authenticationUrlPatterns;
|
||||
}
|
||||
|
||||
public void setAuthenticationUrlPatterns(final List<String> authenticationUrlPatterns) {
|
||||
this.authenticationUrlPatterns = authenticationUrlPatterns;
|
||||
}
|
||||
|
||||
public EnableCasClient.ValidationType getValidationType() {
|
||||
return validationType;
|
||||
}
|
||||
|
||||
public void setValidationType(final EnableCasClient.ValidationType validationType) {
|
||||
this.validationType = validationType;
|
||||
}
|
||||
|
||||
public Boolean getSkipTicketValidation() {
|
||||
return skipTicketValidation;
|
||||
}
|
||||
|
||||
public void setSkipTicketValidation(final Boolean skipTicketValidation) {
|
||||
this.skipTicketValidation = skipTicketValidation;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
package org.jasig.cas.client.boot.configuration;
|
||||
|
||||
import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
||||
|
||||
/**
|
||||
* Callback interface to be implemented by {@link org.springframework.context.annotation.Configuration Configuration} classes annotated with
|
||||
* {@link EnableCasClient} that wish or need to
|
||||
* explicitly configure or customize CAS client filters created by {@link CasClientConfiguration}.
|
||||
*
|
||||
* @author Dmitriy Kopylenko
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public interface CasClientConfigurer {
|
||||
|
||||
/**
|
||||
* Configure or customize CAS authentication filter.
|
||||
*
|
||||
* @param authenticationFilter the authentication filter
|
||||
*/
|
||||
default void configureAuthenticationFilter(final FilterRegistrationBean authenticationFilter) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure or customize CAS validation filter.
|
||||
*
|
||||
* @param validationFilter the validation filter
|
||||
*/
|
||||
default void configureValidationFilter(final FilterRegistrationBean validationFilter) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure or customize CAS http servlet wrapper filter.
|
||||
*
|
||||
* @param httpServletRequestWrapperFilter the http servlet request wrapper filter
|
||||
*/
|
||||
default void configureHttpServletRequestWrapperFilter(final FilterRegistrationBean httpServletRequestWrapperFilter) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure or customize CAS assertion thread local filter.
|
||||
*
|
||||
* @param assertionThreadLocalFilter the assertion thread local filter
|
||||
*/
|
||||
default void configureAssertionThreadLocalFilter(final FilterRegistrationBean assertionThreadLocalFilter) {
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
package org.jasig.cas.client.boot.configuration;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Inherited;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Enables CAS Java client Servlet Filters configuration facility.
|
||||
* To be used together with {@link org.springframework.context.annotation.Configuration Configuration}
|
||||
* or {@link org.springframework.boot.autoconfigure.SpringBootApplication SpringBootApplication} classes.
|
||||
*
|
||||
* <p>For those wishing to customize CAS filters during their creation, application configuration classes carrying this annotation
|
||||
* may implement the {@link CasClientConfigurer} callback interface and override only necessary methods.
|
||||
*
|
||||
* @author Dmitriy Kopylenko
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Documented
|
||||
@Inherited
|
||||
@Import(CasClientConfiguration.class)
|
||||
public @interface EnableCasClient {
|
||||
|
||||
enum ValidationType {
|
||||
CAS,
|
||||
CAS3,
|
||||
SAML
|
||||
}
|
||||
}
|
||||
32
pom.xml
32
pom.xml
|
|
@ -10,24 +10,19 @@
|
|||
<artifactId>cas-client</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>Jasig CAS Client for Java</name>
|
||||
<name>Apereo CAS Client for Java</name>
|
||||
<description>
|
||||
Jasig CAS Client for Java is the integration point for applications that want to speak with a CAS
|
||||
Apereo CAS Client for Java is the integration point for applications that want to speak with a CAS
|
||||
server, either via the CAS 1.0 or CAS 2.0 protocol.
|
||||
</description>
|
||||
<url>http://www.jasig.org/cas</url>
|
||||
|
||||
<issueManagement>
|
||||
<system>JIRA</system>
|
||||
<url>https://issues.jasig.org/browse/CASC</url>
|
||||
</issueManagement>
|
||||
<url>https://www.apereo.org/cas</url>
|
||||
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:Jasig/java-cas-client.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:Jasig/java-cas-client.git</developerConnection>
|
||||
<url>https://github.com/Jasig/java-cas-client</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
<connection>scm:git:git@github.com:apereo/java-cas-client.git</connection>
|
||||
<developerConnection>scm:git:git@github.com:apereo/java-cas-client.git</developerConnection>
|
||||
<url>https://github.com/apereo/java-cas-client</url>
|
||||
<tag>HEAD</tag>
|
||||
</scm>
|
||||
|
||||
<inceptionYear>2006</inceptionYear>
|
||||
|
||||
|
|
@ -55,8 +50,8 @@
|
|||
</developers>
|
||||
|
||||
<organization>
|
||||
<name>Jasig</name>
|
||||
<url>http://www.jasig.org</url>
|
||||
<name>Apereo</name>
|
||||
<url>https://www.apereo.org</url>
|
||||
</organization>
|
||||
|
||||
<build>
|
||||
|
|
@ -76,8 +71,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.6</source>
|
||||
<target>1.6</target>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
|
@ -277,6 +272,7 @@
|
|||
<module>cas-client-support-distributed-ehcache</module>
|
||||
<module>cas-client-support-distributed-memcached</module>
|
||||
<module>cas-client-support-saml</module>
|
||||
<module>cas-client-support-springboot</module>
|
||||
<module>cas-client-integration-tomcat-common</module>
|
||||
<module>cas-client-integration-tomcat-v6</module>
|
||||
<module>cas-client-integration-tomcat-v7</module>
|
||||
|
|
@ -286,7 +282,7 @@
|
|||
</modules>
|
||||
|
||||
<properties>
|
||||
<spring.version>3.1.3.RELEASE</spring.version>
|
||||
<spring.version>5.1.9.RELEASE</spring.version>
|
||||
<ehcache.version>2.6.11</ehcache.version>
|
||||
<clover.version>3.0.2</clover.version>
|
||||
<slf4j.version>1.7.27</slf4j.version>
|
||||
|
|
|
|||
Loading…
Reference in New Issue