This commit is contained in:
Alexey Kudravtsev
2015-10-27 14:20:31 +03:00
parent af4057ba81
commit e2f947baaa
5 changed files with 18 additions and 17 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.jetbrains.annotations.NotNull;
public abstract class PasswordSafeTimed<T> extends TimedReference<T> {
private int myCheckCount;
public PasswordSafeTimed() {
protected PasswordSafeTimed() {
super(null);
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -50,7 +50,8 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
private static final String TEST_PASSWORD_VALUE = "test password";
private final PasswordDatabase myDatabase;
private transient final PasswordSafeTimed<Ref<Object>> myKey = new PasswordSafeTimed<Ref<Object>>() {
private final transient PasswordSafeTimed<Ref<Object>> myKey = new PasswordSafeTimed<Ref<Object>>() {
@Override
protected Ref<Object> compute() {
return Ref.create();
}
@@ -62,7 +63,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
};
public MasterKeyPasswordSafe(PasswordDatabase database) {
this.myDatabase = database;
myDatabase = database;
}
/**
@@ -118,7 +119,6 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
*
* @param oldPassword the old password
* @param newPassword the new password
* @param encrypt
* @return re-encrypted database
*/
boolean changeMasterPassword(String oldPassword, String newPassword, boolean encrypt) {
@@ -209,7 +209,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
return computable.compute();
}
final AsyncFutureResult<Object> future = AsyncFutureFactory.getInstance().createAsyncFutureResult();
final AsyncFutureResult<T> future = AsyncFutureFactory.getInstance().createAsyncFutureResult();
final ExpirableRunnable runnable = new ExpirableRunnable() {
@Override
public boolean isExpired() {
@@ -244,7 +244,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
IdeFocusManager.getGlobalInstance().doWhenFocusSettlesDown(runnable);
}
try {
return (T)future.get();
return future.get();
}
catch (InterruptedException e) {
throw new ProcessCanceledException(e);
@@ -307,7 +307,7 @@ public class MasterKeyPasswordSafe extends BasePasswordSafeProvider {
return setMasterPassword("");
}
@SuppressWarnings({"MethodMayBeStatic"})
@SuppressWarnings("MethodMayBeStatic")
public boolean isOsProtectedPasswordSupported() {
// TODO extension point needed?
return SystemInfo.isWindows;
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2010 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,11 +38,12 @@ public class MemoryPasswordSafe extends BasePasswordSafeProvider {
/**
* The key to use to encrypt data
*/
private transient final AtomicReference<byte[]> key = new AtomicReference<byte[]>();
private final transient AtomicReference<byte[]> key = new AtomicReference<byte[]>();
/**
* The password database
*/
private transient final PasswordSafeTimed<Map<ByteArrayWrapper, byte[]>> database = new PasswordSafeTimed<Map<ByteArrayWrapper, byte[]>>() {
private final transient PasswordSafeTimed<Map<ByteArrayWrapper, byte[]>> database = new PasswordSafeTimed<Map<ByteArrayWrapper, byte[]>>() {
@Override
protected Map<ByteArrayWrapper, byte[]> compute() {
return Collections.synchronizedMap(ContainerUtil.<ByteArrayWrapper, byte[]>newHashMap());
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,9 +19,9 @@ package com.intellij.util;
import com.intellij.openapi.Disposable;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext"})
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
public abstract class TimedComputable<T> extends Timed<T> {
private int myAcquireCount = 0;
private int myAcquireCount;
public TimedComputable(Disposable parentDisposable) {
super(parentDisposable);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,7 @@ package com.intellij.util;
import com.intellij.openapi.Disposable;
import org.jetbrains.annotations.Nullable;
@SuppressWarnings({"NonPrivateFieldAccessedInSynchronizedContext"})
@SuppressWarnings("NonPrivateFieldAccessedInSynchronizedContext")
public class TimedReference<T> extends Timed<T> {
public TimedReference(@Nullable Disposable parentDisposable) {
super(parentDisposable);