View Javadoc

1   /*
2    * $Id: JaasAuthentication.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.security.Authentication;
14  import org.mule.api.security.Credentials;
15  
16  import java.util.Map;
17  
18  import javax.security.auth.Subject;
19  
20  public class JaasAuthentication implements Authentication
21  {
22      private boolean authenticated;
23      private char[] credentials;
24      private String user;
25      private Map properties;
26      private Subject subject;
27    
28      public JaasAuthentication(Credentials credentials)
29      {
30          this.user = credentials.getUsername();
31          this.credentials = credentials.getPassword();
32      }
33      
34      public JaasAuthentication(Object user, Object credentials, Subject subject)
35      {
36          this.user = (String) user;
37          this.credentials = ((String) credentials).toCharArray();
38          this.subject = subject;
39      }
40  
41      public void setAuthenticated(boolean b)
42      {
43          authenticated = b;
44      }
45  
46      public boolean isAuthenticated()
47      {
48          return authenticated;
49      }
50  
51      public Object getCredentials()
52      {
53          return new String(credentials);
54      }
55  
56      public Object getPrincipal()
57      {
58          return user;
59      }
60  
61      public Map getProperties()
62      {
63          return properties;
64      }
65  
66      public void setProperties(Map properties)
67      {
68          this.properties = properties;
69      }
70  
71      public Subject getSubject()
72      {
73          return subject;
74      }
75  }