当前位置: 首页>>代码示例>>Java>>正文


Java ByteArrayWrapper类代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:33,代码来源:MasterKeyPasswordSafe.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:PasswordDatabase.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:MasterKeyPasswordSafe.java

示例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));
  }

}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:PasswordDatabase.java

示例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));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:MemoryPasswordSafe.java

示例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));
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:MemoryPasswordSafe.java

示例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);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:10,代码来源:MemoryPasswordSafe.java

示例8: compute

import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
protected Map<ByteArrayWrapper, byte[]> compute() {
  return Collections.synchronizedMap(ContainerUtil.<ByteArrayWrapper, byte[]>newHashMap());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:MemoryPasswordSafe.java

示例9: getEncryptedPassword

import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
@Override
protected byte[] getEncryptedPassword(byte[] key) {
  return database.get().get(new ByteArrayWrapper(key));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MemoryPasswordSafe.java

示例10: removeEncryptedPassword

import com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper; //导入依赖的package包/类
@Override
protected void removeEncryptedPassword(byte[] key) {
  database.get().remove(new ByteArrayWrapper(key));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MemoryPasswordSafe.java

示例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);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:MemoryPasswordSafe.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PasswordDatabase.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PasswordDatabase.java

示例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));
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:PasswordDatabase.java

示例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);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:PasswordDatabase.java


注:本文中的com.intellij.ide.passwordSafe.impl.providers.ByteArrayWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。