1
2
3
4
5
6
7
8
9
10
11 package org.mule.module.jaas;
12
13 import java.util.HashMap;
14 import java.util.Map;
15
16 import org.mule.api.EncryptionStrategy;
17 import org.mule.api.config.MuleProperties;
18 import org.mule.api.security.CryptoFailureException;
19 import org.mule.security.MuleCredentials;
20 import org.mule.tck.AbstractServiceAndFlowTestCase;
21
22 public abstract class AbstractJaasFunctionalTestCase extends AbstractServiceAndFlowTestCase
23 {
24 public AbstractJaasFunctionalTestCase(ConfigVariant variant, String configResources)
25 {
26 super(variant, configResources);
27 }
28
29 protected Map<String, Object> createMessagePropertiesWithCredentials(String username, String password)
30 throws CryptoFailureException
31 {
32 Map<String, Object> props = new HashMap<String, Object>();
33 String header = createEncryptedHeader(username, password);
34 props.put(MuleProperties.MULE_USER_PROPERTY, header);
35 return props;
36 }
37
38 private String createEncryptedHeader(String username, String password) throws CryptoFailureException
39 {
40 EncryptionStrategy strategy = muleContext.getSecurityManager().getEncryptionStrategy("PBE");
41 return MuleCredentials.createHeader(username, password, "PBE", strategy);
42 }
43 }