All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.pac4j.oauth.profile.vk.VkProfile Maven / Gradle / Ivy

There is a newer version: 6.1.0
Show newest version
package org.pac4j.oauth.profile.vk;

import lombok.val;
import org.pac4j.core.profile.Gender;
import org.pac4j.core.util.CommonHelper;
import org.pac4j.core.util.Pac4jConstants;
import org.pac4j.oauth.profile.OAuth20Profile;

import java.io.Serial;
import java.net.URI;
import java.util.Date;
import java.util.Locale;
import java.util.Objects;

/**
 * 

This class is the user profile for Vk with appropriate getters.

*

It is returned by the {@link org.pac4j.oauth.client.VkClient}.

* * @author indvdum (gotoindvdum[at]gmail[dot]com) * @since 1.5 */ public class VkProfile extends OAuth20Profile { @Serial private static final long serialVersionUID = -7889265305949082980L; /** {@inheritDoc} */ @Override public String getDisplayName() { return String.format("%s %s", getFirstName(), getLastName()).trim(); } /** {@inheritDoc} */ @Override public String getUsername() { var domain = getDomain(); if (domain != null && !domain.isEmpty()) return domain; return getId(); } /** {@inheritDoc} */ @Override public URI getPictureUrl() { return CommonHelper.asURI(getFotoMax()); } /** {@inheritDoc} */ @Override public URI getProfileUrl() { return CommonHelper.asURI(String.format("https://vk.com/id%s", getId())); } /** {@inheritDoc} */ @Override public String getEmail() { return Pac4jConstants.EMPTY_STRING; } /** {@inheritDoc} */ @Override public String getFamilyName() { return getLastName(); } /** {@inheritDoc} */ @Override public Gender getGender() { val gender = (Gender) getAttribute(VkProfileDefinition.SEX); return Objects.requireNonNullElse(gender, Gender.UNSPECIFIED); } /** {@inheritDoc} */ @Override public Locale getLocale() { return null; } /** {@inheritDoc} */ @Override public String getLocation() { return null; } /** {@inheritDoc} */ @Override public String getFirstName() { return (String) getAttribute(VkProfileDefinition.FIRST_NAME); } /** *

getLastName.

* * @return a {@link String} object */ public String getLastName() { return (String) getAttribute(VkProfileDefinition.LAST_NAME); } /** *

getBirthDate.

* * @return a {@link Date} object */ public Date getBirthDate() { return (Date) getAttribute(VkProfileDefinition.BIRTH_DATE); } /** *

getFoto50.

* * @return a {@link String} object */ public String getFoto50() { return (String) getAttribute(VkProfileDefinition.PHOTO_50); } /** *

getFoto100.

* * @return a {@link String} object */ public String getFoto100() { return (String) getAttribute(VkProfileDefinition.PHOTO_100); } /** *

getFoto200Orig.

* * @return a {@link String} object */ public String getFoto200Orig() { return (String) getAttribute(VkProfileDefinition.PHOTO_200_ORIG); } /** *

getFoto200.

* * @return a {@link String} object */ public String getFoto200() { return (String) getAttribute(VkProfileDefinition.PHOTO_200); } /** *

getFoto400Orig.

* * @return a {@link String} object */ public String getFoto400Orig() { return (String) getAttribute(VkProfileDefinition.PHOTO_400_ORIG); } /** *

getFotoMax.

* * @return a {@link String} object */ public String getFotoMax() { return (String) getAttribute(VkProfileDefinition.PHOTO_MAX); } /** *

getFotoMaxOrig.

* * @return a {@link String} object */ public String getFotoMaxOrig() { return (String) getAttribute(VkProfileDefinition.PHOTO_MAX_ORIG); } /** *

isOnline.

* * @return a {@link Boolean} object */ public Boolean isOnline() { return (Boolean) getAttribute(VkProfileDefinition.ONLINE); } /** *

isOnlineMobile.

* * @return a {@link Boolean} object */ public Boolean isOnlineMobile() { return (Boolean) getAttribute(VkProfileDefinition.ONLINE_MOBILE); } /** *

getDomain.

* * @return a {@link String} object */ public String getDomain() { return (String) getAttribute(VkProfileDefinition.DOMAIN); } /** *

isHasMobile.

* * @return a {@link Boolean} object */ public Boolean isHasMobile() { return (Boolean) getAttribute(VkProfileDefinition.HAS_MOBILE); } /** *

getMobilePhone.

* * @return a {@link String} object */ public String getMobilePhone() { return (String) getAttribute(VkProfileDefinition.MOBILE_PHONE); } /** *

getHomePhone.

* * @return a {@link String} object */ public String getHomePhone() { return (String) getAttribute(VkProfileDefinition.HOME_PHONE); } /** *

getSkype.

* * @return a {@link String} object */ public String getSkype() { return (String) getAttribute(VkProfileDefinition.SKYPE); } /** *

getSite.

* * @return a {@link String} object */ public String getSite() { return (String) getAttribute(VkProfileDefinition.SITE); } /** *

isCanPost.

* * @return a {@link Boolean} object */ public Boolean isCanPost() { return (Boolean) getAttribute(VkProfileDefinition.CAN_POST); } /** *

isCanSeeAllPost.

* * @return a {@link Boolean} object */ public Boolean isCanSeeAllPost() { return (Boolean) getAttribute(VkProfileDefinition.CAN_SEE_ALL_POST); } /** *

isCanSeeAudio.

* * @return a {@link Boolean} object */ public Boolean isCanSeeAudio() { return (Boolean) getAttribute(VkProfileDefinition.CAN_SEE_AUDIO); } /** *

isCanWritePrivateMessage.

* * @return a {@link Boolean} object */ public Boolean isCanWritePrivateMessage() { return (Boolean) getAttribute(VkProfileDefinition.CAN_WRITE_PRIVATE_MESSAGE); } /** *

getStatus.

* * @return a {@link String} object */ public String getStatus() { return (String) getAttribute(VkProfileDefinition.STATUS); } /** *

getCommonCount.

* * @return a {@link Integer} object */ public Integer getCommonCount() { return (Integer) getAttribute(VkProfileDefinition.COMMON_COUNT); } /** *

getRelation.

* * @return a {@link Integer} object */ public Integer getRelation() { return (Integer) getAttribute(VkProfileDefinition.RELATION); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy