@Override public String getAuthenticationToken(int userId) { return userDao.getAuthenticationToken(userId); }
@Override public String getObject() { if (ThreadLocalUserContext.getUserId().equals(user.getId()) == true) { return userDao.getAuthenticationToken(user.getId()); } else { // Administrators shouldn't see the token. return "*****"; } } }));
/** * for faster access (due to permanent usage e. g. by subscription of calendars * * @param userId * @return */ @Override public String getCachedAuthenticationToken(final Integer userId) { final PFUserDO user = getUserGroupCache().getUser(userId); if (user == null) { return null; } final String authenticationToken = user.getAuthenticationToken(); if (StringUtils.isBlank(authenticationToken) == false && authenticationToken.trim().length() >= 10) { return authenticationToken; } return userDao.getAuthenticationToken(userId); }
/** * @param additionalParams Request parameters such as "&calId=42", may be null. * @return The url for downloading calendars (without context), e. g. /export/ProjectForge.ics?user=... */ public String getUrl(final String additionalParams) { final PFUserDO user = ThreadLocalUserContext.getUser(); final String authenticationKey = userDao.getAuthenticationToken(user.getId()); final StringBuilder buf = new StringBuilder(); buf.append("token=").append(authenticationKey); if (additionalParams != null) { buf.append(additionalParams); } final String encryptedParams = userService.encrypt(buf.toString()); final String result = "/export/ProjectForge.ics?user=" + user.getId() + "&q=" + encryptedParams; return result; } }
/** * Authentication via http header authenticationUsername and authenticationPassword.<br/> * For getting the user's authentication token. This token can be stored in the client (e. g. mobile app). The user's * password shouldn't be stored in the client for security reasons. The authentication token is renewable through the * ProjectForge's web app (my account). * * @return {@link UserObject} */ @GET @Path(RestPaths.AUTHENTICATE_GET_TOKEN_METHOD) @Produces(MediaType.APPLICATION_JSON) public Response getToken() { final PFUserDO user = ThreadLocalUserContext.getUser(); if (user == null) { log.error("No user given for rest call."); throw new IllegalArgumentException("No user given for the rest call: authenticate/getToken."); } final UserObject userObject = PFUserDOConverter.getUserObject(user); final String authenticationToken = userDao.getAuthenticationToken(user.getId()); userObject.setAuthenticationToken(authenticationToken); final String json = JsonUtils.toJson(userObject); return Response.ok(json).build(); }