org.eclipse.equinox.security_1.1.100.v20120522-1841

16:44:48.015 INFO  jd.cli.Main - Decompiling org.eclipse.equinox.security_1.1.100.v20120522-1841.jar
package org.eclipse.equinox.internal.security.auth;

import java.io.PrintStream;
import java.net.URL;
import org.eclipse.core.internal.runtime.RuntimeLog;
import org.eclipse.core.runtime.Status;
import org.eclipse.equinox.internal.security.storage.PasswordProviderSelector;
import org.eclipse.equinox.internal.security.storage.SecurePreferencesMapper;
import org.eclipse.osgi.framework.log.FrameworkLog;
import org.eclipse.osgi.framework.log.FrameworkLogEntry;
import org.eclipse.osgi.service.datalocation.Location;
import org.eclipse.osgi.service.debug.DebugOptions;
import org.eclipse.osgi.service.environment.EnvironmentInfo;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Filter;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.util.tracker.ServiceTracker;

public class AuthPlugin
  implements BundleActivator
{
  public static final String PI_AUTH = "org.eclipse.equinox.security";
  private static AuthPlugin singleton;
  private BundleContext bundleContext;
  private ServiceTracker debugTracker = null;
  private ServiceTracker configTracker = null;
  private ServiceTracker environmentTracker = null;
  private volatile ServiceTracker logTracker = null;
  public static boolean DEBUG = false;
  public static boolean DEBUG_LOGIN_FRAMEWORK = false;
  
  public static AuthPlugin getDefault()
  {
    return singleton;
  }
  
  public void start(BundleContext context)
    throws Exception
  {
    bundleContext = context;
    singleton = this;
    
    DEBUG = getBooleanOption("org.eclipse.equinox.security/debug", false);
    if (DEBUG) {
      DEBUG_LOGIN_FRAMEWORK = getBooleanOption("org.eclipse.equinox.security/debug/loginFramework", false);
    }
  }
  
  public void stop(BundleContext context)
    throws Exception
  {
    PasswordProviderSelector.stop();
    SecurePreferencesMapper.stop();
    SecurePlatformInternal.getInstance().stop();
    if (debugTracker != null)
    {
      debugTracker.close();
      debugTracker = null;
    }
    if (configTracker != null)
    {
      configTracker.close();
      configTracker = null;
    }
    if (environmentTracker != null)
    {
      environmentTracker.close();
      environmentTracker = null;
    }
    if (logTracker != null)
    {
      logTracker.close();
      logTracker = null;
    }
    bundleContext = null;
    singleton = null;
  }
  
  public BundleContext getBundleContext()
  {
    return bundleContext;
  }
  
  public void logError(String msg, Throwable e)
  {
    RuntimeLog.log(new Status(4, "org.eclipse.equinox.security", msg, e));
  }
  
  public void logMessage(String msg)
  {
    RuntimeLog.log(new Status(1, "org.eclipse.equinox.security", msg, null));
  }
  
  public boolean getBooleanOption(String option, boolean defaultValue)
  {
    if (debugTracker == null)
    {
      if (bundleContext == null) {
        return defaultValue;
      }
      debugTracker = new ServiceTracker(bundleContext, DebugOptions.class.getName(), null);
      debugTracker.open();
    }
    DebugOptions options = (DebugOptions)debugTracker.getService();
    if (options == null) {
      return defaultValue;
    }
    String value = options.getOption(option);
    if (value == null) {
      return defaultValue;
    }
    return value.equalsIgnoreCase("true");
  }
  
  public URL getConfigURL()
  {
    Filter filter = null;
    if (configTracker == null)
    {
      try
      {
        filter = bundleContext.createFilter(Location.CONFIGURATION_FILTER);
      }
      catch (InvalidSyntaxException localInvalidSyntaxException) {}
      configTracker = new ServiceTracker(bundleContext, filter, null);
      configTracker.open();
    }
    Location location = (Location)configTracker.getService();
    if (location == null) {
      return null;
    }
    return location.getURL();
  }
  
  public EnvironmentInfo getEnvironmentInfoService()
  {
    if (environmentTracker == null)
    {
      if (bundleContext == null) {
        return null;
      }
      environmentTracker = new ServiceTracker(bundleContext, EnvironmentInfo.class.getName(), null);
      environmentTracker.open();
    }
    return (EnvironmentInfo)environmentTracker.getService();
  }
  
  public void frameworkLogError(String msg, int severity, Throwable e)
  {
    if ((logTracker == null) && (bundleContext != null))
    {
      logTracker = new ServiceTracker(bundleContext, FrameworkLog.class.getName(), null);
      logTracker.open();
    }
    FrameworkLog log = logTracker == null ? null : (FrameworkLog)logTracker.getService();
    if (log != null)
    {
      log.log(new FrameworkLogEntry("org.eclipse.equinox.security", severity, 0, msg, 0, e, null));
    }
    else
    {
      if (msg != null) {
        System.err.println(msg);
      }
      if (e != null) {
        e.printStackTrace(System.err);
      }
    }
  }
}

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

import java.util.ArrayList;
import javax.security.auth.login.Configuration;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.osgi.util.NLS;

public class ConfigurationFactory
{
  private static final String ELEM_PROVIDER = "loginConfigurationProvider";
  private static final String ATTR_PROVIDER_CLASS = "class";
  private static final String POINT_PROVIDER = "org.eclipse.equinox.security.loginConfigurationProvider";
  private static ConfigurationFactory s_instance = new ConfigurationFactory();
  
  static ConfigurationFactory getInstance()
  {
    return s_instance;
  }
  
  public Configuration[] getConfigurations()
  {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtensionPoint point = registry.getExtensionPoint("org.eclipse.equinox.security.loginConfigurationProvider");
    IExtension[] extensions = point.getExtensions();
    
    ArrayList returnValue = new ArrayList(extensions.length);
    for (int i = 0; i < extensions.length; i++)
    {
      IConfigurationElement[] elements = extensions[i].getConfigurationElements();
      for (int j = 0; j < elements.length; j++)
      {
        Configuration provider = readProvider(elements[j]);
        if (provider != null) {
          returnValue.add(provider);
        }
      }
    }
    return (Configuration[])returnValue.toArray(new Configuration[0]);
  }
  
  private Configuration readProvider(IConfigurationElement element)
  {
    if (!"loginConfigurationProvider".equals(element.getName()))
    {
      reportError(SecAuthMessages.unexpectedConfigElement, element.getName(), element, null);
      return null;
    }
    try
    {
      return (Configuration)element.createExecutableExtension("class");
    }
    catch (CoreException e)
    {
      reportError(SecAuthMessages.instantiationFailed, element.getAttribute("class"), element, e);
    }
    return null;
  }
  
  private void reportError(String template, String arg, IConfigurationElement element, Throwable e)
  {
    String supplier = element.getContributor().getName();
    String message = NLS.bind(template, arg, supplier);
    AuthPlugin.getDefault().logError(message, e);
  }
}

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

import java.util.Hashtable;
import javax.security.auth.login.AppConfigurationEntry;
import javax.security.auth.login.Configuration;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.osgi.util.NLS;

public class ConfigurationFederator
  extends Configuration
{
  private Configuration[] federatedConfigs = null;
  private Hashtable configCache = new Hashtable(5);
  private Hashtable configToProviderMap = new Hashtable(5);
  private final Configuration defaultConfiguration;
  
  public ConfigurationFederator(Configuration defaultConfiguration)
  {
    this.defaultConfiguration = defaultConfiguration;
  }
  
  public synchronized AppConfigurationEntry[] getAppConfigurationEntry(String name)
  {
    AppConfigurationEntry[] returnValue = (AppConfigurationEntry[])configCache.get(name);
    if (returnValue != null) {
      return returnValue;
    }
    Configuration[] configs = getFederatedConfigs();
    Configuration[] allConfigs = configs;
    if (defaultConfiguration != null)
    {
      allConfigs = new Configuration[configs.length + 1];
      System.arraycopy(configs, 0, allConfigs, 0, configs.length);
      allConfigs[configs.length] = defaultConfiguration;
    }
    for (int i = 0; i < allConfigs.length; i++)
    {
      boolean found = false;
      AppConfigurationEntry[] config = allConfigs[i].getAppConfigurationEntry(name);
      if (config != null)
      {
        String cachedProviderName = (String)configToProviderMap.get(name);
        if ((cachedProviderName != null) && (!cachedProviderName.equals(allConfigs[i].getClass().getName())))
        {
          String message = NLS.bind(SecAuthMessages.duplicateJaasConfig1, name, cachedProviderName);
          AuthPlugin.getDefault().logError(message, null);
        }
        else if (found)
        {
          String message = NLS.bind(SecAuthMessages.duplicateJaasConfig2, name, cachedProviderName);
          AuthPlugin.getDefault().logError(message, null);
        }
        else if ((config != null) && (config.length != 0))
        {
          returnValue = config;
          configToProviderMap.put(name, allConfigs[i].getClass().getName());
          configCache.put(name, returnValue);
          found = true;
        }
      }
    }
    if ((returnValue == null) || (returnValue.length == 0))
    {
      String message = NLS.bind(SecAuthMessages.nonExistantJaasConfig, name);
      AuthPlugin.getDefault().logError(message, null);
    }
    return returnValue;
  }
  
  public synchronized void refresh()
  {
    for (int i = 0; i < federatedConfigs.length; i++) {
      federatedConfigs[i].refresh();
    }
    if (defaultConfiguration != null) {
      defaultConfiguration.refresh();
    }
    configCache.clear();
    configToProviderMap.clear();
  }
  
  private Configuration[] getFederatedConfigs()
  {
    if (federatedConfigs == null) {
      federatedConfigs = ConfigurationFactory.getInstance().getConfigurations();
    }
    return federatedConfigs;
  }
}

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

import java.net.URL;
import javax.security.auth.Subject;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.LoginContext;
import javax.security.auth.login.LoginException;
import org.eclipse.equinox.internal.security.auth.events.SecurityEventsManager;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.equinox.security.auth.ILoginContext;
import org.eclipse.equinox.security.auth.ILoginContextListener;

public class SecureContext
  implements ILoginContext
{
  private String configName;
  private LoginContext loginContext;
  private CallbackHandler handler;
  private SecurityEventsManager eventsManager = new SecurityEventsManager();
  private boolean loggedIn = false;
  
  public SecureContext(String configugationName)
  {
    this(configugationName, null, null);
  }
  
  public SecureContext(String configugationName, URL configFile, CallbackHandler handler)
  {
    configName = configugationName;
    SecurePlatformInternal platform = SecurePlatformInternal.getInstance();
    if (configFile != null) {
      platform.addConfigURL(configFile);
    }
    platform.start();
    this.handler = handler;
  }
  
  public void login()
    throws LoginException
  {
    LoginContext context = getLoginContext();
    LoginException loginException = null;
    eventsManager.notifyLoginBegin(context.getSubject());
    try
    {
      context.login();
    }
    catch (LoginException e)
    {
      loginException = e;
    }
    eventsManager.notifyLoginEnd(context.getSubject(), loginException);
    if (loginException != null)
    {
      LoginException rtvException = new LoginException(SecAuthMessages.loginFailure);
      rtvException.initCause(loginException);
      throw rtvException;
    }
    loggedIn = true;
  }
  
  public void logout()
    throws LoginException
  {
    LoginContext context = getLoginContext();
    Subject subject = getLoginContext().getSubject();
    eventsManager.notifyLogoutBegin(subject);
    
    LoginException loginException = null;
    try
    {
      context.logout();
    }
    catch (LoginException e)
    {
      loginException = e;
    }
    eventsManager.notifyLogoutEnd(subject, loginException);
    loggedIn = false;
  }
  
  public Subject getSubject()
    throws LoginException
  {
    if (!loggedIn) {
      login();
    }
    return getLoginContext().getSubject();
  }
  
  public LoginContext getLoginContext()
    throws LoginException
  {
    if (loginContext != null) {
      return loginContext;
    }
    CallbackHandler callbackHandler;
    CallbackHandler callbackHandler;
    if (handler == null) {
      callbackHandler = SecurePlatformInternal.getInstance().loadCallbackHandler(configName);
    } else {
      callbackHandler = handler;
    }
    if (callbackHandler == null) {
      loginContext = new LoginContext(configName);
    } else {
      loginContext = new LoginContext(configName, callbackHandler);
    }
    return loginContext;
  }
  
  public void registerListener(ILoginContextListener listener)
  {
    eventsManager.addListener(listener);
  }
  
  public void unregisterListener(ILoginContextListener listener)
  {
    eventsManager.removeListener(listener);
  }
}

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

import java.io.IOException;
import java.net.URL;
import java.security.Security;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.login.Configuration;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.equinox.internal.security.auth.ext.loader.ExtCallbackHandlerLoader;
import org.osgi.framework.BundleContext;

public class SecurePlatformInternal
{
  private static final String VM_PROPERTY = "equinox.security.vm";
  private static final String SERVER_VM = "server";
  private static final String PROVIDER_URL_BASE = "login.config.url.";
  private static final int MAX_PROVIDER_URL_COUNT = 777;
  private Configuration defaultConfiguration;
  private ExtCallbackHandlerLoader callbackHandlerLoader = new ExtCallbackHandlerLoader();
  private boolean running = false;
  private static final SecurePlatformInternal s_instance = new SecurePlatformInternal();
  
  public static final SecurePlatformInternal getInstance()
  {
    return s_instance;
  }
  
  public CallbackHandler loadCallbackHandler(String configurationName)
  {
    return callbackHandlerLoader.loadCallbackHandler(configurationName);
  }
  
  public void start()
  {
    if (running) {
      return;
    }
    BundleContext context = AuthPlugin.getDefault().getBundleContext();
    String vmType = context.getProperty("equinox.security.vm");
    if ("server".equals(vmType))
    {
      defaultConfiguration = null;
      running = true;
      return;
    }
    try
    {
      defaultConfiguration = Configuration.getConfiguration();
    }
    catch (SecurityException localSecurityException)
    {
      defaultConfiguration = null;
    }
    Configuration.setConfiguration(new ConfigurationFederator(defaultConfiguration));
    running = true;
  }
  
  public void stop()
  {
    if (!running) {
      return;
    }
    if (defaultConfiguration != null)
    {
      Configuration.setConfiguration(defaultConfiguration);
      defaultConfiguration = null;
    }
    running = false;
  }
  
  public boolean addConfigURL(URL url)
  {
    if (url == null) {
      return false;
    }
    for (int i = 1; i <= 777; i++)
    {
      String tag = "login.config.url." + Integer.toString(i);
      String currentURL = Security.getProperty(tag);
      if ((currentURL == null) || (currentURL.length() == 0))
      {
        String path;
        try
        {
          path = FileLocator.toFileURL(url).toExternalForm();
        }
        catch (IOException localIOException)
        {
          String path;
          path = url.toExternalForm();
        }
        Security.setProperty(tag, path);
        return true;
      }
    }
    return false;
  }
}

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

import java.util.Iterator;
import java.util.Vector;
import javax.security.auth.Subject;
import javax.security.auth.login.LoginException;
import org.eclipse.equinox.security.auth.ILoginContextListener;

public class SecurityEventsManager
{
  private Vector listeners = new Vector(5);
  
  public synchronized void addListener(ILoginContextListener listener)
  {
    listeners.add(listener);
  }
  
  public synchronized void removeListener(ILoginContextListener listener)
  {
    listeners.remove(listener);
  }
  
  public void notifyLoginBegin(Subject subject)
  {
    for (Iterator i = listeners.iterator(); i.hasNext();)
    {
      Object listener = i.next();
      if ((listener instanceof ILoginContextListener)) {
        ((ILoginContextListener)listener).onLoginStart(subject);
      }
    }
  }
  
  public void notifyLoginEnd(Subject subject, LoginException loginException)
  {
    for (Iterator i = listeners.iterator(); i.hasNext();)
    {
      Object listener = i.next();
      if ((listener instanceof ILoginContextListener)) {
        ((ILoginContextListener)listener).onLoginFinish(subject, loginException);
      }
    }
  }
  
  public void notifyLogoutBegin(Subject subject)
  {
    for (Iterator i = listeners.iterator(); i.hasNext();)
    {
      Object listener = i.next();
      if ((listener instanceof ILoginContextListener)) {
        ((ILoginContextListener)listener).onLogoutStart(subject);
      }
    }
  }
  
  public void notifyLogoutEnd(Subject subject, LoginException loginException)
  {
    for (Iterator i = listeners.iterator(); i.hasNext();)
    {
      Object listener = i.next();
      if ((listener instanceof ILoginContextListener)) {
        ((ILoginContextListener)listener).onLogoutFinish(subject, loginException);
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.security.auth.events.SecurityEventsManager
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.security.auth.ext.loader;

import javax.security.auth.callback.CallbackHandler;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.equinox.internal.security.auth.AuthPlugin;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.osgi.util.NLS;

public class ExtCallbackHandlerLoader
{
  private static final String POINT_HANDLER = "org.eclipse.equinox.security.callbackHandler";
  private static final String ELEM_HANDLER = "callbackHandler";
  private static final String ATTR_HANDLER_CLASS = "class";
  private static final String POINT_MAPPING = "org.eclipse.equinox.security.callbackHandlerMapping";
  private static final String ELEM_MAPPING = "callbackHandlerMapping";
  private static final String ATTR_MAPPING_CONFIGNAME = "configName";
  private static final String ATTR_MAPPING_CALLBACKID = "callbackHandlerId";
  
  public CallbackHandler loadCallbackHandler(String configName)
  {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    
    IExtensionPoint point = registry.getExtensionPoint("org.eclipse.equinox.security.callbackHandlerMapping");
    IExtension[] extenders = point.getExtensions();
    String extensionId = null;
    for (int i = 0; i < extenders.length; i++)
    {
      IConfigurationElement[] confEelements = extenders[i].getConfigurationElements();
      if (confEelements.length == 1)
      {
        extensionId = loadMappingEntry(confEelements[0], configName);
        if (extensionId != null) {
          break;
        }
      }
    }
    if (extensionId == null) {
      return null;
    }
    IExtensionPoint pointCallbackHandler = registry.getExtensionPoint("org.eclipse.equinox.security.callbackHandler");
    IExtension extension = pointCallbackHandler.getExtension(extensionId);
    if (extension == null) {
      return null;
    }
    IConfigurationElement[] elements = extension.getConfigurationElements();
    if (elements.length != 1) {
      return null;
    }
    return loadHandlerClass(elements[0]);
  }
  
  private String loadMappingEntry(IConfigurationElement element, String configName)
  {
    if (!expectedElement(element, "callbackHandlerMapping")) {
      return null;
    }
    if (configName.equals(element.getAttribute("configName"))) {
      return element.getAttribute("callbackHandlerId");
    }
    return null;
  }
  
  private CallbackHandler loadHandlerClass(IConfigurationElement element)
  {
    if (!expectedElement(element, "callbackHandler")) {
      return null;
    }
    try
    {
      return (CallbackHandler)element.createExecutableExtension("class");
    }
    catch (CoreException e)
    {
      String message = NLS.bind(SecAuthMessages.instantiationFailed1, element.getAttribute("class"));
      AuthPlugin.getDefault().logError(message, e);
    }
    return null;
  }
  
  private boolean expectedElement(IConfigurationElement element, String expectedName)
  {
    if (expectedName.equals(element.getName())) {
      return true;
    }
    String supplier = element.getContributor().getName();
    String message = NLS.bind(SecAuthMessages.unexpectedConfigElement, element.getName(), supplier);
    AuthPlugin.getDefault().logError(message, null);
    return false;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.security.auth.ext.loader.ExtCallbackHandlerLoader
 * Java Class Version: 1.2 (46.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.equinox.internal.security.auth.ext.loader;

import java.util.Map;
import javax.security.auth.spi.LoginModule;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IContributor;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.equinox.internal.security.auth.AuthPlugin;
import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.osgi.util.NLS;

public class ExtLoginModuleLoader
{
  private static final String POINT_MODULE = "org.eclipse.equinox.security.loginModule";
  private static final String ELEM_MODULE = "loginModule";
  private static final String ATTR_MODULE_CLASS = "class";
  
  public static LoginModule load(Map options)
  {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtensionPoint point = registry.getExtensionPoint("org.eclipse.equinox.security.loginModule");
    IExtension[] extensions = point.getExtensions();
    
    String targetPoint = (String)options.get("extensionId");
    
    LoginModule loginModule = null;
    for (int i = 0; i < extensions.length; i++)
    {
      String sourcePoint = extensions[i].getUniqueIdentifier();
      if (sourcePoint != null) {
        if (sourcePoint.equals(targetPoint))
        {
          IConfigurationElement[] elements = extensions[i].getConfigurationElements();
          int elementCount = elements.length;
          if (elementCount == 1)
          {
            loginModule = readEntry(elements[0]);
          }
          else
          {
            String message = NLS.bind(SecAuthMessages.invalidLoginmoduleCount, Integer.toString(elementCount));
            AuthPlugin.getDefault().logError(message, null);
          }
        }
      }
    }
    return loginModule;
  }
  
  private static LoginModule readEntry(IConfigurationElement element)
  {
    if (!"loginModule".equals(element.getName()))
    {
      String supplier = element.getContributor().getName();
      String message = NLS.bind(SecAuthMessages.unexpectedConfigElement, element.getName(), supplier);
      AuthPlugin.getDefault().logError(message, null);
      return null;
    }
    try
    {
      return (LoginModule)element.createExecutableExtension("class");
    }
    catch (CoreException e)
    {
      String supplier = element.getContributor().getName();
      String message = NLS.bind(SecAuthMessages.instantiationFailed, element.getAttribute("class"), supplier);
      AuthPlugin.getDefault().logError(message, e);
    }
    return null;
  }
}

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

import org.eclipse.osgi.util.NLS;

public class SecAuthMessages
  extends NLS
{
  private static final String BUNDLE_NAME = "org.eclipse.equinox.internal.security.auth.nls.messages";
  public static String instantiationFailed;
  public static String instantiationFailed1;
  public static String nullArguments;
  public static String noCallbackhandlerService;
  public static String badServicelistenerSyntaxString;
  public static String serviceAlreadyInstalled;
  public static String loginadminServiceNotIntstalled;
  public static String elementUnexpected;
  public static String loginFailure;
  public static String startFirst;
  public static String stopFirst;
  public static String unsupoprtedCharEncoding;
  public static String badStorageURL;
  public static String unexpectedConfigElement;
  public static String invalidConfigURL;
  public static String badProviderUrl;
  public static String providerUrlUnspecified;
  public static String nonExistantJaasConfig;
  public static String duplicateJaasConfig1;
  public static String duplicateJaasConfig2;
  public static String invalidControlFlag;
  public static String configurationEntryInvalid;
  public static String configurationEntryTypeUnknown;
  public static String documentSystemIdInvalid;
  public static String configurationEntryDuplicate;
  public static String invalidDocument;
  public static String documentExceptionIO;
  public static String documentExceptionParsing;
  public static String configurationDuplicate;
  public static String invalidLoginmoduleCount;
  public static String loginmoduleFactoryNotSet;
  public static String loginmoduleFactoryAlreadySet;
  public static String unsetLoginmoduleFactoryError;
  public static String loginFileURL;
  public static String loginNoPassword;
  public static String loginNoDefaultLocation;
  public static String handleIncorrectFormat;
  public static String noDigestAlgorithm;
  public static String noSecureStorageModule;
  public static String noSecureStorageModules;
  public static String entryTypeIsNull;
  public static String entryTypeInvalid;
  public static String qualifierInvalid;
  public static String qualifierIsNull;
  public static String removedNode;
  public static String invalidNodePath;
  public static String errorOnSave;
  public static String keyringNotAvailable;
  public static String noDefaultPassword;
  public static String invalidEntryFormat;
  public static String noAlgorithms;
  public static String noAlgorithm;
  public static String usingAlgorithm;
  public static String decryptingError;
  public static String encryptingError;
  public static String noDigest;
  public static String failedCreateRecovery;
  public static String initCancelled;
  public static String unableToReadPswdFile;
  public static String fileModifiedMsg;
  public static String fileModifiedNote;
  public static String storedClearText;
  
  static {}
  
  public static void reloadMessages()
  {
    NLS.initializeMessages("org.eclipse.equinox.internal.security.auth.nls.messages", SecAuthMessages.class);
  }
}

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

import javax.crypto.spec.PBEKeySpec;
import org.eclipse.equinox.security.auth.credentials.IPrivateCredential;

public class EquinoxPrivateCredential
  implements IPrivateCredential
{
  private final PBEKeySpec key;
  private final String loginModuleID;
  
  public EquinoxPrivateCredential(PBEKeySpec privateKey, String loginModuleID)
  {
    key = privateKey;
    this.loginModuleID = loginModuleID;
  }
  
  public PBEKeySpec getPrivateKey()
  {
    return key;
  }
  
  public String getProviderID()
  {
    return loginModuleID;
  }
  
  public void clear()
  {
    if (key != null) {
      key.clearPassword();
    }
  }
}

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

import java.security.Principal;
import org.eclipse.equinox.security.auth.credentials.IPublicCredential;

public class EquinoxPublicCredential
  implements IPublicCredential
{
  private final String name;
  private final Principal primaryRole;
  private final Principal[] roles;
  private final String loginModuleID;
  
  public EquinoxPublicCredential(String name, Principal primaryRole, String loginModuleID)
  {
    this.name = name;
    this.primaryRole = primaryRole;
    roles = null;
    this.loginModuleID = loginModuleID;
  }
  
  public EquinoxPublicCredential(String name, Principal[] roles, String loginModuleID)
  {
    this.name = name;
    primaryRole = null;
    this.roles = roles;
    this.loginModuleID = loginModuleID;
  }
  
  public String getName()
  {
    return name;
  }
  
  public Principal getPrimaryRole()
  {
    if (primaryRole != null) {
      return primaryRole;
    }
    if ((roles != null) && (roles.length >= 1)) {
      return roles[0];
    }
    return null;
  }
  
  public Principal[] getRoles()
  {
    return roles;
  }
  
  public String getProviderID()
  {
    return loginModuleID;
  }
}

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

public class Base64
{
  private static final char[] encodeTable = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".toCharArray();
  private static final byte BASE64_PADDING = 126;
  private static final byte BASE64_INVALID = 127;
  private static final byte[] decodeTable = new byte['?'];
  
  static
  {
    for (int i = 0; i < 256; i++) {
      decodeTable[i] = Byte.MAX_VALUE;
    }
    for (int i = 0; i < 64; i++) {
      decodeTable[encodeTable[i]] = ((byte)i);
    }
    decodeTable[61] = 126;
  }
  
  private static byte decode(char c)
  {
    if (c >= '?') {
      throw new IllegalArgumentException();
    }
    return decodeTable[c];
  }
  
  public static byte[] decode(String str)
  {
    if (str == null) {
      return null;
    }
    char[] source = str.toCharArray();
    int originalSize = source.length;
    char[] tmp = new char[originalSize];
    int count = 0;
    for (int i = 0; i < originalSize; i++) {
      if (decode(source[i]) != Byte.MAX_VALUE) {
        tmp[(count++)] = source[i];
      }
    }
    char[] chars = new char[count];
    System.arraycopy(tmp, 0, chars, 0, count);
    
    int size = chars.length;
    byte[] result = new byte[size];
    int pos = 0;
    for (int i = 0; i < size; i += 4)
    {
      byte group1 = decode(chars[i]);
      byte group2 = i + 1 < size ? decode(chars[(i + 1)]) : 0;
      byte group3 = i + 2 < size ? decode(chars[(i + 2)]) : 0;
      byte group4 = i + 3 < size ? decode(chars[(i + 3)]) : 0;
      
      result[(pos++)] = ((byte)(group1 << 2 | group2 >> 4));
      if (group3 != 126) {
        result[(pos++)] = ((byte)((group2 & 0xF) << 4 | group3 >> 2));
      }
      if (group4 != 126) {
        result[(pos++)] = ((byte)((group3 & 0x3) << 6 | group4));
      }
    }
    byte[] output = new byte[pos];
    System.arraycopy(result, 0, output, 0, pos);
    return output;
  }
  
  public static String encode(byte[] bytes)
  {
    if (bytes == null) {
      return null;
    }
    char[] longResult = new char[bytes.length * 2 + 2];
    int pos = 0;
    for (int i = 0; i < bytes.length; i += 3)
    {
      int byte1 = 0xFF & bytes[i];
      int byte2 = i + 1 < bytes.length ? 0xFF & bytes[(i + 1)] : 0;
      int byte3 = i + 2 < bytes.length ? 0xFF & bytes[(i + 2)] : 0;
      
      int group1 = byte1 >> 2;
      int group2 = (byte1 & 0x3) << 4 | byte2 >> 4;
      int group3 = (byte2 & 0xF) << 2 | byte3 >> 6;
      int group4 = byte3 & 0x3F;
      
      longResult[(pos++)] = encodeTable[group1];
      longResult[(pos++)] = encodeTable[group2];
      
      longResult[(pos++)] = (i + 1 < bytes.length ? encodeTable[group3] : '=');
      longResult[(pos++)] = (i + 2 < bytes.length ? encodeTable[group4] : '=');
    }
    char[] result = new char[pos];
    System.arraycopy(longResult, 0, result, 0, pos);
    return new String(result);
  }
}

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

import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtension;
import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.equinox.internal.security.storage.friends.IUICallbacks;
import org.eclipse.equinox.security.storage.provider.IPreferencesContainer;

public class CallbacksProvider
{
  private static final String EXTENSION_POINT = "org.eclipse.equinox.security.internalUI";
  private static final String PROVIDER_MODULE = "provider";
  private static final String CLASS_NAME = "class";
  private static final int NUMBER_OF_QUESTIONS = 2;
  private IUICallbacks callback = null;
  private static CallbacksProvider instance = null;
  
  public static CallbacksProvider getDefault()
  {
    if (instance == null) {
      instance = new CallbacksProvider();
    }
    return instance;
  }
  
  private void init()
  {
    IExtensionRegistry registry = RegistryFactory.getRegistry();
    IExtensionPoint point = registry.getExtensionPoint("org.eclipse.equinox.security.internalUI");
    IExtension[] extensions = point.getExtensions();
    if (extensions.length == 0) {
      return;
    }
    IConfigurationElement[] elements = extensions[0].getConfigurationElements();
    if (elements.length == 0) {
      return;
    }
    IConfigurationElement element = elements[0];
    if (!"provider".equals(element.getName())) {
      return;
    }
    try
    {
      clazz = element.createExecutableExtension("class");
    }
    catch (CoreException localCoreException)
    {
      Object clazz;
      return;
    }
    Object clazz;
    if ((clazz instanceof IUICallbacks)) {
      callback = ((IUICallbacks)clazz);
    }
  }
  
  public void setupChallengeResponse(String moduleID, IPreferencesContainer container)
  {
    if (callback == null) {
      init();
    }
    if (callback != null) {
      callback.setupPasswordRecovery(2, moduleID, container);
    }
  }
  
  public IUICallbacks getCallback()
  {
    if (callback == null) {
      init();
    }
    return callback;
  }
  
  public boolean runningUI()
  {
    IUICallbacks callbackInstalled = getCallback();
    if (callbackInstalled == null) {
      return false;
    }
    return callbackInstalled.runningUI();
  }
}

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

import org.eclipse.equinox.internal.security.auth.nls.SecAuthMessages;
import org.eclipse.equinox.security.storage.StorageException;

public class CryptoData
{
  private static final char MODULE_ID_SEPARATOR = '\t';
  private static final char SALT_SEPARATOR = ',';
  private final String moduleID;
  private final byte[] salt;
  private final byte[] encryptedData;
  
  public CryptoData(String moduleID, byte[] salt, byte[] data)
  {
    this.moduleID = moduleID;
    this.salt = salt;
    encryptedData = data;
  }
  
  public String getModuleID()
  {
    return moduleID;
  }
  
  public byte[] getSalt()
  {
    return salt;
  }
  
  public byte[] getData()
  {
    return encryptedData;
  }
  
  public CryptoData(String data)
    throws StorageException
  {
    int pos = data.indexOf('\t');
    if (pos == -1) {
      throw new StorageException(3, SecAuthMessages.invalidEntryFormat);
    }
    String encrypted;
    String encrypted;
    if (pos == 0)
    {
      moduleID = null;
      encrypted = data.substring(1);
    }
    else
    {
      moduleID = data.substring(0, pos);
      encrypted = data.substring(pos + 1);
    }
    int saltPos = encrypted.indexOf(',');
    if (saltPos != -1)
    {
      salt = Base64.decode(encrypted.substring(0, saltPos));
      encryptedData = Base64.decode(encrypted.substring(saltPos + 1));
    }
    else
    {
      if (encrypted.length() != 0) {
        throw new StorageException(3, SecAuthMessages.invalidEntryFormat);
      }
      salt = null;
      encryptedData = null;
    }
  }
  
  public String toString()
  {
    StringBuffer encryptedText = moduleID == null ? new StringBuffer() : new StringBuffer(moduleID);
    encryptedText.append('\t');
    if (salt != null) {
      encryptedText.append(Base64.encode(salt));
    }
    if (encryptedData != null)
    {
      encryptedText.append(',');
      encryptedText.append(Base64.encode(encryptedData));
    }
    return encryptedText.toString();
  }
}

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

import org.eclipse.equinox.internal.security.storage.friends.IStorageTask;
import org.eclipse.equinox.security.storage.StorageException;

class JavaEncryption$1
  implements IStorageTask
{
  final JavaEncryption this$0;
  
  JavaEncryption$1(JavaEncryption paramJavaEncryption)
  {
    this$0 = paramJavaEncryption;
  }
  
  public void execute()
    throws StorageException
  {
    this$0.internalInitialize();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.equinox.internal.security.storage.JavaEn
1 2 3 4 5

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