001: /*
002: * @(#)SystemSigner.java 1.36 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.util.*;
031: import java.security.*;
032:
033: /**
034: * SunSecurity signer. Like SystemIdentity, it has a trust bit, which
035: * can be set by SunSecurity classes, and a set of accessors for other
036: * classes in sun.security.*.
037: *
038: * @version 1.36, 10/10/06
039: * @author Benjamin Renaud
040: */
041:
042: public class SystemSigner extends Signer {
043:
044: /** use serialVersionUID from JDK 1.1. for interoperability */
045: private static final long serialVersionUID = -2127743304301557711L;
046:
047: /* Is this signer trusted */
048: private boolean trusted = false;
049:
050: /**
051: * Construct a signer with a given name.
052: */
053: public SystemSigner(String name) {
054: super (name);
055: }
056:
057: /**
058: * Construct a signer with a name and a scope.
059: *
060: * @param name the signer's name.
061: *
062: * @param scope the scope for this signer.
063: */
064: public SystemSigner(String name, IdentityScope scope)
065: throws KeyManagementException {
066:
067: super (name, scope);
068: }
069:
070: /* Set the trust status of this signer */
071: void setTrusted(boolean trusted) {
072: this .trusted = trusted;
073: }
074:
075: /**
076: * Returns true if this signer is trusted.
077: */
078: public boolean isTrusted() {
079: return trusted;
080: }
081:
082: /* friendly callback for set keys */
083: void setSignerKeyPair(KeyPair pair)
084: throws InvalidParameterException, KeyException {
085: setKeyPair(pair);
086: }
087:
088: /* friendly callback for getting private keys */
089: PrivateKey getSignerPrivateKey() {
090: return getPrivateKey();
091: }
092:
093: void setSignerInfo(String s) {
094: setInfo(s);
095: }
096:
097: /**
098: * Call back method into a protected method for package friends.
099: */
100: void addSignerCertificate(Certificate cert)
101: throws KeyManagementException {
102: addCertificate(cert);
103: }
104:
105: void clearCertificates() throws KeyManagementException {
106: Certificate[] certs = certificates();
107: for (int i = 0; i < certs.length; i++) {
108: removeCertificate(certs[i]);
109: }
110: }
111:
112: public String toString() {
113: String trustedString = "not trusted";
114: if (trusted) {
115: trustedString = "trusted";
116: }
117: return super .toString() + "[" + trustedString + "]";
118: }
119: }
|