You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ka...@apache.org on 2007/02/16 12:43:06 UTC
svn commit: r508373 - in /webservices/axis2/trunk/c/rampart:
include/oxs_token_x509_certificate.h src/omxmlsec/tokens/Makefile.am
src/omxmlsec/tokens/token_x509_certificate.c src/omxmlsec/xml_signature.c
test/omxmlsec/test.c
Author: kaushalye
Date: Fri Feb 16 03:43:05 2007
New Revision: 508373
URL: http://svn.apache.org/viewvc?view=rev&rev=508373
Log:
1. Adding token <ds:X509Certificate> to OMXMLSecurity
2. Building KeyInfo element while signing.
Added:
webservices/axis2/trunk/c/rampart/include/oxs_token_x509_certificate.h
webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_certificate.c
Modified:
webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am
webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c
Added: webservices/axis2/trunk/c/rampart/include/oxs_token_x509_certificate.h
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/include/oxs_token_x509_certificate.h?view=auto&rev=508373
==============================================================================
--- webservices/axis2/trunk/c/rampart/include/oxs_token_x509_certificate.h (added)
+++ webservices/axis2/trunk/c/rampart/include/oxs_token_x509_certificate.h Fri Feb 16 03:43:05 2007
@@ -0,0 +1,58 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef OXS_TOKEN_X509_CERTIFICATE_H
+#define OXS_TOKEN_X509_CERTIFICATE_H
+
+
+/**
+ * @file oxs_token_x509_certificate.h
+ * @brief
+ */
+
+#include <axis2_defines.h>
+#include <axis2_env.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <axis2_qname.h>
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+/**
+* ds:X509Certificate element
+*/
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_token_get_x509_certificate(const axis2_env_t *env,
+ axiom_node_t *sv_node);
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_x509_certificate_element(const axis2_env_t *env,
+ axiom_node_t *parent,
+ axis2_char_t* cert_data
+ );
+
+
+
+/** @} */
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* OXS_TOKEN_X509_CERTIFICATE_H */
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am?view=diff&rev=508373&r1=508372&r2=508373
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/Makefile.am Fri Feb 16 03:43:05 2007
@@ -7,7 +7,8 @@
token_x509_issuer_name.c token_x509_serial_number.c token_security_token_reference.c \
token_embedded.c token_reference.c token_signature_value.c token_signed_info.c \
token_c14n_method.c token_signature_method.c token_digest_method.c token_digest_value.c \
- token_transform.c token_transforms.c token_signature.c token_ds_reference.c
+ token_transform.c token_transforms.c token_signature.c token_ds_reference.c \
+ token_x509_certificate.c
liboxstokens_la_LIBADD =../../../../util/src/libaxis2_util.la \
../../../../axiom/src/om/libaxis2_axiom.la
Added: webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_certificate.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_certificate.c?view=auto&rev=508373
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_certificate.c (added)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/tokens/token_x509_certificate.c Fri Feb 16 03:43:05 2007
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <oxs_constants.h>
+#include <oxs_error.h>
+#include <oxs_token_x509_certificate.h>
+#include <axiom_element.h>
+#include <oxs_axiom.h>
+
+
+AXIS2_EXTERN axis2_char_t* AXIS2_CALL
+oxs_token_get_x509_certificate(const axis2_env_t *env,
+ axiom_node_t *sv_node)
+{
+ axis2_char_t *sv = NULL;
+ /*TODO Verification*/
+ sv = (axis2_char_t*)oxs_axiom_get_node_content(env, sv_node);
+ return sv;
+
+}
+
+AXIS2_EXTERN axiom_node_t* AXIS2_CALL
+oxs_token_build_x509_certificate_element(const axis2_env_t *env,
+ axiom_node_t *parent,
+ axis2_char_t* cert_data)
+{
+ axiom_node_t *x509_certificate_node = NULL;
+ axiom_element_t *x509_certificate_ele = NULL;
+ axis2_status_t ret;
+ axiom_namespace_t *ns_obj = NULL;
+
+ ns_obj = axiom_namespace_create(env, OXS_DSIG_NS,
+ OXS_DS);
+
+ x509_certificate_ele = axiom_element_create(env, parent, OXS_NODE_X509_CERTIFICATE, ns_obj, &x509_certificate_node);
+ if (!x509_certificate_ele)
+ {
+ oxs_error(env, ERROR_LOCATION,
+ OXS_ERROR_ELEMENT_FAILED, "Error creating %s element", OXS_NODE_X509_CERTIFICATE);
+ return NULL;
+ }
+
+ if (cert_data)
+ {
+ ret = AXIOM_ELEMENT_SET_TEXT(x509_certificate_ele, env, cert_data, x509_certificate_node);
+ }
+
+ return x509_certificate_node;
+
+}
+
Modified: webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c?view=diff&rev=508373&r1=508372&r2=508373
==============================================================================
--- webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c (original)
+++ webservices/axis2/trunk/c/rampart/src/omxmlsec/xml_signature.c Fri Feb 16 03:43:05 2007
@@ -38,8 +38,43 @@
#include <oxs_token_signature_method.h>
#include <oxs_token_signature_value.h>
#include <oxs_token_signed_info.h>
+#include <oxs_token_x509_certificate.h>
+#include <oxs_token_x509_data.h>
+#include <oxs_token_key_info.h>
/*Private functions*/
+/*parent is ds:Signature*/
+static axis2_status_t
+oxs_xml_sig_build_key_info(const axis2_env_t *env,
+ axiom_node_t *parent,
+ oxs_sign_ctx_t *sign_ctx)
+{
+ axiom_node_t *key_info_node = NULL;
+ axiom_node_t *x509_data_node = NULL;
+ axiom_node_t *x509_certificate_node = NULL;
+ axis2_char_t *cert_data = NULL;
+ oxs_x509_cert_t *cert = NULL;
+
+ /*Build the KeyInfo node*/
+ key_info_node = oxs_token_build_key_info_element(env, parent);
+
+ /*TODO: Right now we support only X509Data. But should support other patterns as well*/
+ cert = oxs_sign_ctx_get_certificate(sign_ctx, env);
+ if(!cert){
+ return AXIS2_FAILURE;
+ }
+
+ /*Get certificate data*/
+ cert_data = oxs_x509_cert_get_data(cert, env);
+
+ /*Build the X509Data node*/
+ x509_data_node = oxs_token_build_x509_data_element(env, key_info_node);
+
+ /*Now build the X509Certificate node*/
+ x509_certificate_node = oxs_token_build_x509_certificate_element(env, x509_data_node, cert_data);
+
+ return AXIS2_SUCCESS;
+}
/*parent is ds:SignedInfo*/
static axis2_status_t
@@ -179,7 +214,9 @@
/*At this point we have a complete <SignedInfo> node. Now we need to sign it*/
oxs_xml_sig_sign_signed_info(env, signature_node, signed_info_node, sign_ctx);
-
+ /*Now we need to build the KeyInfo node*/
+ oxs_xml_sig_build_key_info(env, signature_node, sign_ctx);
+
return AXIS2_SUCCESS;
}
Modified: webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c?view=diff&rev=508373&r1=508372&r2=508373
==============================================================================
--- webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c (original)
+++ webservices/axis2/trunk/c/rampart/test/omxmlsec/test.c Fri Feb 16 03:43:05 2007
@@ -113,6 +113,9 @@
printf("Cannot load private key");
}
oxs_sign_ctx_set_private_key(sign_ctx, env, prvkey);
+
+ /*TODO : Set x509 certificate. This is required to set the Key Information in ds:KeyInfo*/
+
/*Set sig algo*/
oxs_sign_ctx_set_sign_mtd_algo(sign_ctx, env, OXS_HREF_RSA_SHA1);
/*Set C14N method*/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org