added ability to remove jsession from service urls (not all servers can work with them)
This commit is contained in:
Scott Battaglia 2008-02-08 15:08:30 +00:00
parent 28df93dad7
commit ac6268509d
2 changed files with 15 additions and 7 deletions

View File

@ -35,6 +35,9 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
/** Defines the parameter to look for for the service. */
private String serviceParameterName = "service";
/** Sets where response.encodeUrl should be called on service urls when constructed. */
private boolean encodeServiceUrl = true;
/**
* The name of the server. Should be in the following format: {protocol}:{hostName}:{port}.
@ -49,6 +52,7 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
setService(getPropertyFromInitParams(filterConfig, "service", null));
setArtifactParameterName(getPropertyFromInitParams(filterConfig, "artifactParameterName", "ticket"));
setServiceParameterName(getPropertyFromInitParams(filterConfig, "serviceParameterName", "service"));
setEncodeServiceUrl(Boolean.parseBoolean(getPropertyFromInitParams(filterConfig, "encodeServiceUrl", "true")));
initInternal(filterConfig);
init();
@ -73,7 +77,7 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
}
protected final String constructServiceUrl(final HttpServletRequest request, final HttpServletResponse response) {
return CommonUtils.constructServiceUrl(request, response, this.service, this.serverName, this.artifactParameterName);
return CommonUtils.constructServiceUrl(request, response, this.service, this.serverName, this.artifactParameterName, this.encodeServiceUrl);
}
public final void setServerName(final String serverName) {
@ -91,6 +95,10 @@ public abstract class AbstractCasFilter extends AbstractConfigurationFilter {
public final void setServiceParameterName(final String serviceParameterName) {
this.serviceParameterName = serviceParameterName;
}
public final void setEncodeServiceUrl(final boolean encodeServiceUrl) {
this.encodeServiceUrl = encodeServiceUrl;
}
public final String getArtifactParameterName() {
return this.artifactParameterName;

View File

@ -133,7 +133,7 @@ public final class CommonUtils {
throw new RuntimeException(e);
}
}
/**
* Constructs a service url from the HttpServletRequest or from the given
* serviceUrl. Prefers the serviceUrl provided if both a serviceUrl and a
@ -144,9 +144,9 @@ public final class CommonUtils {
* @return the service url to use.
*/
public static final String constructServiceUrl(final HttpServletRequest request,
final HttpServletResponse response, final String service, final String serverName, final String artifactParameterName) {
final HttpServletResponse response, final String service, final String serverName, final String artifactParameterName, final boolean encode) {
if (CommonUtils.isNotBlank(service)) {
return response.encodeURL(service);
return encode ? response.encodeURL(service) : service;
}
final StringBuffer buffer = new StringBuffer();
@ -164,8 +164,8 @@ public final class CommonUtils {
artifactParameterName + "=");
if (location == 0) {
final String returnValue = response.encodeURL(buffer
.toString());
final String returnValue = encode ? response.encodeURL(buffer
.toString()): buffer.toString();
if (LOG.isDebugEnabled()) {
LOG.debug("serviceUrl generated: " + returnValue);
}
@ -190,7 +190,7 @@ public final class CommonUtils {
}
}
final String returnValue = response.encodeURL(buffer.toString());
final String returnValue = encode ? response.encodeURL(buffer.toString()) : buffer.toString();
if (LOG.isDebugEnabled()) {
LOG.debug("serviceUrl generated: " + returnValue);
}