Example usage for org.apache.shiro.subject SubjectContext resolveSecurityManager

List of usage examples for org.apache.shiro.subject SubjectContext resolveSecurityManager

Introduction

In this page you can find the example usage for org.apache.shiro.subject SubjectContext resolveSecurityManager.

Prototype

SecurityManager resolveSecurityManager();

Source Link

Document

Resolves the SecurityManager instance that should be used to back the constructed Subject instance (typically used to support org.apache.shiro.subject.support.DelegatingSubject DelegatingSubject implementations).

Usage

From source file:com.caricah.iotracah.bootstrap.security.IOTSecurityManager.java

License:Apache License

/**
 * Determines if there is a {@code SecurityManager} instance in the context, and if not, adds 'this' to the
 * context.  This ensures the SubjectFactory instance will have access to a SecurityManager during Subject
 * construction if necessary./*from   w w w . j a  va2s  .  co m*/
 *
 * @param context the subject context data that may contain a SecurityManager instance.
 * @return The SubjectContext to use to pass to a {@link SubjectFactory} for subject creation.
 * @since 1.0
 */
@SuppressWarnings({ "unchecked" })
protected SubjectContext ensureSecurityManager(SubjectContext context) {
    if (context.resolveSecurityManager() != null) {
        log.trace("Context already contains a SecurityManager instance.  Returning.");
        return context;
    }
    log.trace("No SecurityManager found in context.  Adding self reference.");
    context.setSecurityManager(this);
    return context;
}

From source file:com.caricah.iotracah.bootstrap.security.IOTSubjectFactory.java

License:Apache License

public Subject createSubject(SubjectContext context) {
    org.apache.shiro.mgt.SecurityManager securityManager = context.resolveSecurityManager();
    Session session = context.resolveSession();
    boolean sessionCreationEnabled = context.isSessionCreationEnabled();
    PrincipalCollection principals = context.resolvePrincipals();
    boolean authenticated = context.resolveAuthenticated();
    String host = context.resolveHost();

    return new IOTSubject(principals, authenticated, host, session, sessionCreationEnabled, securityManager);
}