⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 certificateitem.java

📁 这是linux下ssl vpn的实现程序
💻 JAVA
字号:
/*
 *  SSL-Explorer
 *
 *  Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
 *
 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2 of
 *  the License, or (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public
 *  License along with this program; if not, write to the Free Software
 *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
			
package com.sslexplorer.keystore;

import java.security.cert.Certificate;

import com.sslexplorer.boot.KeyStoreManager;
import com.sslexplorer.table.TableItem;

/**
 * A {@link com.sslexplorer.table.TableItem} implementation used by displaying
 * certificates or keys in a {@link com.sslexplorer.boot.KeyStoreManager}.
 * 
 * @author Brett Smith <a href="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
 * @revision $Revision: 1.1 $
 */
public class CertificateItem implements TableItem {
    
    // Private instance variables
    
    private String alias;
    private KeyStoreManager keyStoreManager;

    /**
     * Constructor
     * 
     * @param alias alias for certificate
     * @param certificate the certificate object itself
     * @param keyStoreManager the key store manager that stores this key
     * 
     */
    public CertificateItem(String alias, Certificate certificate, KeyStoreManager keyStoreManager) {
        super();
        this.alias  = alias;
        this.keyStoreManager = keyStoreManager;
    }
    
    /**
     * Get the type of certificate as a string. Current possible values are
     * <b>Trusted Cert.</b>, <b>Certificate</b>, <b>Trusted Key</b>,
     * <b>Key</b> or <b>Unknown</b>.
     * 
     * @return type of certificate as a string.
     */
    public String getType() {
        /* TODO this method doesn't take into i18n so should really return some
         * localed independant constant and be turned into a string on the 
         * JSP side
         */
        try {
	        if(keyStoreManager.getKeyStore().isCertificateEntry(alias)) {	            
	            return keyStoreManager.isCertificateTrusted(
	                            alias) ? "Trusted Cert." : "Certificate" ;
	        }
	        else if (keyStoreManager.getKeyStore().isKeyEntry(alias)){	            
	            return keyStoreManager.isCertificateTrusted(
	                            alias) ? "Trusted Key." : "Key" ;
	        }
        }
        catch(Exception e) {
            
        }
        return "Unknown";
    }
    
    /**
     * Get the alias of the certificate / key
     * 
     * @return alias
     */
    public String getAlias() {
        return alias;
    }

    /* (non-Javadoc)
     * @see com.sslexplorer.table.TableItem#getColumnValue(int)
     */
    public Object getColumnValue(int col) {
        switch(col) {
            case 0:
                return alias;
            default:
                return getType();
        }
    }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -