本文整理汇总了Java中com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper类的典型用法代码示例。如果您正苦于以下问题:Java ByteArrayWrapper类的具体用法?Java ByteArrayWrapper怎么用?Java ByteArrayWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ByteArrayWrapper类属于com.intellij.ide.passwordSafe.impl.providers包,在下文中一共展示了ByteArrayWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: changeMasterPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Encrypt database with new password
*
* @param oldPassword the old password
* @param newPassword the new password
* @param encrypt
* @return re-encrypted database
*/
boolean changeMasterPassword(String oldPassword, String newPassword, boolean encrypt) {
if (!setMasterPassword(oldPassword)) {
return false;
}
byte[] oldKey = (byte[])myKey.get().get(); // set right in the previous call
byte[] newKey = EncryptionUtil.genPasswordKey(newPassword);
ByteArrayWrapper testKey = new ByteArrayWrapper(EncryptionUtil.dbKey(oldKey, MasterKeyPasswordSafe.class, testKey(oldPassword)));
HashMap<ByteArrayWrapper, byte[]> oldDb = new HashMap<ByteArrayWrapper, byte[]>();
myDatabase.copyTo(oldDb);
HashMap<ByteArrayWrapper, byte[]> newDb = new HashMap<ByteArrayWrapper, byte[]>();
for (Map.Entry<ByteArrayWrapper, byte[]> e : oldDb.entrySet()) {
if (testKey.equals(e.getKey())) {
continue;
}
byte[] decryptedKey = EncryptionUtil.decryptKey(oldKey, e.getKey().unwrap());
String decryptedText = EncryptionUtil.decryptText(oldKey, e.getValue());
newDb.put(new ByteArrayWrapper(EncryptionUtil.encryptKey(newKey, decryptedKey)), EncryptionUtil.encryptText(newKey, decryptedText));
}
synchronized (myDatabase.getDbLock()) {
resetMasterPassword(newPassword, encrypt);
myDatabase.putAll(newDb);
}
return true;
}
示例2: getState
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
public State getState() {
TreeMap<ByteArrayWrapper, byte[]> sorted;
String pi;
synchronized (myDatabase) {
pi = toHex(myMasterPasswordInfo);
sorted = new TreeMap<ByteArrayWrapper, byte[]>(myDatabase);
}
String[][] db = new String[2][sorted.size()];
int i = 0;
for (Map.Entry<ByteArrayWrapper, byte[]> e : sorted.entrySet()) {
db[0][i] = toHex(e.getKey().unwrap());
db[1][i] = toHex(e.getValue());
i++;
}
State s = new State();
s.PASSWORDS = db;
s.MASTER_PASSWORD_INFO = pi;
return s;
}
示例3: changeMasterPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Encrypt database with new password
*
* @param oldPassword the old password
* @param newPassword the new password
* @param encrypt
* @return re-encrypted database
*/
boolean changeMasterPassword(String oldPassword, String newPassword, boolean encrypt) {
if (!setMasterPassword(oldPassword)) {
return false;
}
byte[] oldKey = key.get();
byte[] newKey = EncryptionUtil.genPasswordKey(newPassword);
ByteArrayWrapper testKey = new ByteArrayWrapper(EncryptionUtil.dbKey(oldKey, MasterKeyPasswordSafe.class, testKey(oldPassword)));
HashMap<ByteArrayWrapper, byte[]> oldDb = new HashMap<ByteArrayWrapper, byte[]>();
database.copyTo(oldDb);
HashMap<ByteArrayWrapper, byte[]> newDb = new HashMap<ByteArrayWrapper, byte[]>();
for (Map.Entry<ByteArrayWrapper, byte[]> e : oldDb.entrySet()) {
if (testKey.equals(e.getKey())) {
continue;
}
byte[] decryptedKey = EncryptionUtil.decryptKey(oldKey, e.getKey().unwrap());
String decryptedText = EncryptionUtil.decryptText(oldKey, e.getValue());
newDb.put(new ByteArrayWrapper(EncryptionUtil.encryptKey(newKey, decryptedKey)), EncryptionUtil.encryptText(newKey, decryptedText));
}
synchronized (database.getDbLock()) {
resetMasterPassword(newPassword, encrypt);
database.putAll(newDb);
}
return true;
}
示例4: get
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Get password from the database
*
* @param key the encrypted key
* @return the encrypted value or null
*/
public byte[] get(byte[] key) {
synchronized (myDatabase) {
return myDatabase.get(new ByteArrayWrapper(key));
}
}
示例5: getEncryptedPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected byte[] getEncryptedPassword(byte[] key) {
synchronized (database) {
return database.get(new ByteArrayWrapper(key));
}
}
示例6: removeEncryptedPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void removeEncryptedPassword(byte[] key) {
synchronized (database) {
database.remove(new ByteArrayWrapper(key));
}
}
示例7: storeEncryptedPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
protected void storeEncryptedPassword(byte[] key, byte[] encryptedPassword) {
synchronized (database) {
database.put(new ByteArrayWrapper(key), encryptedPassword);
}
}
示例8: compute
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
protected Map<ByteArrayWrapper, byte[]> compute() {
return Collections.synchronizedMap(ContainerUtil.<ByteArrayWrapper, byte[]>newHashMap());
}
示例9: getEncryptedPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
@Override
protected byte[] getEncryptedPassword(byte[] key) {
return database.get().get(new ByteArrayWrapper(key));
}
示例10: removeEncryptedPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
@Override
protected void removeEncryptedPassword(byte[] key) {
database.get().remove(new ByteArrayWrapper(key));
}
示例11: storeEncryptedPassword
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
@Override
protected void storeEncryptedPassword(byte[] key, byte[] encryptedPassword) {
database.get().put(new ByteArrayWrapper(key), encryptedPassword);
}
示例12: copyTo
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Get all entries in the database
*
* @param copy the copy to use
*/
public void copyTo(Map<ByteArrayWrapper, byte[]> copy) {
synchronized (myDatabase) {
copy.putAll(myDatabase);
}
}
示例13: putAll
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Put all entries to the database
*
* @param copy the copy to use
*/
public void putAll(Map<ByteArrayWrapper, byte[]> copy) {
synchronized (myDatabase) {
myDatabase.putAll(copy);
}
}
示例14: remove
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Remove password from the database
*
* @param key the encrypted key
*/
public void remove(byte[] key) {
synchronized (myDatabase) {
myDatabase.remove(new ByteArrayWrapper(key));
}
}
示例15: put
import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
/**
* Put password in the database
*
* @param key the encrypted key
* @param value the encrypted value
*/
public void put(byte[] key, byte[] value) {
synchronized (myDatabase) {
myDatabase.put(new ByteArrayWrapper(key), value);
}
}