src/java.base/share/classes/sun/security/rsa/SunRsaSign.java
changeset 52995 9af672cab7cb
parent 47216 71c04702a3d5
child 57950 4612a3cfb927
equal deleted inserted replaced
52994:d590cf6b4fac 52995:9af672cab7cb
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     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
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    27 
    27 
    28 import java.util.*;
    28 import java.util.*;
    29 
    29 
    30 import java.security.*;
    30 import java.security.*;
    31 
    31 
    32 import sun.security.action.PutAllAction;
       
    33 import static sun.security.util.SecurityConstants.PROVIDER_VER;
    32 import static sun.security.util.SecurityConstants.PROVIDER_VER;
    34 
    33 
    35 /**
    34 /**
    36  * Provider class for the RSA signature provider. Supports RSA keyfactory,
    35  * Provider class for the RSA signature provider. Supports RSA keyfactory,
    37  * keypair generation, and RSA signatures.
    36  * keypair generation, and RSA signatures.
    44     private static final long serialVersionUID = 866040293550393045L;
    43     private static final long serialVersionUID = 866040293550393045L;
    45 
    44 
    46     public SunRsaSign() {
    45     public SunRsaSign() {
    47         super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider");
    46         super("SunRsaSign", PROVIDER_VER, "Sun RSA signature provider");
    48 
    47 
    49         // if there is no security manager installed, put directly into
    48         Provider p = this;
    50         // the provider. Otherwise, create a temporary map and use a
    49         Iterator<Provider.Service> serviceIter = new SunRsaSignEntries(p).iterator();
    51         // doPrivileged() call at the end to transfer the contents
    50 
    52         if (System.getSecurityManager() == null) {
    51         if (System.getSecurityManager() == null) {
    53             SunRsaSignEntries.putEntries(this);
    52             putEntries(serviceIter);
    54         } else {
    53         } else {
    55             // use LinkedHashMap to preserve the order of the PRNGs
    54             AccessController.doPrivileged(new PrivilegedAction<Void>() {
    56             Map<Object, Object> map = new HashMap<>();
    55                 @Override
    57             SunRsaSignEntries.putEntries(map);
    56                 public Void run() {
    58             AccessController.doPrivileged(new PutAllAction(this, map));
    57                     putEntries(serviceIter);
       
    58                     return null;
       
    59                 }
       
    60             });
    59         }
    61         }
    60     }
    62     }
    61 
    63     void putEntries(Iterator<Provider.Service> i) {
       
    64         while (i.hasNext()) {
       
    65             putService(i.next());
       
    66         }
       
    67     }
    62 }
    68 }