Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
Accept but ignore OnlyAcceptMRU parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
samuellb committed Oct 11, 2012
1 parent 3df8588 commit 1a7053b
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions common/biderror.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ typedef enum {
BIDERR_UserCancel = 8002,
BIDERR_InvalidParameter = 8004,
BIDERR_InvalidAction = 8008,
BIDERR_InvalidBoolean = 8012,
BIDERR_InvalidPIN = 8013,
BIDERR_InvalidValue = 8014,
BIDERR_NotSSL = 8015,
Expand Down
23 changes: 22 additions & 1 deletion plugin/plugin.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (c) 2009-2011 Samuel Lidén Borell <samuel@kodafritt.se>
Copyright (c) 2009-2012 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -183,6 +183,11 @@ char *sign_getParam(Plugin *plugin, const char *name) {
return s;
}

// OnlyAcceptMRU (show only last used cert in list)
if (authOrSign && !g_ascii_strcasecmp(name, "OnlyAcceptMRU")) {
return strdup(plugin->info.auth.onlyAcceptMRU ? "true" : "false");
}

// Handle string parameters
char **valuePtr = getParamPointer(plugin, name);

Expand Down Expand Up @@ -223,6 +228,22 @@ bool sign_setParam(Plugin *plugin, const char *name, const char *value) {
return true;
}

// OnlyAcceptMRU: boolean value
if (authOrSign && !g_ascii_strcasecmp(name, "OnlyAcceptMRU")) {
plugin->lastError = BIDERR_OK;

if (!g_ascii_strcasecmp(value, "true")) {
plugin->info.auth.onlyAcceptMRU = true;
return true;
} else if (!g_ascii_strcasecmp(value, "false")) {
plugin->info.auth.onlyAcceptMRU = false;
return true;
}

plugin->lastError = BIDERR_InvalidBoolean;
return false;
}

// TextCharacterEncoding: Only the values "UTF-8" and "ISO-88591-1"
// are allowed (case-sensitive). This value is NOT escaped in the XML
// signature.
Expand Down
4 changes: 3 additions & 1 deletion plugin/plugin.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
Copyright (c) 2009-2011 Samuel Lidén Borell <samuel@kodafritt.se>
Copyright (c) 2009-2012 Samuel Lidén Borell <samuel@kodafritt.se>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down Expand Up @@ -55,6 +55,7 @@ typedef struct {
int32_t serverTime;
char *policys;
char *subjectFilter;
bool onlyAcceptMRU;
void *dummy0, *dummy1; // To be compatible with .sign below
/* Output parameters */
char *signature;
Expand All @@ -65,6 +66,7 @@ typedef struct {
int32_t serverTime;
char *policys;
char *subjectFilter;
bool onlyAcceptMRU;
char *messageEncoding;
char *message;
char *invisibleMessage;
Expand Down
11 changes: 11 additions & 0 deletions tests/test-authsig.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,17 @@
setPar("NonVisibleData", nonVisibleText);
setPar("ServerTime", "1290536889");
setPar("Policys", "MS4yLjc1Mi43OC4xLjE7MS4yLjc1Mi43OC4xLjI7MS4yLjMuNC41OzEuMi4zLjQuMTA=");
setPar("OnlyAcceptMRU", "true");
setPar("OnlyAcceptMRU", "True");
setPar("OnlyAcceptMRU", "TRUE");
/* setPar("OnlyAcceptMRU", "true ");
setPar("OnlyAcceptMRU", " TrUe ");
setPar("OnlyAcceptMRU", "1");
setPar("OnlyAcceptMRU", "2");
setPar("OnlyAcceptMRU", "-1");
setPar("OnlyAcceptMRU", " 1 ");
setPar("OnlyAcceptMRU", "true");*/
setPar("OnlyAcceptMRU", "false");

output.value += "\n";
var params = [
Expand Down

0 comments on commit 1a7053b

Please sign in to comment.