Source:
<code>protected RemoteOperationResult<AuthenticationMethod> run(OwnCloudClient client) { AuthenticationMethod authenticationMethod = null; CheckPathExistenceRemoteOperation operation = new CheckPathExistenceRemoteOperation("", false); client.clearCredentials(); client.setFollowRedirects(false); RemoteOperationResult resultFromExistenceCheck = operation.execute(client); String redirectedLocation = resultFromExistenceCheck.getRedirectedLocation(); Timber.d("Redirected location:" + redirectedLocation); while (redirectedLocation != null && redirectedLocation.length() > 0) { client.setBaseUri(Uri.parse(resultFromExistenceCheck.getRedirectedLocation())); resultFromExistenceCheck = operation.execute(client); redirectedLocation = resultFromExistenceCheck.getRedirectedLocation(); Timber.d("Redirected location:" + redirectedLocation); } if (resultFromExistenceCheck.getHttpCode() == HttpConstants.HTTP_UNAUTHORIZED) { String authenticateHeaders = resultFromExistenceCheck.getAuthenticateHeaders(); Timber.d("Authentication Header:" + authenticateHeaders); <START> if (authenticateHeaders.contains("basic")) { <END> authenticationMethod = AuthenticationMethod.BASIC_HTTP_AUTH; } else if (authenticateHeaders.contains("bearer")) { authenticationMethod = AuthenticationMethod.BEARER_TOKEN; } } else if (resultFromExistenceCheck.isSuccess()) { authenticationMethod = AuthenticationMethod.NONE; } RemoteOperationResult<AuthenticationMethod> result = new RemoteOperationResult<>(resultFromExistenceCheck); if (authenticationMethod == null) { Timber.d("Authentication method not found: "); } else { Timber.d("Authentication method:%s", authenticationMethod); result = new RemoteOperationResult<>(result.getHttpCode(), result.getHttpPhrase(), null); result.setSuccess(true); } result.setData(authenticationMethod); return result; }</code><technical_language>a constant for "basic"</technical_language>

Target:
protected RemoteOperationResult<AuthenticationMethod> run(OwnCloudClient client) { AuthenticationMethod authenticationMethod = null; CheckPathExistenceRemoteOperation operation = new CheckPathExistenceRemoteOperation("", false); client.clearCredentials(); client.setFollowRedirects(false); RemoteOperationResult resultFromExistenceCheck = operation.execute(client); String redirectedLocation = resultFromExistenceCheck.getRedirectedLocation(); Timber.d("Redirected location: %s", redirectedLocation); while (redirectedLocation != null && redirectedLocation.length() > 0) { client.setBaseUri(Uri.parse(resultFromExistenceCheck.getRedirectedLocation())); resultFromExistenceCheck = operation.execute(client); redirectedLocation = resultFromExistenceCheck.getRedirectedLocation(); Timber.d("Redirected location: %s", redirectedLocation); } if (resultFromExistenceCheck.getHttpCode() == HttpConstants.HTTP_UNAUTHORIZED) { String authenticateHeaders = resultFromExistenceCheck.getAuthenticateHeaders(); Timber.d("Authentication Header: %s", authenticateHeaders); if (authenticateHeaders.startsWith(AuthenticationMethod.BASIC_HTTP_AUTH.toString())) { authenticationMethod = AuthenticationMethod.BASIC_HTTP_AUTH; } else if (authenticateHeaders.contains(AuthenticationMethod.BEARER_TOKEN.toString())) { authenticationMethod = AuthenticationMethod.BEARER_TOKEN; } } else if (resultFromExistenceCheck.isSuccess()) { authenticationMethod = AuthenticationMethod.NONE; } RemoteOperationResult<AuthenticationMethod> result = new RemoteOperationResult<>(resultFromExistenceCheck); if (authenticationMethod == null) { Timber.d("Authentication method not found: "); } else { Timber.d("Authentication method: %s", authenticationMethod); result = new RemoteOperationResult<>(result.getHttpCode(), result.getHttpPhrase(), null); result.setSuccess(true); } result.setData(authenticationMethod); return result; }