Home | History | Annotate | Download | only in conscrypt
      1 /*
      2  * Copyright 2013 The Android Open Source Project
      3  *
      4  * Licensed under the Apache License, Version 2.0 (the "License");
      5  * you may not use this file except in compliance with the License.
      6  * You may obtain a copy of the License at
      7  *
      8  *      http://www.apache.org/licenses/LICENSE-2.0
      9  *
     10  * Unless required by applicable law or agreed to in writing, software
     11  * distributed under the License is distributed on an "AS IS" BASIS,
     12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     13  * See the License for the specific language governing permissions and
     14  * limitations under the License.
     15  */
     16 
     17 package org.conscrypt;
     18 
     19 import org.apache.harmony.security.utils.AlgNameMapper;
     20 import org.apache.harmony.security.utils.AlgNameMapperSource;
     21 
     22 class Platform {
     23     private static class NoPreloadHolder {
     24         public static final Platform MAPPER = new Platform();
     25     }
     26 
     27     /**
     28      * Runs all the setup for the platform that only needs to run once.
     29      */
     30     public static void setup() {
     31         NoPreloadHolder.MAPPER.ping();
     32     }
     33 
     34     /**
     35      * Just a placeholder to make sure the class is initialized.
     36      */
     37     private void ping() {
     38     }
     39 
     40     private Platform() {
     41         AlgNameMapper.setSource(new OpenSSLMapper());
     42     }
     43 
     44     private static class OpenSSLMapper implements AlgNameMapperSource {
     45         @Override
     46         public String mapNameToOid(String algName) {
     47             return NativeCrypto.OBJ_txt2nid_oid(algName);
     48         }
     49 
     50         @Override
     51         public String mapOidToName(String oid) {
     52             return NativeCrypto.OBJ_txt2nid_longName(oid);
     53         }
     54     }
     55 }