@NotNull
private HttpClient httpClient;
public String handle(final Credentials credentials,
final String proxyGrantingTicketId) {
final HttpBasedServiceCredentials serviceCredentials = (HttpBasedServiceCredentials) credentials;
final String proxyIou = this.uniqueTicketIdGenerator
.getNewTicketId(PGTIOU_PREFIX);
final String serviceCredentialsAsString = serviceCredentials.getCallbackUrl().toExternalForm();
final StringBuilder stringBuffer = new StringBuilder(
serviceCredentialsAsString.length() + proxyIou.length()
+ proxyGrantingTicketId.length() + 15);
stringBuffer.append(serviceCredentialsAsString);
if (serviceCredentials.getCallbackUrl().getQuery() != null) {
stringBuffer.append("&");
} else {
stringBuffer.append("?");
}
stringBuffer.append("pgtIou=");
stringBuffer.append(proxyIou);
stringBuffer.append("&pgtId=");
stringBuffer.append(proxyGrantingTicketId);
if (this.httpClient.isValidEndPoint(stringBuffer.toString())) {
if (log.isDebugEnabled()) {
log.debug("Sent ProxyIou of " + proxyIou + " for service: "
+ serviceCredentials.toString());
}
return proxyIou;
}
if (log.isDebugEnabled()) {
log.debug("Failed to send ProxyIou of " + proxyIou
+ " for service: " + serviceCredentials.toString());
}
return null;
}