< prev index next >

src/java.base/share/classes/java/security/SecureRandom.java

Print this page




 599      * include a list of known strong {@code SecureRandom}
 600      * implementations in the {@code securerandom.strongAlgorithms}
 601      * Security property.
 602      * <p>
 603      * Every implementation of the Java platform is required to
 604      * support at least one strong {@code SecureRandom} implementation.
 605      *
 606      * @return a strong {@code SecureRandom} implementation as indicated
 607      * by the {@code securerandom.strongAlgorithms} Security property
 608      *
 609      * @throws NoSuchAlgorithmException if no algorithm is available
 610      *
 611      * @see Security#getProperty(String)
 612      *
 613      * @since 1.8
 614      */
 615     public static SecureRandom getInstanceStrong()
 616             throws NoSuchAlgorithmException {
 617 
 618         String property = AccessController.doPrivileged(
 619             new PrivilegedAction<String>() {
 620                 @Override
 621                 public String run() {
 622                     return Security.getProperty(
 623                         "securerandom.strongAlgorithms");
 624                 }
 625             });
 626 
 627         if ((property == null) || (property.length() == 0)) {
 628             throw new NoSuchAlgorithmException(
 629                 "Null/empty securerandom.strongAlgorithms Security Property");
 630         }
 631 
 632         String remainder = property;
 633         while (remainder != null) {
 634             Matcher m;
 635             if ((m = StrongPatternHolder.pattern.matcher(
 636                     remainder)).matches()) {
 637 
 638                 String alg = m.group(1);
 639                 String prov = m.group(3);




 599      * include a list of known strong {@code SecureRandom}
 600      * implementations in the {@code securerandom.strongAlgorithms}
 601      * Security property.
 602      * <p>
 603      * Every implementation of the Java platform is required to
 604      * support at least one strong {@code SecureRandom} implementation.
 605      *
 606      * @return a strong {@code SecureRandom} implementation as indicated
 607      * by the {@code securerandom.strongAlgorithms} Security property
 608      *
 609      * @throws NoSuchAlgorithmException if no algorithm is available
 610      *
 611      * @see Security#getProperty(String)
 612      *
 613      * @since 1.8
 614      */
 615     public static SecureRandom getInstanceStrong()
 616             throws NoSuchAlgorithmException {
 617 
 618         String property = AccessController.doPrivileged(
 619             new PrivilegedAction<>() {
 620                 @Override
 621                 public String run() {
 622                     return Security.getProperty(
 623                         "securerandom.strongAlgorithms");
 624                 }
 625             });
 626 
 627         if ((property == null) || (property.length() == 0)) {
 628             throw new NoSuchAlgorithmException(
 629                 "Null/empty securerandom.strongAlgorithms Security Property");
 630         }
 631 
 632         String remainder = property;
 633         while (remainder != null) {
 634             Matcher m;
 635             if ((m = StrongPatternHolder.pattern.matcher(
 636                     remainder)).matches()) {
 637 
 638                 String alg = m.group(1);
 639                 String prov = m.group(3);


< prev index next >