import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.security.MessageDigest;
import com.vaadin.server.ClientConnector;
import com.vaadin.server.NoInputStreamException;
streamVariable = uI.getConnectorTracker()
.getStreamVariable(connectorId, variableName);
String secKey = uI.getConnectorTracker().getSeckey(streamVariable);
- if (secKey == null || !secKey.equals(parts[3])) {
- // TODO Should rethink error handling
+ String securityKey = parts[3];
+ if (secKey == null || !MessageDigest.isEqual(
+ secKey.getBytes(UTF8),
+ securityKey.getBytes(UTF8))) {
return true;
}
import java.io.IOException;
import java.io.Reader;
+import java.security.MessageDigest;
import java.util.Collection;
import java.util.logging.Level;
import java.util.logging.Logger;
private int longPollingSuspendTimeout = -1;
+ private static final String UTF8 = "UTF-8";
+
/**
* Callback interface used internally to process an event with the
* corresponding UI properly locked.
}
/**
- * Checks whether a given push id matches the session's push id.
+ * Checks whether a given push id matches the session's push id. The
+ * comparison is done using a time-constant method since the push id is used
+ * to protect against cross-site attacks.
*
* @param session
* the vaadin session for which the check should be done
* @return {@code true} if the id is valid, {@code false} otherwise
*/
private static boolean isPushIdValid(VaadinSession session,
- String requestPushId) {
+ String requestPushId) throws IOException {
String sessionPushId = session.getPushId();
- if (requestPushId == null || !requestPushId.equals(sessionPushId)) {
+ if (requestPushId == null || !MessageDigest.isEqual(
+ requestPushId.getBytes(UTF8),
+ sessionPushId.getBytes(UTF8))) {
return false;
}
return true;
// Chrome version does not necessarily match the desired version
// because of auto updates...
browserIdentifier = getExpectedUserAgentString(
- getDesiredCapabilities()) + "87";
+ getDesiredCapabilities()) + "88";
} else {
browserIdentifier = getExpectedUserAgentString(desiredCapabilities)
+ desiredCapabilities.getVersion();