Annotation of embedaddon/strongswan/src/libstrongswan/plugins/keychain/keychain_plugin.c, revision 1.1
1.1 ! misho 1: /*
! 2: * Copyright (C) 2013 Martin Willi
! 3: * Copyright (C) 2013 revosec AG
! 4: *
! 5: * This program is free software; you can redistribute it and/or modify it
! 6: * under the terms of the GNU General Public License as published by the
! 7: * Free Software Foundation; either version 2 of the License, or (at your
! 8: * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
! 9: *
! 10: * This program is distributed in the hope that it will be useful, but
! 11: * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
! 12: * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
! 13: * for more details.
! 14: */
! 15:
! 16: #include "keychain_plugin.h"
! 17: #include "keychain_creds.h"
! 18:
! 19: #include <library.h>
! 20:
! 21: typedef struct private_keychain_plugin_t private_keychain_plugin_t;
! 22:
! 23: /**
! 24: * private data of keychain_plugin
! 25: */
! 26: struct private_keychain_plugin_t {
! 27:
! 28: /**
! 29: * public functions
! 30: */
! 31: keychain_plugin_t public;
! 32:
! 33: /**
! 34: * System level Keychain Services credential set
! 35: */
! 36: keychain_creds_t *creds;
! 37: };
! 38:
! 39: METHOD(plugin_t, get_name, char*,
! 40: private_keychain_plugin_t *this)
! 41: {
! 42: return "keychain";
! 43: }
! 44:
! 45: /**
! 46: * Load/unload certificates from Keychain.
! 47: */
! 48: static bool load_creds(private_keychain_plugin_t *this,
! 49: plugin_feature_t *feature, bool reg, void *data)
! 50: {
! 51: if (reg)
! 52: {
! 53: this->creds = keychain_creds_create();
! 54: }
! 55: else
! 56: {
! 57: this->creds->destroy(this->creds);
! 58: }
! 59: return TRUE;
! 60: }
! 61:
! 62: METHOD(plugin_t, get_features, int,
! 63: private_keychain_plugin_t *this, plugin_feature_t *features[])
! 64: {
! 65: static plugin_feature_t f[] = {
! 66: PLUGIN_CALLBACK((plugin_feature_callback_t)load_creds, NULL),
! 67: PLUGIN_PROVIDE(CUSTOM, "keychain"),
! 68: PLUGIN_DEPENDS(CERT_DECODE, CERT_X509),
! 69: };
! 70: *features = f;
! 71: return countof(f);
! 72: }
! 73:
! 74: METHOD(plugin_t, destroy, void,
! 75: private_keychain_plugin_t *this)
! 76: {
! 77: free(this);
! 78: }
! 79:
! 80: /*
! 81: * see header file
! 82: */
! 83: plugin_t *keychain_plugin_create()
! 84: {
! 85: private_keychain_plugin_t *this;
! 86:
! 87: INIT(this,
! 88: .public = {
! 89: .plugin = {
! 90: .get_name = _get_name,
! 91: .get_features = _get_features,
! 92: .destroy = _destroy,
! 93: },
! 94: },
! 95: );
! 96:
! 97: return &this->public.plugin;
! 98: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>