View Javadoc
1   /**
2    * Copyright 2005-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community 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.opensource.org/licenses/ecl2.php
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  package org.kuali.rice.ksb.security.admin;
17  
18  import java.io.Serializable;
19  import java.security.KeyStore;
20  import java.util.Date;
21  import java.util.HashMap;
22  import java.util.Map;
23  
24  /**
25   * Class used to hold displayable data for KeyStore entries 
26   * 
27   * @author Kuali Rice Team (rice.collab@kuali.org)
28   *
29   */
30  public class KeyStoreEntryDataContainer implements Serializable {
31      
32      private static final String DISPLAYABLE_ENTRY_TYPE_TRUSTED_CERTIFICATE = "Trusted Certificate";
33      private static final String DISPLAYABLE_ENTRY_TYPE_PRIVATE_KEY = "Private Key";
34      private static final String DISPLAYABLE_ENTRY_TYPE_SECRET_KEY = "Secret Key";
35      
36      public static final Map<Class<? extends KeyStore.Entry>,String> DISPLAYABLE_ENTRY_TYPES = new HashMap<Class<? extends KeyStore.Entry>,String>();
37      static {
38          DISPLAYABLE_ENTRY_TYPES.put(KeyStore.TrustedCertificateEntry.class, DISPLAYABLE_ENTRY_TYPE_TRUSTED_CERTIFICATE);
39          DISPLAYABLE_ENTRY_TYPES.put(KeyStore.PrivateKeyEntry.class, DISPLAYABLE_ENTRY_TYPE_PRIVATE_KEY);
40          DISPLAYABLE_ENTRY_TYPES.put(KeyStore.SecretKeyEntry.class, DISPLAYABLE_ENTRY_TYPE_SECRET_KEY);
41      }
42  
43      private String alias;
44      private Date createDate;
45      private Class<? extends KeyStore.Entry> type;
46      
47      public KeyStoreEntryDataContainer(String alias, Date createDate) {
48          super();
49          this.alias = alias;
50          this.createDate = createDate;
51      }
52      
53      public boolean isAllowsRemoval() {
54          if (KeyStore.TrustedCertificateEntry.class.equals(type)) {
55              return true;
56          }
57          return false;
58      }
59      
60      public String getDisplayType() {
61          return DISPLAYABLE_ENTRY_TYPES.get(getType());
62      }
63  
64      /**
65       * @return the alias
66       */
67      public String getAlias() {
68          return this.alias;
69      }
70  
71      /**
72       * @param alias the alias to set
73       */
74      public void setAlias(String alias) {
75          this.alias = alias;
76      }
77  
78      /**
79       * @return the createDate
80       */
81      public Date getCreateDate() {
82          return this.createDate;
83      }
84  
85      /**
86       * @param createDate the createDate to set
87       */
88      public void setCreateDate(Date createDate) {
89          this.createDate = createDate;
90      }
91  
92      /**
93       * @return the type
94       */
95      public Class<? extends KeyStore.Entry> getType() {
96          return this.type;
97      }
98  
99      /**
100      * @param type the type to set
101      */
102     public void setType(Class<? extends KeyStore.Entry> type) {
103         this.type = type;
104     }
105     
106 }