org.eclipse.mylyn.commons.repositories.core_0.9.1.v20120425-0100

16:46:28.031 INFO  jd.cli.Main - Decompiling org.eclipse.mylyn.commons.repositories.core_0.9.1.v20120425-0100.jar
package org.eclipse.mylyn.commons.repositories.core;

import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;

public abstract class RepositoryValidator
{
  private final RepositoryLocation location;
  private IStatus result;
  
  public RepositoryValidator(RepositoryLocation location)
  {
    this.location = location;
  }
  
  public RepositoryLocation getLocation()
  {
    return location;
  }
  
  public IStatus getResult()
  {
    return result;
  }
  
  public abstract IStatus run(IProgressMonitor paramIProgressMonitor);
  
  public void setResult(IStatus result)
  {
    this.result = result;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.RepositoryValidator
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import org.eclipse.core.runtime.Assert;
import org.eclipse.equinox.security.storage.StorageException;

public class UserCredentials
  extends AuthenticationCredentials
{
  private final String domain;
  private final String password;
  private final String userName;
  private final boolean savePassword;
  private final boolean hasSecrets;
  
  public UserCredentials(String userName, String password)
  {
    this(userName, password, null, true, true);
  }
  
  public UserCredentials(String userName, String password, boolean savePassword)
  {
    this(userName, password, null, savePassword, true);
  }
  
  public UserCredentials(String userName, String password, String domain, boolean savePassword)
  {
    this(userName, password, domain, savePassword, true);
  }
  
  public UserCredentials(String userName, String password, String domain, boolean savePassword, boolean hasSecrets)
  {
    Assert.isNotNull(userName);
    Assert.isNotNull(password);
    this.userName = userName;
    this.password = password;
    this.domain = domain;
    this.savePassword = savePassword;
    this.hasSecrets = hasSecrets;
  }
  
  protected UserCredentials(ICredentialsStore store, String prefix, boolean loadSecrets)
    throws StorageException
  {
    this(store.get(prefix + ".user", ""), loadSecrets ? store.get(prefix + ".password", "") : "", store.get(prefix + ".domain", null), store.getBoolean(prefix + ".savePassword", false), loadSecrets);
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    UserCredentials other = (UserCredentials)obj;
    if (domain == null)
    {
      if (domain != null) {
        return false;
      }
    }
    else if (!domain.equals(domain)) {
      return false;
    }
    if (hasSecrets != hasSecrets) {
      return false;
    }
    if (password == null)
    {
      if (password != null) {
        return false;
      }
    }
    else if (!password.equals(password)) {
      return false;
    }
    if (savePassword != savePassword) {
      return false;
    }
    if (userName == null)
    {
      if (userName != null) {
        return false;
      }
    }
    else if (!userName.equals(userName)) {
      return false;
    }
    return true;
  }
  
  public String getDomain()
  {
    return domain;
  }
  
  public String getPassword()
  {
    return password;
  }
  
  public String getUserName()
  {
    return userName;
  }
  
  public boolean getSavePassword()
  {
    return savePassword;
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + (domain == null ? 0 : domain.hashCode());
    result = 31 * result + (hasSecrets ? 1231 : 1237);
    result = 31 * result + (password == null ? 0 : password.hashCode());
    result = 31 * result + (savePassword ? 1231 : 1237);
    result = 31 * result + (userName == null ? 0 : userName.hashCode());
    return result;
  }
  
  public void clear(ICredentialsStore store, String prefix)
  {
    store.remove(prefix + ".user");
    store.remove(prefix + ".password");
    store.remove(prefix + ".domain");
    store.remove(prefix + ".savePassword");
  }
  
  public void save(ICredentialsStore store, String prefix)
  {
    store.put(prefix + ".user", userName, false);
    if (hasSecrets) {
      store.put(prefix + ".password", password, true, savePassword);
    }
    store.put(prefix + ".domain", domain, false);
    store.putBoolean(prefix + ".savePassword", savePassword, false);
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("UserCredentials [domain=");
    builder.append(domain);
    builder.append(", password=");
    builder.append(password == null ? password : "********");
    builder.append(", userName=");
    builder.append(userName);
    builder.append(", savePassword=");
    builder.append(savePassword);
    builder.append(", hasSecrets=");
    builder.append(hasSecrets);
    builder.append("]");
    return builder.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import org.eclipse.core.runtime.Assert;

public class CertificateCredentials
  extends AuthenticationCredentials
{
  private final String keyStoreFileName;
  private final String keyStoreType;
  private final String password;
  private final boolean savePassword;
  private final boolean hasSecrets;
  
  public CertificateCredentials(String keyStoreFileName, String password, String keyStoreType)
  {
    this(keyStoreFileName, password, keyStoreType, true, true);
  }
  
  public CertificateCredentials(String keyStoreFileName, String password, String keyStoreType, boolean savePassword)
  {
    this(keyStoreFileName, password, keyStoreType, savePassword, true);
  }
  
  CertificateCredentials(String keyStoreFileName, String password, String keyStoreType, boolean savePassword, boolean hasSecrets)
  {
    Assert.isNotNull(password);
    this.keyStoreFileName = keyStoreFileName;
    this.password = password;
    this.keyStoreType = keyStoreType;
    this.savePassword = savePassword;
    this.hasSecrets = hasSecrets;
  }
  
  protected CertificateCredentials(ICredentialsStore store, String prefix, boolean loadSecrets)
  {
    this(store.get(prefix + ".keyStoreFileName", null), loadSecrets ? store.get(prefix + ".password", "") : "", store.get(prefix + ".keyStoreType", null), store.getBoolean(prefix + ".savePassword", false), loadSecrets);
  }
  
  public void clear(ICredentialsStore store, String prefix)
  {
    store.remove(prefix + ".keyStoreFileName");
    store.remove(prefix + ".password");
    store.remove(prefix + ".keyStoreType");
    store.remove(prefix + ".savePassword");
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    CertificateCredentials other = (CertificateCredentials)obj;
    if (hasSecrets != hasSecrets) {
      return false;
    }
    if (keyStoreFileName == null)
    {
      if (keyStoreFileName != null) {
        return false;
      }
    }
    else if (!keyStoreFileName.equals(keyStoreFileName)) {
      return false;
    }
    if (keyStoreType == null)
    {
      if (keyStoreType != null) {
        return false;
      }
    }
    else if (!keyStoreType.equals(keyStoreType)) {
      return false;
    }
    if (password == null)
    {
      if (password != null) {
        return false;
      }
    }
    else if (!password.equals(password)) {
      return false;
    }
    if (savePassword != savePassword) {
      return false;
    }
    return true;
  }
  
  public String getKeyStoreFileName()
  {
    return keyStoreFileName;
  }
  
  public String getKeyStoreType()
  {
    return keyStoreType;
  }
  
  public String getPassword()
  {
    return password;
  }
  
  public boolean getSavePassword()
  {
    return savePassword;
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + (hasSecrets ? 1231 : 1237);
    result = 31 * result + (keyStoreFileName == null ? 0 : keyStoreFileName.hashCode());
    result = 31 * result + (keyStoreType == null ? 0 : keyStoreType.hashCode());
    result = 31 * result + (password == null ? 0 : password.hashCode());
    result = 31 * result + (savePassword ? 1231 : 1237);
    return result;
  }
  
  public void save(ICredentialsStore store, String prefix)
  {
    store.put(prefix + ".keyStoreFileName", keyStoreFileName, false);
    if (hasSecrets) {
      store.put(prefix + ".password", password, true);
    }
    store.put(prefix + ".keyStoreType", keyStoreType, false);
    store.putBoolean(prefix + ".savePassword", savePassword, false);
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("CertificateCredentials [keyStoreFileName=");
    builder.append(keyStoreFileName);
    builder.append(", password=");
    builder.append(password == null ? password : "********");
    builder.append(", keyStoreType=");
    builder.append(keyStoreType);
    builder.append(", savePassword=");
    builder.append(savePassword);
    builder.append(", hasSecrets=");
    builder.append(hasSecrets);
    builder.append("]");
    return builder.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.CertificateCredentials
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import org.eclipse.core.runtime.Assert;

public class AuthenticationType<T extends AuthenticationCredentials>
{
  public static final AuthenticationType<CertificateCredentials> CERTIFICATE = new AuthenticationType(
    CertificateCredentials.class, "org.eclipse.mylyn.commons.repositories.core.auth.certficate");
  public static final AuthenticationType<UserCredentials> HTTP = new AuthenticationType(
    UserCredentials.class, "org.eclipse.mylyn.tasklist.repositories.httpauth");
  public static final AuthenticationType<OpenIdCredentials> OPENID = new AuthenticationType(
    OpenIdCredentials.class, "org.eclipse.mylyn.commons.repositories.core.auth.openid");
  public static final AuthenticationType<UserCredentials> PROXY = new AuthenticationType(
    UserCredentials.class, "org.eclipse.mylyn.tasklist.repositories.proxy");
  public static final AuthenticationType<UserCredentials> REPOSITORY = new AuthenticationType(
    UserCredentials.class, "org.eclipse.mylyn.tasklist.repositories");
  private final Class<T> credentialsType;
  private final String key;
  
  public AuthenticationType(Class<T> credentialsType, String key)
  {
    Assert.isNotNull(credentialsType);
    Assert.isNotNull(key);
    this.credentialsType = credentialsType;
    this.key = key;
  }
  
  public Class<T> getCredentialsType()
  {
    return credentialsType;
  }
  
  public String getKey()
  {
    return key;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationType
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

public abstract class AuthenticationCredentials
{
  public abstract void clear(ICredentialsStore paramICredentialsStore, String paramString);
  
  public abstract void save(ICredentialsStore paramICredentialsStore, String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationCredentials
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import java.io.IOException;

public abstract interface ICredentialsStore
{
  public abstract void clear();
  
  public abstract void flush()
    throws IOException;
  
  public abstract String get(String paramString1, String paramString2);
  
  public abstract boolean getBoolean(String paramString, boolean paramBoolean);
  
  public abstract byte[] getByteArray(String paramString, byte[] paramArrayOfByte);
  
  public abstract String[] keys();
  
  public abstract void put(String paramString1, String paramString2, boolean paramBoolean);
  
  public abstract void put(String paramString1, String paramString2, boolean paramBoolean1, boolean paramBoolean2);
  
  public abstract void putBoolean(String paramString, boolean paramBoolean1, boolean paramBoolean2);
  
  public abstract void putByteArray(String paramString, byte[] paramArrayOfByte, boolean paramBoolean);
  
  public abstract void remove(String paramString);
  
  public abstract void copyTo(ICredentialsStore paramICredentialsStore);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.ICredentialsStore
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation;

public class UserAuthenticationRequest
  extends AuthenticationRequest<AuthenticationType<UserCredentials>>
{
  private final boolean needsDomain;
  
  public UserAuthenticationRequest(RepositoryLocation location, AuthenticationType<UserCredentials> authenticationType, boolean needsDomain)
  {
    super(location, authenticationType);
    this.needsDomain = needsDomain;
  }
  
  public boolean needsDomain()
  {
    return needsDomain;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.UserAuthenticationRequest
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import java.util.Map;
import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation;

public class OpenIdAuthenticationRequest
  extends AuthenticationRequest<AuthenticationType<OpenIdCredentials>>
{
  private String alternateUrl;
  private final Map<String, String> providerArgs;
  private final String requestUrl;
  private final String returnUrl;
  private String cookie;
  private String cookieUrl;
  
  public OpenIdAuthenticationRequest(RepositoryLocation location, AuthenticationType<OpenIdCredentials> authenticationType, String requestUrl, Map<String, String> providerArgs, String returnUrl)
  {
    super(location, authenticationType);
    Assert.isNotNull(requestUrl);
    Assert.isNotNull(providerArgs);
    Assert.isNotNull(returnUrl);
    this.requestUrl = requestUrl;
    this.providerArgs = providerArgs;
    this.returnUrl = returnUrl;
  }
  
  public String getAlternateUrl()
  {
    return alternateUrl;
  }
  
  public Map<String, String> getProviderArgs()
  {
    return providerArgs;
  }
  
  public String getRequestUrl()
  {
    return requestUrl;
  }
  
  public void setAlternateUrl(String alternateUrl)
  {
    this.alternateUrl = alternateUrl;
  }
  
  public String getReturnUrl()
  {
    return returnUrl;
  }
  
  public void setCookie(String cookie)
  {
    this.cookie = cookie;
  }
  
  public void setCookieUrl(String cookieUrl)
  {
    this.cookieUrl = cookieUrl;
  }
  
  public String getCookie()
  {
    return cookie;
  }
  
  public String getCookieUrl()
  {
    return cookieUrl;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.OpenIdAuthenticationRequest
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

public class OpenIdCredentials
  extends AuthenticationCredentials
{
  private final String responseUrl;
  private final String token;
  
  public OpenIdCredentials(String responseUrl, String token)
  {
    this.responseUrl = responseUrl;
    this.token = token;
  }
  
  protected OpenIdCredentials(ICredentialsStore store, String prefix, boolean loadSecrets)
  {
    this(store.get(prefix + ".responseUrl", null), store.get(prefix + ".token", null));
  }
  
  public boolean equals(Object obj)
  {
    if (this == obj) {
      return true;
    }
    if (obj == null) {
      return false;
    }
    if (getClass() != obj.getClass()) {
      return false;
    }
    OpenIdCredentials other = (OpenIdCredentials)obj;
    if (responseUrl == null)
    {
      if (responseUrl != null) {
        return false;
      }
    }
    else if (!responseUrl.equals(responseUrl)) {
      return false;
    }
    if (token == null)
    {
      if (token != null) {
        return false;
      }
    }
    else if (!token.equals(token)) {
      return false;
    }
    return true;
  }
  
  public String getResponseUrl()
  {
    return responseUrl;
  }
  
  public String getToken()
  {
    return token;
  }
  
  public int hashCode()
  {
    int result = 1;
    result = 31 * result + (responseUrl == null ? 0 : responseUrl.hashCode());
    result = 31 * result + (token == null ? 0 : token.hashCode());
    return result;
  }
  
  public void clear(ICredentialsStore store, String prefix)
  {
    store.remove(prefix + ".responseUrl");
    store.remove(prefix + ".token");
  }
  
  public void save(ICredentialsStore store, String prefix)
  {
    store.put(prefix + ".responseUrl", responseUrl, true);
    store.put(prefix + ".token", token, true);
  }
  
  public String toString()
  {
    StringBuilder builder = new StringBuilder();
    builder.append("OpenIdCredentials [responseUrl=");
    builder.append(responseUrl);
    builder.append(", token=");
    builder.append(token);
    builder.append("]");
    return builder.toString();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.OpenIdCredentials
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import java.io.IOException;
import org.eclipse.core.runtime.Assert;

public class AuthenticationException
  extends IOException
{
  private static final long serialVersionUID = 1L;
  private final AuthenticationRequest<?> request;
  private final boolean shouldRetry;
  
  public AuthenticationException(String message, AuthenticationRequest<?> request, boolean shouldRetry)
  {
    super(message);
    Assert.isNotNull(request);
    this.request = request;
    this.shouldRetry = shouldRetry;
  }
  
  public AuthenticationException(String message, AuthenticationRequest<?> request)
  {
    this(message, request, false);
  }
  
  public AuthenticationException(AuthenticationRequest<?> request)
  {
    this(null, request, false);
  }
  
  public AuthenticationRequest<?> getRequest()
  {
    return request;
  }
  
  public boolean shouldRetry()
  {
    return shouldRetry;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationException
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core.auth;

import org.eclipse.core.runtime.Assert;
import org.eclipse.mylyn.commons.repositories.core.RepositoryLocation;

public class AuthenticationRequest<T extends AuthenticationType<?>>
{
  private final T authenticationType;
  private final RepositoryLocation location;
  private final String message;
  
  public AuthenticationRequest(RepositoryLocation location, T authenticationType, String message)
  {
    Assert.isNotNull(location);
    Assert.isNotNull(authenticationType);
    this.location = location;
    this.authenticationType = authenticationType;
    this.message = message;
  }
  
  public AuthenticationRequest(RepositoryLocation location, T authenticationType)
  {
    this(location, authenticationType, null);
  }
  
  public T getAuthenticationType()
  {
    return authenticationType;
  }
  
  public RepositoryLocation getLocation()
  {
    return location;
  }
  
  public String getMessage()
  {
    return message;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationRequest
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core;

public abstract interface IRepositoryLocationChangeListener
{
  public abstract void repositoryChanged(RepositoryLocationChangeEvent paramRepositoryLocationChangeEvent);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.IRepositoryLocationChangeListener
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core;

import org.eclipse.core.runtime.PlatformObject;

public class RepositoryCategory
  extends PlatformObject
{
  private final String id;
  private final String label;
  private final int rank;
  public static final String ID_CATEGORY_BUGS = "org.eclipse.mylyn.category.bugs";
  public static final String ID_CATEGORY_BUILDS = "org.eclipse.mylyn.category.build";
  public static final String ID_CATEGORY_OTHER = "org.eclipse.mylyn.category.other";
  public static final String ID_CATEGORY_REVIEWS = "org.eclipse.mylyn.category.review";
  public static final String ID_CATEGORY_TASKS = "org.eclipse.mylyn.category.tasks";
  public static final String ID_CATEGORY_ALL = "org.eclipse.mylyn.category.all";
  public static final String ID_CATEGORY_ROOT = "org.eclipse.mylyn.category.root";
  
  public RepositoryCategory(String id, String label, int rank)
  {
    this.id = id;
    this.label = label;
    this.rank = rank;
  }
  
  public String getId()
  {
    return id;
  }
  
  public int compareTo(Object arg0)
  {
    if ((arg0 instanceof RepositoryCategory)) {
      return getRank() - ((RepositoryCategory)arg0).getRank();
    }
    return 0;
  }
  
  public int getRank()
  {
    return rank;
  }
  
  public String getLabel()
  {
    return label;
  }
  
  public String toString()
  {
    return getLabel();
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.RepositoryCategory
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core;

import java.util.EventObject;
import org.eclipse.core.runtime.Assert;

public class RepositoryLocationChangeEvent
  extends EventObject
{
  private static final long serialVersionUID = -8177578930986469693L;
  private final Type type;
  
  public static enum Type
  {
    ALL,  CREDENTIALS,  PROYX;
  }
  
  public RepositoryLocationChangeEvent(RepositoryLocation source, Type type)
  {
    super(source);
    this.type = type;
    Assert.isNotNull(source);
  }
  
  public RepositoryLocation getSource()
  {
    return (RepositoryLocation)super.getSource();
  }
  
  public Type getType()
  {
    return type;
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.RepositoryLocationChangeEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core;

import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.SocketAddress;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.core.runtime.Status;
import org.eclipse.mylyn.commons.core.StatusHandler;
import org.eclipse.mylyn.commons.core.net.NetUtil;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationCredentials;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationRequest;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationType;
import org.eclipse.mylyn.commons.repositories.core.auth.ICredentialsStore;
import org.eclipse.mylyn.commons.repositories.core.auth.UserCredentials;
import org.eclipse.mylyn.internal.commons.repositories.core.CredentialsFactory;
import org.eclipse.mylyn.internal.commons.repositories.core.InMemoryCredentialsStore;
import org.eclipse.mylyn.internal.commons.repositories.core.LocationService;

public class RepositoryLocation
  extends PlatformObject
{
  private static boolean flushCredentialsErrorLogged;
  public static final String PROPERTY_ID = "id";
  public static final String PROPERTY_LABEL = "label";
  public static final String PROPERTY_OFFLINE = "org.eclipse.mylyn.tasklist.repositories.offline";
  public static final String PROPERTY_PROXY_HOST = "org.eclipse.mylyn.repositories.proxy.host";
  public static final String PROPERTY_PROXY_PORT = "org.eclipse.mylyn.repositories.proxy.port";
  public static final String PROPERTY_PROXY_USEDEFAULT = "org.eclipse.mylyn.repositories.proxy.usedefault";
  public static final String PROPERTY_URL = "url";
  public static final String PROPERTY_USERNAME = "org.eclipse.mylyn.repositories.username";
  private static final String ENABLED = ".enabled";
  private ICredentialsStore credentialsStore;
  
  private static Map<String, String> createDefaultProperties()
  {
    Map<String, String> defaultProperties = new HashMap();
    defaultProperties.put("org.eclipse.mylyn.repositories.proxy.usedefault", Boolean.TRUE.toString());
    return defaultProperties;
  }
  
  private IStatus errorStatus = null;
  private final Map<String, String> properties = new LinkedHashMap();
  private final List<PropertyChangeListener> propertyChangeListeners = new CopyOnWriteArrayList();
  private final List<IRepositoryLocationChangeListener> repositoryLocationChangeListeners = new CopyOnWriteArrayList();
  private ILocationService service;
  private final boolean workingCopy;
  
  public RepositoryLocation()
  {
    this(createDefaultProperties(), LocationService.getDefault(), false);
  }
  
  public RepositoryLocation(String url)
  {
    this();
    setUrl(url);
  }
  
  public RepositoryLocation(Map<String, String> properties)
  {
    this(properties, LocationService.getDefault(), true);
  }
  
  public RepositoryLocation(Map<String, String> properties, ILocationService service, boolean workingCopy)
  {
    this.properties.putAll(properties);
    this.service = service;
    this.workingCopy = workingCopy;
    if (this.properties.get("id") == null) {
      this.properties.put("id", UUID.randomUUID().toString());
    }
  }
  
  public RepositoryLocation(RepositoryLocation source)
  {
    this(source.getProperties(), source.getService(), true);
  }
  
  public void addPropertyChangeListener(PropertyChangeListener listener)
  {
    propertyChangeListeners.add(listener);
  }
  
  public void apply(RepositoryLocation location)
  {
    String oldId = getProperty("id");
    ICredentialsStore oldCredentialsStore = null;
    if (oldId != null) {
      oldCredentialsStore = getCredentialsStore();
    }
    HashSet<String> removed = new HashSet(properties.keySet());
    removed.removeAll(properties.keySet());
    for (Map.Entry<String, String> entry : properties.entrySet()) {
      setProperty((String)entry.getKey(), (String)entry.getValue());
    }
    for (String key : removed) {
      setProperty(key, null);
    }
    String newId = getProperty("id");
    if (newId != null)
    {
      ICredentialsStore newCredentialsStore = getCredentialsStore();
      if ((!newId.equals(oldId)) && 
        (oldCredentialsStore != null))
      {
        oldCredentialsStore.copyTo(newCredentialsStore);
        oldCredentialsStore.clear();
      }
      if ((location.getCredentialsStore() instanceof InMemoryCredentialsStore)) {
        ((InMemoryCredentialsStore)location.getCredentialsStore()).copyTo(newCredentialsStore);
      }
      try
      {
        newCredentialsStore.flush();
      }
      catch (IOException e)
      {
        if (!flushCredentialsErrorLogged)
        {
          flushCredentialsErrorLogged = true;
          StatusHandler.log(new Status(
            4, 
            "org.eclipse.mylyn.commons.repositories.core", 
            "Unexpected error occured while flushing credentials. Credentials may not have been saved.", e));
        }
      }
    }
    fireRepositoryLocationChangeEvent(RepositoryLocationChangeEvent.Type.ALL);
  }
  
  public void clearCredentials()
  {
    getCredentialsStore().clear();
  }
  
  public boolean getBooleanPropery(String key)
  {
    String value = getProperty(key);
    return (value != null) && (Boolean.parseBoolean(value));
  }
  
  public <T extends AuthenticationCredentials> T getCredentials(AuthenticationType<T> authType)
  {
    return getCredentials(authType, true);
  }
  
  public <T extends AuthenticationCredentials> T getCredentials(AuthenticationType<T> authType, boolean loadSecrets)
  {
    String prefix = authType.getKey();
    if (getBooleanPropery(prefix + ".enabled"))
    {
      if (getId() == null) {
        return null;
      }
      return CredentialsFactory.create(authType.getCredentialsType(), getCredentialsStore(), prefix, loadSecrets);
    }
    return null;
  }
  
  public ICredentialsStore getCredentialsStore()
  {
    if (credentialsStore == null) {
      return getService().getCredentialsStore(getId());
    }
    return credentialsStore;
  }
  
  public String getId()
  {
    String id = getProperty("id");
    if (id == null) {
      throw new IllegalStateException("Repository ID is not set");
    }
    return id;
  }
  
  public String getLabel()
  {
    String label = (String)properties.get("label");
    if ((label != null) && (label.length() > 0)) {
      return label;
    }
    return getUrl();
  }
  
  public Map<String, String> getProperties()
  {
    return new LinkedHashMap(properties);
  }
  
  public String getProperty(String name)
  {
    return (String)properties.get(name);
  }
  
  public Proxy getProxy()
  {
    if (Boolean.parseBoolean(getProperty("org.eclipse.mylyn.repositories.proxy.usedefault"))) {
      return null;
    }
    String proxyHost = getProperty("org.eclipse.mylyn.repositories.proxy.host");
    String proxyPort = getProperty("org.eclipse.mylyn.repositories.proxy.port");
    if ((proxyHost != null) && (proxyHost.length() > 0) && (proxyPort != null)) {
      try
      {
        int proxyPortNum = Integer.parseInt(proxyPort);
        UserCredentials credentials = (UserCredentials)getCredentials(AuthenticationType.PROXY);
        if (credentials != null) {
          return NetUtil.createProxy(proxyHost, proxyPortNum, credentials.getUserName(), 
            credentials.getPassword(), credentials.getDomain());
        }
        return NetUtil.createProxy(proxyHost, proxyPortNum);
      }
      catch (NumberFormatException e)
      {
        StatusHandler.log(new Status(4, "org.eclipse.mylyn.commons.repositories.core", 0, 
          "Error occured while configuring proxy. Invalid port \"" + 
          proxyPort + "\" specified.", e));
      }
    }
    return null;
  }
  
  public Proxy getProxyForHost(String host, String proxyType)
  {
    Proxy proxy = getProxy();
    if (proxy != null) {
      return proxy;
    }
    return getService().getProxyForHost(host, proxyType);
  }
  
  public ILocationService getService()
  {
    return service;
  }
  
  public IStatus getStatus()
  {
    return errorStatus;
  }
  
  public String getUrl()
  {
    return getProperty("url");
  }
  
  public String getUserName()
  {
    return getProperty("org.eclipse.mylyn.repositories.username");
  }
  
  public boolean hasProperty(String name)
  {
    String value = getProperty(name);
    return (value != null) && (value.trim().length() > 0);
  }
  
  public boolean hasUrl(String url)
  {
    Assert.isNotNull(url);
    String myUrl = getUrl();
    if (myUrl == null) {
      return false;
    }
    try
    {
      return new URI(url + "/").normalize().equals(new URI(myUrl + "/").normalize());
    }
    catch (URISyntaxException localURISyntaxException) {}
    return false;
  }
  
  public boolean isOffline()
  {
    return Boolean.parseBoolean(getProperty("org.eclipse.mylyn.tasklist.repositories.offline"));
  }
  
  public boolean isWorkingCopy()
  {
    return workingCopy;
  }
  
  public void removePropertyChangeListener(PropertyChangeListener listener)
  {
    propertyChangeListeners.remove(listener);
  }
  
  public <T extends AuthenticationCredentials> void removeCredentials(AuthenticationType<T> authType, T credentials)
  {
    String prefix = authType.getKey();
    credentials.clear(getCredentialsStore(), prefix);
  }
  
  public void removeProperty(String key)
  {
    setProperty(key, null);
  }
  
  public <T extends AuthenticationCredentials> T requestCredentials(AuthenticationRequest<AuthenticationType<T>> request, IProgressMonitor monitor)
  {
    return getService().requestCredentials(request, monitor);
  }
  
  public <T extends AuthenticationCredentials> void setCredentials(AuthenticationType<T> authType, T credentials)
  {
    String prefix = authType.getKey();
    if (credentials == null)
    {
      setProperty(prefix + ".enabled", String.valueOf(false));
    }
    else
    {
      setProperty(prefix + ".enabled", String.valueOf(true));
      credentials.save(getCredentialsStore(), prefix);
    }
    fireRepositoryLocationChangeEvent(RepositoryLocationChangeEvent.Type.CREDENTIALS);
  }
  
  public void setCredentialsStore(ICredentialsStore credentialsStore)
  {
    this.credentialsStore = credentialsStore;
  }
  
  public void setIdPreservingCredentialsStore(String id)
  {
    Assert.isNotNull(id);
    ICredentialsStore store = getCredentialsStore();
    setProperty("id", id);
    if (credentialsStore == null) {
      setCredentialsStore(store);
    }
  }
  
  public void setLabel(String label)
  {
    setProperty("label", label);
  }
  
  public void setOffline(boolean offline)
  {
    properties.put("org.eclipse.mylyn.tasklist.repositories.offline", String.valueOf(offline));
  }
  
  public void setProperty(String key, String newValue)
  {
    validatePropertyChange(key, newValue);
    String oldValue = (String)properties.get(key);
    if (hasChanged(oldValue, newValue))
    {
      properties.put(key.intern(), newValue != null ? newValue.intern() : null);
      handlePropertyChange(key, oldValue, newValue);
    }
  }
  
  public void validatePropertyChange(String key, String newValue)
  {
    Assert.isNotNull(key);
    if ((key.equals("id")) && (newValue == null)) {
      throw new IllegalArgumentException("The ID property must not be null");
    }
  }
  
  public void setProxy(Proxy proxy)
  {
    if (proxy == null)
    {
      setProperty("org.eclipse.mylyn.repositories.proxy.usedefault", Boolean.toString(true));
    }
    else
    {
      SocketAddress address = proxy.address();
      if ((address instanceof InetSocketAddress))
      {
        setProperty("org.eclipse.mylyn.repositories.proxy.host", ((InetSocketAddress)address).getHostName());
        setProperty("org.eclipse.mylyn.repositories.proxy.port", Integer.toString(((InetSocketAddress)address).getPort()));
        setProperty("org.eclipse.mylyn.repositories.proxy.usedefault", Boolean.toString(false));
      }
      else
      {
        throw new IllegalArgumentException("Invalid proxy address");
      }
    }
    fireRepositoryLocationChangeEvent(RepositoryLocationChangeEvent.Type.PROYX);
  }
  
  public void setService(ILocationService service)
  {
    this.service = service;
  }
  
  public void setStatus(IStatus errorStatus)
  {
    this.errorStatus = errorStatus;
  }
  
  public void setUrl(String url)
  {
    setProperty("url", url);
  }
  
  public void setUserName(String userName)
  {
    setProperty("org.eclipse.mylyn.repositories.username", userName);
  }
  
  public String toString()
  {
    return getLabel();
  }
  
  private void handlePropertyChange(String key, Object old, Object value)
  {
    if ("id".equals(key)) {
      credentialsStore = null;
    }
    firePropertyChangeEvent(key, old, value);
  }
  
  private void firePropertyChangeEvent(String key, Object old, Object value)
  {
    PropertyChangeEvent event = new PropertyChangeEvent(this, key, old, value);
    for (PropertyChangeListener listener : propertyChangeListeners) {
      listener.propertyChange(event);
    }
  }
  
  private void fireRepositoryLocationChangeEvent(RepositoryLocationChangeEvent.Type type)
  {
    RepositoryLocationChangeEvent event = new RepositoryLocationChangeEvent(this, type);
    for (IRepositoryLocationChangeListener listener : repositoryLocationChangeListeners) {
      listener.repositoryChanged(event);
    }
  }
  
  private boolean hasChanged(Object oldValue, Object newValue)
  {
    return ((oldValue != null) && (!oldValue.equals(newValue))) || ((oldValue == null) && (newValue != null));
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.RepositoryLocation
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core;

public enum RepositoryLocationChangeEvent$Type
{
  ALL,  CREDENTIALS,  PROYX;
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.RepositoryLocationChangeEvent.Type
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.commons.repositories.core;

import java.net.Proxy;
import javax.net.ssl.X509TrustManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationCredentials;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationRequest;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationType;
import org.eclipse.mylyn.commons.repositories.core.auth.ICredentialsStore;

public abstract interface ILocationService
{
  public abstract Proxy getProxyForHost(String paramString1, String paramString2);
  
  public abstract X509TrustManager getTrustManager();
  
  public abstract <T extends AuthenticationCredentials> T requestCredentials(AuthenticationRequest<AuthenticationType<T>> paramAuthenticationRequest, IProgressMonitor paramIProgressMonitor);
  
  public abstract ICredentialsStore getCredentialsStore(String paramString);
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.commons.repositories.core.ILocationService
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.repositories.core;

import java.net.Proxy;
import org.eclipse.mylyn.commons.core.net.NetUtil;
import org.eclipse.mylyn.commons.core.net.ProxyProvider;

class LocationService$PlatformProxyProvider
  extends ProxyProvider
{
  static PlatformProxyProvider INSTANCE = new PlatformProxyProvider();
  
  public Proxy getProxyForHost(String host, String proxyType)
  {
    return NetUtil.getProxy(host, proxyType);
  }
}

/* Location:
 * Qualified Name:     org.eclipse.mylyn.internal.commons.repositories.core.LocationService.PlatformProxyProvider
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package org.eclipse.mylyn.internal.commons.repositories.core;

import java.lang.reflect.Constructor;
import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationCredentials;
import org.eclipse.mylyn.commons.repositories.core.auth.ICredentialsStore;

public class CredentialsFactory
{
  public static <T extends AuthenticationCredentials> T create(Class<T> credentialsType, ICredentialsStore credentialsStore, String key, boolean loadSecrets)
  {
    try
    {
      Constructor<T> constructor = credentialsType.getDeclaredConstructor(new Class[] { ICredentialsStore.class, String.class, 
        Boolean.TYPE });
      constructor.setAccessible(true);
      return (AuthenticationCredentials)constructor.newInstance(new Object[] { credentialsStore, key, Boolean.valueOf(loadSecrets) });
    }
    catch (Exception e)
    {
 
1 2

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