123 * properly initialized.
124 * @exception KeyException if the key pair cannot be set for any
125 * other reason.
126 * @exception SecurityException if a security manager exists and its
127 * {@code checkSecurityAccess} method doesn't allow
128 * setting the key pair.
129 *
130 * @see SecurityManager#checkSecurityAccess
131 */
132 public final void setKeyPair(KeyPair pair)
133 throws InvalidParameterException, KeyException {
134 check("setSignerKeyPair");
135 final PublicKey pub = pair.getPublic();
136 PrivateKey priv = pair.getPrivate();
137
138 if (pub == null || priv == null) {
139 throw new InvalidParameterException();
140 }
141 try {
142 AccessController.doPrivileged(
143 new PrivilegedExceptionAction<Void>() {
144 public Void run() throws KeyManagementException {
145 setPublicKey(pub);
146 return null;
147 }
148 });
149 } catch (PrivilegedActionException pae) {
150 throw (KeyManagementException) pae.getException();
151 }
152 privateKey = priv;
153 }
154
155 String printKeys() {
156 String keys = "";
157 PublicKey publicKey = getPublicKey();
158 if (publicKey != null && privateKey != null) {
159 keys = "\tpublic and private keys initialized";
160
161 } else {
162 keys = "\tno keys";
163 }
|
123 * properly initialized.
124 * @exception KeyException if the key pair cannot be set for any
125 * other reason.
126 * @exception SecurityException if a security manager exists and its
127 * {@code checkSecurityAccess} method doesn't allow
128 * setting the key pair.
129 *
130 * @see SecurityManager#checkSecurityAccess
131 */
132 public final void setKeyPair(KeyPair pair)
133 throws InvalidParameterException, KeyException {
134 check("setSignerKeyPair");
135 final PublicKey pub = pair.getPublic();
136 PrivateKey priv = pair.getPrivate();
137
138 if (pub == null || priv == null) {
139 throw new InvalidParameterException();
140 }
141 try {
142 AccessController.doPrivileged(
143 new PrivilegedExceptionAction<>() {
144 public Void run() throws KeyManagementException {
145 setPublicKey(pub);
146 return null;
147 }
148 });
149 } catch (PrivilegedActionException pae) {
150 throw (KeyManagementException) pae.getException();
151 }
152 privateKey = priv;
153 }
154
155 String printKeys() {
156 String keys = "";
157 PublicKey publicKey = getPublicKey();
158 if (publicKey != null && privateKey != null) {
159 keys = "\tpublic and private keys initialized";
160
161 } else {
162 keys = "\tno keys";
163 }
|