Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Add workarounds for WildFly bugs: WFLY-3617, WFLY-3744
Browse files Browse the repository at this point in the history
  • Loading branch information
seanf committed Sep 11, 2014
1 parent 1f2f2c7 commit 1501295
Showing 1 changed file with 34 additions and 2 deletions.
Expand Up @@ -23,25 +23,57 @@
import io.undertow.servlet.ServletExtension;
import io.undertow.servlet.api.DeploymentInfo;
import io.undertow.util.ImmediateAuthenticationMechanismFactory;
import lombok.extern.slf4j.Slf4j;
import org.zanata.security.DummyAuthenticationMechanism;

import javax.servlet.ServletContext;
import javax.servlet.SessionCookieConfig;

/**
* This Undertow servlet extension adds a dummy SPNEGO implemention so
* that we can deploy on WildFly.
* This Undertow servlet extension adds a dummy SPNEGO implementation so
* that we can deploy on WildFly, and also provides other workarounds as
* needed.
*
* @author Sean Flanigan <a href="mailto:sflaniga@redhat.com">sflaniga@redhat.com</a>
*/
@Slf4j
public class ZanataServletExtension implements ServletExtension {

@Override
public void handleDeployment(DeploymentInfo deploymentInfo,
ServletContext servletContext) {
if (!deploymentInfo.getAuthenticationMechanisms().containsKey("SPNEGO")) {
log.debug("Registering dummy SPNEGO authentication mechanism");
deploymentInfo.addAuthenticationMechanism("SPNEGO",
new ImmediateAuthenticationMechanismFactory(
new DummyAuthenticationMechanism()));
}

String contextPath = servletContext.getContextPath();

// workaround for https://issues.jboss.org/browse/WFLY-3744
if (contextPath == null || contextPath.equals("/")) {
log.warn("ContextPath was \"/\", changing to \"\" (WFLY-3744 workaround)");
deploymentInfo.setContextPath("");
}

// workaround for https://issues.jboss.org/browse/WFLY-3617
SessionCookieConfig cookieConfig =
servletContext.getSessionCookieConfig();
String cookiePath = cookieConfig.getPath();
if (cookiePath == null) {
log.info("Cookie path is null");
} else if (cookiePath.isEmpty()) {
String newCookiePath;
if (contextPath == null || contextPath.isEmpty()) {
newCookiePath = "/";
} else {
newCookiePath = contextPath;
}
log.warn("Cookie path was empty, changing to \"{}\" (WFLY-3617 workaround)", newCookiePath);
cookieConfig.setPath(newCookiePath);
} else {
log.info("Cookie path is \"{}\"", cookiePath);
}
}
}

0 comments on commit 1501295

Please sign in to comment.