View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.module.jaas;
8   
9   import org.mule.api.security.Authentication;
10  import org.mule.api.security.Credentials;
11  
12  import java.util.Map;
13  
14  import javax.security.auth.Subject;
15  
16  public class JaasAuthentication implements Authentication
17  {
18      private boolean authenticated;
19      private char[] credentials;
20      private String user;
21      private Map properties;
22      private Subject subject;
23    
24      public JaasAuthentication(Credentials credentials)
25      {
26          this.user = credentials.getUsername();
27          this.credentials = credentials.getPassword();
28      }
29      
30      public JaasAuthentication(Object user, Object credentials, Subject subject)
31      {
32          this.user = (String) user;
33          this.credentials = ((String) credentials).toCharArray();
34          this.subject = subject;
35      }
36  
37      public void setAuthenticated(boolean b)
38      {
39          authenticated = b;
40      }
41  
42      public boolean isAuthenticated()
43      {
44          return authenticated;
45      }
46  
47      public Object getCredentials()
48      {
49          return new String(credentials);
50      }
51  
52      public Object getPrincipal()
53      {
54          return user;
55      }
56  
57      public Map getProperties()
58      {
59          return properties;
60      }
61  
62      public void setProperties(Map properties)
63      {
64          this.properties = properties;
65      }
66  
67      public Subject getSubject()
68      {
69          return subject;
70      }
71  }