summaryrefslogtreecommitdiff
path: root/plugin/plugin.c
diff options
context:
space:
mode:
authorSamuel Lidén Borell <samuel@slbdata.se>2009-06-09 17:56:11 +0200
committerSamuel Lidén Borell <samuel@slbdata.se>2010-01-02 21:48:08 +0100
commit74489a59dd0fc0d519f7c19b8598f65696a05147 (patch)
treeb2b01afe5ec7a3db55c8e303233ade8c759e5232 /plugin/plugin.c
parent8379b263db4a77324c2132f38718e8fd597db967 (diff)
downloadfribid-74489a59dd0fc0d519f7c19b8598f65696a05147.tar.gz
fribid-74489a59dd0fc0d519f7c19b8598f65696a05147.tar.bz2
fribid-74489a59dd0fc0d519f7c19b8598f65696a05147.zip
Implemented signing
Diffstat (limited to 'plugin/plugin.c')
-rw-r--r--plugin/plugin.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/plugin/plugin.c b/plugin/plugin.c
index 716ebc5..c062c5e 100644
--- a/plugin/plugin.c
+++ b/plugin/plugin.c
@@ -24,6 +24,13 @@ void plugin_free(Plugin *plugin) {
free(plugin->info.auth.policys);
free(plugin->info.auth.signature);
break;
+ case PT_Signer:
+ free(plugin->info.sign.challenge);
+ free(plugin->info.sign.policys);
+ free(plugin->info.sign.subjectFilter);
+ free(plugin->info.sign.message);
+ free(plugin->info.sign.signature);
+ break;
}
free(plugin->url);
free(plugin->hostname);
@@ -32,14 +39,28 @@ void plugin_free(Plugin *plugin) {
}
-static char **getParamPointer(Plugin *plugin, const char *name) {
- if (!strcmp(name, "Challenge")) return &plugin->info.auth.challenge;
+static char **getCommonParamPointer(Plugin *plugin, const char *name) {
if (!strcmp(name, "Policys")) return &plugin->info.auth.policys;
if (!strcmp(name, "Signature")) return &plugin->info.auth.signature;
return NULL;
}
-char *auth_getParam(Plugin *plugin, const char *name) {
+static char **getParamPointer(Plugin *plugin, const char *name) {
+ switch (plugin->type) {
+ case PT_Authentication:
+ if (!strcmp(name, "Challenge")) return &plugin->info.auth.challenge;
+ return getCommonParamPointer(plugin, name);
+ case PT_Signer:
+ if (!strcmp(name, "Nonce")) return &plugin->info.sign.challenge;
+ if (!strcmp(name, "Subjects")) return &plugin->info.sign.subjectFilter;
+ if (!strcmp(name, "TextToBeSigned")) return &plugin->info.sign.message;
+ return getCommonParamPointer(plugin, name);
+ default:
+ return NULL;
+ }
+}
+
+char *sign_getParam(Plugin *plugin, const char *name) {
char **valuePtr = getParamPointer(plugin, name);
char *value = NULL;
@@ -48,7 +69,7 @@ char *auth_getParam(Plugin *plugin, const char *name) {
return (value != NULL ? value : strdup(""));
}
-bool auth_setParam(Plugin *plugin, const char *name, const char *value) {
+bool sign_setParam(Plugin *plugin, const char *name, const char *value) {
char **valuePtr = getParamPointer(plugin, name);
if (valuePtr == NULL) return false;
@@ -58,15 +79,17 @@ bool auth_setParam(Plugin *plugin, const char *name, const char *value) {
return true;
}
-int auth_performAction(Plugin *plugin, const char *action) {
- if (!strcmp(action, "Authenticate")) {
- return auth_performAction_Authenticate(plugin);
+int sign_performAction(Plugin *plugin, const char *action) {
+ if ((plugin->type == PT_Authentication) && !strcmp(action, "Authenticate")) {
+ return sign_performAction_Authenticate(plugin);
+ } else if ((plugin->type == PT_Signer) && !strcmp(action, "Sign")) {
+ return sign_performAction_Sign(plugin);
} else {
return 1;
}
}
-int auth_getLastError(Plugin *plugin) {
+int sign_getLastError(Plugin *plugin) {
return plugin->lastError;
}