Skip to content

Commit

Permalink
[FEDIZ-79] Encoding of SignInResponse configurable
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/cxf/fediz/trunk@1574223 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
owulff committed Mar 4, 2014
1 parent 7c08ab9 commit 0fbe60a
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.security.cert.X509Certificate;

import javax.servlet.ServletOutputStream;
Expand Down Expand Up @@ -83,6 +84,7 @@ public class FederationAuthenticator extends LoginAuthenticator {

private String configFile;
private FederationConfigurator configurator;
private String encoding = "UTF-8";

public FederationAuthenticator() {
}
Expand Down Expand Up @@ -130,14 +132,28 @@ public void setConfigFile(String configFile) {
this.configFile = configFile;
}

public String getEncoding() {
return encoding;
}

public void setEncoding(String encoding) {
this.encoding = encoding;
}

/* ------------------------------------------------------------ */
public Authentication validateRequest(ServletRequest req, ServletResponse res, boolean mandatory)
throws ServerAuthException {

if (!mandatory) {
return new DeferredAuthentication(this);
}


try {
req.setCharacterEncoding(this.encoding);
} catch (UnsupportedEncodingException ex) {
LOG.warn("Unsupported encoding '" + this.encoding + "'", ex);
}

HttpServletRequest request = (HttpServletRequest)req;
HttpServletResponse response = (HttpServletResponse)res;
String uri = request.getRequestURI();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class FederationAuthenticator extends FormAuthenticator {
*/
protected String configFile;
protected boolean tokenExpirationValidation = true;
protected String encoding = "UTF-8";

private FederationConfigurator configurator;

Expand All @@ -99,6 +100,14 @@ public void setConfigFile(String configFile) {
this.configFile = configFile;
}

public String getEncoding() {
return encoding;
}

public void setEncoding(String encoding) {
this.encoding = encoding;
}

public boolean isTokenExpirationValidation() {
return tokenExpirationValidation;
}
Expand Down Expand Up @@ -166,6 +175,8 @@ public void invoke(Request request, Response response) throws IOException,
ServletException {

LOG.debug("WsFedAuthenticator:invoke()");
request.setCharacterEncoding(this.encoding);

if (request.getRequestURL().indexOf(FederationConstants.METADATA_PATH_URI) != -1) {
if (LOG.isInfoEnabled()) {
LOG.info("WS-Federation Metadata document requested");
Expand Down

0 comments on commit 0fbe60a

Please sign in to comment.