Package org.apache.shiro.subject.support

Examples of org.apache.shiro.subject.support.SubjectThreadState


        auth.initBaseRealm();
        if (auth.isInited()) {
            PrincipalCollection principals = new SimplePrincipalCollection("system", "it.freedomotic.security");
            Subject SysSubject = new Subject.Builder().principals(principals).buildSubject();
            SysSubject.getSession().setTimeout(-1);
            ThreadState threadState = new SubjectThreadState(SysSubject);
            threadState.bind();
            LOG.info("Booting as user:" + auth.getSubject().getPrincipal() +". Session will last:"+auth.getSubject().getSession().getTimeout());
        }

        String resourcesPath =
                new File(Info.getApplicationPath()
View Full Code Here


    @Override
    public boolean bindFakeUser(String userName) {
        if (baseRealm.accountExists(userName)) {
            PrincipalCollection principals = new SimplePrincipalCollection(userName, BASE_REALM_NAME);
            Subject subj = new Subject.Builder().principals(principals).buildSubject();
            ThreadState threadState = new SubjectThreadState(subj);
            threadState.bind();
            return true;
        }
        return false;
    }
View Full Code Here

  public ExtDirectJsonRequestProcessorThread() {
    Subject subject = SecurityUtils.getSubject();
    checkState(subject != null, "Subject is not set");
    // create the thread state by this moment as this is created in the master (web container) thread
    threadState = new SubjectThreadState(subject);
    processRequest = ServletScopes.continueRequest(new Callable<String>()
    {
      @Override
      public String call() {
        threadState.bind();
View Full Code Here

  @Mock
  private Subject subject;

  @Before
  public void setUp() throws Exception {
    threadState = new SubjectThreadState(subject);
    threadState.bind();
  }
View Full Code Here

    protected Subject getSubject() {
        return SecurityUtils.getSubject();
    }

    protected ThreadState createThreadState(Subject subject) {
        return new SubjectThreadState(subject);
    }
View Full Code Here

    private ThreadState threadState;

    protected void bind(Subject subject) {
        clearSubject();
        this.threadState = new SubjectThreadState(subject);
        this.threadState.bind();
    }
View Full Code Here

        ThreadContext.remove();
    }

    protected Subject newSubject(SecurityManager securityManager) {
        Subject subject = new Subject.Builder(securityManager).buildSubject();
        threadState = new SubjectThreadState(subject);
        threadState.bind();
        return subject;
    }
View Full Code Here

    public void attachSubject()
    {
        this.mockShiroSession = Mockito.mock(Session.class);
        this.mockSubject = Mockito.mock(Subject.class);
        Mockito.when(this.mockSubject.getSession()).thenReturn(this.mockShiroSession);
        this.threadState = new SubjectThreadState(this.mockSubject);
        this.threadState.bind();
    }
View Full Code Here

        tester.getApplication().getComponentInstantiationListeners()
            .add(new PaxWicketSpringBeanComponentInjector(tester.getApplication(), context));
        mockShiroSession = mock(Session.class);
        mockSubject = mock(Subject.class);
        when(mockSubject.getSession()).thenReturn(mockShiroSession);
        threadState = new SubjectThreadState(mockSubject);
        threadState.bind();

        final AtomicReference<Object> authenticated = new AtomicReference<Object>();

        Mockito.doAnswer(new Answer<Void>() {
View Full Code Here

  /**
   * 綁定Subject到當前線程.
   */
  protected static void bindSubject(Subject subject) {
    clearSubject();
    threadState = new SubjectThreadState(subject);
    threadState.bind();
  }
View Full Code Here

TOP

Related Classes of org.apache.shiro.subject.support.SubjectThreadState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.