|
From: <cs...@us...> - 2008-09-11 21:29:44
|
Revision: 52
http://bespp.svn.sourceforge.net/bespp/?rev=52&view=rev
Author: csmith
Date: 2008-09-11 21:29:53 +0000 (Thu, 11 Sep 2008)
Log Message:
-----------
- process headers in separate function
- added created/expired timestamps to WS-Security header on reply
- GetFactoryAttributesDocument now returns list of ContainedResources
Modified Paths:
--------------
trunk/besclient/libbes.c
trunk/besserver/auth.c
trunk/besserver/auth.h
trunk/besserver/besserver-typemap.dat
trunk/besserver/besserver.c
Modified: trunk/besclient/libbes.c
===================================================================
--- trunk/besclient/libbes.c 2008-05-19 15:33:33 UTC (rev 51)
+++ trunk/besclient/libbes.c 2008-09-11 21:29:53 UTC (rev 52)
@@ -47,6 +47,7 @@
struct Namespace default_namespaces[] =
{
{"SOAP-ENV", "http://schemas.xmlsoap.org/soap/envelope/", "http://www.w3.org/*/soap-envelope", NULL},
+ {"wsu", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", NULL, NULL},
{"wsse", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", NULL, NULL},
{"wsa", "http://www.w3.org/2005/08/addressing", NULL, NULL},
{"bes", "http://schemas.ggf.org/bes/2006/08/bes-factory", NULL, NULL},
@@ -145,25 +146,34 @@
setErrorString(context, context->soap, BESE_SOAP_ERR);
return BESE_SOAP_ERR;
}
+ if (soap_wsse_add_Timestamp(soap, NULL, 60)) {
+ setErrorString(context, context->soap, BESE_SOAP_ERR);
+ return BESE_SOAP_ERR;
+ }
}
if (x509cert) {
+ if (context->x509cert) free(context->x509cert);
context->x509cert = strdup(x509cert);
}
if (x509pass) {
+ if (context->x509pass) free(context->x509pass);
context->x509pass = strdup(x509pass);
}
if (capath) {
+ if (context->capath) free(context->capath);
context->capath = strdup(capath);
}
if (user) {
+ if (context->user) free(context->user);
context->user = strdup(user);
}
if (pass) {
+ if (context->pass) free(context->pass);
context->pass = strdup(pass);
}
@@ -183,6 +193,10 @@
setErrorString(context, context->soap, BESE_SOAP_ERR);
return BESE_SOAP_ERR;
}
+ if (soap_wsse_add_Timestamp(context->soap, NULL, 60)) {
+ setErrorString(context, context->soap, BESE_SOAP_ERR);
+ return BESE_SOAP_ERR;
+ }
return BESE_OK;
}
Modified: trunk/besserver/auth.c
===================================================================
--- trunk/besserver/auth.c 2008-05-19 15:33:33 UTC (rev 51)
+++ trunk/besserver/auth.c 2008-09-11 21:29:53 UTC (rev 52)
@@ -104,7 +104,7 @@
}
int
-authenticate(struct soap *s, char *username, int namelen)
+authenticate(struct soap *s, char *username, int namelen, int *sslauth)
{
static char fname[] = "authenticate";
struct _wsse__UsernameToken *token;
@@ -117,6 +117,7 @@
clientcert = SSL_get_peer_certificate(s->ssl);
if (clientcert) {
+ if (sslauth) *sslauth = 1;
if (SSL_get_verify_result(s->ssl) != X509_V_OK) {
return soap_wsse_fault(s, wsse__FailedAuthentication, NULL);
}
@@ -135,7 +136,8 @@
return SOAP_OK;
}
-
+ if (sslauth) *sslauth = 0;
+
/* no X.509 certificate ... look for WS-Security tokens */
token = soap_wsse_UsernameToken(s, NULL);
if (token) {
Modified: trunk/besserver/auth.h
===================================================================
--- trunk/besserver/auth.h 2008-05-19 15:33:33 UTC (rev 51)
+++ trunk/besserver/auth.h 2008-09-11 21:29:53 UTC (rev 52)
@@ -34,6 +34,6 @@
char *password;
};
-int authenticate(struct soap*, char *, int);
+int authenticate(struct soap*, char *, int, int*);
#endif /*AUTH_H_*/
Modified: trunk/besserver/besserver-typemap.dat
===================================================================
--- trunk/besserver/besserver-typemap.dat 2008-05-19 15:33:33 UTC (rev 51)
+++ trunk/besserver/besserver-typemap.dat 2008-09-11 21:29:53 UTC (rev 52)
@@ -76,7 +76,7 @@
SOAP_ENV__Header =\
struct SOAP_ENV__Header\n\
{\n\
- mustUnderstand _wsse__Security *wsse__Security 0;\n\
+ _wsse__Security *wsse__Security 0;\n\
_wsa__MessageID wsa__MessageID 0;\n\
_wsa__RelatesTo *wsa__RelatesTo 0;\n\
_wsa__From *wsa__From 0;\n\
Modified: trunk/besserver/besserver.c
===================================================================
--- trunk/besserver/besserver.c 2008-05-19 15:33:33 UTC (rev 51)
+++ trunk/besserver/besserver.c 2008-09-11 21:29:53 UTC (rev 52)
@@ -59,6 +59,7 @@
int isRemoteApplication(struct jobcard*);
int getRemoteEPR(struct soap*, int, struct soap_dom_element**);
int getContainedResources(struct soap*, struct bes__FactoryResourceAttributesDocumentType*, int);
+int processHeaders(struct soap*, char*, int);
char *service_endpoint = NULL;
@@ -271,13 +272,10 @@
fprintf(stderr, "In %s...\n", fname);
- if ((rc = authenticate(s, username, USERNAMELEN))) {
- clear_header(s);
+ if ((rc = processHeaders(s, username, USERNAMELEN))) {
return rc;
}
- clear_header(s);
-
jc = (struct jobcard*)soap_malloc(s, sizeof(struct jobcard));
if (jc == NULL) {
return soap_receiver_fault(s, MEM_ALLOC, NULL);
@@ -340,12 +338,10 @@
fprintf(stderr, "In %s...\n", fname);
- if ((rc = authenticate(s, username, USERNAMELEN))) {
+ if ((rc = processHeaders(s, username, USERNAMELEN))) {
return rc;
}
- clear_header(s);
-
if (req->__sizeActivityIdentifier == 0) {
resp->__sizeResponse = 0;
resp->Response = NULL;
@@ -420,12 +416,10 @@
fprintf(stderr, "In %s...\n", fname);
- if ((rc = authenticate(s, username, USERNAMELEN))) {
+ if ((rc = processHeaders(s, username, USERNAMELEN))) {
return rc;
}
- clear_header(s);
-
if (req->__sizeActivityIdentifier == 0) {
resp->__sizeResponse = 0;
resp->Response = NULL;
@@ -524,12 +518,10 @@
fprintf(stderr, "In %s...\n", fname);
- if ((rc = authenticate(s, username, USERNAMELEN))) {
+ if ((rc = processHeaders(s, username, USERNAMELEN))) {
return rc;
}
- clear_header(s);
-
if (req->__sizeActivityIdentifier == 0) {
resp->__sizeResponse = 0;
resp->Response = NULL;
@@ -608,7 +600,7 @@
{
static char fname[] = "__bes__GetFactoryAttributesDocument";
struct bes__FactoryResourceAttributesDocumentType *attrs;
- struct wsa_EndpointReferenceType *epr;
+ struct wsa_EndpointReferenceType *epr;
struct jobInfoEnt *jinfo;
char *clustername;
int num_jobs, i, rc;
@@ -616,12 +608,10 @@
fprintf(stderr, "In %s....\n", fname);
- if ((rc = authenticate(s, username, USERNAMELEN))) {
+ if ((rc = processHeaders(s, username, USERNAMELEN))) {
return rc;
}
- clear_header(s);
-
attrs = (struct bes__FactoryResourceAttributesDocumentType*)soap_malloc(s,
sizeof(struct bes__FactoryResourceAttributesDocumentType));
if (attrs == NULL) {
@@ -680,7 +670,7 @@
}
/* TotalNumberOfContainedResources and ContainedResource */
- if ((rc = getContainedResources(s, attrs, 0))) {
+ if ((rc = getContainedResources(s, attrs, 1))) {
if (rc == BESE_MEM_ALLOC) {
return soap_receiver_fault(s, MEM_ALLOC, NULL);
}
@@ -716,8 +706,6 @@
resp->bes__FactoryResourceAttributesDocument = attrs;
- clear_header(s);
-
return SOAP_OK;
}
@@ -853,6 +841,9 @@
memset(contained_resources, 0, sizeof(struct soap_dom_element)
*num_contained_resources);
for (j = 0, i = 0; i < numhosts; i++) {
+ if (hinfo[i].maxCpus == 0) {
+ continue;
+ }
resource = (struct bes__BasicResourceAttributesDocumentType*)soap_malloc(
s, sizeof(struct bes__BasicResourceAttributesDocumentType));
if (!resource) {
@@ -990,6 +981,21 @@
return SOAP_OK;
}
+int
+processHeaders(struct soap *s, char *username, int usernamelen)
+{
+ int rc = SOAP_OK;
+ int sslauth = 0;
+
+ rc = authenticate(s, username, usernamelen, &sslauth);
+ clear_header(s);
+ if (!sslauth) {
+ soap_wsse_add_Timestamp(s, NULL, 30);
+ }
+
+ return rc;
+}
+
/*
* Don't know why these aren't being generated, but ....
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|