本文整理汇总了Java中com.owncloud.android.lib.common.OwnCloudCredentialsFactory类的典型用法代码示例。如果您正苦于以下问题:Java OwnCloudCredentialsFactory类的具体用法?Java OwnCloudCredentialsFactory怎么用?Java OwnCloudCredentialsFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OwnCloudCredentialsFactory类属于com.owncloud.android.lib.common包,在下文中一共展示了OwnCloudCredentialsFactory类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initAccessToServer
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
private void initAccessToServer(Context context) {
Log.v(LOG_TAG, "Setting up client instance to access OC server...");
mServerUri = context.getString(R.string.server_base_url);
mUser = context.getString(R.string.username);
mPass = context.getString(R.string.password);
mClient = new OwnCloudClient(
Uri.parse(mServerUri),
NetworkUtils.getMultiThreadedConnManager()
);
mClient.setDefaultTimeouts(
OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,
OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT);
mClient.setFollowRedirects(true);
mClient.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
mUser,
mPass
)
);
Log.v(LOG_TAG, "Client instance set up.");
}
示例2: setUp
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
mSSMgr = new SingleSessionManager();
mServerUri = Uri.parse(getContext().getString(R.string.server_base_url));
mUsername = getContext().getString(R.string.username);
mValidAccount = new OwnCloudAccount(
mServerUri, OwnCloudCredentialsFactory.newBasicCredentials(
mUsername,
getContext().getString(R.string.password)
)
);
mAnonymousAccount = new OwnCloudAccount(
mServerUri, OwnCloudCredentialsFactory.getAnonymousCredentials());
}
示例3: setUp
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
mSFMgr = new SimpleFactoryManager();
mServerUri = Uri.parse(getContext().getString(R.string.server_base_url));
mUsername = getContext().getString(R.string.username);
mValidAccount = new OwnCloudAccount(
mServerUri, OwnCloudCredentialsFactory.newBasicCredentials(
mUsername,
getContext().getString(R.string.password)
)
);
mAnonymousAccount = new OwnCloudAccount(
mServerUri, OwnCloudCredentialsFactory.getAnonymousCredentials());
}
示例4: testGetSetCredentials
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
public void testGetSetCredentials() {
OwnCloudClient client =
new OwnCloudClient(mServerUri, NetworkUtils.getMultiThreadedConnManager());
assertNotNull("Returned NULL credentials", client.getCredentials());
assertEquals("Not instanced without credentials",
client.getCredentials(), OwnCloudCredentialsFactory.getAnonymousCredentials());
OwnCloudCredentials credentials =
OwnCloudCredentialsFactory.newBasicCredentials("user", "pass");
client.setCredentials(credentials);
assertEquals("Basic credentials not set", credentials, client.getCredentials());
credentials = OwnCloudCredentialsFactory.newBearerCredentials("bearerToken");
client.setCredentials(credentials);
assertEquals("Bearer credentials not set", credentials, client.getCredentials());
credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials("samlSessionCookie=124");
client.setCredentials(credentials);
assertEquals("SAML2 session credentials not set", credentials, client.getCredentials());
}
示例5: initClient
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
private OwnCloudClient initClient() {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(mContext);
String accountName = prefs.getString(Settings.PREF_ACCOUNT_NAME, null);
String password = prefs.getString(Settings.PREF_ACCOUNT_PASSWORD, null);
if (TextUtils.isEmpty(accountName) || TextUtils.isEmpty(password)) {
// start LoginActivity
showLoginActivity();
return null;
}
Uri baseUrl = Settings.getAccountURL(accountName);
String username = Settings.getAccountUsername(accountName);
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(baseUrl, mContext, false);
client.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials(username, password));
return client;
}
示例6: doInBackground
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
@Override
protected Account doInBackground(Account... selectedAccounts) {
Account selectedAccount = selectedAccounts[0];
Uri baseUrl = Settings.getAccountURL(selectedAccount.name);
String username = Settings.getAccountUsername(selectedAccount.name);
String password = PreferenceManager.getDefaultSharedPreferences(LoginActivity.this).getString(Settings.PREF_ACCOUNT_PASSWORD, null);
if (password == null) {
return null;
}
OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(baseUrl, LoginActivity.this, false);
client.setCredentials(OwnCloudCredentialsFactory.newBasicCredentials(username, password));
if (!Settings.checkRemoteAccess(client)) {
return null;
}
return selectedAccount;
}
示例7: onCreate
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_test);
mServerUri = getString(R.string.server_base_url);
mUser = getString(R.string.username);
mPass = getString(R.string.password);
Protocol pr = Protocol.getProtocol("https");
if (pr == null || !(pr.getSocketFactory() instanceof SelfSignedConfidentSslSocketFactory)) {
try {
ProtocolSocketFactory psf = new SelfSignedConfidentSslSocketFactory();
Protocol.registerProtocol(
"https",
new Protocol("https", psf, 443));
} catch (GeneralSecurityException e) {
Log.e(TAG, "Self-signed confident SSL context could not be loaded");
}
}
mClient = new OwnCloudClient(Uri.parse(mServerUri), NetworkUtils.getMultiThreadedConnManager());
mClient.setDefaultTimeouts(
OwnCloudClientFactory.DEFAULT_DATA_TIMEOUT,
OwnCloudClientFactory.DEFAULT_CONNECTION_TIMEOUT);
mClient.setFollowRedirects(true);
mClient.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
mUser,
mPass
)
);
mClient.setBaseUri(Uri.parse(mServerUri));
Log.v(TAG, "onCreate finished, ownCloud client ready");
}
示例8: setUpOcClientArguments
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
private HashMap<String, Object> setUpOcClientArguments() {
OwnCloudClient mClientOwnCloud;
Uri serverUri = Uri.parse(AppData.getSourcePath());
if (AppData.getUserName().equals(SettingsDefaults.getDefaultValueForKey(R.string.sett_key_username)) ||
AppData.getUserPassword().equals(SettingsDefaults.getDefaultValueForKey(R.string.sett_key_password)) ||
AppData.getSourcePath().equals(SettingsDefaults.getDefaultValueForKey(R.string.sett_key_srcpath_owncloud)) ||
AppData.getSourcePath().equals("") ||
serverUri == null) {
return null;
}
if (DEBUG) Log.i(TAG, "OwnCloud serverUri: " + serverUri);
// Create client object to perform remote operations
mClientOwnCloud = OwnCloudClientFactory.createOwnCloudClient(serverUri, getApplicationContext(), true);
mClientOwnCloud.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
AppData.getUserName(),
AppData.getUserPassword()
)
);
args.put(Downloader_OC.CLIENT, mClientOwnCloud);
args.put(Downloader_OC.HANDLER, new Handler());
args.put(Keys.PICFRAMEPATH, AppData.getExtFolderAppRoot());
args.put(Keys.CONTEXT, getApplicationContext());
// args.put(Downloader_OC.REMOTEFOLDER, settObj. getRemoteFolderPath); TODO FOLDERPICKER STUFF
args.put(Keys.CALLBACK, this);
return args;
}
示例9: buildClient
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
private void buildClient() {
serverUri = Uri.parse(AppData.getSourcePath());
mClient = OwnCloudClientFactory
.createOwnCloudClient(
serverUri,
_MainApp.getINSTANCE().getApplicationContext(),
true);
mClient.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
AppData.getUserName(),
AppData.getUserPassword()
));
}
示例10: onCreate
import com.owncloud.android.lib.common.OwnCloudCredentialsFactory; //导入依赖的package包/类
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
mHandler = new Handler();
Uri serverUri = Uri.parse(getString(R.string.server_base_url));
mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, this, true);
mClient.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
getString(R.string.username),
getString(R.string.password)
)
);
mFilesAdapter = new FilesArrayAdapter(this, R.layout.file_in_list);
((ListView)findViewById(R.id.list_view)).setAdapter(mFilesAdapter);
// TODO move to background thread or task
AssetManager assets = getAssets();
try {
String sampleFileName = getString(R.string.sample_file_name);
File upFolder = new File(getCacheDir(), getString(R.string.upload_folder_path));
upFolder.mkdir();
File upFile = new File(upFolder, sampleFileName);
FileOutputStream fos = new FileOutputStream(upFile);
InputStream is = assets.open(sampleFileName);
int count = 0;
byte[] buffer = new byte[1024];
while ((count = is.read(buffer, 0, buffer.length)) >= 0) {
fos.write(buffer, 0, count);
}
is.close();
fos.close();
} catch (IOException e) {
Toast.makeText(this, R.string.error_copying_sample_file, Toast.LENGTH_SHORT).show();
Log.e(LOG_TAG, getString(R.string.error_copying_sample_file), e);
}
mFrame = findViewById(R.id.frame);
}