protected static String getOwnerMail() {
    Authentication currentAuthentication = SecurityContextHolder.getContext().getAuthentication();
    String email = "";
    if (currentAuthentication instanceof SocialAuthenticationToken) {
      SocialAuthenticationToken social = (SocialAuthenticationToken) currentAuthentication;

      switch (social.getProviderId()) {
        case ("google"):
          Google google = (Google) social.getConnection().getApi();
          email = google.plusOperations().getGoogleProfile().getAccountEmail();
          break;
        case ("facebook"):
          Facebook facebook = (Facebook) social.getConnection().getApi();
          email = facebook.userOperations().getUserProfile().getEmail();
          break;
      }
    } else if (currentAuthentication instanceof UsernamePasswordAuthenticationToken) {
      UsernamePasswordAuthenticationToken local =
          (UsernamePasswordAuthenticationToken) currentAuthentication;
      email = (String) local.getPrincipal();
    } else if (currentAuthentication instanceof AnonymousAuthenticationToken) {
      return null;
    }
    return email;
  }
 public void setConnectionValues(Google google, ConnectionValues values) {
   GoogleProfile profile = google.userOperations().getUserProfile();
   values.setProviderUserId(profile.getId());
   values.setDisplayName(profile.getName());
   values.setProfileUrl(profile.getLink());
   values.setImageUrl(profile.getProfilePictureUrl());
 }
Пример #3
0
 @ResponseBody
 @RequestMapping(value = "/moments/delete", method = POST)
 public void deleteMoment(@RequestBody String id) {
   try {
     google.plusOperations().deleteMoment(id);
   } catch (HttpClientErrorException e) {
     System.out.println(e.getResponseBodyAsString());
   }
 }
 public UserProfile fetchUserProfile(Google google) {
   GoogleProfile profile = google.userOperations().getUserProfile();
   return new UserProfileBuilder()
       .setUsername(profile.getEmail())
       .setEmail(profile.getEmail())
       .setName(profile.getName())
       .setFirstName(profile.getFirstName())
       .setLastName(profile.getLastName())
       .build();
 }
Пример #5
0
 @ResponseBody
 @RequestMapping(value = "/moments/insert", method = POST)
 public Moment insertMoment(@RequestBody Moment moment) {
   return google.plusOperations().insertMoment(moment);
 }
Пример #6
0
 @ResponseBody
 @RequestMapping("/moments/list")
 public MomentsPage listMoments(String pageToken) {
   return google.plusOperations().getMoments(pageToken);
 }
Пример #7
0
 @ResponseBody
 @RequestMapping("/activities/{activityId}/comments")
 public ActivityCommentsPage getComments(
     @PathVariable String activityId, @RequestParam(required = false) String pageToken) {
   return google.plusOperations().getComments(activityId, pageToken);
 }
Пример #8
0
 @ResponseBody
 @RequestMapping("/activities/{id}")
 public Activity getActivity(@PathVariable String id) {
   return google.plusOperations().getActivity(id);
 }
Пример #9
0
 @ResponseBody
 @RequestMapping("/activities/list/{profileId}")
 public ActivitiesPage getActivities(@PathVariable String profileId, String pageToken) {
   return google.plusOperations().getActivities(profileId, pageToken);
 }
Пример #10
0
 @ResponseBody
 @RequestMapping("/activities/search")
 public ActivitiesPage searchPublicActivities(
     String query, @RequestParam(required = false) String pageToken) {
   return google.plusOperations().searchPublicActivities(query, pageToken);
 }
Пример #11
0
 @ResponseBody
 @RequestMapping("/people/{activityId}/resharers")
 public PeoplePage getResharers(
     @PathVariable String activityId, @RequestParam(required = false) String pageToken) {
   return google.plusOperations().getActivityResharers(activityId, pageToken);
 }
Пример #12
0
 @ResponseBody
 @RequestMapping("/people/{id}/circles")
 public PeoplePage getCircles(
     @PathVariable String id, @RequestParam(required = false) String pageToken) {
   return google.plusOperations().getPeopleInCircles(id, pageToken);
 }
Пример #13
0
 @ResponseBody
 @RequestMapping("/people/{id}")
 public Person getPerson(@PathVariable String id) {
   return google.plusOperations().getPerson(id);
 }
Пример #14
0
 @ResponseBody
 @RequestMapping("/people")
 public PeoplePage searchPeople(String query, @RequestParam(required = false) String pageToken) {
   return google.plusOperations().searchPeople(query, pageToken);
 }