本文整理汇总了Java中com.microsoft.aad.adal.TokenCacheItem类的典型用法代码示例。如果您正苦于以下问题:Java TokenCacheItem类的具体用法?Java TokenCacheItem怎么用?Java TokenCacheItem使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TokenCacheItem类属于com.microsoft.aad.adal包,在下文中一共展示了TokenCacheItem类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTokensForUser
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Get tokens for user.
*
* @param userid Userid
* @return list of {@link com.microsoft.aad.adal.TokenCacheItem}
*/
@Override
public ArrayList<TokenCacheItem> getTokensForUser(String userid) {
Iterator<TokenCacheItem> results = this.getAll();
ArrayList<TokenCacheItem> tokenItems = new ArrayList<TokenCacheItem>();
while (results.hasNext()) {
TokenCacheItem item = results.next();
if (item.getUserInfo() != null
&& item.getUserInfo().getUserId().equalsIgnoreCase(userid)) {
tokenItems.add(item);
}
}
return tokenItems;
}
示例2: showTokens
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
private void showTokens() {
ITokenCacheStore currentCache = mAuthContext.getCache();
if (currentCache != null && currentCache instanceof DefaultTokenCacheStore) {
DefaultTokenCacheStore cache = (DefaultTokenCacheStore)currentCache;
StringBuilder tokeninfo = new StringBuilder();
Iterator<TokenCacheItem> iterator = cache.getAll();
while (iterator.hasNext()) {
TokenCacheItem item = iterator.next();
tokeninfo.append("Key:" + CacheKey.createCacheKey(item).toString() + " Expires:"
+ item.getExpiresOn() + " token:" + item.getAccessToken().substring(0, 10)
+ "\n");
tokeninfo.append("--------------\n");
}
createAndShowDialog(tokeninfo.toString(), "Tokens");
}
}
示例3: getTokensForUser
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Get tokens for user.
*
* @param userid Userid
* @return list of {@link TokenCacheItem}
*/
public ArrayList<TokenCacheItem> getTokensForUser(String userid) {
Iterator<TokenCacheItem> results = this.getAll();
ArrayList<TokenCacheItem> tokenItems = new ArrayList<TokenCacheItem>();
while (results.hasNext()) {
TokenCacheItem item = results.next();
if (item.getUserInfo() != null
&& item.getUserInfo().getUniqueId().equalsIgnoreCase(userid)) {
tokenItems.add(item);
}
}
return tokenItems;
}
示例4: getTokensForUser
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Get tokens for user.
*
* @param userid Userid
* @return list of {@link TokenCacheItem}
*/
@Override
public ArrayList<TokenCacheItem> getTokensForUser(String userid) {
Iterator<TokenCacheItem> results = this.getAll();
ArrayList<TokenCacheItem> tokenItems = new ArrayList<TokenCacheItem>();
while (results.hasNext()) {
TokenCacheItem item = results.next();
if (item.getUserInfo() != null
&& item.getUserInfo().getUserId().equalsIgnoreCase(userid)) {
tokenItems.add(item);
}
}
return tokenItems;
}
示例5: getItem
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
@Override
public TokenCacheItem getItem(String key) {
if (key == null) {
throw new IllegalArgumentException("key");
}
return cache.get(key);
}
示例6: setItem
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
@Override
public void setItem(String key, TokenCacheItem item) {
if (key == null) {
throw new IllegalArgumentException("key");
}
if (item == null) {
throw new IllegalArgumentException("item");
}
cache.put(key, item);
}
示例7: getAll
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* User can query over iterator values.
*/
@Override
public Iterator<TokenCacheItem> getAll() {
Iterator<TokenCacheItem> values = cache.values().iterator();
return values;
}
示例8: getUniqueUsersWithTokenCache
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Unique users with tokens.
*
* @return unique users
*/
@Override
public HashSet<String> getUniqueUsersWithTokenCache() {
Iterator<TokenCacheItem> results = this.getAll();
HashSet<String> users = new HashSet<String>();
while (results.hasNext()) {
TokenCacheItem item = results.next();
if (item.getUserInfo() != null && !users.contains(item.getUserInfo().getUserId())) {
users.add(item.getUserInfo().getUserId());
}
}
return users;
}
示例9: getTokensForResource
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Tokens for resource.
*
* @param resource Resource identifier
* @return list of {@link com.microsoft.aad.adal.TokenCacheItem}
*/
@Override
public ArrayList<TokenCacheItem> getTokensForResource(String resource) {
Iterator<TokenCacheItem> results = this.getAll();
ArrayList<TokenCacheItem> tokenItems = new ArrayList<TokenCacheItem>();
while (results.hasNext()) {
TokenCacheItem item = results.next();
if (item.getResource().equals(resource)) {
tokenItems.add(item);
}
}
return tokenItems;
}
示例10: clearTokensForUser
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Clear tokens for user without additional retry.
*
* @param userid UserId
*/
@Override
public void clearTokensForUser(String userid) {
ArrayList<TokenCacheItem> results = this.getTokensForUser(userid);
for (TokenCacheItem item : results) {
if (item.getUserInfo() != null
&& item.getUserInfo().getUserId().equalsIgnoreCase(userid)) {
this.removeItem(CacheKey.createCacheKey(item));
}
}
}
示例11: getTokensAboutToExpire
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
/**
* Get tokens about to expire.
*
* @return list of {@link com.microsoft.aad.adal.TokenCacheItem}
*/
@Override
public ArrayList<TokenCacheItem> getTokensAboutToExpire() {
Iterator<TokenCacheItem> results = this.getAll();
ArrayList<TokenCacheItem> tokenItems = new ArrayList<TokenCacheItem>();
while (results.hasNext()) {
TokenCacheItem item = results.next();
if (isAboutToExpire(item.getExpiresOn())) {
tokenItems.add(item);
}
}
return tokenItems;
}
示例12: setTokenExpire
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
private void setTokenExpire() {
// get items and set them to expired from cache
// default cache is in use by default
ITokenCacheStore currentCache = mAuthContext.getCache();
String key = CacheKey.createCacheKey(Constants.AUTHORITY_URL, Constants.RESOURCE_ID,
Constants.CLIENT_ID, false, Constants.USER_HINT);
TokenCacheItem item = currentCache.getItem(key);
if (item != null) {
Calendar timeExpired = new GregorianCalendar(TimeZone.getTimeZone("UTC"));
timeExpired.add(Calendar.MINUTE, -50);
item.setExpiresOn(timeExpired.getTime());
currentCache.setItem(key, item);
}
}
示例13: getItem
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
public TokenCacheItem getItem(String key) {
if (key == null) {
throw new IllegalArgumentException("key");
}
return cache.get(key);
}
示例14: removeItem
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
public void removeItem(TokenCacheItem key) {
if (key == null) {
throw new IllegalArgumentException("key");
}
cache.remove(key);
}
示例15: setItem
import com.microsoft.aad.adal.TokenCacheItem; //导入依赖的package包/类
public void setItem(String key, TokenCacheItem item) {
if (key == null) {
throw new IllegalArgumentException("key");
}
if (item == null) {
throw new IllegalArgumentException("item");
}
cache.put(key, item);
}