Save This Page
Home » openjdk-7 » java » security » spec » [javadoc | source]
    1   /*
    2    * Copyright (c) 1997, 2005, Oracle and/or its affiliates. All rights reserved.
    3    * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
    4    *
    5    * This code is free software; you can redistribute it and/or modify it
    6    * under the terms of the GNU General Public License version 2 only, as
    7    * published by the Free Software Foundation.  Oracle designates this
    8    * particular file as subject to the "Classpath" exception as provided
    9    * by Oracle in the LICENSE file that accompanied this code.
   10    *
   11    * This code is distributed in the hope that it will be useful, but WITHOUT
   12    * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   13    * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
   14    * version 2 for more details (a copy is included in the LICENSE file that
   15    * accompanied this code).
   16    *
   17    * You should have received a copy of the GNU General Public License version
   18    * 2 along with this work; if not, write to the Free Software Foundation,
   19    * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
   20    *
   21    * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
   22    * or visit www.oracle.com if you need additional information or have any
   23    * questions.
   24    */
   25   
   26   package java.security.spec;
   27   
   28   /**
   29    * This class represents a public or private key in encoded format.
   30    *
   31    * @author Jan Luehe
   32    *
   33    *
   34    * @see java.security.Key
   35    * @see java.security.KeyFactory
   36    * @see KeySpec
   37    * @see X509EncodedKeySpec
   38    * @see PKCS8EncodedKeySpec
   39    *
   40    * @since 1.2
   41    */
   42   
   43   public abstract class EncodedKeySpec implements KeySpec {
   44   
   45       private byte[] encodedKey;
   46   
   47       /**
   48        * Creates a new EncodedKeySpec with the given encoded key.
   49        *
   50        * @param encodedKey the encoded key. The contents of the
   51        * array are copied to protect against subsequent modification.
   52        * @exception NullPointerException if <code>encodedKey</code>
   53        * is null.
   54        */
   55       public EncodedKeySpec(byte[] encodedKey) {
   56           this.encodedKey = encodedKey.clone();
   57       }
   58   
   59       /**
   60        * Returns the encoded key.
   61        *
   62        * @return the encoded key. Returns a new array each time
   63        * this method is called.
   64        */
   65       public byte[] getEncoded() {
   66           return this.encodedKey.clone();
   67       }
   68   
   69       /**
   70        * Returns the name of the encoding format associated with this
   71        * key specification.
   72        *
   73        * <p>If the opaque representation of a key
   74        * (see {@link java.security.Key Key}) can be transformed
   75        * (see {@link java.security.KeyFactory KeyFactory})
   76        * into this key specification (or a subclass of it),
   77        * <code>getFormat</code> called
   78        * on the opaque key returns the same value as the
   79        * <code>getFormat</code> method
   80        * of this key specification.
   81        *
   82        * @return a string representation of the encoding format.
   83        */
   84       public abstract String getFormat();
   85   }

Save This Page
Home » openjdk-7 » java » security » spec » [javadoc | source]