闪验业务流程
官网提供了demo下载(有签名工具类,发送http请求工具类,加解密工具类):

下面贴出核心业务代码:

package com.pica.cloud.account.account.server.model;import com.alibaba.fastjson.JSONObject;
import com.pica.cloud.account.account.server.entity.LogLoginOnekey;
import com.pica.cloud.account.account.server.entity.MobileDataEntity;
import com.pica.cloud.account.account.server.entity.QueryMobileEntity;
import com.pica.cloud.account.account.server.mapper.LogLoginOnekeyMapper;
import com.pica.cloud.account.account.server.util.AESUtil;
import com.pica.cloud.account.account.server.util.HttpUtil;
import com.pica.cloud.account.account.server.util.MD5;
import com.pica.cloud.account.account.server.util.RSAUtil;
import com.pica.cloud.account.account.server.util.SignUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* 创蓝闪验-一键登录
*/
@Component
public class OneClickProcessor {private static final String DEFAULT_ENCRYPT_TYPE = "0";private Logger logger = LoggerFactory.getLogger(this.getClass());//手机号加解密方式 0 AES 1 RSA , 可以不传,不传则手机号解密直接使用AES解密private String aesEncryptType = DEFAULT_ENCRYPT_TYPE;private String rsaEncryptType = "1";private String encryptType = DEFAULT_ENCRYPT_TYPE;private static final String SHANYAN_SUCCESS_CODE = "200000";//创建应用时填入的rsa公钥对应的私钥字符串public static final String privateKey = "";public static final Integer TYPE_IOS = 2;public static final Integer TYPE_ANDROID = 1;private static final String TOKEN = "token";private static final String APPID = "appId";private static final String ENCRYPT_TYPE = "encryptType";private static final String SIGN = "sign";@Value("${shanyan.url.mobilequery}")private String mobileQueryUrl;@Value("${shanyan.android.appId}")private String androidAppId;@Value("${shanyan.android.appKey}")private String androidAppKey;@Value("${shanyan.ios.appId}")private String iosAppId;@Value("${shanyan.ios.appKey}")private String iosAppKey;@Autowiredprivate LogLoginOnekeyMapper logLoginOnekeyMapper;public QueryMobileEntity tokenExchangeMobile(String token, Integer type) {if (type == null || StringUtils.isEmpty(token)) {return null;}String appId;String appKey;if (type.equals(TYPE_ANDROID)) {appId = androidAppId;appKey = androidAppKey;} else if (type.equals(TYPE_IOS)) {appId = iosAppId;appKey = iosAppKey;} else {return null;}//从SDK获取的token参数QueryMobileEntity queryMobileEntity = null;try {Map<String, String> params = new HashMap<>();params.put(TOKEN, token);params.put(APPID, appId);params.put(ENCRYPT_TYPE, encryptType);//可以不传,不传则解密直接使用AES解密params.put(SIGN, SignUtils.getSign(params, appKey));queryMobileEntity = HttpUtil.postForm(mobileQueryUrl, params, QueryMobileEntity.class);if (null != queryMobileEntity) {logger.info("一键登录token换取手机号结果:{}", queryMobileEntity);String code = queryMobileEntity.getCode();     //返回码 200000为成功if (SHANYAN_SUCCESS_CODE.equals(code)) {MobileDataEntity mobileDataEntity = queryMobileEntity.getData();String mobile = mobileDataEntity.getMobileName();if (aesEncryptType.equals(encryptType)) {String key = MD5.getMD5Code(appKey);mobile = AESUtil.decrypt(mobile, key.substring(0, 16), key.substring(16));} else if (rsaEncryptType.equals(encryptType)) {mobile = RSAUtil.decryptByPrivateKeyForLongStr(mobile, privateKey);}queryMobileEntity.setMobile(mobile);}}} catch (Exception e) {logger.error(e.getMessage());}return queryMobileEntity;}}

创蓝闪验一键登录(Java实现)相关推荐

  1. 创蓝闪验php手机号一键登录

    创蓝闪验php手机号一键登录 注意:对外接口需要两个必要参数,flash_token.type(安卓或ios) flash_token从哪里来: 是安卓和ios端集成创蓝闪验sdk以后通过调用sdk相 ...

  2. App接入阿里云号码认证服务 一键登录 Java后端服务部分

    下面是后台java部分,通过App端,用户确认授权后拿到的actoken来换取电话号码 Java服务端SDK <dependency><groupId>com.aliyun&l ...

  3. 闪验联通定制版SDK iOS集成文档

    SDK说明 适用版本 本文匹配的 SDK 版本:2.0.5及以上版本. 使用 Xcode 10.0 及以上版本 资源文件 待定?? 创建应用 在 创蓝万数平台的闪验 上创建应用,通过审核后将会得到ap ...

  4. 移动验证:本机校验和一键登录(中移动、中联通、中电信提供)

    更新时间:2019/07/23 先推荐 直接从三大运营商那里直接做这个功能,相对麻烦.所以我们想到了三方代理 代理1:阿里云 - 号码验证,每次4分,已经支持一键登录,SDK大约在20M左右,UI是半 ...

  5. 神奇的一键登录是怎么实现的?

    以前我做过自动获取手机号码,然后点击获取手机验证码,这样减少了输入手机号的过程,让注册登录过程简化了一点.这是通过Api直接获取手机SIM卡上的信息,直接 读取手机号,当时遇到各种问题,比如的手机卡获 ...

  6. java 短信验证码(创蓝接口)调用

    接口文档 : https://zz.253.com/v5.html#/api_word /*** 手机号码限制* @author w* */ @Retention(RetentionPolicy.RU ...

  7. 易验APP一键登录对接文档

    易验APP一键登录对接文档 1. 能力申请 注意事项: 1.认证取号服务必须打开蜂窝数据流量,并且应用应有蜂窝数据权限: 2.取号请求过程需要消耗用户少量数据流量(国外漫游时可能会产生额外的费用): ...

  8. 易验:APP一键登录,就这么简单

    易验,APP一键登录 1. 能力申请 注意事项: 1.认证取号服务必须打开蜂窝数据流量,并且应用应有蜂窝数据权限: 2.取号请求过程需要消耗用户少量数据流量(国外漫游时可能会产生额外的费用): 3.使 ...

  9. Android测试闪验demo-一键登录

    话不多说,先上图,结果页因涉及隐私,中间四位做了隐藏处理 最近项目有个需求(其实是自己主张的),公司项目分企业端和用户端,一直是两个APP,前段时间要合并,就想到了一键登录,简单快捷,在这里就看一下闪 ...

最新文章

  1. 16.swift字典
  2. js弹框带传值父窗口给子框_JavaScript实现弹出子窗口并传值给父窗口
  3. Java 正则表达式 总结
  4. selenium,webdriver 执行js语句 对象是百度
  5. Netty 采用NIO 而非AIO 的理由
  6. overflow-x理解_前端系列学习笔记
  7. 金陵科技学院计算机答辩,金陵科技学院优秀毕业论文答辩ppt模板
  8. apache字体文件跨域_在CabloyJS中将Webpack生成的文件自动上传到阿里云OSS
  9. ICPC2020小米网络选拔赛第一场复盘
  10. java程序打包exe
  11. Charles for Mac(信息抓包工具)
  12. HDU 3911 Black And White(线段树区间合并+lazy操作)
  13. 【图论】昂贵的聘礼(最短路变形)
  14. 避免社会工程和网络钓鱼攻击
  15. JDK8各个历史版本下载方法
  16. win10专业版安装后没有wifi
  17. Software Architecture Pattern(Mark Richards)笔记
  18. PS 2019 Mac版 自学入门系列(二)——区域选中
  19. golang从channel读数据的各种情况
  20. 华尔街大神:跌势不止,做空不止,你把握住了吗?

热门文章

  1. 编译并测试 android goldfish kernel x86
  2. matlab中 cos(pi/2) sin(pi)不等于0怎么办
  3. 脚本调度-sqoop导出分区表-判断分区目录是否存在
  4. Frp内网穿透实现远程桌面连接
  5. 49个项目管理过程ITTO整理(详细)
  6. arm服务器虚拟x86,x86服务器与arm
  7. Fabric学习笔记——一、环境搭建(小白入门)
  8. App can't be opened because it is from an unidentified developer
  9. 如何避免面向监狱编程以及程序员如何通过合法途径获利
  10. spice Main Channel definition