src/share/classes/java/security/KeyRep.java

Print this page


   1 /*
   2  * Copyright (c) 2003, 2011, 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


  99      * The Key encoding format
 100      *
 101      * @serial
 102      */
 103     private String format;
 104 
 105     /**
 106      * The encoded Key bytes
 107      *
 108      * @serial
 109      */
 110     private byte[] encoded;
 111 
 112     /**
 113      * Construct the alternate Key class.
 114      *
 115      * <p>
 116      *
 117      * @param type either one of Type.SECRET, Type.PUBLIC, or Type.PRIVATE
 118      * @param algorithm the algorithm returned from
 119      *          <code>Key.getAlgorithm()</code>
 120      * @param format the encoding format returned from
 121      *          <code>Key.getFormat()</code>
 122      * @param encoded the encoded bytes returned from
 123      *          <code>Key.getEncoded()</code>
 124      *
 125      * @exception NullPointerException
 126      *          if type is <code>null</code>,
 127      *          if algorithm is <code>null</code>,
 128      *          if format is <code>null</code>,
 129      *          or if encoded is <code>null</code>
 130      */
 131     public KeyRep(Type type, String algorithm,
 132                 String format, byte[] encoded) {
 133 
 134         if (type == null || algorithm == null ||
 135             format == null || encoded == null) {
 136             throw new NullPointerException("invalid null input(s)");
 137         }
 138 
 139         this.type = type;
 140         this.algorithm = algorithm;
 141         this.format = format.toUpperCase(Locale.ENGLISH);
 142         this.encoded = encoded.clone();
 143     }
 144 
 145     /**
 146      * Resolve the Key object.
 147      *
 148      * <p> This method supports three Type/format combinations:
 149      * <ul>


   1 /*
   2  * Copyright (c) 2003, 2013, 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


  99      * The Key encoding format
 100      *
 101      * @serial
 102      */
 103     private String format;
 104 
 105     /**
 106      * The encoded Key bytes
 107      *
 108      * @serial
 109      */
 110     private byte[] encoded;
 111 
 112     /**
 113      * Construct the alternate Key class.
 114      *
 115      * <p>
 116      *
 117      * @param type either one of Type.SECRET, Type.PUBLIC, or Type.PRIVATE
 118      * @param algorithm the algorithm returned from
 119      *          {@code Key.getAlgorithm()}
 120      * @param format the encoding format returned from
 121      *          {@code Key.getFormat()}
 122      * @param encoded the encoded bytes returned from
 123      *          {@code Key.getEncoded()}
 124      *
 125      * @exception NullPointerException
 126      *          if type is {@code null},
 127      *          if algorithm is {@code null},
 128      *          if format is {@code null},
 129      *          or if encoded is {@code null}
 130      */
 131     public KeyRep(Type type, String algorithm,
 132                 String format, byte[] encoded) {
 133 
 134         if (type == null || algorithm == null ||
 135             format == null || encoded == null) {
 136             throw new NullPointerException("invalid null input(s)");
 137         }
 138 
 139         this.type = type;
 140         this.algorithm = algorithm;
 141         this.format = format.toUpperCase(Locale.ENGLISH);
 142         this.encoded = encoded.clone();
 143     }
 144 
 145     /**
 146      * Resolve the Key object.
 147      *
 148      * <p> This method supports three Type/format combinations:
 149      * <ul>