View Javadoc

1   /*
2    * $Id: DefaultMuleAuthentication.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.security;
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  public class DefaultMuleAuthentication implements Authentication
20  {
21      private boolean authenticated;
22      private char[] credentials;
23      private String user;
24      private Map properties;
25      private MuleEvent event;
26      
27      public DefaultMuleAuthentication(Credentials credentials)
28      {
29          this(credentials, null);
30      }
31      
32      public DefaultMuleAuthentication(Credentials credentials, MuleEvent event)
33      {
34          this.event = event;
35          this.user = credentials.getUsername();
36          this.credentials = credentials.getPassword();
37      }
38  
39      public MuleEvent getEvent()
40      {
41          return event;
42      }
43  
44      public void setEvent(MuleEvent muleEvent)
45      {
46          this.event = muleEvent;
47      }
48  
49      public void setAuthenticated(boolean b)
50      {
51          authenticated = b;
52      }
53  
54      public boolean isAuthenticated()
55      {
56          return authenticated;
57      }
58  
59      public Object getCredentials()
60      {
61          return new String(credentials);
62      }
63  
64      public Object getPrincipal()
65      {
66          return user;
67      }
68  
69      public Map getProperties()
70      {
71          return properties;
72      }
73  
74      public void setProperties(Map properties)
75      {
76          this.properties = properties;
77      }
78  
79  }