View Javadoc

1   /*
2    * $Id: TestSecurityComponent.java 19191 2010-08-25 21:05:23Z tcarlson $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.tck.security;
12  
13  
14  import org.mule.api.MuleEventContext;
15  import org.mule.api.lifecycle.Callable;
16  import org.mule.api.security.Authentication;
17  import org.mule.api.security.SecurityContext;
18  
19  import org.apache.commons.logging.Log;
20  import org.apache.commons.logging.LogFactory;
21  
22  public class TestSecurityComponent implements Callable
23  {
24      protected static final Log logger = LogFactory.getLog(TestSecurityComponent.class);
25      
26      public Object onCall(MuleEventContext eventContext) throws Exception
27      {
28          SecurityContext securityContext = eventContext.getSession().getSecurityContext();
29          Authentication authentication = securityContext.getAuthentication();
30  
31          int numberLogins = (Integer) authentication.getProperties().get(TestSingleUserSecurityProvider.PROPERTY_NUMBER_LOGINS);
32          String favoriteColor = (String) authentication.getProperties().get(TestSingleUserSecurityProvider.PROPERTY_FAVORITE_COLOR);
33  
34          String msg = "user = " + authentication.getPrincipal() + ", logins = " + numberLogins + ", color = " + favoriteColor;
35          logger.debug(msg);
36          return msg;
37      }
38  }
39  
40