1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18 package java.security; 19 20 import java.io.Serializable; 21 22 /** 23 * {@code Key} is the common interface for all keys. 24 * 25 * @see PublicKey 26 * @see PrivateKey 27 */ 28 public interface Key extends Serializable { 29 30 /** 31 * The {@code serialVersionUID} to be compatible with JDK1.1. 32 */ 33 public static final long serialVersionUID = 6603384152749567654L; 34 35 /** 36 * Returns the name of the algorithm of this key. If the algorithm is 37 * unknown, {@code null} is returned. 38 * 39 * @return the name of the algorithm of this key or {@code null} if the 40 * algorithm is unknown. 41 */ getAlgorithm()42 public String getAlgorithm(); 43 44 /** 45 * Returns the name of the format used to encode this key, or {@code null} 46 * if it can not be encoded. 47 * 48 * @return the name of the format used to encode this key, or {@code null} 49 * if it can not be encoded. 50 */ getFormat()51 public String getFormat(); 52 53 /** 54 * Returns the encoded form of this key, or {@code null} if encoding is not 55 * supported by this key. 56 * 57 * @return the encoded form of this key, or {@code null} if encoding is not 58 * supported by this key. 59 */ getEncoded()60 public byte[] getEncoded(); 61 } 62