refactored encoding method

This commit is contained in:
Scott Battaglia 2007-02-09 19:33:43 +00:00
parent 8e51324483
commit c6284f1d1e
4 changed files with 8 additions and 13 deletions

View File

@ -97,12 +97,12 @@ public abstract class AbstractUrlBasedTicketValidator implements
/**
* Helper method to encode the service url.
*
* @param service the service url to encode.
* @return the encoded service url.
* @param value the String to encode.
* @return the encoded String.
*/
protected final String getEncodedService(final Service service) {
protected final String urlEncode(final String value) {
try {
return URLEncoder.encode(service.getId(), "UTF-8");
return URLEncoder.encode(value, "UTF-8");
} catch (final Exception e) {
throw new RuntimeException(e);
}

View File

@ -30,7 +30,7 @@ public final class Cas10TicketValidator extends AbstractUrlBasedTicketValidator
protected String constructURL(final String ticketId, final Service service) {
return getCasServerUrl() + "validate?ticket=" + ticketId
+ (isRenew() ? "&renew=true" : "") + "&service="
+ getEncodedService(service);
+ urlEncode(service.getId());
}
protected final Assertion parseResponse(final String response)

View File

@ -64,9 +64,9 @@ public class Cas20ServiceTicketValidator extends
+ ticketId
+ (isRenew() ? "&renew=true" : "")
+ "&service="
+ getEncodedService(service)
+ urlEncode(service.getId())
+ (this.proxyCallbackUrl != null ? "&pgtUrl="
+ getEncodedService(this.proxyCallbackUrl) : "");
+ urlEncode(this.proxyCallbackUrl.getId()) : "");
}
protected final Assertion parseResponse(final String response)

View File

@ -46,12 +46,7 @@ public class Saml10TicketValidator extends AbstractUrlBasedTicketValidator {
protected String constructURL(final String ticketId, final Service service) {
try {
final String encodedTicket = URLEncoder.encode(ticketId, "UTF-8");
return getCasServerUrl() + "/samlValidate?SAMLart=" + encodedTicket + "&TARGET=" + getEncodedService(service);
} catch (final Exception e) {
return getCasServerUrl() + "/samlValidate?SAMLart=" + ticketId + "&TARGET=" + getEncodedService(service);
}
return getCasServerUrl() + "/samlValidate?SAMLart=" + urlEncode(ticketId) + "&TARGET=" + urlEncode(service.getId());
}
protected Assertion parseResponse(final String response) throws ValidationException {