mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 14:54:52 +02:00
6383195: javax.crypto.spec.PBEKeySpec is not thread safe
Reviewed-by: weijun
This commit is contained in:
parent
e052d7f4bc
commit
791fc5791a
2 changed files with 98 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 1997, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
|
@ -173,7 +173,7 @@ public class PBEKeySpec implements KeySpec {
|
|||
* Clears the internal copy of the password.
|
||||
*
|
||||
*/
|
||||
public final void clearPassword() {
|
||||
public final synchronized void clearPassword() {
|
||||
if (password != null) {
|
||||
Arrays.fill(password, ' ');
|
||||
password = null;
|
||||
|
@ -191,7 +191,7 @@ public class PBEKeySpec implements KeySpec {
|
|||
* calling <code>clearPassword</code> method.
|
||||
* @return the password.
|
||||
*/
|
||||
public final char[] getPassword() {
|
||||
public final synchronized char[] getPassword() {
|
||||
if (password == null) {
|
||||
throw new IllegalStateException("password has been cleared");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue