View Javadoc

1   /*
2    * $Id: JaasAuthenticationWithNtLoginModule.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.module.jaas;
12  
13  import org.mule.api.EncryptionStrategy;
14  import org.mule.api.MuleMessage;
15  import org.mule.api.config.MuleProperties;
16  import org.mule.module.client.MuleClient;
17  import org.mule.security.MuleCredentials;
18  import org.mule.tck.FunctionalTestCase;
19  import org.mule.util.SystemUtils;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  public class JaasAuthenticationWithNtLoginModule extends FunctionalTestCase
25  {
26  
27      protected boolean isDisabledInThisEnvironment()
28      {
29          return SystemUtils.IS_OS_UNIX;
30      }
31  
32      public void testCaseAuthentication() throws Exception
33      {
34          MuleClient client = new MuleClient(muleContext);
35  
36          Map props = new HashMap();
37          EncryptionStrategy strategy = muleContext
38              .getSecurityManager()
39              .getEncryptionStrategy("PBE");
40          String header = MuleCredentials.createHeader("Marie.Rizzo", "dragon", "PBE", strategy);
41          props.put(MuleProperties.MULE_USER_PROPERTY, header);
42          MuleMessage m = client.send("vm://test", "Test", props);
43  
44          assertNotNull(m);
45          assertTrue(m.getPayload() instanceof String);
46          assertTrue(m.getPayloadAsString().equals("Test Received"));
47      }
48  
49      protected String getConfigResources()
50      {
51          return "mule-conf-with-NTLoginModule.xml";
52      }
53  }