View Javadoc

1   /*
2    * $Id: SaveCertificateCallback.java 20321 2010-11-24 15:21:24Z dfeist $
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.transport.ssl;
12  
13  import org.mule.api.MuleEventContext;
14  import org.mule.tck.functional.EventCallback;
15  
16  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicBoolean;
17  import edu.emory.mathcs.backport.java.util.concurrent.atomic.AtomicReference;
18  
19  public class SaveCertificateCallback implements EventCallback
20  {
21  
22      private AtomicReference certificates;
23      private AtomicBoolean called;
24  
25      public SaveCertificateCallback()
26      {
27          clear();
28      }
29  
30      public void eventReceived(MuleEventContext context, Object component) throws Exception
31      {
32          certificates.set(context.getMessage().getOutboundProperty(SslConnector.LOCAL_CERTIFICATES));
33          called.set(true);
34      }
35  
36      public void clear()
37      {
38          certificates = new AtomicReference();
39          called = new AtomicBoolean(false);
40      }
41  
42      public boolean isCalled()
43      {
44          return called.get();
45      }
46  
47      public Object getCertificates()
48      {
49          return certificates.get();
50      }
51  
52  }