org.eclipse.equinox.security.win32.x86_64_1.0.100.v20120522-2049

16:44:47.053 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.security.win32.x86_64_1.0.100.v20120522-2049.jar
package org.eclipse.equinox.internal.security.win32;

import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.spec.PBEKeySpec;
import org.eclipse.equinox.internal.security.auth.AuthPlugin;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.equinox.internal.security.storage.Base64;
import org.eclipse.equinox.internal.security.win32.nls.WinCryptoMessages;
import org.eclipse.equinox.security.storage.ISecurePreferences;
import org.eclipse.equinox.security.storage.StorageException;
import org.eclipse.equinox.security.storage.provider.IPreferencesContainer;
import org.eclipse.equinox.security.storage.provider.PasswordProvider;

public class WinCrypto
  extends PasswordProvider
{
  private static final String WIN_PROVIDER_NODE = "/org.eclipse.equinox.secure.storage/windows64";
  private static final String PASSWORD_KEY = "encryptedPassword";
  private static final int PASSWORD_LENGTH = 250;
  
  static
  {
    System.loadLibrary("jnicrypt64");
  }
  
  public native byte[] windecrypt(byte[] paramArrayOfByte);
  
  public native byte[] winencrypt(byte[] paramArrayOfByte);
  
  public PBEKeySpec getPassword(IPreferencesContainer container, int passwordType)
  {
    byte[] encryptedPassword;
    byte[] encryptedPassword;
    if ((passwordType & 0x1) == 0) {
      encryptedPassword = getEncryptedPassword(container);
    } else {
      encryptedPassword = null;
    }
    if (encryptedPassword != null)
    {
      byte[] decryptedPassword = windecrypt(encryptedPassword);
      if (decryptedPassword != null)
      {
        String password = new String(decryptedPassword);
        return new PBEKeySpec(password.toCharArray());
      }
      StorageException e = new StorageException(2, WinCryptoMessages.decryptPasswordFailed);
      AuthPlugin.getDefault().logError(WinCryptoMessages.decryptPasswordFailed, e);
      return null;
    }
    AuthPlugin.getDefault().logMessage(WinCryptoMessages.newPasswordGenerated);
    
    byte[] rawPassword = new byte['�'];
    SecureRandom random = new SecureRandom();
    random.setSeed(System.currentTimeMillis());
    random.nextBytes(rawPassword);
    String password = Base64.encode(rawPassword);
    if (savePassword(password, container)) {
      return new PBEKeySpec(password.toCharArray());
    }
    return null;
  }
  
  private byte[] getEncryptedPassword(IPreferencesContainer container)
  {
    ISecurePreferences node = container.getPreferences().node("/org.eclipse.equinox.secure.storage/windows64");
    try
    {
      passwordHint = node.get("encryptedPassword", null);
    }
    catch (StorageException e)
    {
      String passwordHint;
      AuthPlugin.getDefault().logError(WinCryptoMessages.decryptPasswordFailed, e);
      return null;
    }
    String passwordHint;
    if (passwordHint == null) {
      return null;
    }
    return Base64.decode(passwordHint);
  }
  
  private boolean savePassword(String password, IPreferencesContainer container)
  {
    byte[] data = winencrypt(password.getBytes());
    if (data == null)
    {
      StorageException e = new StorageException(2, WinCryptoMessages.encryptPasswordFailed);
      AuthPlugin.getDefault().logError(WinCryptoMessages.encryptPasswordFailed, e);
      return false;
    }
    String encodedEncryptyedPassword = Base64.encode(data);
    ISecurePreferences node = container.getPreferences().node("/org.eclipse.equinox.secure.storage/windows64");
    try
    {
      node.put("encryptedPassword", encodedEncryptyedPassword, false);
    }
    catch (StorageException e)
    {
      AuthPlugin.getDefault().logError(SecAuthMessages.errorOnSave, e);
      return false;
    }
    try
    {
      node.flush();
    }
    catch (IOException e)
    {
      AuthPlugin.getDefault().logError(SecAuthMessages.errorOnSave, e);
      return false;
    }
    return true;
  }
  
  public boolean retryOnError(Exception e, IPreferencesContainer container)
  {
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.security.win32.WinCrypto
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.security.win32.nls;

import org.eclipse.osgi.util.NLS;

public class WinCryptoMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.security.win32.nls.messages";
  public static String encryptPasswordFailed;
  public static String decryptPasswordFailed;
  public static String newPasswordGenerated;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.security.win32.nls.messages", WinCryptoMessages.class);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.security.win32.nls.WinCryptoMessages
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
1

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2017. Infinite Loop Ltd