Hello,
I found something that could be useful to add to the org.acegisecurity.ui.cas.CasProcessingFilter.
When working in proxy mode, after receiving a proxy ticket and validating it to CAS, acegi will always redirect the proxied web application to its defaultTargetUrl defined in applicationContext.xml file.
It would be nice if we could pass some extra parameters from the proxy to this default URL.
A solution would be to append extra parameter to /j_acegi_cas_security_check?ticket=.... when calling from proxy and to slightly modify the behaviour of the method AbstractProcessingFilter.
successfulAuthentication() to handle those extra parameters and append them to the default URL. What do you think?
Cheers,
Lucas Opara
Sample code:
protected void successfulAuthentication(HttpServletRequest request, HttpServletResponse response, Authentication authResult) {
//....
if (targetUrl == null) {
targetUrl = request.getContextPath() + getDefaultTargetUrl();
//ADDED by LOP 22/02/2006 - BEGIN
Map params = request.getParameterMap();
if(params != null && !params.isEmpty()) {
//other parameters to append to targetUrl
Iterator it = params.entrySet().iterator();
int i=0;
while (it.hasNext()) {
targetUrl = request.getContextPath() + getDefaultTargetUrl();
//ADDED by LOP 22/02/2006 - BEGIN
Map params = request.getParameterMap();
if(params != null && !params.isEmpty()) {
//other parameters to append to targetUrl
Iterator it = params.entrySet().iterator();
int i=0;
while (it.hasNext()) {
i++;
Map.Entry pair = (Map.Entry)it.next();
if("ticket".equals(pair.getKey())) {
continue;
}
targetUrl += (i==1 ? "?" : "&") + (String)pair.getKey() + "=" + arrayToString((String[])pair.getValue());
}
}
//ADDED by LOP 22/02/2006 - END
}
Map.Entry pair = (Map.Entry)it.next();
if("ticket".equals(pair.getKey())) {
continue;
}
targetUrl += (i==1 ? "?" : "&") + (String)pair.getKey() + "=" + arrayToString((String[])pair.getValue());
}
}
//ADDED by LOP 22/02/2006 - END
}
//...
}
private String arrayToString(String s[]) {
int k;
String result = "";
k = s.length;
if (k > 0) {
result = s[0];
for (int i= 1 ; i < k; i++) {
result += s[i] ;
}
}
return result;
}
int k;
String result = "";
k = s.length;
if (k > 0) {
result = s[0];
for (int i= 1 ; i < k; i++) {
result += s[i] ;
}
}
return result;
}
