List of usage examples for java.rmi RemoteException getMessage
public String getMessage()
From source file:com.criticalsoftware.mobics.presentation.extension.DefaultExceptionHandler.java
/** * If there's an ActionBean present, send the user back where they came from with a stern warning, otherwise send * them to the global error page./*w w w . j ava2 s.co m*/ * * @param exception a remote exception * @param request The HttpServletRequest * @param response The HttpServletResponse * @return A ForwardResolution */ public Resolution handle(RemoteException exception, HttpServletRequest request, HttpServletResponse response) { LOGGER.error(exception.getMessage(), exception); return insideJobToError("error.RemoteException", request, response); }
From source file:edu.indiana.d2i.htrc.oauth2.filter.OAuth2Filter.java
/** * Extract the access token from servlet request header and validate it via WSO2 IS. If token is invalid or * expired filter will throw a error and stop of handing over the request to next filter in chain. If there is no * token header filter will reject the request without any checks. * @param servletRequest in-coming request object * @param servletResponse servlet response object * @param filterChain servlet filter chain * @throws IOException/*from w w w . j av a2s . c om*/ * @throws ServletException */ public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException { String errMsg = null; String requestId = randomUUID(); HttpServletRequest req = (HttpServletRequest) servletRequest; HttpServletResponse res = (HttpServletResponse) servletResponse; OAuth2RequestWrapper modifiedRequest = new OAuth2RequestWrapper(req); modifiedRequest.setRequestId(requestId); modifiedRequest.setRemoteAddress(req.getRemoteAddr()); ContextExtractor contextExtractor = new ContextExtractor(req); Auditor auditor = AuditorFactory.getAuditor(contextExtractor.getContextMap()); String accessToken = null; OAuth2TokenValidationResponseDTO responseDTO = null; try { OAuthAccessResourceRequest accessResourceRequest = new OAuthAccessResourceRequest(req, TokenType.BEARER); accessToken = accessResourceRequest.getAccessToken(); auditor.log("OAUTH2_FILTER_REQUEST_RECEIVED", requestId, accessToken); Enumeration headerNames = req.getHeaderNames(); while (headerNames.hasMoreElements()) { String headerName = (String) headerNames.nextElement(); auditor.log(headerName, ":", req.getHeader(headerName)); } responseDTO = validateToken(accessToken); List<String> registered_user = new ArrayList<String>(); registered_user.add(responseDTO.getAuthorizedUser()); if (responseDTO.getAuthorizedUser() != null) { modifiedRequest.setRemoteUser(responseDTO.getAuthorizedUser()); } Map<String, List<String>> contextMap = contextExtractor.getContextMap(); if (responseDTO.getAuthorizedUser() != null) { contextMap.put(KEY_REMOTE_USER, registered_user); } // We need to create new auditor instance after we create the context map out of servlet request. auditor = AuditorFactory.getAuditor(contextMap); auditor.log("OAUTH2_FILTER_REQUEST_AUTHENTICATED", requestId, accessToken); } catch (OAuthProblemException e) { errMsg = "OAuth exception."; log.error(errMsg, e); auditor.log("OAUTH2_FILTER_UNAUTHENTICATED_REQUEST", requestId, accessToken); auditor.error(errMsg, accessToken, e.getError(), e.getMessage()); respondWithError(res, e); return; } catch (OAuthSystemException e) { errMsg = "OAuth system exception."; log.error(errMsg, e); auditor.log("OAUTH2_FILTER_UNAUTHENTICATED_REQUEST", requestId, accessToken); auditor.error(errMsg, accessToken, e.getMessage()); throw new ServletException(e); } catch (RemoteException re) { errMsg = "Error occurred while invoking token validation service."; log.error(errMsg, re); auditor.log("OAUTH2_FILTER_UNAUTHENTICATED_REQUEST", requestId, accessToken); auditor.error(errMsg, accessToken, re.getMessage()); throw new ServletException(errMsg, re); } filterChain.doFilter(modifiedRequest, servletResponse); }
From source file:edu.umd.lib.servlets.permissions.PermissionsServlet.java
@Override public void destroy() { // close repository log.info("Closing repository."); if (repository != null) { repository.close();//w w w .j a v a 2s. c o m repository = null; } // done log.info("Repository closed."); if (startRemoteServer) { // unbinding from registry String name = null; try { name = new RepositoryUrl(bindingAddress).getName(); log.info("Unbinding '" + name + "' from registry."); registry.unbind(name); } catch (RemoteException e) { log.error("Error during unbinding '" + name + "': " + e.getMessage()); } catch (NotBoundException e) { log.error("Error during unbinding '" + name + "': " + e.getMessage()); } catch (MalformedURLException e) { log.error("MalformedURLException while parsing '" + bindingAddress + "': " + e.getMessage()); } // unexporting from registry try { log.info("Unexporting rmi repository: " + bindingAddress); UnicastRemoteObject.unexportObject(rmiRepository, true); } catch (NoSuchObjectException e) { log.error("Error during rmi shutdown for address: " + bindingAddress, e); } // shutdown registry if (registryIsEmbedded) { try { log.info("Closing rmiregistry: " + bindingAddress); UnicastRemoteObject.unexportObject(registry, true); } catch (NoSuchObjectException e) { log.error("Error during rmi shutdown for address: " + bindingAddress, e); } } // force the distributed GC to fire, otherwise in tomcat with embedded // rmi registry the process won't end // this procedure is necessary specifically for Tomcat log.info("Repository terminated, waiting for garbage to clear"); Thread garbageClearThread = new Thread("garbage clearer") { @Override public void run() { for (int i = 0; i < 5; i++) { try { Thread.sleep(3000); System.gc(); } catch (InterruptedException ignored) { } } } }; garbageClearThread.setDaemon(true); garbageClearThread.start(); } if (repositoryService != null) { HippoServiceRegistry.unregisterService(repositoryService, RepositoryService.class); } if (repositoryClusterService != null) { HippoServiceRegistry.unregisterService(repositoryClusterService, RepositoryClusterService.class); } }
From source file:net.sf.ehcache.distribution.RMICacheManagerPeerListener.java
/** * Returns a list of bound objects.//from w w w . ja v a2s . co m * <p/> * This should match the list of cachePeers i.e. they should always be bound * * @return a list of String representations of <code>RMICachePeer</code> objects */ protected String[] listBoundRMICachePeers() throws CacheException { try { return registry.list(); } catch (RemoteException e) { throw new CacheException("Unable to list cache peers " + e.getMessage()); } }
From source file:edu.northwestern.bioinformatics.studycalendar.grid.PSCAdverseEventConsumerTest.java
public void testAuthorizationForUserWithoutAeReporterRole() throws Exception { logger.info("### Running Authorization test with no AE_REPORTER role"); AENotificationType ae = getNotification(); adverseEventConsumer.setGridServicesAuthorizationHelper(gridServicesAuthorizationHelper); adverseEventConsumer.setPscUserDetailsService(pscUserDetailsService); expect(gridServicesAuthorizationHelper.getCurrentUsername()).andReturn("John"); expect(pscUserDetailsService.loadUserByUsername("John")).andReturn(userWithoutAeReporterRole); EasyMock.replay(gridServicesAuthorizationHelper); EasyMock.replay(pscUserDetailsService); try {//from w w w. java 2 s . com adverseEventConsumer.register(ae); fail("Authorization Failed: RegsitrationConsumer should've thrown an exception!"); } catch (RemoteException e) { assertEquals("Test failed:", "Access Denied: user does not have AE_REPORTER role", e.getMessage()); } EasyMock.verify(gridServicesAuthorizationHelper); EasyMock.verify(pscUserDetailsService); assertTrue("must not have any notificaitons.", studySubjectAssignment.getNotifications().isEmpty()); logger.info("### End Authorization test with no AE_REPORTER role"); }
From source file:com.heliumv.api.BaseApi.java
public void respondUnavailable(RemoteException e) { log.info("default-log", e); getServletResponse().setHeader(X_HV_ERROR_CODE, HvErrorCode.REMOTE_EXCEPTION.toString()); getServletResponse().setHeader(X_HV_ERROR_CODE_DESCRIPTION, e.getMessage()); getServletResponse().setStatus(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()); }
From source file:com.heliumv.api.BaseApi.java
public Response getUnavailable(RemoteException e) { return getResponseBuilder().status(Response.Status.INTERNAL_SERVER_ERROR) .header(X_HV_ERROR_CODE, HvErrorCode.REMOTE_EXCEPTION.toString()) .header(X_HV_ERROR_CODE_DESCRIPTION, e.getMessage()).build(); }
From source file:au.com.jwatmuff.genericp2p.rmi.RMIPeerManager.java
@Override public void unregisterService(String serviceName) { PeerService service = peerServiceMap.remove(serviceName); if (service == null) { log.warn("Attempt to unregister unknown service: " + serviceName); return;/*from ww w . j a v a 2 s . c o m*/ } try { service.exporter.destroy(); } catch (RemoteException e) { log.error(e.getMessage(), e); } }
From source file:edu.northwestern.bioinformatics.studycalendar.grid.PSCAdverseEventConsumerTest.java
public void testAuthorizationForAeReporterRoleWithCorrectStudyNoStudySite() throws Exception { logger.info("### Running Authorization test AE_REPORTER role, associated Study and no studySite"); AENotificationType ae = getNotification(); adverseEventConsumer.setGridServicesAuthorizationHelper(gridServicesAuthorizationHelper); adverseEventConsumer.setPscUserDetailsService(pscUserDetailsService); expect(gridServicesAuthorizationHelper.getCurrentUsername()).andReturn("John"); expect(pscUserDetailsService.loadUserByUsername("John")).andReturn(userWithIncorrectStudySite); EasyMock.replay(gridServicesAuthorizationHelper); EasyMock.replay(pscUserDetailsService); try {/* w w w. j a va 2s . c om*/ adverseEventConsumer.register(ae); fail("Authorization Failed: RegsitrationConsumer should've thrown an exception!"); } catch (RemoteException e) { assertEquals("Test failed:", "Access Denied: AE_REPORTER is not authorized for this Site Identifier : SITE_01", e.getMessage()); } EasyMock.verify(gridServicesAuthorizationHelper); EasyMock.verify(pscUserDetailsService); assertTrue("must not have any notificaitons.", studySubjectAssignment.getNotifications().isEmpty()); logger.info("### End Authorization test AE_REPORTER role, associated Study and no studySite"); }
From source file:edu.northwestern.bioinformatics.studycalendar.grid.PSCAdverseEventConsumerTest.java
public void testAuthorizationForAeReporterRoleWithNoStudy() throws Exception { logger.info("### Running Authorization test AE_REPORTER role and no study"); AENotificationType ae = getNotification(); adverseEventConsumer.setGridServicesAuthorizationHelper(gridServicesAuthorizationHelper); adverseEventConsumer.setPscUserDetailsService(pscUserDetailsService); expect(gridServicesAuthorizationHelper.getCurrentUsername()).andReturn("John"); expect(pscUserDetailsService.loadUserByUsername("John")).andReturn(userWithIncorrectStudy); EasyMock.replay(gridServicesAuthorizationHelper); EasyMock.replay(pscUserDetailsService); try {//from www. j ava2 s. com adverseEventConsumer.register(ae); fail("Authorization Failed: RegsitrationConsumer should've thrown an exception!"); } catch (RemoteException e) { assertEquals("Test failed:", "Access Denied: AE_REPORTER is not authorized for this Study Identifier : TEST_STUDY", e.getMessage()); } EasyMock.verify(gridServicesAuthorizationHelper); EasyMock.verify(pscUserDetailsService); assertTrue("must not have any notificaitons.", studySubjectAssignment.getNotifications().isEmpty()); logger.info("### End Authorization test AE_REPORTER role and no study"); }