Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.commons.repositories.core/src/org/eclipse/mylyn/internal/commons/repositories/core/CredentialsFactory.java')
-rw-r--r--org.eclipse.mylyn.commons.repositories.core/src/org/eclipse/mylyn/internal/commons/repositories/core/CredentialsFactory.java35
1 files changed, 35 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.commons.repositories.core/src/org/eclipse/mylyn/internal/commons/repositories/core/CredentialsFactory.java b/org.eclipse.mylyn.commons.repositories.core/src/org/eclipse/mylyn/internal/commons/repositories/core/CredentialsFactory.java
new file mode 100644
index 00000000..9850a745
--- /dev/null
+++ b/org.eclipse.mylyn.commons.repositories.core/src/org/eclipse/mylyn/internal/commons/repositories/core/CredentialsFactory.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.internal.commons.repositories.core;
+
+import org.eclipse.equinox.security.storage.StorageException;
+import org.eclipse.mylyn.commons.repositories.core.auth.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.repositories.core.auth.ICredentialsStore;
+import org.eclipse.mylyn.commons.repositories.core.auth.UsernamePasswordCredentials;
+
+/**
+ * Simple factory that creates {@link AuthenticationCredentials} objects.
+ *
+ * @author Steffen Pingel
+ */
+public class CredentialsFactory {
+
+ @SuppressWarnings("unchecked")
+ public static <T extends AuthenticationCredentials> T create(Class<T> credentialsKind,
+ ICredentialsStore credentialsStore, String key) throws StorageException {
+ if (credentialsKind == UsernamePasswordCredentials.class) {
+ return (T) UsernamePasswordCredentials.create(credentialsStore, key);
+ }
+ throw new IllegalArgumentException("Unknown credentials type: " + credentialsKind); //$NON-NLS-1$
+ }
+
+}

Back to the top