Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* setup UI: login with URL and client certificate * account settings UI: show either username/password or client certificate alias * AccountSettings: serve credentials in generalized Credentials objects * HttpClient: use Credentials (instead of username/password) for authentication * HttpClient: always use CustomTlsSocketFactory * CustomTlsSocketFactory: support client certificates
- Loading branch information
Showing
18 changed files
with
390 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
app/src/main/java/at/bitfire/davdroid/model/Credentials.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright © Ricki Hirner (bitfire web engineering). | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the GNU Public License v3.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.gnu.org/licenses/gpl.html | ||
*/ | ||
|
||
package at.bitfire.davdroid.model | ||
|
||
import java.io.Serializable | ||
|
||
class Credentials @JvmOverloads constructor( | ||
@JvmField val userName: String? = null, | ||
@JvmField val password: String? = null, | ||
@JvmField val certificateAlias: String? = null | ||
): Serializable { | ||
|
||
enum class Type { | ||
UsernamePassword, | ||
ClientCertificate | ||
} | ||
|
||
val type: Type | ||
|
||
init { | ||
type = when { | ||
!certificateAlias.isNullOrEmpty() -> | ||
Type.ClientCertificate | ||
!userName.isNullOrEmpty() && !password.isNullOrEmpty() -> | ||
Type.UsernamePassword | ||
else -> | ||
throw IllegalArgumentException("Either username/password or certificate alias must be set") | ||
} | ||
} | ||
|
||
override fun toString(): String { | ||
return "Credentials(type=$type, userName=$userName, certificateAlias=$certificateAlias)" | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.