List of usage examples for org.apache.shiro.spring.remoting SecureRemoteInvocationFactory SecureRemoteInvocationFactory
public SecureRemoteInvocationFactory(String sessionId)
From source file:de.scoopgmbh.copper.monitoring.client.context.ApplicationContext.java
License:Apache License
protected void connect(final String serverAdressParam, final String user, final String password) { boolean secureConnect = StringUtils.hasText(user) && StringUtils.hasText(password); String serverAdress = serverAdressParam; if (!serverAdress.endsWith("/")) { serverAdress = serverAdress + "/"; }/*w w w . ja va2 s .co m*/ final LoginService loginService; final CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor(); DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(10, false); httpInvokerRequestExecutor.getHttpClient().getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler); httpInvokerRequestExecutor.getHttpClient().getParams().setSoTimeout(1000 * 60 * 5); { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class); httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "loginService"); httpInvokerProxyFactoryBean.afterPropertiesSet(); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); loginService = (LoginService) httpInvokerProxyFactoryBean.getObject(); } final String sessionId; if (secureConnect) { try { sessionId = loginService.doLogin(user, password); } catch (RemoteException e) { throw new RuntimeException(e); } } else { sessionId = ""; } if (sessionId == null) { getIssueReporterSingleton().reportWarning("Invalid user/password", null, new Runnable() { @Override public void run() { createLoginForm().show(); } }); } else { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAdress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); RemoteInvocationFactory remoteInvocationFactory = secureConnect ? new SecureRemoteInvocationFactory(sessionId) : new DefaultRemoteInvocationFactory(); httpInvokerProxyFactoryBean.setRemoteInvocationFactory(remoteInvocationFactory); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); httpInvokerProxyFactoryBean.afterPropertiesSet(); final CopperMonitoringService copperMonitoringService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); final String serverAdressFinal = serverAdress; Platform.runLater(new Runnable() { @Override public void run() { setGuiCopperDataProvider(copperMonitoringService, serverAdressFinal, sessionId); } }); } }
From source file:de.scoopgmbh.copper.monitoring.server.SpringRemotingServerTest.java
License:Apache License
@Test public void test_with_valid_user() throws Exception { String sessionId;/*from w w w . java 2s. com*/ { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class); httpInvokerProxyFactoryBean.setServiceUrl(LOGIN_SERVICE); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxyFactoryBean.afterPropertiesSet(); LoginService loginService = (LoginService) httpInvokerProxyFactoryBean.getObject(); sessionId = loginService.doLogin("user1", "pass1"); } { final HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); httpInvokerProxyFactoryBean.setServiceUrl(COPPER_MONITORING_SERVICE); httpInvokerProxyFactoryBean.setRemoteInvocationFactory(new SecureRemoteInvocationFactory(sessionId)); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxyFactoryBean.afterPropertiesSet(); CopperMonitoringService copperMonitorService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); assertNotNull(copperMonitorService); try { copperMonitorService.getSettings(); } catch (RemoteException e) { throw new RuntimeException(e); } } }
From source file:de.scoopgmbh.copper.monitoring.server.SpringRemotingServerTest.java
License:Apache License
@Test(expected = RemoteAccessException.class) public void test_with_invalid_user() throws Exception { String sessionId;//from w w w . ja va 2 s . co m { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class); httpInvokerProxyFactoryBean.setServiceUrl(LOGIN_SERVICE); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxyFactoryBean.afterPropertiesSet(); LoginService loginService = (LoginService) httpInvokerProxyFactoryBean.getObject(); sessionId = loginService.doLogin("userXXXX", "passXXXX"); assertNull(sessionId); } { final HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); httpInvokerProxyFactoryBean.setServiceUrl(COPPER_MONITORING_SERVICE); httpInvokerProxyFactoryBean.setRemoteInvocationFactory(new SecureRemoteInvocationFactory(sessionId)); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxyFactoryBean.afterPropertiesSet(); CopperMonitoringService copperMonitorService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); assertNotNull(copperMonitorService); try { copperMonitorService.getSettings(); } catch (RemoteException e) { throw new RuntimeException(e); } } }
From source file:de.scoopgmbh.copper.monitoring.server.SpringRemotingServerTest.java
License:Apache License
@Test(expected = RemoteAccessException.class) public void test_without_user() throws RemoteException { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); httpInvokerProxyFactoryBean.setServiceUrl(COPPER_MONITORING_SERVICE); ;/*from w ww .j a v a 2 s . c o m*/ httpInvokerProxyFactoryBean.setRemoteInvocationFactory(new SecureRemoteInvocationFactory("dgfdgdg")); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(new CommonsHttpInvokerRequestExecutor()); httpInvokerProxyFactoryBean.afterPropertiesSet(); CopperMonitoringService copperMonitorService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); assertNotNull(copperMonitorService); copperMonitorService.getSettings(); }
From source file:org.copperengine.monitoring.client.context.ApplicationContext.java
License:Apache License
protected void connect(final String serverAddressParam, final String user, final String password) { boolean secureConnect = StringUtils.hasText(user) && StringUtils.hasText(password); String serverAddress = serverAddressParam; if (!serverAddress.endsWith("/")) { serverAddress = serverAddress + "/"; }/* w w w . ja va2 s . co m*/ final LoginService loginService; final CommonsHttpInvokerRequestExecutor httpInvokerRequestExecutor = new CommonsHttpInvokerRequestExecutor(); DefaultHttpMethodRetryHandler retryHandler = new DefaultHttpMethodRetryHandler(10, false); httpInvokerRequestExecutor.getHttpClient().getParams().setParameter(HttpMethodParams.RETRY_HANDLER, retryHandler); httpInvokerRequestExecutor.getHttpClient().getParams().setSoTimeout(1000 * 60 * 5); { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(LoginService.class); httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "loginService"); httpInvokerProxyFactoryBean.afterPropertiesSet(); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); loginService = (LoginService) httpInvokerProxyFactoryBean.getObject(); } final String sessionId; if (secureConnect) { try { sessionId = loginService.doLogin(user, password); } catch (RemoteException e) { throw new RuntimeException(e); } } else { sessionId = ""; } if (sessionId == null) { getIssueReporterSingleton().reportWarning("Invalid user/password", null, new Runnable() { @Override public void run() { createLoginForm().show(); } }); } else { HttpInvokerProxyFactoryBean httpInvokerProxyFactoryBean = new HttpInvokerProxyFactoryBean(); httpInvokerProxyFactoryBean.setServiceUrl(serverAddress + "copperMonitoringService"); httpInvokerProxyFactoryBean.setServiceInterface(CopperMonitoringService.class); RemoteInvocationFactory remoteInvocationFactory = secureConnect ? new SecureRemoteInvocationFactory(sessionId) : new DefaultRemoteInvocationFactory(); httpInvokerProxyFactoryBean.setRemoteInvocationFactory(remoteInvocationFactory); httpInvokerProxyFactoryBean.setHttpInvokerRequestExecutor(httpInvokerRequestExecutor); httpInvokerProxyFactoryBean.afterPropertiesSet(); final CopperMonitoringService copperMonitoringService = (CopperMonitoringService) httpInvokerProxyFactoryBean .getObject(); final String serverAddressFinal = serverAddress; Platform.runLater(new Runnable() { @Override public void run() { setGuiCopperDataProvider(copperMonitoringService, serverAddressFinal, sessionId); } }); } }