View Javadoc

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