View Javadoc

1   /*
2    * Copyright  2003-2004 The Apache Software Foundation.
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *
16   */
17  
18  package org.apache.ws.security;
19  
20  /***
21   * WSDocInfoStore store WSDocInfo structure in a static Hash. 
22   * 
23   * Also the access methods are static. Thus it is possible to exchange
24   * WSDocInfo between otherwise unrelated functions/methods.
25   * The main usage for this is (are) the transformation functions that
26   * are called during Signature/Verfication process. 
27   * 
28   * @author Werner Dittmann (Werner.Dittmann@siemens.com)
29   */
30  
31  import java.util.Hashtable;
32  
33  public class WSDocInfoStore {
34  
35      static Hashtable storage = new Hashtable(10);
36  
37      public static WSDocInfo lookup(int hash) {
38          Integer intObj = new Integer(hash);
39          return (WSDocInfo) storage.get(intObj);
40      }
41  
42      public static void store(WSDocInfo info) {
43          Integer intObj = new Integer(info.getHash());
44          if (storage.containsKey(intObj)) {
45              return;
46          }
47          storage.put(intObj, info);
48      }
49  
50      public static void delete(int hash) {
51          Integer intObj = new Integer(hash);
52          WSDocInfo wsInfo = (WSDocInfo) storage.get(intObj);
53          if (wsInfo != null) {
54              wsInfo.clear();
55              storage.remove(intObj);
56          }
57      }
58  
59      public static void delete(WSDocInfo info) {
60          delete(info.getHash());
61      }
62  }