< prev index next >

src/jdk.crypto.cryptoki/share/classes/sun/security/pkcs11/Config.java

Print this page
rev 59383 : [mq]: final
   1 /*
   2  * Copyright (c) 2003, 2017, 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


 646         }
 647     }
 648 
 649     private void checkDup(String keyword) throws IOException {
 650         if (parsedKeywords.contains(keyword)) {
 651             throw excLine(keyword + " must only be specified once");
 652         }
 653     }
 654 
 655     //
 656     // individual entry parsing methods
 657     //
 658 
 659     private String parseLibrary(String keyword) throws IOException {
 660         checkDup(keyword);
 661         parseEquals();
 662         String lib = parseLine();
 663         lib = expand(lib);
 664         int i = lib.indexOf("/$ISA/");
 665         if (i != -1) {
 666             // replace "/$ISA/" with "/sparcv9/" on 64-bit Solaris SPARC
 667             // and with "/amd64/" on Solaris AMD64.
 668             // On all other platforms, just turn it into a "/"
 669             String prefix = lib.substring(0, i);
 670             String suffix = lib.substring(i + 5);
 671             if (osName.equals("SunOS") && osArch.equals("sparcv9")) {
 672                 lib = prefix + "/sparcv9" + suffix;
 673             } else if (osName.equals("SunOS") && osArch.equals("amd64")) {
 674                 lib = prefix + "/amd64" + suffix;
 675             } else {
 676                 lib = prefix + suffix;
 677             }
 678         }
 679         debug(keyword + ": " + lib);
 680 
 681         // Check to see if full path is specified to prevent the DLL
 682         // preloading attack
 683         if (!(new File(lib)).isAbsolute()) {
 684             throw new ConfigurationException(
 685                 "Absolute path required for library value: " + lib);
 686         }
 687         return lib;
 688     }
 689 
 690     private void parseDescription(String keyword) throws IOException {
 691         checkDup(keyword);
 692         parseEquals();
 693         description = parseLine();
 694         debug("description: " + description);
 695     }
 696 
 697     private void parseSlotID(String keyword) throws IOException {


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


 646         }
 647     }
 648 
 649     private void checkDup(String keyword) throws IOException {
 650         if (parsedKeywords.contains(keyword)) {
 651             throw excLine(keyword + " must only be specified once");
 652         }
 653     }
 654 
 655     //
 656     // individual entry parsing methods
 657     //
 658 
 659     private String parseLibrary(String keyword) throws IOException {
 660         checkDup(keyword);
 661         parseEquals();
 662         String lib = parseLine();
 663         lib = expand(lib);
 664         int i = lib.indexOf("/$ISA/");
 665         if (i != -1) {
 666             // replace "/$ISA/" with "/"


 667             String prefix = lib.substring(0, i);
 668             String suffix = lib.substring(i + 5);





 669             lib = prefix + suffix;

 670         }
 671         debug(keyword + ": " + lib);
 672 
 673         // Check to see if full path is specified to prevent the DLL
 674         // preloading attack
 675         if (!(new File(lib)).isAbsolute()) {
 676             throw new ConfigurationException(
 677                 "Absolute path required for library value: " + lib);
 678         }
 679         return lib;
 680     }
 681 
 682     private void parseDescription(String keyword) throws IOException {
 683         checkDup(keyword);
 684         parseEquals();
 685         description = parseLine();
 686         debug("description: " + description);
 687     }
 688 
 689     private void parseSlotID(String keyword) throws IOException {


< prev index next >