Example usage for org.apache.shiro UnavailableSecurityManagerException UnavailableSecurityManagerException

List of usage examples for org.apache.shiro UnavailableSecurityManagerException UnavailableSecurityManagerException

Introduction

In this page you can find the example usage for org.apache.shiro UnavailableSecurityManagerException UnavailableSecurityManagerException.

Prototype

public UnavailableSecurityManagerException(String message) 

Source Link

Usage

From source file:org.codice.ddf.security.SecurityTest.java

License:Open Source License

@Test
public void testRunWithSubjectOrElevateWhenSystemSubjectHasAdminRole() throws Exception {
    when(SecurityUtils.getSubject()).thenThrow(new UnavailableSecurityManagerException(""));
    when(systemSubject.execute(callable)).thenReturn("Success!");
    configureMocksForBundleContext("server");

    String result = Security.runAsAdminWithException(() -> security.runWithSubjectOrElevate(callable));

    assertThat(result, is("Success!"));
    verifyStatic();//from  www  . j  a v a2 s  . co  m
    SecurityLogger.auditWarn("Elevating current user permissions to use System subject");
    verifyZeroInteractions(shiroSubject);
}