use of com.pratilipi.data.type.AccessToken in project pratilipi by Pratilipi.
the class AccessTokenDataUtil method newUserAccessToken.
public static AccessToken newUserAccessToken(HttpServletRequest request) {
DataAccessor dataAccessor = DataAccessorFactory.getDataAccessor();
AccessToken accessToken = dataAccessor.newAccessToken();
accessToken.setUserId(0L);
accessToken.setDeviceLocation(request.getHeader("X-AppEngine-City"), request.getHeader("X-AppEngine-Region"), request.getHeader("X-AppEngine-Country"));
accessToken.setDeviceUserAgent(request.getHeader("User-Agent"));
accessToken.setExpiry(new Date(new Date().getTime() + MAX_EXPIRY_MILLIS));
accessToken.setCreationDate(new Date());
accessToken = dataAccessor.createOrUpdateAccessToken(accessToken);
return accessToken;
}
use of com.pratilipi.data.type.AccessToken in project pratilipi by Pratilipi.
the class TagsApi method addTags.
@Post
public GenericResponse addTags(PostRequest request) throws InsufficientAccessException {
// Security Hack
AccessToken accessToken = AccessTokenFilter.getAccessToken();
if (accessToken.getUserId() != 5073076857339904L) {
Logger.getLogger(TagsApi.class.getSimpleName()).log(Level.SEVERE, "AccessToken : " + accessToken.getId());
Logger.getLogger(TagsApi.class.getSimpleName()).log(Level.SEVERE, "User Id : " + accessToken.getUserId());
throw new InsufficientAccessException();
}
Gson gson = new Gson();
// Creating TagData object.
TagData tagData = gson.fromJson(gson.toJson(request), TagData.class);
tagData = TagDataUtil.saveTag(tagData);
return new GenericResponse();
}
Aggregations