/** * The user's birthday, typed to {@code java.util.Date} if possible. * * @return The user's birthday, or {@code null} if unavailable or only available in month/year format. */ public Date getBirthdayAsDate() { if (isBlank(getBirthday()) || getBirthday().split("/").length < 2) { return null; } return toDateFromShortFormat(birthday); }
/** * The user's hometown name. * * @return The user's hometown name. */ public String getHometownName() { if (getHometown() != null) return getHometown().getName(); return hometownAsString; }
String email = me.getEmail(); String firstName = me.getFirstName(); String lastName = me.getLastName(); String name = me.getName(); Boolean verified = me.getVerified();
Guest guest = guestService.getGuest(user.getUsername()); final String autoLoginToken = generateSecureRandomString(); if (guest==null) { FacebookClient.AccessToken accessToken = new DefaultFacebookClient().obtainExtendedAccessToken(appId, appSecret, access_token); String firstname = user.getFirstName(); String lastname = user.getLastName(); guest = guestService.createGuest(user.getUsername(), firstname!=null?firstname:"", lastname!=null?lastname:"", null, user.getEmail(), Guest.RegistrationMethod.REGISTRATION_METHOD_FACEBOOK, null); final ApiKey apiKey = guestService.createApiKey(guest.getId(), Connector.getConnector("facebook"));
@Override public Identity identity() throws IOException { Identity identity = Identity.ANONYMOUS; if (this.resource.uriInfo().getQueryParameters() .containsKey(Facebook.FLAG)) { final List<String> code = this.resource.uriInfo() // @checkstyle MultipleStringLiterals (1 line) .getQueryParameters().get("code"); if (code == null || code.isEmpty()) { throw new WebApplicationException( new IllegalArgumentException( "HTTP query parameter 'code' is mandatory" ), HttpURLConnection.HTTP_BAD_REQUEST ); } final User fbuser = this.fetch(this.token(code.get(0))); identity = new Identity.Simple( URN.create(String.format("urn:facebook:%s", fbuser.getId())), fbuser.getName(), UriBuilder.fromUri("https://graph.facebook.com/") .path("/{id}/picture") .build(fbuser.getId()) ); } return identity; }
@Override public Opt<Identity> enter(final Request trequest) throws IOException { final Href href = new RqHref.Base(trequest).href(); final Iterator<String> code = href.param(PsFacebook.CODE).iterator(); if (!code.hasNext()) { throw new HttpException( HttpURLConnection.HTTP_BAD_REQUEST, "code is not provided by Facebook" ); } final User user = this.fetch( this.token(href.toString(), code.next()) ); final Map<String, String> props = new HashMap<>(0); props.put("name", user.getName()); props.put( PsFacebook.PICTURE, new Href("https://graph.facebook.com/") .path(user.getId()) .path(PsFacebook.PICTURE) .toString() ); return new Opt.Single<>( new Identity.Simple( String.format("urn:facebook:%s", user.getId()), props ) ); }
@Override public Opt<Identity> enter(final Request trequest) throws IOException { final Href href = new RqHref.Base(trequest).href(); final Iterator<String> code = href.param(PsFacebook.CODE).iterator(); if (!code.hasNext()) { throw new HttpException( HttpURLConnection.HTTP_BAD_REQUEST, "code is not provided by Facebook" ); } final User user = this.fetch( this.token(href.toString(), code.next()) ); final Map<String, String> props = new HashMap<>(0); props.put("name", user.getName()); props.put( PsFacebook.PICTURE, new Href("https://graph.facebook.com/") .path(user.getId()) .path(PsFacebook.PICTURE) .toString() ); return new Opt.Single<>( new Identity.Simple( String.format("urn:facebook:%s", user.getId()), props ) ); }
/** * The user's hometown name. * * @return The user's hometown name. */ public String getHometownName() { if (getHometown() != null) return getHometown().getName(); return hometownAsString; }
/** * The user's birthday, typed to {@code java.util.Date} if possible. * * @return The user's birthday, or {@code null} if unavailable or only * available in month/year format. */ public Date getBirthdayAsDate() { if (isBlank(getBirthday()) || getBirthday().split("/").length < 2) return null; return toDateFromShortFormat(birthday); }