001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017:
018: /**
019: * @author Aleksei Y. Semenov
020: * @version $Revision$
021: */package java.security;
022:
023: /**
024: * @com.intel.drl.spec_ref
025: *
026: * @deprecated Replaced by behavior in
027: * {@link java.security.cert java.security.cert} package and
028: * {@link java.security.Principal Principal}
029: */
030: @Deprecated
031: public abstract class Signer extends Identity {
032:
033: /**
034: * @com.intel.drl.spec_ref
035: */
036: private static final long serialVersionUID = -1763464102261361480L;
037:
038: /**
039: * @com.intel.drl.spec_ref
040: */
041: private PrivateKey privateKey;
042:
043: /**
044: * @com.intel.drl.spec_ref
045: */
046: protected Signer() {
047: super ();
048: }
049:
050: /**
051: * @com.intel.drl.spec_ref
052: */
053: public Signer(String name) {
054: super (name);
055: }
056:
057: /**
058: * @com.intel.drl.spec_ref
059: */
060: public Signer(String name, IdentityScope scope)
061: throws KeyManagementException {
062: super (name, scope);
063: }
064:
065: /**
066: * @com.intel.drl.spec_ref
067: */
068: public PrivateKey getPrivateKey() {
069: SecurityManager sm = System.getSecurityManager();
070: if (sm != null) {
071: sm.checkSecurityAccess("getSignerPrivateKey"); //$NON-NLS-1$
072: }
073:
074: return privateKey;
075: }
076:
077: /**
078: * @com.intel.drl.spec_ref
079: */
080: public final void setKeyPair(KeyPair pair)
081: throws InvalidParameterException, KeyException {
082:
083: if (pair == null) {
084: throw new NullPointerException();
085: }
086:
087: if ((pair.getPrivate() == null) || (pair.getPublic() == null)) {
088: throw new InvalidParameterException();
089: }
090: SecurityManager sm = System.getSecurityManager();
091: if (sm != null) {
092: sm.checkSecurityAccess("setSignerKeyPair"); //$NON-NLS-1$
093: }
094: final PublicKey pk = pair.getPublic();
095: try {
096: AccessController
097: .doPrivileged(new PrivilegedExceptionAction<Void>() {
098: public Void run() throws KeyManagementException {
099: setPublicKey(pk);
100: return null;
101: }
102: });
103: } catch (PrivilegedActionException e) {
104: throw new KeyException(e.getException());
105: }
106: this .privateKey = pair.getPrivate();
107: }
108:
109: /**
110: * @com.intel.drl.spec_ref
111: */
112: public String toString() {
113: String s = "[Signer]" + getName(); //$NON-NLS-1$
114: if (getScope() != null) {
115: s = s + '[' + getScope().toString() + ']';
116: }
117: return s;
118: }
119: }
|