Example usage for org.apache.shiro.env Environment Environment

List of usage examples for org.apache.shiro.env Environment Environment

Introduction

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

Prototype

Environment

Source Link

Usage

From source file:org.apache.activemq.shiro.authz.AuthorizationFilterTest.java

License:Apache License

private ConnectionContext createContext(Subject subject) {
    ConnectionContext ctx = new ConnectionContext();
    ConnectionInfo info = new ConnectionInfo();
    Environment environment = new Environment() {
        @Override// w  w  w. j a  v a 2  s .c o  m
        public org.apache.shiro.mgt.SecurityManager getSecurityManager() {
            return null; //not needed in this test.
        }
    };
    SubjectConnectionReference ref = new SubjectConnectionReference(ctx, info, environment, subject);
    SubjectSecurityContext secCtx = new SubjectSecurityContext(ref);
    ctx.setSecurityContext(secCtx);
    return ctx;
}

From source file:org.apache.activemq.shiro.ShiroPlugin.java

License:Apache License

private Environment ensureEnvironment() throws ConfigurationException {
    if (this.environment != null) {
        return this.environment;
    }/*w ww .  j  a  v  a2s.  com*/

    //this.environment is null - set it:
    if (this.securityManager != null) {
        this.environment = new Environment() {
            @Override
            public SecurityManager getSecurityManager() {
                return ShiroPlugin.this.securityManager;
            }
        };
        return this.environment;
    }

    this.iniEnvironment.init(); //will automatically catch any config errors and throw.

    this.environment = iniEnvironment;

    return this.iniEnvironment;
}