mirror of
				https://github.com/owncloud/android-library.git
				synced 2025-10-31 02:17:41 +00:00 
			
		
		
		
	Merge branch 'develop'
This commit is contained in:
		
						commit
						dbc8c325d7
					
				| @ -1,7 +1,7 @@ | |||||||
| language: android | language: android | ||||||
| android: | android: | ||||||
|   components: |   components: | ||||||
|     - build-tools-20.0.0 |     - build-tools-22.0.1 | ||||||
|     - android-19 |     - android-19 | ||||||
|     - android-17 |     - android-17 | ||||||
|     - android-14 |     - android-14 | ||||||
|  | |||||||
| @ -3,7 +3,7 @@ buildscript { | |||||||
|         mavenCentral() |         mavenCentral() | ||||||
|     } |     } | ||||||
|     dependencies { |     dependencies { | ||||||
|         classpath 'com.android.tools.build:gradle:1.0.0' |         classpath 'com.android.tools.build:gradle:1.2.3' | ||||||
|     } |     } | ||||||
| } | } | ||||||
| apply plugin: 'com.android.library' | apply plugin: 'com.android.library' | ||||||
| @ -13,14 +13,12 @@ repositories { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| dependencies { | dependencies { | ||||||
|     compile 'commons-httpclient:commons-httpclient:3.1' |     compile 'org.apache.jackrabbit:jackrabbit-webdav:2.10.1' | ||||||
|     compile 'org.apache.jackrabbit:jackrabbit-webdav:2.7.2' |  | ||||||
|     compile 'org.slf4j:slf4j-api:1.7.5' |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| android { | android { | ||||||
|     compileSdkVersion 19 |     compileSdkVersion 19 | ||||||
|     buildToolsVersion "20.0.0" |     buildToolsVersion "22.0.1" | ||||||
| 
 | 
 | ||||||
|     sourceSets { |     sourceSets { | ||||||
|         main { |         main { | ||||||
|  | |||||||
										
											Binary file not shown.
										
									
								
							| @ -10,7 +10,7 @@ dependencies { | |||||||
| 
 | 
 | ||||||
| android { | android { | ||||||
|     compileSdkVersion 19 |     compileSdkVersion 19 | ||||||
|     buildToolsVersion "20.0.0" |     buildToolsVersion "22.0.1" | ||||||
| 
 | 
 | ||||||
|     sourceSets { |     sourceSets { | ||||||
|         main { |         main { | ||||||
|  | |||||||
| @ -82,8 +82,9 @@ public class OwnCloudClientFactory { | |||||||
|         boolean isSamlSso = |         boolean isSamlSso = | ||||||
|                 am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; |                 am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; | ||||||
|         OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); |         OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); | ||||||
|          | 
 | ||||||
|         if (isOauth2) {     |         String username = account.name.substring(0, account.name.lastIndexOf('@')); | ||||||
|  |         if (isOauth2) { | ||||||
|             String accessToken = am.blockingGetAuthToken( |             String accessToken = am.blockingGetAuthToken( | ||||||
|             		account,  |             		account,  | ||||||
|             		AccountTypeUtils.getAuthTokenTypeAccessToken(account.type),  |             		AccountTypeUtils.getAuthTokenTypeAccessToken(account.type),  | ||||||
| @ -100,11 +101,10 @@ public class OwnCloudClientFactory { | |||||||
|             		false); |             		false); | ||||||
|              |              | ||||||
|             client.setCredentials( |             client.setCredentials( | ||||||
|             		OwnCloudCredentialsFactory.newSamlSsoCredentials(accessToken) |             		OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken) | ||||||
|     		); |     		); | ||||||
| 
 | 
 | ||||||
|         } else { |         } else { | ||||||
|             String username = account.name.substring(0, account.name.lastIndexOf('@')); |  | ||||||
|             //String password = am.getPassword(account); |             //String password = am.getPassword(account); | ||||||
|             String password = am.blockingGetAuthToken( |             String password = am.blockingGetAuthToken( | ||||||
|             		account,  |             		account,  | ||||||
| @ -136,7 +136,8 @@ public class OwnCloudClientFactory { | |||||||
|         boolean isSamlSso = |         boolean isSamlSso = | ||||||
|                 am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; |                 am.getUserData(account, AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; | ||||||
|         OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); |         OwnCloudClient client = createOwnCloudClient(baseUri, appContext, !isSamlSso); | ||||||
|          | 
 | ||||||
|  |         String username = account.name.substring(0, account.name.lastIndexOf('@')); | ||||||
|         if (isOauth2) {    // TODO avoid a call to getUserData here |         if (isOauth2) {    // TODO avoid a call to getUserData here | ||||||
|             AccountManagerFuture<Bundle> future =  am.getAuthToken( |             AccountManagerFuture<Bundle> future =  am.getAuthToken( | ||||||
|             		account,   |             		account,   | ||||||
| @ -166,12 +167,11 @@ public class OwnCloudClientFactory { | |||||||
|             String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN); |             String accessToken = result.getString(AccountManager.KEY_AUTHTOKEN); | ||||||
|             if (accessToken == null) throw new AuthenticatorException("WTF!"); |             if (accessToken == null) throw new AuthenticatorException("WTF!"); | ||||||
|             client.setCredentials( |             client.setCredentials( | ||||||
|             		OwnCloudCredentialsFactory.newSamlSsoCredentials(accessToken) |             		OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken) | ||||||
|     		); |     		); | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|         } else { |         } else { | ||||||
|             String username = account.name.substring(0, account.name.lastIndexOf('@')); |  | ||||||
|             //String password = am.getPassword(account); |             //String password = am.getPassword(account); | ||||||
|             //String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(), |             //String password = am.blockingGetAuthToken(account, MainApp.getAuthTokenTypePass(), | ||||||
|             // false); |             // false); | ||||||
|  | |||||||
| @ -36,8 +36,8 @@ public class OwnCloudCredentialsFactory { | |||||||
|         return new OwnCloudBearerCredentials(authToken); |         return new OwnCloudBearerCredentials(authToken); | ||||||
| 	} | 	} | ||||||
|      |      | ||||||
| 	public static OwnCloudCredentials newSamlSsoCredentials(String sessionCookie) { | 	public static OwnCloudCredentials newSamlSsoCredentials(String username, String sessionCookie) { | ||||||
| 		return new OwnCloudSamlSsoCredentials(sessionCookie); | 		return new OwnCloudSamlSsoCredentials(username, sessionCookie); | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	public static final OwnCloudCredentials getAnonymousCredentials() { | 	public static final OwnCloudCredentials getAnonymousCredentials() { | ||||||
|  | |||||||
| @ -30,9 +30,11 @@ import android.net.Uri; | |||||||
| 
 | 
 | ||||||
| public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials { | public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials { | ||||||
| 
 | 
 | ||||||
|  | 	private String mUsername; | ||||||
| 	private String mSessionCookie; | 	private String mSessionCookie; | ||||||
| 
 | 
 | ||||||
| 	public OwnCloudSamlSsoCredentials(String sessionCookie) { | 	public OwnCloudSamlSsoCredentials(String username, String sessionCookie) { | ||||||
|  | 		mUsername = username != null ? username : ""; | ||||||
| 		mSessionCookie = sessionCookie != null ? sessionCookie : ""; | 		mSessionCookie = sessionCookie != null ? sessionCookie : ""; | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| @ -63,8 +65,8 @@ public class OwnCloudSamlSsoCredentials implements OwnCloudCredentials { | |||||||
| 
 | 
 | ||||||
| 	@Override | 	@Override | ||||||
| 	public String getUsername() { | 	public String getUsername() { | ||||||
| 		// its unknown | 		// not relevant for authentication, but relevant for informational purposes | ||||||
| 		return null; | 		return mUsername; | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
| 	@Override | 	@Override | ||||||
|  | |||||||
| @ -167,7 +167,9 @@ public class AccountUtils { | |||||||
|         boolean isSamlSso = am.getUserData( |         boolean isSamlSso = am.getUserData( | ||||||
|         		account,  |         		account,  | ||||||
|         		AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; |         		AccountUtils.Constants.KEY_SUPPORTS_SAML_WEB_SSO) != null; | ||||||
|          | 
 | ||||||
|  |         String username = account.name.substring(0, account.name.lastIndexOf('@')); | ||||||
|  | 
 | ||||||
|         if (isOauth2) {     |         if (isOauth2) {     | ||||||
|             String accessToken = am.blockingGetAuthToken( |             String accessToken = am.blockingGetAuthToken( | ||||||
|             		account,  |             		account,  | ||||||
| @ -182,10 +184,9 @@ public class AccountUtils { | |||||||
|             		AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type),  |             		AccountTypeUtils.getAuthTokenTypeSamlSessionCookie(account.type),  | ||||||
|             		false); |             		false); | ||||||
|              |              | ||||||
|             credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(accessToken); |             credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials(username, accessToken); | ||||||
| 
 | 
 | ||||||
|         } else { |         } else { | ||||||
|             String username = account.name.substring(0, account.name.lastIndexOf('@')); |  | ||||||
|             String password = am.blockingGetAuthToken( |             String password = am.blockingGetAuthToken( | ||||||
|             		account,  |             		account,  | ||||||
|             		AccountTypeUtils.getAuthTokenTypePass(account.type),  |             		AccountTypeUtils.getAuthTokenTypePass(account.type),  | ||||||
|  | |||||||
| @ -12,7 +12,7 @@ dependencies { | |||||||
| 
 | 
 | ||||||
| android { | android { | ||||||
|     compileSdkVersion 19 |     compileSdkVersion 19 | ||||||
|     buildToolsVersion "20.0.0" |     buildToolsVersion "22.0.1" | ||||||
| 
 | 
 | ||||||
|     sourceSets { |     sourceSets { | ||||||
|         main { |         main { | ||||||
|  | |||||||
| @ -135,7 +135,7 @@ public class OwnCloudClientTest extends AndroidTestCase { | |||||||
| 		client.setCredentials(credentials); | 		client.setCredentials(credentials); | ||||||
| 		assertEquals("Bearer credentials not set", credentials, client.getCredentials()); | 		assertEquals("Bearer credentials not set", credentials, client.getCredentials()); | ||||||
| 
 | 
 | ||||||
| 		credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials("samlSessionCookie=124"); | 		credentials = OwnCloudCredentialsFactory.newSamlSsoCredentials("user", "samlSessionCookie=124"); | ||||||
| 		client.setCredentials(credentials); | 		client.setCredentials(credentials); | ||||||
| 		assertEquals("SAML2 session credentials not set", credentials, client.getCredentials()); | 		assertEquals("SAML2 session credentials not set", credentials, client.getCredentials()); | ||||||
| 		 | 		 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user