Package org.springframework.security.context

Examples of org.springframework.security.context.SecurityContext


public class PentahoSecurityContextHolderStrategyTest {

  @Test
  public void testGetContext() throws Exception {
    final PentahoSecurityContextHolderStrategy strategy = new PentahoSecurityContextHolderStrategy();
    SecurityContext context = strategy.getContext();
    assertNotNull( context );
    final Authentication authentication = mock( Authentication.class );
    context.setAuthentication( authentication );

    assertSame( authentication, strategy.getContext().getAuthentication() );
    Thread thread = new Thread( new Runnable() {
      @Override public void run() {
        assertSame( authentication, strategy.getContext().getAuthentication() );
View Full Code Here


        String threadUser = getCurrentThreadUser();
        if (threadUser != null && threadUser.trim().length() > 0) {
            return threadUser;
        }

        SecurityContext context = SecurityContextHolder.getContext();
        Authentication auth = context.getAuthentication();

        if (auth == null) {
            return ROLE_ANONYMOUS;
        }
View Full Code Here

        }
    }

    public Collection<String> getCurrentRoles() {
        Collection<String> results = new HashSet<String>();
        SecurityContext context = SecurityContextHolder.getContext();
        Authentication auth = context.getAuthentication();

        if (auth != null) {
            Object userObj = auth.getPrincipal();
            if (userObj instanceof UserDetails) {
                GrantedAuthority[] authorities = ((UserDetails)userObj).getAuthorities();
View Full Code Here

    _service.setUserDao(_userDao);
  }

  @After
  public void tearDown() {
    SecurityContext context = SecurityContextHolder.getContext();
    context.setAuthentication(null);
  }
View Full Code Here

     * @return Result of invoking SUT.
     */
    private Principal runTest(final boolean exceptionOnError)
    {
        // Save off the current security context, so that it can be reset when this test is complete.
        SecurityContext originalSecurityContext = SecurityContextHolder.getContext();
        SecurityContextHolder.setContext(securityContext);

        SpringSecurityContextPrincipalPopulator sut = new SpringSecurityContextPrincipalPopulator(
exceptionOnError);

View Full Code Here

        femv.setUniqueKey("KeyGoesHere");
        femv.setStreamScopeId(1L);
        final ArrayList<DisplayEntityModelView> results = new ArrayList<DisplayEntityModelView>(1);
        results.add(femv);

        SecurityContext originalContext = SecurityContextHolder.getContext();
        SecurityContextHolder.setContext(securityContext);

        context.checking(new Expectations()
        {
            {
View Full Code Here

    public void testRepresentFailure() throws ResourceException, IOException
    {
        final Variant variant = context.mock(Variant.class);
        setupCommonInitExpectations("abc");

        SecurityContext originalContext = SecurityContextHolder.getContext();
        SecurityContextHolder.setContext(securityContext);

        context.checking(new Expectations()
        {
            {
View Full Code Here

     */
    private Principal getPrincipal()
    {
        try
        {
            SecurityContext securityCtx = SecurityContextHolder.getContext();
            if (securityCtx == null)
            {
                throw new AuthorizationException("No security context available.");
            }

            Authentication auth = securityCtx.getAuthentication();
            if (auth == null)
            {
                return null;
            }

View Full Code Here

    @Override
    public String transform(final Object inTransformType)
    {
        try
        {
            SecurityContext securityCtx = SecurityContextHolder.getContext();
            Authentication auth = securityCtx.getAuthentication();
            if (auth != null)
            {
                Object obj = auth.getPrincipal();
                if (obj instanceof ConsumerDetails)
                {
View Full Code Here

TOP

Related Classes of org.springframework.security.context.SecurityContext

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.