001 /** 002 * Copyright 2005-2012 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.ksb.security.admin; 017 018 import java.io.Serializable; 019 import java.security.KeyStore; 020 import java.util.Date; 021 import java.util.HashMap; 022 import java.util.Map; 023 024 /** 025 * Class used to hold displayable data for KeyStore entries 026 * 027 * @author Kuali Rice Team (rice.collab@kuali.org) 028 * 029 */ 030 public class KeyStoreEntryDataContainer implements Serializable { 031 032 private static final String DISPLAYABLE_ENTRY_TYPE_TRUSTED_CERTIFICATE = "Trusted Certificate"; 033 private static final String DISPLAYABLE_ENTRY_TYPE_PRIVATE_KEY = "Private Key"; 034 private static final String DISPLAYABLE_ENTRY_TYPE_SECRET_KEY = "Secret Key"; 035 036 public static final Map<Class<? extends KeyStore.Entry>,String> DISPLAYABLE_ENTRY_TYPES = new HashMap<Class<? extends KeyStore.Entry>,String>(); 037 static { 038 DISPLAYABLE_ENTRY_TYPES.put(KeyStore.TrustedCertificateEntry.class, DISPLAYABLE_ENTRY_TYPE_TRUSTED_CERTIFICATE); 039 DISPLAYABLE_ENTRY_TYPES.put(KeyStore.PrivateKeyEntry.class, DISPLAYABLE_ENTRY_TYPE_PRIVATE_KEY); 040 DISPLAYABLE_ENTRY_TYPES.put(KeyStore.SecretKeyEntry.class, DISPLAYABLE_ENTRY_TYPE_SECRET_KEY); 041 } 042 043 private String alias; 044 private Date createDate; 045 private Class<? extends KeyStore.Entry> type; 046 047 public KeyStoreEntryDataContainer(String alias, Date createDate) { 048 super(); 049 this.alias = alias; 050 this.createDate = createDate; 051 } 052 053 public boolean isAllowsRemoval() { 054 if (KeyStore.TrustedCertificateEntry.class.equals(type)) { 055 return true; 056 } 057 return false; 058 } 059 060 public String getDisplayType() { 061 return DISPLAYABLE_ENTRY_TYPES.get(getType()); 062 } 063 064 /** 065 * @return the alias 066 */ 067 public String getAlias() { 068 return this.alias; 069 } 070 071 /** 072 * @param alias the alias to set 073 */ 074 public void setAlias(String alias) { 075 this.alias = alias; 076 } 077 078 /** 079 * @return the createDate 080 */ 081 public Date getCreateDate() { 082 return this.createDate; 083 } 084 085 /** 086 * @param createDate the createDate to set 087 */ 088 public void setCreateDate(Date createDate) { 089 this.createDate = createDate; 090 } 091 092 /** 093 * @return the type 094 */ 095 public Class<? extends KeyStore.Entry> getType() { 096 return this.type; 097 } 098 099 /** 100 * @param type the type to set 101 */ 102 public void setType(Class<? extends KeyStore.Entry> type) { 103 this.type = type; 104 } 105 106 }