View Javadoc

1   /*
2    * $Id: SpringAuthenticationAdapter.java 22391 2011-07-12 12:00:48Z dirk.olmes $
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.spring.security;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.security.Authentication;
15  
16  import java.util.Map;
17  
18  import org.springframework.security.core.GrantedAuthority;
19  
20  /**
21   * 
22   */
23  public class SpringAuthenticationAdapter implements Authentication
24  {
25      private static final long serialVersionUID = -5906282218126929871L;
26  
27      private org.springframework.security.core.Authentication delegate;    
28      private Map properties;
29      private MuleEvent event;
30      
31      public SpringAuthenticationAdapter(org.springframework.security.core.Authentication authentication)    
32      {
33          this(authentication, null);
34      }
35  
36      public SpringAuthenticationAdapter(org.springframework.security.core.Authentication authentication, Map properties)    
37      {
38          this(authentication, properties, null);
39      }
40  
41      public SpringAuthenticationAdapter(org.springframework.security.core.Authentication authentication, Map properties, MuleEvent event)    
42      {
43          this.delegate = authentication;
44          this.properties = properties;
45          this.event = event;
46      }
47  
48      @Override
49      public void setAuthenticated(boolean b)
50      {
51          delegate.setAuthenticated(b);
52      }
53  
54      @Override
55      public boolean isAuthenticated()
56      {
57          return delegate.isAuthenticated();
58      }
59  
60      public org.springframework.security.core.GrantedAuthority[] getAuthorities()    
61      {
62          return delegate.getAuthorities().toArray(new GrantedAuthority[delegate.getAuthorities().size()]);        
63      }
64  
65      @Override
66      public Object getCredentials()
67      {
68          return delegate.getCredentials();
69      }
70  
71      public Object getDetails()
72      {
73          return delegate.getDetails();
74      }
75  
76      @Override
77      public Object getPrincipal()
78      {
79          return delegate.getPrincipal();
80      }
81  
82      @Override
83      public int hashCode()
84      {
85          return delegate.hashCode();
86      }
87  
88      @Override
89      public boolean equals(Object another)
90      {
91          return delegate.equals(another);
92      }
93  
94      public String getName()
95      {
96          return delegate.getName();
97      }
98  
99      public org.springframework.security.core.Authentication getDelegate()    
100     {
101         return delegate;
102     }
103 
104     @Override
105     public Map getProperties()
106     {
107         return properties;
108     }
109 
110     @Override
111     public void setProperties(Map properties)
112     {
113         this.properties = properties;
114     }
115 
116     @Override
117     public MuleEvent getEvent()
118     {
119         return event;
120     }
121 
122     public void setEvent(MuleEvent muleEvent)
123     {
124         this.event = muleEvent;
125     }
126 }