View Javadoc

1   /*
2    * $Id: PGPAuthentication.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.pgp;
12  
13  import org.mule.api.MuleEvent;
14  import org.mule.api.security.Authentication;
15  
16  import java.util.Map;
17  
18  import org.bouncycastle.openpgp.PGPPublicKey;
19  
20  public class PGPAuthentication implements Authentication
21  {
22      private boolean authenticated;
23      private String userName;
24      private Message message;
25      private PGPPublicKey publicKey;
26      private MuleEvent event;
27      
28      public PGPAuthentication(String userName, Message message)
29      {
30          this(userName, message, null);
31      }
32  
33      public PGPAuthentication(String userName, Message message, MuleEvent event)
34      {
35          this.authenticated = false;
36          this.userName = userName;
37          this.message = message;
38      }
39  
40      public void setAuthenticated(boolean b)
41      {
42          authenticated = b;
43      }
44  
45      public boolean isAuthenticated()
46      {
47          return authenticated;
48      }
49  
50      public Object getCredentials()
51      {
52          return message;
53      }
54  
55      public Object getDetails()
56      {
57          return publicKey;
58      }
59  
60      protected void setDetails(PGPPublicKey publicKey)
61      {
62          this.publicKey = publicKey;
63      }
64  
65      public Object getPrincipal()
66      {
67          return userName;
68      }
69  
70      public Map getProperties()
71      {
72          // TODO
73          return null;
74      }
75  
76      public void setProperties(Map securityMode)
77      {
78          // TODO
79  
80      }
81  
82      public MuleEvent getEvent()
83      {
84          return event;
85      }
86  
87      public void setEvent(MuleEvent muleEvent)
88      {
89          this.event = muleEvent;
90      }
91  }