jdk/src/share/classes/sun/security/provider/SystemIdentity.java
changeset 4840 74d64c277d62
parent 4839 6b3edc448285
parent 4396 d78c0cb4baf7
child 4841 ae658e3b0f27
equal deleted inserted replaced
4839:6b3edc448285 4840:74d64c277d62
     1 /*
       
     2  * Copyright 1996-2000 Sun Microsystems, Inc.  All Rights Reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Sun designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Sun in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
       
    22  * CA 95054 USA or visit www.sun.com if you need additional information or
       
    23  * have any questions.
       
    24  */
       
    25 
       
    26 package sun.security.provider;
       
    27 
       
    28 import java.io.Serializable;
       
    29 import java.util.Enumeration;
       
    30 import java.security.*;
       
    31 
       
    32 /**
       
    33  * An identity with a very simple trust mechanism.
       
    34  *
       
    35  * @author      Benjamin Renaud
       
    36  */
       
    37 
       
    38 public class SystemIdentity extends Identity implements Serializable {
       
    39 
       
    40     /** use serialVersionUID from JDK 1.1. for interoperability */
       
    41     private static final long serialVersionUID = 9060648952088498478L;
       
    42 
       
    43     /* This should be changed to ACL */
       
    44     boolean trusted = false;
       
    45 
       
    46     /* Free form additional information about this identity. */
       
    47     private String info;
       
    48 
       
    49     public SystemIdentity(String name, IdentityScope scope)
       
    50     throws InvalidParameterException, KeyManagementException {
       
    51         super(name, scope);
       
    52     }
       
    53 
       
    54     /**
       
    55      * Is this identity trusted by sun.* facilities?
       
    56      */
       
    57     public boolean isTrusted() {
       
    58         return trusted;
       
    59     }
       
    60 
       
    61     /**
       
    62      * Set the trust status of this identity.
       
    63      */
       
    64     protected void setTrusted(boolean trusted) {
       
    65         this.trusted = trusted;
       
    66     }
       
    67 
       
    68     void setIdentityInfo(String info) {
       
    69         super.setInfo(info);
       
    70     }
       
    71 
       
    72     String getIndentityInfo() {
       
    73         return super.getInfo();
       
    74     }
       
    75 
       
    76     /**
       
    77      * Call back method into a protected method for package friends.
       
    78      */
       
    79     void setIdentityPublicKey(PublicKey key) throws KeyManagementException {
       
    80         setPublicKey(key);
       
    81     }
       
    82 
       
    83     /**
       
    84      * Call back method into a protected method for package friends.
       
    85      */
       
    86     void addIdentityCertificate(Certificate cert)
       
    87     throws KeyManagementException {
       
    88         addCertificate(cert);
       
    89     }
       
    90 
       
    91     void clearCertificates() throws KeyManagementException {
       
    92         Certificate[] certs = certificates();
       
    93         for (int i = 0; i < certs.length; i++) {
       
    94             removeCertificate(certs[i]);
       
    95         }
       
    96     }
       
    97 
       
    98     public String toString() {
       
    99         String trustedString = "not trusted";
       
   100         if (trusted) {
       
   101             trustedString = "trusted";
       
   102         }
       
   103         return super.toString() + "[" + trustedString + "]";
       
   104     }
       
   105 
       
   106 
       
   107 }