1   /*
2    * $Id: JaasAuthenticationWithNtLoginModule.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.extras.jaas;
12  
13  import org.mule.MuleManager;
14  import org.mule.config.MuleProperties;
15  import org.mule.extras.client.MuleClient;
16  import org.mule.impl.security.MuleCredentials;
17  import org.mule.tck.FunctionalTestCase;
18  import org.mule.umo.UMOEncryptionStrategy;
19  import org.mule.umo.UMOMessage;
20  
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  public class JaasAuthenticationWithNtLoginModule extends FunctionalTestCase
25  {
26  
27      public JaasAuthenticationWithNtLoginModule()
28      {
29          super();
30          this.setDisposeManagerPerSuite(true);
31      }
32  
33      public void testCaseAuthentication() throws Exception
34      {
35          MuleClient client = new MuleClient();
36  
37          Map props = new HashMap();
38          UMOEncryptionStrategy strategy = MuleManager.getInstance()
39              .getSecurityManager()
40              .getEncryptionStrategy("PBE");
41          String header = MuleCredentials.createHeader("Marie.Rizzo", "dragon", "PBE", strategy);
42          props.put(MuleProperties.MULE_USER_PROPERTY, header);
43          UMOMessage m = client.send("vm://test", "Test", props);
44  
45          assertNotNull(m);
46          assertTrue(m.getPayload() instanceof String);
47          assertTrue(m.getPayloadAsString().equals("Test Received"));
48      }
49  
50      protected String getConfigResources()
51      {
52          return "mule-conf-with-NTLoginModule.xml";
53      }
54  }