blob: 7412b63c381441356de2aff05619f94f64734325 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
/*******************************************************************************
* 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;
import org.eclipse.equinox.security.storage.StorageException;
import org.eclipse.mylyn.commons.repositories.auth.AuthenticationCredentials;
import org.eclipse.mylyn.commons.repositories.auth.ICredentialsStore;
import org.eclipse.mylyn.commons.repositories.auth.UsernamePasswordCredentials;
/**
* Simple factory that creates {@link AuthenticationCredentials} objects.
*
* @author Steffen Pingel
*/
public class CredentialsFactory {
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$
}
}
|