< prev index next >

## src/java.base/share/classes/java/security/Provider.java

Print this page

       1 /*
       2  * Copyright (c) 1996, 2020, 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
     843
     844     // register the id attributes for this provider
     845     // this is to ensure that equals() and hashCode() do not incorrectly
     846     // report to different provider objects as the same
     847     private void putId() {
     848         // note: name and info may be null
     849         super.put("Provider.id name", String.valueOf(name));
     850         super.put("Provider.id version", String.valueOf(versionStr));
     851         super.put("Provider.id info", String.valueOf(info));
     852         super.put("Provider.id className", this.getClass().getName());
     853     }
     854
     855    /**
     856     * Reads the {@code ObjectInputStream} for the default serializable fields.
     857     * If the serialized field {@code versionStr} is found in the STREAM FIELDS,
     858     * its String value will be used to populate both the version string and
     859     * version number. If {@code versionStr} is not found, but {@code version}
     860     * is, then its double value will be used to populate both fields.
     861     *
     862     * @param in the {@code ObjectInputStream} to read

     863     * @serial
     864     */
     865     @java.io.Serial
     866     private void readObject(ObjectInputStream in)
     867                 throws IOException, ClassNotFoundException {
     868         Map<Object,Object> copy = new HashMap<>();
     869         for (Map.Entry<Object,Object> entry : super.entrySet()) {
     870             copy.put(entry.getKey(), entry.getValue());
     871         }
     872         defaults = null;
     873         in.defaultReadObject();
     874         if (this.versionStr == null) {
     875             // set versionStr based on version when not found in serialized bytes
     876             this.versionStr = Double.toString(this.version);
     877         } else {
     878             // otherwise, set version based on versionStr
     879             this.version = parseVersionStr(this.versionStr);
     880         }
     881         this.serviceMap = new ConcurrentHashMap<>();
     882         implClear();
       1 /*
       2  * Copyright (c) 1996, 2021, 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
     843
     844     // register the id attributes for this provider
     845     // this is to ensure that equals() and hashCode() do not incorrectly
     846     // report to different provider objects as the same
     847     private void putId() {
     848         // note: name and info may be null
     849         super.put("Provider.id name", String.valueOf(name));
     850         super.put("Provider.id version", String.valueOf(versionStr));
     851         super.put("Provider.id info", String.valueOf(info));
     852         super.put("Provider.id className", this.getClass().getName());
     853     }
     854
     855    /**
     856     * Reads the {@code ObjectInputStream} for the default serializable fields.
     857     * If the serialized field {@code versionStr} is found in the STREAM FIELDS,
     858     * its String value will be used to populate both the version string and
     859     * version number. If {@code versionStr} is not found, but {@code version}
     860     * is, then its double value will be used to populate both fields.
     861     *
     862     * @param in the {@code ObjectInputStream} to read
     863     * @throws IOException if an I/O error occurs
     864     * @throws ClassNotFoundException if a serialized class cannot be loaded
     865     * @serial
     866     */
     867     @java.io.Serial
     868     private void readObject(ObjectInputStream in)
     869                 throws IOException, ClassNotFoundException {
     870         Map<Object,Object> copy = new HashMap<>();
     871         for (Map.Entry<Object,Object> entry : super.entrySet()) {
     872             copy.put(entry.getKey(), entry.getValue());
     873         }
     874         defaults = null;
     875         in.defaultReadObject();
     876         if (this.versionStr == null) {
     877             // set versionStr based on version when not found in serialized bytes
     878             this.versionStr = Double.toString(this.version);
     879         } else {
     880             // otherwise, set version based on versionStr
     881             this.version = parseVersionStr(this.versionStr);
     882         }
     883         this.serviceMap = new ConcurrentHashMap<>();
     884         implClear();

< prev index next >