Merge branch 'bug5221'

This commit is contained in:
Georg Herdt committed 2020-12-11 16:35:29 +01:00
commit bb43e0d88e
6 files changed
+49 -6

No files matched your search

@@ -3,4 +3,5 @@ source.. = src/,\
output.. = bin/
bin.includes = META-INF/,\
.,\
WEB-INF/
WEB-INF/,\
redirect.html
@@ -0,0 +1,29 @@
<html>
<head>
<title>Igtimi</title>
<script>
function loadAndReplace() {
var request = new XMLHttpRequest();
var base64 = window.location.href.substring(window.location.href.lastIndexOf("?")+1);
var target = atob(base64);
console.log("decode post target " + base64 + " -> " + target);
request.open("POST", target);
request.setRequestHeader("X-SAPSSE-Forward-Request-To","master");
request.addEventListener("load", function(event) {
if (request.status >= 200 && request.status < 300) {
document.getElementById("body").innerHTML = request.responseText;
} else {
document.getElementById("body").innerHTML = "<b>error reading data from server</b>";
}
});
request.send();
}
function refresh() {
loadAndReplace();
}
</script>
</head>
<body id="body" onload="refresh()" >
</body>
</html>
@@ -4,10 +4,12 @@ import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.util.Base64;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
@@ -55,7 +57,10 @@ public class AuthorizationCallback {
Response result;
if (state != null) {
// redirect to the server whose base URL is contained in the state parameter
result = Response.temporaryRedirect(new URI(state+"/igtimi/oauth/v1"+AUTHORIZATIONCALLBACK+"?code="+URLEncoder.encode(code, "UTF-8"))).build();
String target = Base64.getEncoder().encodeToString(
(state + "/igtimi/oauth/v1" + AUTHORIZATIONCALLBACK + "?code=" + URLEncoder.encode(code, "UTF-8"))
.getBytes());
result = Response.temporaryRedirect(new URI(state + "/igtimi/redirect.html?" + target)).build();
} else {
if (code != null) {
try {
@@ -82,7 +87,15 @@ public class AuthorizationCallback {
}
return result;
}
@POST
@Produces("text/plain;charset=UTF-8")
@Path(AUTHORIZATIONCALLBACK)
public Response obtainAccessTokenPost(@QueryParam("code") String code, @QueryParam("state") String state)
throws ClientProtocolException, IOException, IllegalStateException, ParseException, URISyntaxException {
return obtainAccessToken(code, state);
}
@GET
@Produces("application/json;charset=UTF-8")
@Path("uri")
@@ -24,7 +24,7 @@ import com.sap.sailing.expeditionconnector.ExpeditionMessage;
import com.sap.sailing.expeditionconnector.ExpeditionTrackerFactory;
import com.sap.sailing.expeditionconnector.UDPExpeditionReceiver;
public class ExpeditionWindMeasureStatusGetServlet extends SailingServerHttpServletWithPostBasedConrentReplacing implements ExpeditionListener {
public class ExpeditionWindMeasureStatusGetServlet extends SailingServerHttpServletWithPostBasedContentReplacing implements ExpeditionListener {
private static final long serialVersionUID = -6791613843435009810L;
private Map<Integer, ExpeditionMessageInfo> lastMessageInfosPerBoat;
@@ -20,7 +20,7 @@ import com.sap.sse.common.HttpRequestHeaderConstants;
* @author Axel Uhl (D043530)
*
*/
public abstract class SailingServerHttpServletWithPostBasedConrentReplacing extends SailingServerHttpServlet {
public abstract class SailingServerHttpServletWithPostBasedContentReplacing extends SailingServerHttpServlet {
private static final long serialVersionUID = -2819428093387051473L;
protected void writePostRefreshingHeadAndEmptyBody(HttpServletRequest req, HttpServletResponse resp, String title) throws IOException {
@@ -39,7 +39,7 @@ import com.sap.sse.common.Util;
* @author Simon Marcel Pamies
*
*/
public abstract class WindStatusServlet extends SailingServerHttpServletWithPostBasedConrentReplacing implements IgtimiWindListener, BulkFixReceiver {
public abstract class WindStatusServlet extends SailingServerHttpServletWithPostBasedContentReplacing implements IgtimiWindListener, BulkFixReceiver {
private static final Logger logger = Logger.getLogger(WindStatusServlet.class.getName());
private static final long serialVersionUID = -6791613843435003810L;