/** * Update user password. * * @param headers * @param username * @return * @throws IOException * @throws JargonException */ @RequestMapping(value = "/services/users/{username}/updatepwd", method = RequestMethod.GET) @ResponseBody public IBIOMESResponse updateUserPassword( @PathVariable("username") String username, @RequestParam("oldPwd") String oldPwd, @RequestParam("newPwd") String newPwd) throws JargonException, IOException { IRODSAccount irodsAccount = (IRODSAccount) request.getSession().getAttribute("SPRING_SECURITY_CONTEXT"); UserAO userAO = irodsAccessObjectFactory.getUserAO(irodsAccount); try { userAO.changeAUserPasswordByThatUser(username, oldPwd, newPwd); // create new iRODS account object to reflect changes IRODSAccount newAccount = IRODSAccount.instance( irodsAccount.getHost(), irodsAccount.getPort(), irodsAccount.getUserName(), newPwd, irodsAccount.getHomeDirectory(), irodsAccount.getZone(), irodsAccount.getDefaultStorageResource()); IRODSSession session = irodsAccessObjectFactory.getIrodsSession(); // TODO UPDATE SESSION INFO!!! OR SOEMTHING WRONG HERE... AuthResponse authResponse = null; IRODSAccessObjectFactory accessAO = IRODSAccessObjectFactoryImpl.instance(session); try { request.getSession().removeAttribute("SPRING_SECURITY_CONTEXT"); authResponse = accessAO.authenticateIRODSAccount(newAccount); session.currentConnection(authResponse.getAuthenticatedIRODSAccount()); request .getSession() .setAttribute("SPRING_SECURITY_CONTEXT", authResponse.getAuthenticatedIRODSAccount()); } catch (JargonException e) { e.printStackTrace(); return new IBIOMESResponse( false, "Cannot update session information. Exception: " + e.getLocalizedMessage(), null); } } catch (AuthenticationException exc) { return new IBIOMESResponse(false, "Current password is not correct", null); } return new IBIOMESResponse(true, "Password successfully updated", null); }