001: /*
002: * @(#)SystemIdentity.java 1.31 06/10/10
003: *
004: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
005: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
006: *
007: * This program is free software; you can redistribute it and/or
008: * modify it under the terms of the GNU General Public License version
009: * 2 only, as published by the Free Software Foundation.
010: *
011: * This program is distributed in the hope that it will be useful, but
012: * WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * General Public License version 2 for more details (a copy is
015: * included at /legal/license.txt).
016: *
017: * You should have received a copy of the GNU General Public License
018: * version 2 along with this work; if not, write to the Free Software
019: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA
021: *
022: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
023: * Clara, CA 95054 or visit www.sun.com if you need additional
024: * information or have any questions.
025: *
026: */
027:
028: package sun.security.provider;
029:
030: import java.io.Serializable;
031: import java.util.Enumeration;
032: import java.security.*;
033:
034: /**
035: * An identity with a very simple trust mechanism.
036: *
037: * @version 1.31, 10/10/06
038: * @author Benjamin Renaud
039: */
040:
041: public class SystemIdentity extends Identity implements Serializable {
042:
043: /** use serialVersionUID from JDK 1.1. for interoperability */
044: private static final long serialVersionUID = 9060648952088498478L;
045:
046: /* This should be changed to ACL */
047: boolean trusted = false;
048:
049: /* Free form additional information about this identity. */
050: private String info;
051:
052: public SystemIdentity(String name, IdentityScope scope)
053: throws InvalidParameterException, KeyManagementException {
054: super (name, scope);
055: }
056:
057: /**
058: * Is this identity trusted by sun.* facilities?
059: */
060: public boolean isTrusted() {
061: return trusted;
062: }
063:
064: /**
065: * Set the trust status of this identity.
066: */
067: protected void setTrusted(boolean trusted) {
068: this .trusted = trusted;
069: }
070:
071: void setIdentityInfo(String info) {
072: super .setInfo(info);
073: }
074:
075: String getIndentityInfo() {
076: return super .getInfo();
077: }
078:
079: /**
080: * Call back method into a protected method for package friends.
081: */
082: void setIdentityPublicKey(PublicKey key)
083: throws KeyManagementException {
084: setPublicKey(key);
085: }
086:
087: /**
088: * Call back method into a protected method for package friends.
089: */
090: void addIdentityCertificate(Certificate cert)
091: throws KeyManagementException {
092: addCertificate(cert);
093: }
094:
095: void clearCertificates() throws KeyManagementException {
096: Certificate[] certs = certificates();
097: for (int i = 0; i < certs.length; i++) {
098: removeCertificate(certs[i]);
099: }
100: }
101:
102: public String toString() {
103: String trustedString = "not trusted";
104: if (trusted) {
105: trustedString = "trusted";
106: }
107: return super .toString() + "[" + trustedString + "]";
108: }
109:
110: }
|