org-netbeans-modules-keyring

16:39:59.905 INFO  jd.cli.Main - Decompiling org-netbeans-modules-keyring.jar
package org.netbeans.api.keyring;

class Keyring$1 {}

/* Location:
 * Qualified Name:     org.netbeans.api.keyring.Keyring.1
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.api.keyring;

import java.util.HashMap;
import java.util.Map;
import org.netbeans.spi.keyring.KeyringProvider;

class Keyring$DummyKeyringProvider
  implements KeyringProvider
{
  public boolean enabled()
  {
    return true;
  }
  
  private final Map<String, byte[]> passwords = new HashMap();
  
  public char[] read(String paramString)
  {
    byte[] arrayOfByte = (byte[])passwords.get(paramString);
    return arrayOfByte != null ? Keyring.access$100(arrayOfByte) : null;
  }
  
  public void save(String paramString1, char[] paramArrayOfChar, String paramString2)
  {
    passwords.put(paramString1, Keyring.access$200(paramArrayOfChar));
  }
  
  public void delete(String paramString)
  {
    passwords.remove(paramString);
  }
}

/* Location:
 * Qualified Name:     org.netbeans.api.keyring.Keyring.DummyKeyringProvider
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.api.keyring;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.netbeans.spi.keyring.KeyringProvider;
import org.openide.util.Lookup;
import org.openide.util.Parameters;

public class Keyring
{
  private static final Logger LOG = Logger.getLogger("org.netbeans.modules.keyring");
  private static KeyringProvider PROVIDER;
  
  private static synchronized KeyringProvider provider()
  {
    if (PROVIDER == null)
    {
      for (KeyringProvider localKeyringProvider : Lookup.getDefault().lookupAll(KeyringProvider.class)) {
        if (localKeyringProvider.enabled())
        {
          PROVIDER = localKeyringProvider;
          break;
        }
      }
      if (PROVIDER == null) {
        PROVIDER = new DummyKeyringProvider(null);
      }
      LOG.log(Level.FINE, "Using provider: {0}", PROVIDER);
    }
    return PROVIDER;
  }
  
  public static synchronized char[] read(String paramString)
  {
    Parameters.notNull("key", paramString);
    LOG.log(Level.FINEST, "reading: {0}", paramString);
    return provider().read(paramString);
  }
  
  public static synchronized void save(String paramString1, char[] paramArrayOfChar, String paramString2)
  {
    Parameters.notNull("key", paramString1);
    Parameters.notNull("password", paramArrayOfChar);
    LOG.log(Level.FINEST, "saving: {0}", paramString1);
    provider().save(paramString1, paramArrayOfChar, paramString2);
    Arrays.fill(paramArrayOfChar, '\000');
  }
  
  public static synchronized void delete(String paramString)
  {
    Parameters.notNull("key", paramString);
    LOG.log(Level.FINEST, "deleting: {0}", paramString);
    provider().delete(paramString);
  }
  
  private static class DummyKeyringProvider
    implements KeyringProvider
  {
    public boolean enabled()
    {
      return true;
    }
    
    private final Map<String, byte[]> passwords = new HashMap();
    
    public char[] read(String paramString)
    {
      byte[] arrayOfByte = (byte[])passwords.get(paramString);
      return arrayOfByte != null ? Keyring.bytes2Chars(arrayOfByte) : null;
    }
    
    public void save(String paramString1, char[] paramArrayOfChar, String paramString2)
    {
      passwords.put(paramString1, Keyring.chars2Bytes(paramArrayOfChar));
    }
    
    public void delete(String paramString)
    {
      passwords.remove(paramString);
    }
  }
  
  private static byte[] chars2Bytes(char[] paramArrayOfChar)
  {
    byte[] arrayOfByte = new byte[paramArrayOfChar.length * 2];
    for (int i = 0; i < paramArrayOfChar.length; i++)
    {
      arrayOfByte[(i * 2)] = ((byte)(paramArrayOfChar[i] / '?'));
      arrayOfByte[(i * 2 + 1)] = ((byte)(paramArrayOfChar[i] % '?'));
    }
    return arrayOfByte;
  }
  
  private static char[] bytes2Chars(byte[] paramArrayOfByte)
  {
    char[] arrayOfChar = new char[paramArrayOfByte.length / 2];
    for (int i = 0; i < arrayOfChar.length; i++) {
      arrayOfChar[i] = ((char)(paramArrayOfByte[(i * 2)] * 256 + paramArrayOfByte[(i * 2 + 1)]));
    }
    return arrayOfChar;
  }
}

/* Location:
 * Qualified Name:     org.netbeans.api.keyring.Keyring
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.netbeans.spi.keyring;

public abstract interface KeyringProvider
{
  public abstract boolean enabled();
  
  public abstract char[] read(String paramString);
  
  public abstract void save(String paramString1, char[] paramArrayOfChar, String paramString2);
  
  public abstract void delete(String paramString);
}

/* Location:
 * Qualified Name:     org.netbeans.spi.keyring.KeyringProvider
 * Java Class Version: 6 (50.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