diff options
author | Tobias Brunner <tobias@strongswan.org> | 2012-08-08 12:59:39 +0200 |
---|---|---|
committer | Tobias Brunner <tobias@strongswan.org> | 2012-08-13 11:00:28 +0200 |
commit | 3aa5c609c39f7a6418f9bbf67d46293a77e023fe (patch) | |
tree | 2b0563ece4cf280f638c3c6d611d178a17e4c4a4 | |
parent | 8430e54d83e71b8cc806e12274905b6d0ea10f0c (diff) | |
download | strongswan-3aa5c609c39f7a6418f9bbf67d46293a77e023fe.tar.bz2 strongswan-3aa5c609c39f7a6418f9bbf67d46293a77e023fe.tar.xz |
Android specific credential set also provides user credentials
-rw-r--r-- | src/frontends/android/jni/libandroidbridge/backend/android_creds.c | 27 | ||||
-rw-r--r-- | src/frontends/android/jni/libandroidbridge/backend/android_creds.h | 14 |
2 files changed, 37 insertions, 4 deletions
diff --git a/src/frontends/android/jni/libandroidbridge/backend/android_creds.c b/src/frontends/android/jni/libandroidbridge/backend/android_creds.c index ee9549d9c..27023d721 100644 --- a/src/frontends/android/jni/libandroidbridge/backend/android_creds.c +++ b/src/frontends/android/jni/libandroidbridge/backend/android_creds.c @@ -34,7 +34,7 @@ struct private_android_creds_t { android_creds_t public; /** - * Credential set storing trusted certificates + * Credential set storing trusted certificates and user credentials */ mem_cred_t *creds; @@ -108,6 +108,28 @@ METHOD(credential_set_t, create_cert_enumerator, enumerator_t*, this->lock); } +METHOD(android_creds_t, add_username_password, void, + private_android_creds_t *this, char *username, char *password) +{ + shared_key_t *shared_key; + identification_t *id; + chunk_t secret; + + secret = chunk_create(password, strlen(password)); + shared_key = shared_key_create(SHARED_EAP, chunk_clone(secret)); + id = identification_create_from_string(username); + + this->creds->add_shared(this->creds, shared_key, id, NULL); +} + +METHOD(credential_set_t, create_shared_enumerator, enumerator_t*, + private_android_creds_t *this, shared_key_type_t type, + identification_t *me, identification_t *other) +{ + return this->creds->set.create_shared_enumerator(&this->creds->set, + type, me, other); +} + METHOD(android_creds_t, clear, void, private_android_creds_t *this) { @@ -137,11 +159,12 @@ android_creds_t *android_creds_create() .public = { .set = { .create_cert_enumerator = _create_cert_enumerator, - .create_shared_enumerator = (void*)return_null, + .create_shared_enumerator = _create_shared_enumerator, .create_private_enumerator = (void*)return_null, .create_cdp_enumerator = (void*)return_null, .cache_cert = (void*)nop, }, + .add_username_password = _add_username_password, .clear = _clear, .destroy = _destroy, }, diff --git a/src/frontends/android/jni/libandroidbridge/backend/android_creds.h b/src/frontends/android/jni/libandroidbridge/backend/android_creds.h index 4b19b1bf5..33de838c1 100644 --- a/src/frontends/android/jni/libandroidbridge/backend/android_creds.h +++ b/src/frontends/android/jni/libandroidbridge/backend/android_creds.h @@ -27,7 +27,8 @@ typedef struct android_creds_t android_creds_t; /** - * Android credential set that provides CA certificates via JNI. + * Android credential set that provides CA certificates via JNI and supplied + * user credentials. */ struct android_creds_t { @@ -37,7 +38,16 @@ struct android_creds_t { credential_set_t set; /** - * Clear the cached CA certificates. + * Add user name and password for EAP authentication + * + * @param username user name + * @param password password + */ + void (*add_username_password)(android_creds_t *this, char *username, + char *password); + + /** + * Clear the cached certificates and stored credentials. */ void (*clear)(android_creds_t *this); |