本文整理汇总了Java中org.apache.shiro.UnavailableSecurityManagerException类的典型用法代码示例。如果您正苦于以下问题:Java UnavailableSecurityManagerException类的具体用法?Java UnavailableSecurityManagerException怎么用?Java UnavailableSecurityManagerException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
UnavailableSecurityManagerException类属于org.apache.shiro包,在下文中一共展示了UnavailableSecurityManagerException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: resolveSecurityManager
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
public SecurityManager resolveSecurityManager() {
SecurityManager securityManager = getSecurityManager();
if (securityManager == null) {
if (log.isDebugEnabled()) {
log.debug("No SecurityManager available in subject context map. " +
"Falling back to SecurityUtils.getSecurityManager() lookup.");
}
try {
securityManager = SecurityUtils.getSecurityManager();
} catch (UnavailableSecurityManagerException e) {
if (log.isDebugEnabled()) {
log.debug("No SecurityManager available via SecurityUtils. Heuristics exhausted.", e);
}
}
}
return securityManager;
}
示例2: checkSubjectIs
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
private void checkSubjectIs(String id) {
try {
Subject subject = SecurityUtils.getSubject();
if (subject.isAuthenticated()) {
if (id.equals( ((UserInfo)subject.getPrincipal()).getOpenid() ) || subject.hasRole(RegAuthorizationInfo.ADMINSTRATOR_ROLE) ) {
return;
} else {
throw new AuthorizationException("Cannot change credentials for another user");
}
} else {
throw new UnauthenticatedException();
}
} catch (UnavailableSecurityManagerException e) {
// Allow to proceed if no security system is configured
}
}
示例3: getRequestor
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
public static String getRequestor(HttpServletRequest request) {
try {
UserInfo user = (UserInfo) SecurityUtils.getSubject().getPrincipal();
if (user != null) {
return NameUtils.encodeSafeName(user.toString());
}
} catch (UnavailableSecurityManagerException e) {
// shiro not running, presumably test mode, fall through to default requestor based on IP
}
if (request.getHeader(FORWARDED_FOR_HEADER) != null) {
return request.getHeader(FORWARDED_FOR_HEADER);
}
return request.getRemoteAddr();
}
示例4: isAuthorized
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
/**
* Test if the user of authorized to execute this command
*/
public boolean isAuthorized() {
RegPermission required = permissionRequired();
if (required != null) {
try {
Subject subject = SecurityUtils.getSubject();
if (subject.isPermitted(required)) {
return true;
} else {
log.warn("Authorization failure for " + subject.getPrincipal() + ", requested permission " + required);
return false;
}
} catch (UnavailableSecurityManagerException e) {
log.warn("Security is not configured, assuming test mode");
return true;
}
} else {
return true;
}
}
示例5: tearDownShiro
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
/**
* Method description
*
*/
private void tearDownShiro()
{
try
{
SecurityManager securityManager = SecurityUtils.getSecurityManager();
LifecycleUtils.destroy(securityManager);
ThreadContext.unbindSecurityManager();
ThreadContext.unbindSubject();
ThreadContext.remove();
}
catch (UnavailableSecurityManagerException e)
{
// we don't care about this when cleaning up the test environment
// (for example, maybe the subclass is a unit test and it didn't
// need a SecurityManager instance because it was using only mock Subject instances)
}
SecurityUtils.setSecurityManager(null);
}
示例6: tearDownShiro
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
@AfterClass
public static void tearDownShiro() {
doClearSubject();
try {
org.apache.shiro.mgt.SecurityManager securityManager = SecurityUtils.getSecurityManager();
LifecycleUtils.destroy( securityManager );
}
catch ( UnavailableSecurityManagerException e ) {
// we don't care about this when cleaning up the test environment
// (for example, maybe the subclass is a unit test and it didn't
// need a SecurityManager instance because it was using only
// mock Subject instances)
}
SecurityUtils.setSecurityManager( null );
}
示例7: getSession
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
public Session getSession() {
Session session = null;
try {
Subject subject = SecurityUtils.getSubject();
session = subject.getSession(false);
if (session == null) {
session = subject.getSession();
}
} catch (InvalidSessionException e) {
logger.error("Invalid session error", e);
} catch (UnavailableSecurityManagerException e2) {
logger.error("Unavailable SecurityManager error", e2);
}
return session;
}
示例8: isIntegratedSecurity
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的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;
}
示例9: getSession
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
public Session getSession(){
Session session = null;
try{
Subject subject = SecurityUtils.getSubject();
session = subject.getSession(false);
if (session == null){
session = subject.getSession();
}
}catch (InvalidSessionException e){
logger.error("Invalid session error", e);
}catch (UnavailableSecurityManagerException e2){
logger.error("Unavailable SecurityManager error", e2);
}
return session;
}
示例10: tearDownShiro
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
@AfterClass
public static void tearDownShiro() {
doClearSubject();
try {
SecurityManager securityManager = getSecurityManager();
LifecycleUtils.destroy(securityManager);
} catch (UnavailableSecurityManagerException e) {
//we don't care about this when cleaning up the test environment
//(for example, maybe the subclass is a unit test and it didn't
// need a SecurityManager instance because it was using only
// mock Subject instances)
}
setSecurityManager(null);
}
示例11: tearDownShiro
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
@AfterClass
public static void tearDownShiro() {
doClearSubject();
try {
SecurityManager securityManager = getSecurityManager();
LifecycleUtils.destroy(securityManager);
} catch (UnavailableSecurityManagerException e) {
//we don't care about this when cleaning up the test environment
//(for example, maybe the subclass is a unit test and it didn't
// need a SecurityManager instance because it was using only
// mock Subject instances)
}
setSecurityManager(null);
}
示例12: getPrincipalName
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
private String getPrincipalName(){
try {
if (SecurityUtils.getSubject() == null || SecurityUtils.getSubject().getPrincipal() == null) return "Unauthenticated";
return SecurityUtils.getSubject().getPrincipal().toString();
} catch (UnavailableSecurityManagerException e) {
log.warn("Audit being called with no valid security context. This is probably caused by being called from unit tests");
return "Security Manager Not Configured";
}
}
示例13: checkSecurityManager
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
/**
* Called once the server has started to check the security manager.
*/
protected void checkSecurityManager() {
try {
if (AuthUtils.isDefault()) {
_logger.logWarn("*****************************************************************");
_logger.logWarn(" Warning: Server running with default permissive SecurityManager ");
_logger.logWarn("*****************************************************************");
}
} catch (UnavailableSecurityManagerException ex) {
_logger.logError("***************************************************");
_logger.logError(" Error: Server running without any SecurityManager ");
_logger.logError("***************************************************");
}
}
示例14: createDefaultInstance
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
@Override
protected SecurityManager createDefaultInstance() {
try {
SecurityManager sm = AuthUtils.getSecurityManager();
if (sm instanceof WebSecurityManager) {
return sm;
}
return super.createDefaultInstance();
} catch (UnavailableSecurityManagerException ex) {
return super.createDefaultInstance();
}
}
示例15: isRememberMe
import org.apache.shiro.UnavailableSecurityManagerException; //导入依赖的package包/类
@Override
public boolean isRememberMe() {
try {
return getAuthentication().isRemembered();
} catch (final UnavailableSecurityManagerException e) {
return false;
}
}