use of com.itrus.portal.db.RealNameAuthenticationExample in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method getRealNameAuthenticationByTwo.
/**
* 获取密码服务配置
* @return
* @throws Exception
*/
public RealNameAuthentication getRealNameAuthenticationByTwo() throws Exception {
RealNameAuthenticationExample re = new RealNameAuthenticationExample();
RealNameAuthenticationExample.Criteria rec = re.createCriteria();
rec.andTypeEqualTo(2);
RealNameAuthentication realname = this.getRealNameAuthenticationExample(re);
return realname;
}
use of com.itrus.portal.db.RealNameAuthenticationExample in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method getRealNameAuthenticationByThree.
/**
* 获取时间戳服务配置
* @return
* @throws Exception
*/
public RealNameAuthentication getRealNameAuthenticationByThree() throws Exception {
RealNameAuthenticationExample re = new RealNameAuthenticationExample();
RealNameAuthenticationExample.Criteria rec = re.createCriteria();
rec.andTypeEqualTo(3);
RealNameAuthentication realname = this.getRealNameAuthenticationExample(re);
return realname;
}
use of com.itrus.portal.db.RealNameAuthenticationExample in project portal by ixinportal.
the class RealNameAuthenticationSerivceImpl method getRealNameAuthenticationByOne.
/**
* 获取原子服务配置
* @return
* @throws Exception
*/
public RealNameAuthentication getRealNameAuthenticationByOne() throws Exception {
RealNameAuthenticationExample re = new RealNameAuthenticationExample();
RealNameAuthenticationExample.Criteria rec = re.createCriteria();
rec.andTypeEqualTo(1);
RealNameAuthentication realname = this.getRealNameAuthenticationExample(re);
return realname;
}
use of com.itrus.portal.db.RealNameAuthenticationExample in project portal by ixinportal.
the class AuthService method getToken.
// @Autowired
// private static RealNameAuthenticationSerivceImpl authenticationSerivceImpl = new RealNameAuthenticationSerivceImpl();
/**
* 获得token
* 访问其他接口的时候 在头信息增加 Authorization :bear+token bear和token之间加个空格
*/
private static String getToken() {
// client_secret:43b484748d3a936330bc50da70d6ce69e1dfef90
try {
// RealNameAuthentication realNameAuthentication = authenticationSerivceImpl.getRealNameAuthenticationExample(new RealNameAuthenticationExample());
long nowDate = System.currentTimeMillis();
if (ACCESS_TOKEN != null && new Date(nowDate + inDateTime).before(inDate)) {
return ACCESS_TOKEN;
}
RealNameAuthentication realNameAuthentication = CacheCustomer.getAUTH_CONFIG_MAP().get(2);
if (realNameAuthentication == null) {
List<RealNameAuthentication> list = SpringContextHolder.getBean(SqlSession.class).selectList("com.itrus.portal.db.RealNameAuthenticationMapper.selectByExample", new RealNameAuthenticationExample());
if (list == null || list.isEmpty()) {
return null;
}
for (RealNameAuthentication nameAuthentication : list) {
if (nameAuthentication.getType() == 2)
realNameAuthentication = nameAuthentication;
}
if (realNameAuthentication == null) {
return null;
}
}
Map params = new HashMap();
params.put("grant_type", "client_credentials");
params.put("client_id", realNameAuthentication.getIdCode());
params.put("client_secret", realNameAuthentication.getKeyCode());
String rep = HttpClientUtil.postForm(realNameAuthentication.getAccessTokenaddress() + TOKEN, null, params);
// System.out.println("AuthService getToken()_rep : " + rep);
JSONObject data = JSON.parseObject(rep);
ACCESS_TOKEN = data.getString("access_token");
inDate = new Date(nowDate + data.getLongValue("expires_in"));
return ACCESS_TOKEN;
} catch (RestClientException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
use of com.itrus.portal.db.RealNameAuthenticationExample in project portal by ixinportal.
the class AuthService method getToken.
// @Autowired
// private static RealNameAuthenticationSerivceImpl authenticationSerivceImpl = new RealNameAuthenticationSerivceImpl();
/**
* 获得token
* 访问其他接口的时候 在头信息增加 Authorization :bear+token bear和token之间加个空格
*/
private static String getToken() {
// client_secret:43b484748d3a936330bc50da70d6ce69e1dfef90
try {
// RealNameAuthentication realNameAuthentication = authenticationSerivceImpl.getRealNameAuthenticationExample(new RealNameAuthenticationExample());
Long nowDate = System.currentTimeMillis();
if (ACCESS_TOKEN != null && new Date(nowDate + inDateTime).before(inDate)) {
return ACCESS_TOKEN;
}
List<RealNameAuthentication> list = sqlSession.selectList("com.itrus.portal.db.RealNameAuthenticationMapper.selectByExample", new RealNameAuthenticationExample());
if (list == null || list.isEmpty()) {
return null;
}
RealNameAuthentication realNameAuthentication = null;
for (RealNameAuthentication nameAuthentication : list) {
if (nameAuthentication.getType() == 1)
realNameAuthentication = nameAuthentication;
}
if (realNameAuthentication == null) {
return null;
}
Map params = new HashMap();
params.put("grant_type", "client_credentials");
params.put("client_id", realNameAuthentication.getIdCode());
params.put("client_secret", realNameAuthentication.getKeyCode());
String rep = HttpClientUtil.postForm(realNameAuthentication.getAccessTokenaddress() + TOKEN, null, params);
JSONObject data = JSON.parseObject(rep);
ACCESS_TOKEN = data.getString("access_token");
inDate = new Date(nowDate + data.getInteger("expires_in") * 1000);
return ACCESS_TOKEN;
} catch (RestClientException e) {
e.printStackTrace();
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonParseException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
Aggregations