Java Code Examples for com.akaxin.proto.core.ConfigProto#RealNameConfig

The following examples show how to use com.akaxin.proto.core.ConfigProto#RealNameConfig . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SiteConfig.java    From wind-im with Apache License 2.0 5 votes vote down vote up
public static ConfigProto.RealNameConfig getRealNameConfig() {
	ConfigProto.RealNameConfig realNameConfig = null;
	if (getConfigMap() != null) {
		String value = getConfigMap().get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE);
		if (StringUtils.isNumeric(value)) {
			realNameConfig = ConfigProto.RealNameConfig.forNumber(Integer.valueOf(value));
		}
	}
	return realNameConfig == null ? ConfigProto.RealNameConfig.REALNAME_NO : realNameConfig;
}
 
Example 2
Source File: SiteConfig.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public static ConfigProto.RealNameConfig getRealNameConfig() {
	ConfigProto.RealNameConfig realNameConfig = null;
	if (getConfigMap() != null) {
		String value = getConfigMap().get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE);
		if (StringUtils.isNumeric(value)) {
			realNameConfig = ConfigProto.RealNameConfig.forNumber(Integer.valueOf(value));
		}
	}
	return realNameConfig == null ? ConfigProto.RealNameConfig.REALNAME_NO : realNameConfig;
}
 
Example 3
Source File: SiteConfig.java    From openzaly with Apache License 2.0 5 votes vote down vote up
public static ConfigProto.RealNameConfig getRealNameConfig() {
	ConfigProto.RealNameConfig realNameConfig = null;
	if (getConfigMap() != null) {
		String value = getConfigMap().get(ConfigProto.ConfigKey.REALNAME_STATUS_VALUE);
		if (StringUtils.isNumeric(value)) {
			realNameConfig = ConfigProto.RealNameConfig.forNumber(Integer.valueOf(value));
		}
	}
	return realNameConfig == null ? ConfigProto.RealNameConfig.REALNAME_NO : realNameConfig;
}
 
Example 4
Source File: ApiSiteService.java    From wind-im with Apache License 2.0 4 votes vote down vote up
private String verifyPlatformPhoneAndGetGlobalUserId(String userIdPubk, String phoneToken) throws ZalyException2 {
	phoneToken = null;
	if (StringUtils.isEmpty(phoneToken)) {
		logger.debug("api.site.login with phoneToken={}", phoneToken);
		return UserIdUtils.getV1GlobalUserId(userIdPubk);
	}

	// 登陆去平台校验实名机制
	ConfigProto.RealNameConfig realNameConfig = SiteConfig.getRealNameConfig();

	if (ConfigProto.RealNameConfig.REALNAME_YES == realNameConfig) {
		PlatformPhoneBean bean = PlatformUserPhone.getInstance().getPhoneIdFromPlatform(phoneToken);
		String fullPhoneId = bean.getFullPhoneId();
		String platformUserIdPubk = bean.getUserIdPubk();
		logger.debug("get platform realname phone info bean={}", bean);

		if (StringUtils.isEmpty(fullPhoneId)) {
			return UserIdUtils.getV1GlobalUserId(userIdPubk);
		}

		if (!userIdPubk.equals(platformUserIdPubk)) {
			logger.error("api.site.login equals={} userIdPubk={} platformUserIdPubk={}", false, userIdPubk,
					platformUserIdPubk);
			return UserIdUtils.getV1GlobalUserId(userIdPubk);
		}

		// 手机号查询用户身份
		UserProfileBean profile = UserProfileDao.getInstance().getUserProfileByFullPhoneId(fullPhoneId);

		if (profile != null && StringUtils.isNoneEmpty(platformUserIdPubk, profile.getUserIdPubk())) {

			if (platformUserIdPubk.equals(profile.getUserIdPubk())) {
				logger.debug("new site realname login verifyPlatformPhone success");
				return UserIdUtils.getV1GlobalUserId(platformUserIdPubk);
			} else {
				// 更新数据
				String globalUserId = UserIdUtils.getV1GlobalUserId(platformUserIdPubk);
				boolean updateRes = UserProfileDao.getInstance().updateUserIdPubk(profile.getSiteUserId(),
						globalUserId, userIdPubk);

				if (!updateRes) {
					throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_UPDATENEWPUBK);
				}
			}

		}

	}

	return UserIdUtils.getV1GlobalUserId(userIdPubk);
}
 
Example 5
Source File: ApiSiteService.java    From openzaly with Apache License 2.0 4 votes vote down vote up
private String verifyPlatformPhoneAndGetGlobalUserId(String userIdPubk, String phoneToken) throws ZalyException2 {
	phoneToken = null;
	if (StringUtils.isEmpty(phoneToken)) {
		logger.debug("api.site.login with phoneToken={}", phoneToken);
		return UserIdUtils.getV1GlobalUserId(userIdPubk);
	}

	// 登陆去平台校验实名机制
	ConfigProto.RealNameConfig realNameConfig = SiteConfig.getRealNameConfig();

	if (ConfigProto.RealNameConfig.REALNAME_YES == realNameConfig) {
		PlatformPhoneBean bean = PlatformUserPhone.getInstance().getPhoneIdFromPlatform(phoneToken);
		String fullPhoneId = bean.getFullPhoneId();
		String platformUserIdPubk = bean.getUserIdPubk();
		logger.debug("get platform realname phone info bean={}", bean);

		if (StringUtils.isEmpty(fullPhoneId)) {
			return UserIdUtils.getV1GlobalUserId(userIdPubk);
		}

		if (!userIdPubk.equals(platformUserIdPubk)) {
			logger.error("api.site.login equals={} userIdPubk={} platformUserIdPubk={}", false, userIdPubk,
					platformUserIdPubk);
			return UserIdUtils.getV1GlobalUserId(userIdPubk);
		}

		// 手机号查询用户身份
		UserProfileBean profile = UserProfileDao.getInstance().getUserProfileByFullPhoneId(fullPhoneId);

		if (profile != null && StringUtils.isNoneEmpty(platformUserIdPubk, profile.getUserIdPubk())) {

			if (platformUserIdPubk.equals(profile.getUserIdPubk())) {
				logger.debug("new site realname login verifyPlatformPhone success");
				return UserIdUtils.getV1GlobalUserId(platformUserIdPubk);
			} else {
				// 更新数据
				String globalUserId = UserIdUtils.getV1GlobalUserId(platformUserIdPubk);
				boolean updateRes = UserProfileDao.getInstance().updateUserIdPubk(profile.getSiteUserId(),
						globalUserId, userIdPubk);

				if (!updateRes) {
					throw new ZalyException2(ErrorCode2.ERROR2_LOGGIN_UPDATENEWPUBK);
				}
			}

		}

	}

	return UserIdUtils.getV1GlobalUserId(userIdPubk);
}