mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 06:06:11 +00:00
register the UserManagementService in gwt.ui bundle's web.xml, solving the cross-bundle RPC issue
This commit is contained in:
@@ -90,6 +90,16 @@
|
||||
<servlet-name>DataMiningService</servlet-name>
|
||||
<url-pattern>/service/datamining</url-pattern>
|
||||
</servlet-mapping>
|
||||
<servlet>
|
||||
<display-name>User Management Service</display-name>
|
||||
<servlet-name>UserManagementService</servlet-name>
|
||||
<servlet-class>com.sap.sse.security.ui.server.UserManagementServiceImpl</servlet-class>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>UserManagementService</servlet-name>
|
||||
<url-pattern>/service/usermanagement</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
|
||||
<!-- enabling remote logging -->
|
||||
<servlet>
|
||||
|
||||
@@ -19,7 +19,8 @@ Require-Bundle: com.sap.sailing.domain,
|
||||
org.junit4;bundle-version="4.8.2",
|
||||
com.sap.sailing.domain.test,
|
||||
org.mockito.mockito-core;bundle-version="1.9.5",
|
||||
com.sap.sse.common
|
||||
com.sap.sse.common,
|
||||
org.eclipse.jetty.server;bundle-version="9.2.2"
|
||||
Import-Package: com.sap.sailing.server.gateway.jaxrs,
|
||||
com.sap.sailing.server.gateway.jaxrs.spi,
|
||||
org.json.simple,
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
<dispatcher>ERROR</dispatcher>
|
||||
</filter-mapping>
|
||||
|
||||
|
||||
<servlet>
|
||||
<display-name>User Management Service</display-name>
|
||||
<servlet-name>UserManagementService</servlet-name>
|
||||
|
||||
-6
@@ -44,7 +44,6 @@ public class LoginPanel extends FlowPanel implements UserStatusEventHandler {
|
||||
|
||||
static {
|
||||
EntryPointHelper.registerASyncService((ServiceDefTarget) userManagementService,
|
||||
RemoteServiceMappingConstants.WEB_CONTEXT_PATH,
|
||||
RemoteServiceMappingConstants.userManagementServiceRemotePath);
|
||||
}
|
||||
|
||||
@@ -103,7 +102,6 @@ public class LoginPanel extends FlowPanel implements UserStatusEventHandler {
|
||||
infoPanel.setWidget(loginPanel);
|
||||
wrapperPanel.add(infoPanel);
|
||||
add(wrapperPanel);
|
||||
|
||||
addUserStatusEventHandler(this);
|
||||
registerStorageListener();
|
||||
updateUser();
|
||||
@@ -112,11 +110,9 @@ public class LoginPanel extends FlowPanel implements UserStatusEventHandler {
|
||||
private void initLoginContent() {
|
||||
loginPanel = new FormPanel();
|
||||
loginPanel.addSubmitHandler(new SubmitHandler() {
|
||||
|
||||
@Override
|
||||
public void onSubmit(SubmitEvent event) {
|
||||
userManagementService.login(name.getText(), password.getText(), new AsyncCallback<SuccessInfo>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Window.alert(caught.getMessage());
|
||||
@@ -134,9 +130,7 @@ public class LoginPanel extends FlowPanel implements UserStatusEventHandler {
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
FlowPanel formContent = new FlowPanel();
|
||||
|
||||
Label nameLabel = new Label("Name: ");
|
||||
formContent.add(nameLabel);
|
||||
name = new TextBox();
|
||||
|
||||
+31
@@ -1,5 +1,8 @@
|
||||
package com.sap.sse.security.ui.server;
|
||||
|
||||
import java.lang.reflect.InvocationHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.lang.reflect.Proxy;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
@@ -14,6 +17,7 @@ import java.util.concurrent.FutureTask;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpSession;
|
||||
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
@@ -23,6 +27,7 @@ import org.osgi.framework.BundleContext;
|
||||
import org.osgi.util.tracker.ServiceTracker;
|
||||
|
||||
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
|
||||
import com.google.gwt.user.server.rpc.SerializationPolicy;
|
||||
import com.sap.sse.security.Credential;
|
||||
import com.sap.sse.security.SecurityService;
|
||||
import com.sap.sse.security.SessionUtils;
|
||||
@@ -86,6 +91,32 @@ public class UserManagementServiceImpl extends RemoteServiceServlet implements U
|
||||
return "Hello";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SerializationPolicy doGetSerializationPolicy(HttpServletRequest request, String moduleBaseURL,
|
||||
String strongName) {
|
||||
final String emulatedContextPath = "/"+(moduleBaseURL.split("/")[3]);
|
||||
try {
|
||||
final Method getContextPath = HttpServletRequest.class.getDeclaredMethod("getContextPath");
|
||||
HttpServletRequest proxyRequestAnsweringWithEmulatedContextPath = (HttpServletRequest) Proxy
|
||||
.newProxyInstance(request.getClass().getClassLoader(), new Class[] { HttpServletRequest.class },
|
||||
new InvocationHandler() {
|
||||
@Override
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
if (method.equals(getContextPath)) {
|
||||
return emulatedContextPath;
|
||||
} else {
|
||||
return method.invoke(proxy, args);
|
||||
}
|
||||
}
|
||||
});
|
||||
return super.doGetSerializationPolicy(proxyRequestAnsweringWithEmulatedContextPath, moduleBaseURL, strongName);
|
||||
} catch (NoSuchMethodException | SecurityException e) {
|
||||
logger.log(Level.SEVERE, "Error obtaining serialization policy for " + request + " with moduleBaseURL "
|
||||
+ moduleBaseURL, e);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<UserDTO> getUserList() {
|
||||
List<UserDTO> users = new ArrayList<>();
|
||||
|
||||
Reference in New Issue
Block a user