private EncryCredentialInfo buildEncryCredentialInfo(String appId, AuthenticationImpl authentication, Principal principal){
EncryCredentialInfo encryCredentialInfo = new EncryCredentialInfo();
if(authentication==null || principal==null){
return encryCredentialInfo;
}
Ki4soKey ki4soKey = keyService.findKeyByAppId(appId);
if(ki4soKey==null){
logger.log(Level.INFO, "no key for app id {0}", appId);
throw new NoKi4soKeyException();
}
encryCredentialInfo.setAppId(appId);
encryCredentialInfo.setCreateTime(authentication.getAuthenticatedDate());
encryCredentialInfo.setUserId(principal.getId());
encryCredentialInfo.setKeyId(ki4soKey.getKeyId());
Date expiredTime = new Date((authentication.getAuthenticatedDate().getTime()+DURATION));
encryCredentialInfo.setExpiredTime(expiredTime);
return encryCredentialInfo;
}