View Javadoc

1   /*
2    * $Id: SecurityNotification.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.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.impl.internal.notifications;
12  
13  import org.mule.umo.manager.UMOServerNotification;
14  
15  /**
16   * <code>SecurityNotification</code> is fired when a request for authorisation
17   * occurs. The event may denote successful access or denied access depending on the
18   * type of event. Subscribing to these notifications developers can maintain an
19   * access log, block clients, etc.
20   * 
21   * @see org.mule.MuleManager
22   * @see org.mule.umo.manager.UMOManager
23   */
24  public class SecurityNotification extends UMOServerNotification
25  {
26      /**
27       * Serial version
28       */
29      private static final long serialVersionUID = 5951835321289699941L;
30  
31      public static final int SECURITY_AUTHENTICATION_FAILED = SECURITY_EVENT_ACTION_START_RANGE + 1;
32  
33      private static final transient String[] ACTIONS = new String[]{"authentication failed"};
34  
35      public SecurityNotification(org.mule.umo.security.SecurityException message, int action)
36      {
37          super(message, action);
38          resourceIdentifier = message.toString();
39      }
40  
41      protected String getPayloadToString()
42      {
43          return source.toString();
44      }
45  
46      protected String getActionName(int action)
47      {
48          int i = action - SECURITY_EVENT_ACTION_START_RANGE;
49          if (i - 1 > ACTIONS.length)
50          {
51              return String.valueOf(action);
52          }
53          return ACTIONS[i - 1];
54      }
55  
56      public String getType()
57      {
58          return TYPE_WARNING;
59      }
60  }