List of usage examples for org.springframework.remoting RemoteAccessException getMessage
@Override
@Nullable
public String getMessage()
From source file:de.juwimm.cms.util.Communication.java
public SiteValue[] getSites(String userName, String passwd) throws InvalidUsernameException, NoSitesException, LocalizedException { log.info("Trying to fetching Sites for User " + userName); try {/*from ww w .ja v a 2 s. co m*/ SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_GLOBAL); RemoteAuthenticationManager remoteAuthenticationService = RemoteServiceLocator.instance() .getRemoteAuthenticationService(); GrantedAuthority[] authorities = remoteAuthenticationService.attemptAuthentication(userName, String.valueOf(passwd)); SecurityContextHolder.getContext().setAuthentication( new UsernamePasswordAuthenticationToken(userName, String.valueOf(passwd), authorities)); log.debug(SecurityContextHolder.getContext().getAuthentication()); } catch (RemoteAccessException e) { if (e.getCause() != null && e.getCause() instanceof SpringSecurityException) { log.info("authentication failed: " + e.getMessage()); throw new InvalidUsernameException(); } LocalizedException ge = new LocalizedException("communication.login.unkwownError", "unknown error", e); ge.logThrowException(); throw ge; } try { ClientServiceSpring cs = getClientService(); SiteValue[] sites = cs.getSites(); return sites; } catch (Exception e) { // e.printStackTrace(); throw new NoSitesException("No sites associated?", e); } }