本文整理匯總了Java中org.apache.shiro.SecurityUtils.getSecurityManager方法的典型用法代碼示例。如果您正苦於以下問題:Java SecurityUtils.getSecurityManager方法的具體用法?Java SecurityUtils.getSecurityManager怎麽用?Java SecurityUtils.getSecurityManager使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.shiro.SecurityUtils
的用法示例。
在下文中一共展示了SecurityUtils.getSecurityManager方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getRealm
import org.apache.shiro.SecurityUtils; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static <T> T getRealm(Class<? extends Realm> realmType){
RealmSecurityManager securityManager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
if(!CollectionUtils.isEmpty(securityManager.getRealms())){
for(Iterator<Realm> it = securityManager.getRealms().iterator(); it.hasNext();){
Realm realm = it.next();
if(realm.getClass().equals(realmType)){
return (T) realm;
}
}
}
return null;
}
示例2: getPrincipals
import org.apache.shiro.SecurityUtils; //導入方法依賴的package包/類
@Override
public PrincipalCollection getPrincipals() {
RealmSecurityManager manager = (RealmSecurityManager) SecurityUtils.getSecurityManager();
SimplePrincipalCollection ret = new SimplePrincipalCollection();
for (Realm realm : manager.getRealms()) {
/*
if (realm instanceof ProfileRealm) {
String email = token.getEmail();
if (((ProfileRealm) realm).accountExists(email)) {
ret.add(email, realm.getName());
}
}
*/
}
ret.add(token.getEmail(), bearerTokenAuthenticatingRealm.getName());
return ret;
}
示例3: isIntegratedSecurity
import org.apache.shiro.SecurityUtils; //導入方法依賴的package包/類
/**
* check if Shiro's security manager is configured
*
* @return true if configured, false if not
*/
public boolean isIntegratedSecurity() {
if (isIntegratedSecurity != null) {
return isIntegratedSecurity;
}
try {
isIntegratedSecurity = (SecurityUtils.getSecurityManager() != null);
} catch (UnavailableSecurityManagerException e) {
isIntegratedSecurity = false;
}
return isIntegratedSecurity;
}