diff options
Diffstat (limited to 'neethi/src/secpolicy/model')
27 files changed, 5961 insertions, 0 deletions
diff --git a/neethi/src/secpolicy/model/Makefile.am b/neethi/src/secpolicy/model/Makefile.am new file mode 100644 index 0000000..b24ddb7 --- /dev/null +++ b/neethi/src/secpolicy/model/Makefile.am @@ -0,0 +1,21 @@ +TESTS = + +noinst_LTLIBRARIES = librp_model.la + +librp_model_la_SOURCES = algorithmsuite.c asymmetric_binding.c \ + binding_commons.c header.c element.c https_token.c layout.c \ + property.c rampart_config.c secpolicy.c security_context_token.c \ + signed_encrypted_elements.c signed_encrypted_parts.c signed_encrypted_items.c \ + supporting_tokens.c symmetric_asymmetric_binding_commons.c \ + symmetric_binding.c transport_binding.c ut.c wss10.c wss11.c x509_token.c \ + trust10.c issued_token.c saml_token.c token.c + + +librp_model_la_LIBADD = ../../../../util/src/libaxutil.la + + +INCLUDES = -I$(top_builddir)/include \ + -I ../../../include \ + -I ../../../../util/include \ + -I ../../../../axiom/include \ + -I ../../../../include diff --git a/neethi/src/secpolicy/model/algorithmsuite.c b/neethi/src/secpolicy/model/algorithmsuite.c new file mode 100644 index 0000000..db3426c --- /dev/null +++ b/neethi/src/secpolicy/model/algorithmsuite.c @@ -0,0 +1,627 @@ +/* + * 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 <rp_algorithmsuite.h> + +struct rp_algorithmsuite_t +{ + axis2_char_t *algosuite_string; + axis2_char_t *symmetric_signature; + axis2_char_t *asymmetric_signature; + axis2_char_t *computed_key; + int max_symmetric_keylength; + int min_asymmetric_keylength; + int max_asymmetric_keylength; + axis2_char_t *digest; + axis2_char_t *encryption; + axis2_char_t *symmetrickeywrap; + axis2_char_t *asymmetrickeywrap; + axis2_char_t *encryption_key_derivation; + axis2_char_t *signature_key_derivation; + int encryption_key_derivation_keylength; + int signature_key_derivation_keylength; + int min_symmetric_keylength; + axis2_char_t *c14n; + axis2_char_t *soap_normalization; + axis2_char_t *str_transformation; + axis2_char_t *xpath; + int ref; + +}; + +AXIS2_EXTERN rp_algorithmsuite_t *AXIS2_CALL +rp_algorithmsuite_create( + const axutil_env_t *env) +{ + rp_algorithmsuite_t *algorithmsuite = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + algorithmsuite = (rp_algorithmsuite_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_algorithmsuite_t)); + + if(algorithmsuite == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); + return NULL; + } + algorithmsuite->algosuite_string = NULL; + algorithmsuite->symmetric_signature = RP_HMAC_SHA1; + algorithmsuite->asymmetric_signature = RP_RSA_SHA1; + algorithmsuite->computed_key = RP_P_SHA1; + algorithmsuite->max_symmetric_keylength = 256; + algorithmsuite->min_asymmetric_keylength = 1024; + algorithmsuite->max_asymmetric_keylength = 4096; + algorithmsuite->digest = NULL; + algorithmsuite->encryption = NULL; + algorithmsuite->symmetrickeywrap = NULL; + algorithmsuite->asymmetrickeywrap = NULL; + algorithmsuite->encryption_key_derivation = NULL; + algorithmsuite->signature_key_derivation = NULL; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + algorithmsuite->min_symmetric_keylength = 0; + ; + algorithmsuite->c14n = RP_EX_C14N; + algorithmsuite->soap_normalization = NULL; + algorithmsuite->str_transformation = NULL; + algorithmsuite->xpath = NULL; + algorithmsuite->ref = 0; + return algorithmsuite; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_algorithmsuite_free( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + if(algorithmsuite) + { + if(--(algorithmsuite->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, algorithmsuite); + algorithmsuite = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_algosuite_string( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + if(!algorithmsuite) + return NULL; + else + return algorithmsuite->algosuite_string; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_algosuite( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *algosuite_string) +{ + AXIS2_PARAM_CHECK(env->error, algosuite_string, AXIS2_FAILURE); + + algorithmsuite->algosuite_string = algosuite_string; + + if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC256) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_AES256; + algorithmsuite->symmetrickeywrap = RP_KW_AES256; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L256; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 256; + algorithmsuite->encryption_key_derivation_keylength = 256; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC192) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_AES192; + algorithmsuite->symmetrickeywrap = RP_KW_AES192; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC128) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_AES128; + algorithmsuite->symmetrickeywrap = RP_KW_AES128; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L128; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L128; + algorithmsuite->min_symmetric_keylength = 128; + algorithmsuite->encryption_key_derivation_keylength = 128; + algorithmsuite->signature_key_derivation_keylength = 128; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_TRIPLE_DES) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_TRIPLE_DES; + algorithmsuite->symmetrickeywrap = RP_KW_TRIPLE_DES; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC256_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_AES256; + algorithmsuite->symmetrickeywrap = RP_KW_AES256; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L256; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 256; + algorithmsuite->encryption_key_derivation_keylength = 256; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC192_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_AES192; + algorithmsuite->symmetrickeywrap = RP_KW_AES192; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC128_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_AES128; + algorithmsuite->symmetrickeywrap = RP_KW_AES128; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L128; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L128; + algorithmsuite->min_symmetric_keylength = 128; + algorithmsuite->encryption_key_derivation_keylength = 128; + algorithmsuite->signature_key_derivation_keylength = 128; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_TRIPLE_DES_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA1; + algorithmsuite->encryption = RP_TRIPLE_DES; + algorithmsuite->symmetrickeywrap = RP_KW_TRIPLE_DES; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC256_SHA256) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_AES256; + algorithmsuite->symmetrickeywrap = RP_KW_AES256; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L256; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 256; + algorithmsuite->encryption_key_derivation_keylength = 256; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC192_SHA256) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_AES192; + algorithmsuite->symmetrickeywrap = RP_KW_AES192; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC128_SHA256) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_AES128; + algorithmsuite->symmetrickeywrap = RP_KW_AES128; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L128; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L128; + algorithmsuite->min_symmetric_keylength = 128; + algorithmsuite->encryption_key_derivation_keylength = 128; + algorithmsuite->signature_key_derivation_keylength = 128; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_TRIPLE_DES_SHA256) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_TRIPLE_DES; + algorithmsuite->symmetrickeywrap = RP_KW_TRIPLE_DES; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA_OAEP; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC256_SHA256_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_AES256; + algorithmsuite->symmetrickeywrap = RP_KW_AES256; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L256; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 256; + algorithmsuite->encryption_key_derivation_keylength = 256; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC192_SHA256_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_AES192; + algorithmsuite->symmetrickeywrap = RP_KW_AES192; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_BASIC128_SHA256_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_AES128; + algorithmsuite->symmetrickeywrap = RP_KW_AES128; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L128; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L128; + algorithmsuite->min_symmetric_keylength = 128; + algorithmsuite->encryption_key_derivation_keylength = 128; + algorithmsuite->signature_key_derivation_keylength = 128; + + return AXIS2_SUCCESS; + } + else if(axutil_strcmp(algosuite_string, RP_ALGO_SUITE_TRIPLE_DES_SHA256_RSA15) == 0) + { + algorithmsuite->digest = RP_SHA256; + algorithmsuite->encryption = RP_TRIPLE_DES; + algorithmsuite->symmetrickeywrap = RP_KW_TRIPLE_DES; + algorithmsuite->asymmetrickeywrap = RP_KW_RSA15; + algorithmsuite->encryption_key_derivation = RP_P_SHA1_L192; + algorithmsuite->signature_key_derivation = RP_P_SHA1_L192; + algorithmsuite->min_symmetric_keylength = 192; + algorithmsuite->encryption_key_derivation_keylength = 192; + algorithmsuite->signature_key_derivation_keylength = 192; + + return AXIS2_SUCCESS; + } + else + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_symmetric_signature( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->symmetric_signature; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_symmetric_signature( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *symmetric_signature) +{ + AXIS2_PARAM_CHECK(env->error, symmetric_signature, AXIS2_FAILURE); + + algorithmsuite->symmetric_signature = symmetric_signature; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_asymmetric_signature( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->asymmetric_signature; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_asymmetric_signature( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *asymmetric_signature) +{ + AXIS2_PARAM_CHECK(env->error, asymmetric_signature, AXIS2_FAILURE); + + algorithmsuite->asymmetric_signature = asymmetric_signature; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_computed_key( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->computed_key; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_computed_key( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *computed_key) +{ + AXIS2_PARAM_CHECK(env->error, computed_key, AXIS2_FAILURE); + + algorithmsuite->computed_key = computed_key; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_digest( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->digest; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_encryption( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->encryption; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_algorithmsuite_get_max_symmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->max_symmetric_keylength; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_max_symmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + int max_symmetric_keylength) +{ + algorithmsuite->max_symmetric_keylength = max_symmetric_keylength; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_algorithmsuite_get_min_symmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->min_symmetric_keylength; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_algorithmsuite_get_encryption_derivation_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->encryption_key_derivation_keylength; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_algorithmsuite_get_signature_derivation_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->signature_key_derivation_keylength; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_algorithmsuite_get_max_asymmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->max_asymmetric_keylength; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_max_asymmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + int max_asymmetric_keylength) +{ + algorithmsuite->max_asymmetric_keylength = max_asymmetric_keylength; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_algorithmsuite_get_min_asymmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->min_asymmetric_keylength; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_min_asymmetric_keylength( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + int min_asymmetric_keylength) +{ + algorithmsuite->min_asymmetric_keylength = min_asymmetric_keylength; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_symmetrickeywrap( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->symmetrickeywrap; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_asymmetrickeywrap( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->asymmetrickeywrap; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_signature_key_derivation( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->signature_key_derivation; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_encryption_key_derivation( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->encryption_key_derivation; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_soap_normalization( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->soap_normalization; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_soap_normalization( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *soap_normalization) +{ + AXIS2_PARAM_CHECK(env->error, soap_normalization, AXIS2_FAILURE); + algorithmsuite->soap_normalization = soap_normalization; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_str_transformation( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->str_transformation; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_str_transformation( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *str_transformation) +{ + AXIS2_PARAM_CHECK(env->error, str_transformation, AXIS2_FAILURE); + algorithmsuite->str_transformation = str_transformation; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_c14n( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->c14n; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_c14n( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *c14n) +{ + AXIS2_PARAM_CHECK(env->error, c14n, AXIS2_FAILURE); + algorithmsuite->c14n = c14n; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_algorithmsuite_get_xpath( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + return algorithmsuite->xpath; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_set_xpath( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env, + axis2_char_t *xpath) +{ + AXIS2_PARAM_CHECK(env->error, xpath, AXIS2_FAILURE); + algorithmsuite->xpath = xpath; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_algorithmsuite_increment_ref( + rp_algorithmsuite_t *algorithmsuite, + const axutil_env_t *env) +{ + algorithmsuite->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/asymmetric_binding.c b/neethi/src/secpolicy/model/asymmetric_binding.c new file mode 100644 index 0000000..0e57dce --- /dev/null +++ b/neethi/src/secpolicy/model/asymmetric_binding.c @@ -0,0 +1,160 @@ +/* + * 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 <rp_asymmetric_binding.h> + +struct rp_asymmetric_binding_t +{ + rp_symmetric_asymmetric_binding_commons_t *symmetric_asymmetric_binding_commons; + rp_property_t *initiator_token; + rp_property_t *recipient_token; + int ref; +}; + +AXIS2_EXTERN rp_asymmetric_binding_t *AXIS2_CALL +rp_asymmetric_binding_create( + const axutil_env_t *env) +{ + rp_asymmetric_binding_t *asymmetric_binding = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + asymmetric_binding = (rp_asymmetric_binding_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_asymmetric_binding_t)); + + if(asymmetric_binding == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); + return NULL; + } + asymmetric_binding->symmetric_asymmetric_binding_commons = NULL; + asymmetric_binding->initiator_token = NULL; + asymmetric_binding->recipient_token = NULL; + asymmetric_binding->ref = 0; + + return asymmetric_binding; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_asymmetric_binding_free( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env) +{ + if(asymmetric_binding) + { + + if(--(asymmetric_binding->ref) > 0) + { + return; + } + + if(asymmetric_binding->symmetric_asymmetric_binding_commons) + { + rp_symmetric_asymmetric_binding_commons_free( + asymmetric_binding-> symmetric_asymmetric_binding_commons, env); + asymmetric_binding->symmetric_asymmetric_binding_commons = NULL; + } + if(asymmetric_binding->initiator_token) + { + rp_property_free(asymmetric_binding->initiator_token, env); + asymmetric_binding->initiator_token = NULL; + } + if(asymmetric_binding->recipient_token) + { + rp_property_free(asymmetric_binding->recipient_token, env); + asymmetric_binding->recipient_token = NULL; + } + AXIS2_FREE(env->allocator, asymmetric_binding); + } + + return; +} + +/* Implementations */ + +AXIS2_EXTERN rp_symmetric_asymmetric_binding_commons_t *AXIS2_CALL +rp_asymmetric_binding_get_symmetric_asymmetric_binding_commons( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env) +{ + return asymmetric_binding->symmetric_asymmetric_binding_commons; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_asymmetric_binding_set_symmetric_asymmetric_binding_commons( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env, + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons) +{ + AXIS2_PARAM_CHECK(env->error, symmetric_asymmetric_binding_commons, AXIS2_FAILURE); + + asymmetric_binding->symmetric_asymmetric_binding_commons = symmetric_asymmetric_binding_commons; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_asymmetric_binding_get_initiator_token( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env) +{ + return asymmetric_binding->initiator_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_asymmetric_binding_set_initiator_token( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env, + rp_property_t *initiator_token) +{ + AXIS2_PARAM_CHECK(env->error, initiator_token, AXIS2_FAILURE); + + rp_property_increment_ref(initiator_token, env); + asymmetric_binding->initiator_token = initiator_token; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_asymmetric_binding_set_recipient_token( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env, + rp_property_t *recipient_token) +{ + AXIS2_PARAM_CHECK(env->error, recipient_token, AXIS2_FAILURE); + + rp_property_increment_ref(recipient_token, env); + asymmetric_binding->recipient_token = recipient_token; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_asymmetric_binding_get_recipient_token( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env) +{ + return asymmetric_binding->recipient_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_asymmetric_binding_increment_ref( + rp_asymmetric_binding_t *asymmetric_binding, + const axutil_env_t *env) +{ + asymmetric_binding->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/binding_commons.c b/neethi/src/secpolicy/model/binding_commons.c new file mode 100644 index 0000000..9795c78 --- /dev/null +++ b/neethi/src/secpolicy/model/binding_commons.c @@ -0,0 +1,245 @@ +/* + * 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 <rp_binding_commons.h> + +struct rp_binding_commons_t +{ + rp_algorithmsuite_t *algorithmsuite; + axis2_bool_t include_timestamp; + rp_layout_t *layout; + rp_supporting_tokens_t *signed_supporting_tokens; + rp_supporting_tokens_t *signed_endorsing_supporting_tokens; + rp_supporting_tokens_t *endorsing_supporting_tokens; + rp_supporting_tokens_t *supporting_tokens; +}; + +AXIS2_EXTERN rp_binding_commons_t *AXIS2_CALL +rp_binding_commons_create( + const axutil_env_t *env) +{ + rp_binding_commons_t *binding_commons = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + binding_commons = (rp_binding_commons_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_binding_commons_t)); + + if(binding_commons == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Out of memory"); + return NULL; + } + binding_commons->algorithmsuite = NULL; + binding_commons->include_timestamp = AXIS2_FALSE; + binding_commons->layout = NULL; + binding_commons->signed_supporting_tokens = NULL; + binding_commons->signed_endorsing_supporting_tokens = NULL; + binding_commons->endorsing_supporting_tokens = NULL; + binding_commons->supporting_tokens = NULL; + + return binding_commons; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_binding_commons_free( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + if(binding_commons) + { + if(binding_commons->algorithmsuite) + { + rp_algorithmsuite_free(binding_commons->algorithmsuite, env); + binding_commons->algorithmsuite = NULL; + } + if(binding_commons->layout) + { + rp_layout_free(binding_commons->layout, env); + binding_commons->layout = NULL; + } + if(binding_commons->signed_supporting_tokens) + { + rp_supporting_tokens_free(binding_commons->signed_supporting_tokens, env); + binding_commons->signed_supporting_tokens = NULL; + } + if(binding_commons->signed_endorsing_supporting_tokens) + { + rp_supporting_tokens_free(binding_commons-> signed_endorsing_supporting_tokens, env); + binding_commons->signed_endorsing_supporting_tokens = NULL; + } + if(binding_commons->endorsing_supporting_tokens) + { + rp_supporting_tokens_free(binding_commons-> endorsing_supporting_tokens, env); + binding_commons->endorsing_supporting_tokens = NULL; + } + if(binding_commons->supporting_tokens) + { + rp_supporting_tokens_free(binding_commons->supporting_tokens, env); + binding_commons->supporting_tokens = NULL; + } + AXIS2_FREE(env->allocator, binding_commons); + binding_commons = NULL; + + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_binding_commons_get_include_timestamp( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->include_timestamp; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_include_timestamp( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + axis2_bool_t include_timestamp) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, include_timestamp, AXIS2_FAILURE); + + binding_commons->include_timestamp = include_timestamp; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_algorithmsuite_t *AXIS2_CALL +rp_binding_commons_get_algorithmsuite( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->algorithmsuite; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_algorithmsuite( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + rp_algorithmsuite_t *algorithmsuite) +{ + AXIS2_PARAM_CHECK(env->error, algorithmsuite, AXIS2_FAILURE); + + rp_algorithmsuite_increment_ref(algorithmsuite, env); + binding_commons->algorithmsuite = algorithmsuite; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_layout_t *AXIS2_CALL +rp_binding_commons_get_layout( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->layout; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_layout( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + rp_layout_t *layout) +{ + AXIS2_PARAM_CHECK(env->error, layout, AXIS2_FAILURE); + rp_layout_increment_ref(layout, env); + binding_commons->layout = layout; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_binding_commons_get_signed_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->signed_supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_signed_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + rp_supporting_tokens_t *signed_supporting_tokens) +{ + AXIS2_PARAM_CHECK(env->error, signed_supporting_tokens, AXIS2_FAILURE); + binding_commons->signed_supporting_tokens = signed_supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_binding_commons_get_signed_endorsing_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->signed_endorsing_supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_signed_endorsing_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + rp_supporting_tokens_t *signed_endorsing_supporting_tokens) +{ + AXIS2_PARAM_CHECK(env->error, signed_endorsing_supporting_tokens, AXIS2_FAILURE); + + binding_commons->signed_endorsing_supporting_tokens = signed_endorsing_supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_binding_commons_get_endorsing_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->endorsing_supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_endorsing_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + rp_supporting_tokens_t *endorsing_supporting_tokens) +{ + AXIS2_PARAM_CHECK(env->error, endorsing_supporting_tokens, AXIS2_FAILURE); + binding_commons->endorsing_supporting_tokens = endorsing_supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_binding_commons_get_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env) +{ + return binding_commons->supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_binding_commons_set_supporting_tokens( + rp_binding_commons_t *binding_commons, + const axutil_env_t *env, + rp_supporting_tokens_t *supporting_tokens) +{ + AXIS2_PARAM_CHECK(env->error, supporting_tokens, AXIS2_FAILURE); + binding_commons->supporting_tokens = supporting_tokens; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/element.c b/neethi/src/secpolicy/model/element.c new file mode 100644 index 0000000..125fef3 --- /dev/null +++ b/neethi/src/secpolicy/model/element.c @@ -0,0 +1,112 @@ +/* + * 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 <rp_element.h> + +struct rp_element_t +{ + axis2_char_t *name; + axis2_char_t *nspace; +}; + +AXIS2_EXTERN rp_element_t *AXIS2_CALL +rp_element_create( + const axutil_env_t * env) +{ + rp_element_t *element = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + element = (rp_element_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_element_t)); + + if(element == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + element->name = NULL; + element->nspace = NULL; + + return element; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_element_free( + rp_element_t * element, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(element) + { + AXIS2_FREE(env->allocator, element); + element = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_element_get_name( + rp_element_t * element, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return element->name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_element_set_name( + rp_element_t * element, + const axutil_env_t * env, + axis2_char_t * name) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE); + + element->name = name; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_element_get_namespace( + rp_element_t * element, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return element->nspace; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_element_set_namespace( + rp_element_t * element, + const axutil_env_t * env, + axis2_char_t * nspace) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, nspace, AXIS2_FAILURE); + + element->nspace = nspace; + + return AXIS2_SUCCESS; + +} diff --git a/neethi/src/secpolicy/model/header.c b/neethi/src/secpolicy/model/header.c new file mode 100644 index 0000000..9aab978 --- /dev/null +++ b/neethi/src/secpolicy/model/header.c @@ -0,0 +1,123 @@ +/* + * 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 <rp_header.h> + +struct rp_header_t +{ + axis2_char_t *name; + axis2_char_t *nspace; +}; + +AXIS2_EXTERN rp_header_t *AXIS2_CALL +rp_header_create( + const axutil_env_t * env) +{ + rp_header_t *header = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + header = (rp_header_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_header_t)); + + if(header == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + header->name = NULL; + header->nspace = NULL; + + return header; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_header_free( + rp_header_t * header, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(header) + { + if(header->name) + { + AXIS2_FREE(env->allocator, header->name); + header->name = NULL; + } + if(header->nspace) + { + AXIS2_FREE(env->allocator, header->nspace); + header->nspace = NULL; + } + + AXIS2_FREE(env->allocator, header); + header = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_header_get_name( + rp_header_t * header, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return header->name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_header_set_name( + rp_header_t * header, + const axutil_env_t * env, + axis2_char_t * name) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, name, AXIS2_FAILURE); + + header->name = axutil_strdup(env, name); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_header_get_namespace( + rp_header_t * header, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return header->nspace; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_header_set_namespace( + rp_header_t * header, + const axutil_env_t * env, + axis2_char_t * nspace) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, nspace, AXIS2_FAILURE); + + header->nspace = axutil_strdup(env, nspace); + + return AXIS2_SUCCESS; + +} diff --git a/neethi/src/secpolicy/model/https_token.c b/neethi/src/secpolicy/model/https_token.c new file mode 100644 index 0000000..100af45 --- /dev/null +++ b/neethi/src/secpolicy/model/https_token.c @@ -0,0 +1,153 @@ +/* + * 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 <rp_https_token.h> + +struct rp_https_token_t +{ + axis2_char_t *inclusion; + axis2_bool_t derivedkeys; + axis2_bool_t require_client_certificate; + int ref; +}; + +AXIS2_EXTERN rp_https_token_t *AXIS2_CALL +rp_https_token_create( + const axutil_env_t * env) +{ + rp_https_token_t *https_token = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + https_token = (rp_https_token_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_https_token_t)); + + if(https_token == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + https_token->inclusion = RP_INCLUDE_ALWAYS; + https_token->derivedkeys = AXIS2_FALSE; + https_token->require_client_certificate = AXIS2_FALSE; + https_token->ref = 0; + + return https_token; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_https_token_free( + rp_https_token_t * https_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(https_token) + { + if(--(https_token->ref) > 0) + { + return; + } + AXIS2_FREE(env->allocator, https_token); + https_token = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_https_token_get_inclusion( + rp_https_token_t * https_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return https_token->inclusion; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_https_token_set_inclusion( + rp_https_token_t * https_token, + const axutil_env_t * env, + axis2_char_t * inclusion) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, inclusion, AXIS2_FAILURE); + + https_token->inclusion = inclusion; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_https_token_get_derivedkeys( + rp_https_token_t * https_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return https_token->derivedkeys; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_https_token_set_derivedkeys( + rp_https_token_t * https_token, + const axutil_env_t * env, + axis2_bool_t derivedkeys) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, derivedkeys, AXIS2_FAILURE); + + https_token->derivedkeys = derivedkeys; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_https_token_get_require_client_certificate( + rp_https_token_t * https_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return https_token->require_client_certificate; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_https_token_set_require_client_certificate( + rp_https_token_t * https_token, + const axutil_env_t * env, + axis2_bool_t require_client_certificate) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, require_client_certificate, AXIS2_FAILURE) + https_token->require_client_certificate = require_client_certificate; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_https_token_increment_ref( + rp_https_token_t * https_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + https_token->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/issued_token.c b/neethi/src/secpolicy/model/issued_token.c new file mode 100644 index 0000000..00948f2 --- /dev/null +++ b/neethi/src/secpolicy/model/issued_token.c @@ -0,0 +1,211 @@ +/* + * 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 <rp_issued_token.h> + +struct rp_issued_token +{ + axis2_char_t *inclusion; + axiom_node_t *issuer_epr; + axiom_node_t *requested_sec_token_template; + axis2_bool_t derivedkeys; + axis2_bool_t require_external_reference; + axis2_bool_t require_internal_reference; + int ref; +}; + +AXIS2_EXTERN rp_issued_token_t * AXIS2_CALL +rp_issued_token_create( + const axutil_env_t *env) +{ + rp_issued_token_t *issued_token = NULL; + + issued_token = (rp_issued_token_t*)AXIS2_MALLOC(env->allocator, sizeof(rp_issued_token_t)); + + if(issued_token == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + issued_token->inclusion = NULL; + issued_token->issuer_epr = NULL; + issued_token->requested_sec_token_template = NULL; + issued_token->derivedkeys = AXIS2_FALSE; + issued_token->require_external_reference = AXIS2_FALSE; + issued_token->require_internal_reference = AXIS2_FALSE; + issued_token->ref = 0; + + return issued_token; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_issued_token_free( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + if(issued_token) + { + if(--(issued_token->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, issued_token); + issued_token = NULL; + } + return; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +rp_issued_token_get_inclusion( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + return issued_token->inclusion; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_set_inclusion( + rp_issued_token_t *issued_token, + const axutil_env_t *env, + axis2_char_t *inclusion) +{ + if(inclusion) + { + issued_token->inclusion = inclusion; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +rp_issued_token_get_issuer_epr( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + return issued_token->issuer_epr; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_set_issuer_epr( + rp_issued_token_t *issued_token, + const axutil_env_t *env, + axiom_node_t *issuer_epr) +{ + if(issuer_epr) + { + issued_token->issuer_epr = issuer_epr; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axiom_node_t * AXIS2_CALL +rp_issued_token_get_requested_sec_token_template( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + return issued_token->requested_sec_token_template; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_set_requested_sec_token_template( + rp_issued_token_t *issued_token, + const axutil_env_t *env, + axiom_node_t *req_sec_token_template) +{ + if(req_sec_token_template) + { + issued_token->requested_sec_token_template = req_sec_token_template; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_issued_token_get_derivedkeys( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + return issued_token->derivedkeys; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_set_derivedkeys( + rp_issued_token_t *issued_token, + const axutil_env_t *env, + axis2_bool_t derivedkeys) +{ + AXIS2_PARAM_CHECK(env->error, derivedkeys, AXIS2_FAILURE); + issued_token->derivedkeys = derivedkeys; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_issued_token_get_require_external_reference( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + return issued_token->require_external_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_set_require_exernal_reference( + rp_issued_token_t *issued_token, + const axutil_env_t *env, + axis2_bool_t require_external_reference) +{ + AXIS2_PARAM_CHECK(env->error, require_external_reference, AXIS2_FAILURE); + issued_token->require_external_reference = require_external_reference; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_issued_token_get_require_internal_reference( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + return issued_token->require_internal_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_set_require_internal_reference( + rp_issued_token_t *issued_token, + const axutil_env_t *env, + axis2_bool_t require_internal_reference) +{ + AXIS2_PARAM_CHECK(env->error, require_internal_reference, AXIS2_FAILURE); + issued_token->require_internal_reference = require_internal_reference; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_issued_token_increment_ref( + rp_issued_token_t *issued_token, + const axutil_env_t *env) +{ + issued_token->ref++; + return AXIS2_SUCCESS; +} + diff --git a/neethi/src/secpolicy/model/layout.c b/neethi/src/secpolicy/model/layout.c new file mode 100644 index 0000000..b4591c4 --- /dev/null +++ b/neethi/src/secpolicy/model/layout.c @@ -0,0 +1,99 @@ +/* + * 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 <rp_layout.h> + +struct rp_layout_t +{ + axis2_char_t *value; + int ref; +}; + +AXIS2_EXTERN rp_layout_t *AXIS2_CALL +rp_layout_create( + const axutil_env_t * env) +{ + rp_layout_t *layout = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + layout = (rp_layout_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_layout_t)); + + if(layout == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + layout->value = RP_LAYOUT_STRICT; + layout->ref = 0; + return layout; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_layout_free( + rp_layout_t * layout, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(layout) + { + if(--(layout->ref) > 0) + { + return; + } + AXIS2_FREE(env->allocator, layout); + layout = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_layout_get_value( + rp_layout_t * layout, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return layout->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_layout_set_value( + rp_layout_t * layout, + const axutil_env_t * env, + axis2_char_t * value) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + + layout->value = value; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_layout_increment_ref( + rp_layout_t * layout, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + layout->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/property.c b/neethi/src/secpolicy/model/property.c new file mode 100644 index 0000000..a8d806c --- /dev/null +++ b/neethi/src/secpolicy/model/property.c @@ -0,0 +1,265 @@ +/* + * 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 <rp_property.h> +#include <rp_symmetric_binding.h> +#include <rp_asymmetric_binding.h> +#include <rp_transport_binding.h> +#include <rp_supporting_tokens.h> +#include <rp_wss10.h> +#include <rp_wss11.h> + +struct rp_property_t +{ + rp_property_type_t type; + void *value; + int ref; +}; + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_property_create( + const axutil_env_t * env) +{ + rp_property_t *property = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + property = (rp_property_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_property_t)); + + if(property == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + property->type = RP_PROPERTY_UNKNOWN; + property->value = NULL; + property->ref = 0; + + return property; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_property_free( + rp_property_t * property, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(property) + { + if(--(property->ref) > 0) + { + return; + } + + if(property->value) + { + switch(property->type) + { + case RP_PROPERTY_USERNAME_TOKEN: + rp_username_token_free((rp_username_token_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_X509_TOKEN: + rp_x509_token_free((rp_x509_token_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_ISSUED_TOKEN: + rp_issued_token_free((rp_issued_token_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SAML_TOKEN: + rp_saml_token_free((rp_saml_token_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SECURITY_CONTEXT_TOKEN: + rp_security_context_token_free((rp_security_context_token_t *)property->value, + env); + property->value = NULL; + break; + + case RP_PROPERTY_HTTPS_TOKEN: + rp_https_token_free((rp_https_token_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SYMMETRIC_BINDING: + rp_symmetric_binding_free((rp_symmetric_binding_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_ASYMMETRIC_BINDING: + rp_asymmetric_binding_free((rp_asymmetric_binding_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_TRANSPORT_BINDING: + rp_transport_binding_free((rp_transport_binding_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SIGNED_SUPPORTING_TOKEN: + rp_supporting_tokens_free((rp_supporting_tokens_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SIGNED_ENDORSING_SUPPORTING_TOKEN: + rp_supporting_tokens_free((rp_supporting_tokens_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SUPPORTING_SUPPORTING_TOKEN: + rp_supporting_tokens_free((rp_supporting_tokens_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_ENDORSING_SUPPORTING_TOKEN: + rp_supporting_tokens_free((rp_supporting_tokens_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_SUPPORTING_TOKEN: + rp_supporting_tokens_free((rp_supporting_tokens_t *)property-> value, env); + property->value = NULL; + break; + + case RP_PROPERTY_WSS10: + rp_wss10_free((rp_wss10_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_WSS11: + rp_wss11_free((rp_wss11_t *)property->value, env); + property->value = NULL; + break; + + case RP_PROPERTY_UNKNOWN: + break; + } + } + AXIS2_FREE(env->allocator, property); + } + + return; +} + +/* Implementations */ +AXIS2_EXTERN void *AXIS2_CALL +rp_property_get_value( + rp_property_t * property, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return property->value; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_property_set_value( + rp_property_t * property, + const axutil_env_t * env, + void *value, + rp_property_type_t type) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, value, AXIS2_FAILURE); + + property->type = type; + + if(type == RP_PROPERTY_X509_TOKEN) + { + rp_x509_token_increment_ref((rp_x509_token_t *)value, env); + } + else if(type == RP_PROPERTY_SECURITY_CONTEXT_TOKEN) + { + rp_security_context_token_increment_ref((rp_security_context_token_t *)value, env); + } + else if(type == RP_PROPERTY_WSS10) + { + rp_wss10_increment_ref((rp_wss10_t *)value, env); + } + else if(type == RP_PROPERTY_WSS11) + { + rp_wss11_increment_ref((rp_wss11_t *)value, env); + } + else if(type == RP_PROPERTY_USERNAME_TOKEN) + { + rp_username_token_increment_ref((rp_username_token_t *)value, env); + } + + else if(type == RP_PROPERTY_HTTPS_TOKEN) + { + rp_https_token_increment_ref((rp_https_token_t *)value, env); + } + + else if(type == RP_PROPERTY_SIGNED_SUPPORTING_TOKEN) + { + rp_supporting_tokens_increment_ref((rp_supporting_tokens_t *)value, env); + } + else if(type == RP_PROPERTY_SUPPORTING_SUPPORTING_TOKEN) + { + rp_supporting_tokens_increment_ref((rp_supporting_tokens_t *)value, env); + } + else if(type == RP_PROPERTY_SIGNED_ENDORSING_SUPPORTING_TOKEN) + { + rp_supporting_tokens_increment_ref((rp_supporting_tokens_t *)value, env); + } + else if(type == RP_PROPERTY_ENDORSING_SUPPORTING_TOKEN) + { + rp_supporting_tokens_increment_ref((rp_supporting_tokens_t *)value, env); + } + else if(type == RP_PROPERTY_ASYMMETRIC_BINDING) + { + rp_asymmetric_binding_increment_ref((rp_asymmetric_binding_t *)value, env); + } + else if(type == RP_PROPERTY_TRANSPORT_BINDING) + { + rp_transport_binding_increment_ref((rp_transport_binding_t *)value, env); + } + else if(type == RP_PROPERTY_SYMMETRIC_BINDING) + { + rp_symmetric_binding_increment_ref((rp_symmetric_binding_t *)value, env); + } + property->value = (void *)value; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_property_type_t AXIS2_CALL +rp_property_get_type( + rp_property_t * property, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return property->type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_property_increment_ref( + rp_property_t * property, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + property->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/rampart_config.c b/neethi/src/secpolicy/model/rampart_config.c new file mode 100644 index 0000000..ba8bebd --- /dev/null +++ b/neethi/src/secpolicy/model/rampart_config.c @@ -0,0 +1,446 @@ +/* + * 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 <rp_rampart_config.h> + +struct rp_rampart_config_t +{ + axis2_char_t *user; + axis2_char_t *encryption_user; + axis2_char_t *password_callback_class; + axis2_char_t *authenticate_module; + axis2_char_t *replay_detector; + axis2_char_t *sct_provider; + axis2_char_t *password_type; + axis2_char_t *time_to_live; + axis2_char_t *clock_skew_buffer; + axis2_char_t *need_millisecond_precision; + axis2_char_t *receiver_certificate_file; + axis2_char_t *certificate_file; + axis2_char_t *private_key_file; + axis2_char_t *pkcs12_file; + axis2_char_t *rd_val; + int ref; +}; + +AXIS2_EXTERN rp_rampart_config_t *AXIS2_CALL +rp_rampart_config_create( + const axutil_env_t * env) +{ + rp_rampart_config_t *rampart_config = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + rampart_config = (rp_rampart_config_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_rampart_config_t)); + + if(rampart_config == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + rampart_config->user = NULL; + rampart_config->encryption_user = NULL; + rampart_config->password_callback_class = NULL; + rampart_config->private_key_file = NULL; + rampart_config->receiver_certificate_file = NULL; + rampart_config->certificate_file = NULL; + rampart_config->authenticate_module = NULL; + rampart_config->replay_detector = NULL; + rampart_config->sct_provider = NULL; + rampart_config->password_type = NULL; + rampart_config->time_to_live = NULL; + rampart_config->clock_skew_buffer = NULL; + rampart_config->need_millisecond_precision = NULL; + rampart_config->pkcs12_file = NULL; + rampart_config->rd_val = NULL; + rampart_config->ref = 0; + + return rampart_config; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_rampart_config_free( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(rampart_config) + { + if(--(rampart_config->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, rampart_config); + rampart_config = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_user( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->user; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_user( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * user) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, user, AXIS2_FAILURE); + + rampart_config->user = user; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_encryption_user( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->encryption_user; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_encryption_user( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * encryption_user) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encryption_user, AXIS2_FAILURE); + + rampart_config->encryption_user = encryption_user; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_password_callback_class( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->password_callback_class; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_password_callback_class( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * password_callback_class) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, password_callback_class, AXIS2_FAILURE); + + rampart_config->password_callback_class = password_callback_class; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_authenticate_module( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->authenticate_module; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_authenticate_module( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * authenticate_module) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, authenticate_module, AXIS2_FAILURE); + + rampart_config->authenticate_module = authenticate_module; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_replay_detector( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->replay_detector; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_replay_detector( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * replay_detector) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, replay_detector, AXIS2_FAILURE); + + rampart_config->replay_detector = replay_detector; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_sct_provider( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->sct_provider; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_sct_provider( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * sct_module) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, sct_module, AXIS2_FAILURE); + + rampart_config->sct_provider = sct_module; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_password_type( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->password_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_password_type( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * password_type) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, password_type, AXIS2_FAILURE); + + rampart_config->password_type = password_type; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_private_key_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->private_key_file; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_private_key_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * private_key_file) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, private_key_file, AXIS2_FAILURE); + + rampart_config->private_key_file = private_key_file; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_receiver_certificate_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->receiver_certificate_file; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_receiver_certificate_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * receiver_certificate_file) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, receiver_certificate_file, AXIS2_FAILURE); + + rampart_config->receiver_certificate_file = receiver_certificate_file; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_certificate_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->certificate_file; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_certificate_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * certificate_file) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, certificate_file, AXIS2_FAILURE); + + rampart_config->certificate_file = certificate_file; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_time_to_live( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->time_to_live; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_time_to_live( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * time_to_live) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, time_to_live, AXIS2_FAILURE); + + rampart_config->time_to_live = time_to_live; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_clock_skew_buffer( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + return rampart_config->clock_skew_buffer; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_clock_skew_buffer( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * clock_skew_buffer) +{ + rampart_config->clock_skew_buffer = clock_skew_buffer; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_need_millisecond_precision( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + return rampart_config->need_millisecond_precision; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_need_millisecond_precision( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * need_millisecond_precision) +{ + rampart_config->need_millisecond_precision = need_millisecond_precision; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_pkcs12_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + return rampart_config->pkcs12_file; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_pkcs12_file( + rp_rampart_config_t * rampart_config, + const axutil_env_t *env, + axis2_char_t * pkcs12_file) +{ + if(rampart_config) + { + if(pkcs12_file) + { + rampart_config->pkcs12_file = pkcs12_file; + return AXIS2_SUCCESS; + } + + return AXIS2_FAILURE; + } + + return AXIS2_FAILURE; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_rampart_config_get_rd_val( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return rampart_config->rd_val; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_set_rd_val( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env, + axis2_char_t * rd_val) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, rd_val, AXIS2_FAILURE); + + rampart_config->rd_val = rd_val; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_rampart_config_increment_ref( + rp_rampart_config_t * rampart_config, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + rampart_config->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/saml_token.c b/neethi/src/secpolicy/model/saml_token.c new file mode 100644 index 0000000..ae0f1ea --- /dev/null +++ b/neethi/src/secpolicy/model/saml_token.c @@ -0,0 +1,160 @@ +/* + * 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 <rp_saml_token.h> + +struct rp_saml_token +{ + axis2_char_t *inclusion; + axis2_bool_t derivedkeys; + axis2_bool_t require_key_identifier_reference; + axis2_char_t *token_version_and_type; + int ref; +}; + +AXIS2_EXTERN rp_saml_token_t * AXIS2_CALL +rp_saml_token_create( + const axutil_env_t *env) +{ + rp_saml_token_t * saml_token; + + saml_token = (rp_saml_token_t*)AXIS2_MALLOC(env->allocator, sizeof(rp_saml_token_t)); + + if(saml_token == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + saml_token->inclusion = NULL; + saml_token->derivedkeys = AXIS2_FALSE; + saml_token->require_key_identifier_reference = AXIS2_FALSE; + saml_token->token_version_and_type = NULL; + saml_token->ref = 0; + + return saml_token; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_saml_token_free( + rp_saml_token_t *saml_token, + const axutil_env_t *env) +{ + if(saml_token) + { + if(--(saml_token->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, saml_token); + saml_token = NULL; + } + + return; +} + +AXIS2_EXTERN axis2_char_t * AXIS2_CALL +rp_saml_token_get_inclusion( + rp_saml_token_t *saml_token, + const axutil_env_t *env) +{ + return saml_token->inclusion; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_saml_token_set_inclusion( + rp_saml_token_t *saml_token, + const axutil_env_t *env, + axis2_char_t * inclusion) +{ + AXIS2_PARAM_CHECK(env->error, inclusion, AXIS2_FAILURE); + saml_token->inclusion = inclusion; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_saml_token_get_derivedkeys( + rp_saml_token_t *saml_token, + const axutil_env_t *env) +{ + return saml_token->derivedkeys; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_saml_token_set_derivedkeys( + rp_saml_token_t *saml_token, + const axutil_env_t *env, + axis2_bool_t derivedkeys) +{ + AXIS2_PARAM_CHECK(env->error, derivedkeys, AXIS2_FAILURE); + saml_token->derivedkeys = derivedkeys; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_saml_token_get_require_key_identifier_reference( + rp_saml_token_t * saml_token, + const axutil_env_t * env) +{ + return saml_token->require_key_identifier_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_saml_token_set_require_key_identifier_reference( + rp_saml_token_t * saml_token, + const axutil_env_t * env, + axis2_bool_t require_key_identifier_reference) +{ + AXIS2_PARAM_CHECK(env->error, require_key_identifier_reference, AXIS2_FAILURE); + saml_token->require_key_identifier_reference = require_key_identifier_reference; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_saml_token_get_token_version_and_type( + rp_saml_token_t * saml_token, + const axutil_env_t * env) +{ + return saml_token->token_version_and_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_saml_token_set_token_version_and_type( + rp_saml_token_t * saml_token, + const axutil_env_t * env, + axis2_char_t * token_version_and_type) +{ + AXIS2_PARAM_CHECK(env->error, token_version_and_type, AXIS2_FAILURE); + + saml_token->token_version_and_type = token_version_and_type; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_saml_token_increment_ref( + rp_saml_token_t * saml_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + saml_token->ref++; + return AXIS2_SUCCESS; +} + diff --git a/neethi/src/secpolicy/model/secpolicy.c b/neethi/src/secpolicy/model/secpolicy.c new file mode 100644 index 0000000..fdd112c --- /dev/null +++ b/neethi/src/secpolicy/model/secpolicy.c @@ -0,0 +1,493 @@ +/* + * 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 <rp_secpolicy.h> + +struct rp_secpolicy_t +{ + rp_property_t *binding; + rp_property_t *wss; + rp_trust10_t *trust10; + rp_supporting_tokens_t *supporting_tokens; + rp_supporting_tokens_t *signed_supporting_tokens; + rp_supporting_tokens_t *endorsing_supporting_tokens; + rp_supporting_tokens_t *signed_endorsing_supporting_tokens; + rp_signed_encrypted_parts_t *signed_parts; + rp_signed_encrypted_parts_t *encrypted_parts; + rp_signed_encrypted_elements_t *signed_elements; + rp_signed_encrypted_elements_t *encrypted_elements; + rp_signed_encrypted_items_t *signed_items; + rp_signed_encrypted_items_t *encrypted_items; + rp_rampart_config_t *rampart_config; + +}; + +AXIS2_EXTERN rp_secpolicy_t *AXIS2_CALL +rp_secpolicy_create( + const axutil_env_t * env) +{ + rp_secpolicy_t *secpolicy = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + secpolicy = (rp_secpolicy_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_secpolicy_t)); + + if(secpolicy == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + secpolicy->binding = NULL; + secpolicy->wss = NULL; + secpolicy->trust10 = NULL; + secpolicy->supporting_tokens = NULL; + secpolicy->signed_supporting_tokens = NULL; + secpolicy->endorsing_supporting_tokens = NULL; + secpolicy->signed_endorsing_supporting_tokens = NULL; + secpolicy->signed_parts = NULL; + secpolicy->encrypted_parts = NULL; + secpolicy->signed_elements = NULL; + secpolicy->encrypted_elements = NULL; + secpolicy->signed_items = NULL; + secpolicy->encrypted_items = NULL; + secpolicy->rampart_config = NULL; + + return secpolicy; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_secpolicy_free( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(secpolicy) + { + if(secpolicy->binding) + { + rp_property_free(secpolicy->binding, env); + secpolicy->binding = NULL; + } + if(secpolicy->wss) + { + rp_property_free(secpolicy->wss, env); + secpolicy->wss = NULL; + } + if(secpolicy->trust10) + { + rp_trust10_free(secpolicy->trust10, env); + secpolicy->trust10 = NULL; + } + if(secpolicy->supporting_tokens) + { + rp_supporting_tokens_free(secpolicy->supporting_tokens, env); + secpolicy->supporting_tokens = NULL; + } + if(secpolicy->signed_supporting_tokens) + { + rp_supporting_tokens_free(secpolicy->signed_supporting_tokens, env); + secpolicy->signed_supporting_tokens = NULL; + } + if(secpolicy->endorsing_supporting_tokens) + { + rp_supporting_tokens_free(secpolicy->endorsing_supporting_tokens, env); + secpolicy->endorsing_supporting_tokens = NULL; + } + if(secpolicy->signed_endorsing_supporting_tokens) + { + rp_supporting_tokens_free(secpolicy-> signed_endorsing_supporting_tokens, env); + secpolicy->signed_endorsing_supporting_tokens = NULL; + } + if(secpolicy->signed_parts) + { + rp_signed_encrypted_parts_free(secpolicy->signed_parts, env); + secpolicy->signed_parts = NULL; + } + if(secpolicy->encrypted_parts) + { + rp_signed_encrypted_parts_free(secpolicy->encrypted_parts, env); + secpolicy->encrypted_parts = NULL; + } + if(secpolicy->signed_elements) + { + rp_signed_encrypted_elements_free(secpolicy->signed_elements, env); + secpolicy->signed_elements = NULL; + } + if(secpolicy->encrypted_elements) + { + rp_signed_encrypted_elements_free(secpolicy->encrypted_elements, env); + secpolicy->encrypted_elements = NULL; + } + if(secpolicy->signed_items) + { + rp_signed_encrypted_items_free(secpolicy->signed_items, env); + secpolicy->signed_items = NULL; + } + if(secpolicy->encrypted_items) + { + rp_signed_encrypted_items_free(secpolicy->encrypted_items, env); + secpolicy->encrypted_items = NULL; + } + if(secpolicy->rampart_config) + { + rp_rampart_config_free(secpolicy->rampart_config, env); + secpolicy->rampart_config = NULL; + } + AXIS2_FREE(env->allocator, secpolicy); + } + + return; +} + +/* Implementations */ +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_secpolicy_get_binding( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->binding; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_binding( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_property_t * binding) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, binding, AXIS2_FAILURE); + rp_property_increment_ref(binding, env); + secpolicy->binding = binding; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_supporting_tokens_t * supporting_tokens) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, supporting_tokens, AXIS2_FAILURE); + + rp_supporting_tokens_increment_ref(supporting_tokens, env); + secpolicy->supporting_tokens = supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_secpolicy_get_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_signed_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_supporting_tokens_t * signed_supporting_tokens) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_supporting_tokens, AXIS2_FAILURE); + + rp_supporting_tokens_increment_ref(signed_supporting_tokens, env); + secpolicy->signed_supporting_tokens = signed_supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_secpolicy_get_signed_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->signed_supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_endorsing_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_supporting_tokens_t * endorsing_supporting_tokens) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, endorsing_supporting_tokens, AXIS2_FAILURE); + + rp_supporting_tokens_increment_ref(endorsing_supporting_tokens, env); + secpolicy->endorsing_supporting_tokens = endorsing_supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_secpolicy_get_endorsing_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->endorsing_supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_signed_endorsing_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_supporting_tokens_t * signed_endorsing_supporting_tokens) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_endorsing_supporting_tokens, AXIS2_FAILURE); + + rp_supporting_tokens_increment_ref(signed_endorsing_supporting_tokens, env); + secpolicy->signed_endorsing_supporting_tokens = signed_endorsing_supporting_tokens; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_secpolicy_get_signed_endorsing_supporting_tokens( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->signed_endorsing_supporting_tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_signed_parts( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_signed_encrypted_parts_t * signed_parts) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_parts, AXIS2_FAILURE); + rp_signed_encrypted_parts_increment_ref(signed_parts, env); + secpolicy->signed_parts = signed_parts; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_signed_encrypted_parts_t *AXIS2_CALL +rp_secpolicy_get_signed_parts( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->signed_parts; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_encrypted_parts( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_signed_encrypted_parts_t * encrypted_parts) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encrypted_parts, AXIS2_FAILURE); + + rp_signed_encrypted_parts_increment_ref(encrypted_parts, env); + secpolicy->encrypted_parts = encrypted_parts; + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_signed_encrypted_parts_t *AXIS2_CALL +rp_secpolicy_get_encrypted_parts( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->encrypted_parts; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_signed_elements( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_signed_encrypted_elements_t * signed_elements) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_elements, AXIS2_FAILURE); + + rp_signed_encrypted_elements_increment_ref(signed_elements, env); + secpolicy->signed_elements = signed_elements; + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_signed_encrypted_elements_t *AXIS2_CALL +rp_secpolicy_get_signed_elements( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->signed_elements; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_encrypted_elements( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_signed_encrypted_elements_t * encrypted_elements) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encrypted_elements, AXIS2_FAILURE); + + rp_signed_encrypted_elements_increment_ref(encrypted_elements, env); + secpolicy->encrypted_elements = encrypted_elements; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_signed_encrypted_elements_t *AXIS2_CALL +rp_secpolicy_get_encrypted_elements( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->encrypted_elements; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_signed_items( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_signed_encrypted_items_t * signed_items) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_items, AXIS2_FAILURE); + + secpolicy->signed_items = signed_items; + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_signed_encrypted_items_t *AXIS2_CALL +rp_secpolicy_get_signed_items( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->signed_items; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_encrypted_items( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_signed_encrypted_items_t * encrypted_items) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encrypted_items, AXIS2_FAILURE); + + secpolicy->encrypted_items = encrypted_items; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_signed_encrypted_items_t *AXIS2_CALL +rp_secpolicy_get_encrypted_items( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->encrypted_items; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_wss( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_property_t * wss) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, wss, AXIS2_FAILURE); + + rp_property_increment_ref(wss, env); + secpolicy->wss = wss; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_secpolicy_get_wss( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->wss; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_trust10( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_trust10_t * trust10) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, trust10, AXIS2_FAILURE); + + rp_trust10_increment_ref(trust10, env); + secpolicy->trust10 = trust10; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_trust10_t *AXIS2_CALL +rp_secpolicy_get_trust10( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->trust10; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_secpolicy_set_rampart_config( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env, + rp_rampart_config_t * rampart_config) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, rampart_config, AXIS2_FAILURE); + + rp_rampart_config_increment_ref(rampart_config, env); + secpolicy->rampart_config = rampart_config; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_rampart_config_t *AXIS2_CALL +rp_secpolicy_get_rampart_config( + rp_secpolicy_t * secpolicy, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return secpolicy->rampart_config; +} diff --git a/neethi/src/secpolicy/model/security_context_token.c b/neethi/src/secpolicy/model/security_context_token.c new file mode 100644 index 0000000..9b00465 --- /dev/null +++ b/neethi/src/secpolicy/model/security_context_token.c @@ -0,0 +1,239 @@ +/* + * 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 <rp_security_context_token.h> + +struct rp_security_context_token_t +{ + rp_token_t *token; + axis2_bool_t require_external_uri_ref; + axis2_bool_t sc10_security_context_token; + neethi_policy_t *bootstrap_policy; + axis2_bool_t is_secure_conversation_token; + int ref; +}; + +AXIS2_EXTERN rp_security_context_token_t *AXIS2_CALL +rp_security_context_token_create( + const axutil_env_t * env) +{ + rp_security_context_token_t *security_context_token = NULL; + + security_context_token = (rp_security_context_token_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_security_context_token_t)); + + if(!security_context_token) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] Security context token assertion creation failed. Insufficient memory"); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + security_context_token->ref = 0; + security_context_token->require_external_uri_ref = AXIS2_FALSE; + security_context_token->sc10_security_context_token = AXIS2_FALSE; + security_context_token->bootstrap_policy = NULL; + security_context_token->is_secure_conversation_token = AXIS2_FALSE; + + security_context_token->token = rp_token_create(env); + if(!security_context_token->token) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] Security context token assertion creation failed."); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + rp_security_context_token_free(security_context_token, env); + return NULL; + } + + return security_context_token; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_security_context_token_free( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env) +{ + if(security_context_token) + { + if(--(security_context_token->ref) > 0) + { + return; + } + + if(security_context_token->bootstrap_policy) + { + neethi_policy_free(security_context_token->bootstrap_policy, env); + } + + rp_token_free(security_context_token->token, env); + AXIS2_FREE(env->allocator, security_context_token); + security_context_token = NULL; + } +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_security_context_token_get_inclusion( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env) +{ + return rp_token_get_inclusion(security_context_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_inclusion( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + axis2_char_t * inclusion) +{ + return rp_token_set_inclusion(security_context_token->token, env, inclusion); +} + +AXIS2_EXTERN derive_key_type_t AXIS2_CALL +rp_security_context_token_get_derivedkey( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env) +{ + return rp_token_get_derivedkey_type(security_context_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_derivedkey( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + derive_key_type_t derivedkey) +{ + return rp_token_set_derivedkey_type(security_context_token->token, env, derivedkey); +} + +AXIS2_EXTERN derive_key_version_t AXIS2_CALL +rp_security_context_token_get_derivedkey_version( + rp_security_context_token_t *security_context_token, + const axutil_env_t *env) +{ + return rp_token_get_derive_key_version(security_context_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_derivedkey_version( + rp_security_context_token_t *security_context_token, + const axutil_env_t *env, + derive_key_version_t version) +{ + return rp_token_set_derive_key_version(security_context_token->token, env, version); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_security_context_token_get_require_external_uri_ref( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env) +{ + return security_context_token->require_external_uri_ref; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_require_external_uri_ref( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + axis2_bool_t require_external_uri_ref) +{ + security_context_token->require_external_uri_ref = require_external_uri_ref; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_security_context_token_get_sc10_security_context_token( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env) +{ + return security_context_token->sc10_security_context_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_sc10_security_context_token( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + axis2_bool_t sc10_security_context_token) +{ + security_context_token->sc10_security_context_token = sc10_security_context_token; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_security_context_token_get_issuer( + rp_security_context_token_t *security_context_token, + const axutil_env_t *env) +{ + return rp_token_get_issuer(security_context_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_issuer( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + axis2_char_t *issuer) +{ + return rp_token_set_issuer(security_context_token->token, env, issuer); +} + +AXIS2_EXTERN neethi_policy_t *AXIS2_CALL +rp_security_context_token_get_bootstrap_policy( + rp_security_context_token_t *security_context_token, + const axutil_env_t *env) +{ + return security_context_token->bootstrap_policy; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_bootstrap_policy( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + neethi_policy_t *bootstrap_policy) +{ + security_context_token->bootstrap_policy = bootstrap_policy; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_security_context_token_get_is_secure_conversation_token( + rp_security_context_token_t *security_context_token, + const axutil_env_t *env) +{ + return security_context_token->is_secure_conversation_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_set_is_secure_conversation_token( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env, + axis2_bool_t is_secure_conversation_token) +{ + security_context_token->is_secure_conversation_token = is_secure_conversation_token; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_security_context_token_increment_ref( + rp_security_context_token_t * security_context_token, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + security_context_token->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/signed_encrypted_elements.c b/neethi/src/secpolicy/model/signed_encrypted_elements.c new file mode 100644 index 0000000..b656f0f --- /dev/null +++ b/neethi/src/secpolicy/model/signed_encrypted_elements.c @@ -0,0 +1,180 @@ +/* + * 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 <rp_signed_encrypted_elements.h> + +struct rp_signed_encrypted_elements_t +{ + axis2_bool_t signedelements; + axutil_array_list_t *xpath_expressions; + axis2_char_t *xpath_version; + int ref; + +}; + +AXIS2_EXTERN rp_signed_encrypted_elements_t *AXIS2_CALL +rp_signed_encrypted_elements_create( + const axutil_env_t * env) +{ + rp_signed_encrypted_elements_t *signed_encrypted_elements = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + signed_encrypted_elements = (rp_signed_encrypted_elements_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_signed_encrypted_elements_t)); + + if(signed_encrypted_elements == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + signed_encrypted_elements->xpath_expressions = NULL; + + signed_encrypted_elements->xpath_expressions = axutil_array_list_create(env, 0); + if(!(signed_encrypted_elements->xpath_expressions)) + { + rp_signed_encrypted_elements_free(signed_encrypted_elements, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + signed_encrypted_elements->xpath_version = NULL; + signed_encrypted_elements->ref = 0; + + return signed_encrypted_elements; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_signed_encrypted_elements_free( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(signed_encrypted_elements) + { + if(--(signed_encrypted_elements->ref) > 0) + { + return; + } + + if(signed_encrypted_elements->xpath_expressions) + { + int i = 0; + for(i = 0; i < axutil_array_list_size(signed_encrypted_elements-> xpath_expressions, + env); i++) + { + axis2_char_t *expression = NULL; + expression = (axis2_char_t *)axutil_array_list_get( + signed_encrypted_elements-> xpath_expressions, env, i); + if(expression) + AXIS2_FREE(env->allocator, expression); + + expression = NULL; + } + axutil_array_list_free(signed_encrypted_elements->xpath_expressions, env); + signed_encrypted_elements->xpath_expressions = NULL; + + } + AXIS2_FREE(env->allocator, signed_encrypted_elements); + signed_encrypted_elements = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_signed_encrypted_elements_get_signedelements( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return signed_encrypted_elements->signedelements; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_elements_set_signedelements( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env, + axis2_bool_t signedelements) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signedelements, AXIS2_FAILURE); + + signed_encrypted_elements->signedelements = signedelements; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +rp_signed_encrypted_elements_get_xpath_expressions( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return signed_encrypted_elements->xpath_expressions; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_elements_add_expression( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env, + axis2_char_t * expression) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, expression, AXIS2_FAILURE); + + axutil_array_list_add(signed_encrypted_elements->xpath_expressions, env, expression); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_signed_encrypted_elements_get_xpath_version( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return signed_encrypted_elements->xpath_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_elements_set_xpath_version( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env, + axis2_char_t * xpath_version) +{ + + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, xpath_version, AXIS2_FAILURE); + + signed_encrypted_elements->xpath_version = xpath_version; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_elements_increment_ref( + rp_signed_encrypted_elements_t * signed_encrypted_elements, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + signed_encrypted_elements->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/signed_encrypted_items.c b/neethi/src/secpolicy/model/signed_encrypted_items.c new file mode 100644 index 0000000..e3e6150 --- /dev/null +++ b/neethi/src/secpolicy/model/signed_encrypted_items.c @@ -0,0 +1,136 @@ +/* + * 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 <rp_signed_encrypted_items.h> + +struct rp_signed_encrypted_items_t +{ + axis2_bool_t signeditems; + axutil_array_list_t *elements; + +}; + +AXIS2_EXTERN rp_signed_encrypted_items_t *AXIS2_CALL +rp_signed_encrypted_items_create( + const axutil_env_t * env) +{ + rp_signed_encrypted_items_t *signed_encrypted_items = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + signed_encrypted_items = (rp_signed_encrypted_items_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_signed_encrypted_items_t)); + + if(signed_encrypted_items == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + signed_encrypted_items->elements = NULL; + + signed_encrypted_items->elements = axutil_array_list_create(env, 0); + if(!(signed_encrypted_items->elements)) + { + rp_signed_encrypted_items_free(signed_encrypted_items, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + return signed_encrypted_items; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_signed_encrypted_items_free( + rp_signed_encrypted_items_t * signed_encrypted_items, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(signed_encrypted_items) + { + + if(signed_encrypted_items->elements) + { + int i = 0; + for(i = 0; i < axutil_array_list_size(signed_encrypted_items->elements, env); i++) + { + rp_element_t *element = NULL; + element = (rp_element_t *)axutil_array_list_get(signed_encrypted_items->elements, + env, i); + if(element) + rp_element_free(element, env); + + element = NULL; + } + axutil_array_list_free(signed_encrypted_items->elements, env); + signed_encrypted_items->elements = NULL; + + } + AXIS2_FREE(env->allocator, signed_encrypted_items); + signed_encrypted_items = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_signed_encrypted_items_get_signeditems( + rp_signed_encrypted_items_t * signed_encrypted_items, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return signed_encrypted_items->signeditems; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_items_set_signeditems( + rp_signed_encrypted_items_t * signed_encrypted_items, + const axutil_env_t * env, + axis2_bool_t signeditems) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signeditems, AXIS2_FAILURE); + signed_encrypted_items->signeditems = signeditems; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +rp_signed_encrypted_items_get_elements( + rp_signed_encrypted_items_t * signed_encrypted_items, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return signed_encrypted_items->elements; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_items_add_element( + rp_signed_encrypted_items_t * signed_encrypted_items, + const axutil_env_t * env, + rp_element_t * element) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, element, AXIS2_FAILURE); + + axutil_array_list_add(signed_encrypted_items->elements, env, element); + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/signed_encrypted_parts.c b/neethi/src/secpolicy/model/signed_encrypted_parts.c new file mode 100644 index 0000000..0f16e83 --- /dev/null +++ b/neethi/src/secpolicy/model/signed_encrypted_parts.c @@ -0,0 +1,176 @@ +/* + * 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 <rp_signed_encrypted_parts.h> + +struct rp_signed_encrypted_parts_t +{ + axis2_bool_t body; + axis2_bool_t signedparts; + axis2_bool_t attachments; + axutil_array_list_t *headers; + int ref; +}; + +AXIS2_EXTERN rp_signed_encrypted_parts_t *AXIS2_CALL +rp_signed_encrypted_parts_create( + const axutil_env_t * env) +{ + rp_signed_encrypted_parts_t *signed_encrypted_parts = NULL; + signed_encrypted_parts = (rp_signed_encrypted_parts_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_signed_encrypted_parts_t)); + + if(!signed_encrypted_parts) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] Cannot create signed_encrypted_parts. Insuficient memory."); + return NULL; + } + + signed_encrypted_parts->headers = axutil_array_list_create(env, 0); + if(!signed_encrypted_parts->headers) + { + rp_signed_encrypted_parts_free(signed_encrypted_parts, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] Cannot create signed_encrypted_parts. Headers array list creation failed."); + return NULL; + } + + signed_encrypted_parts->body = AXIS2_FALSE; + signed_encrypted_parts->ref = 0; + signed_encrypted_parts->signedparts = AXIS2_FALSE; + signed_encrypted_parts->attachments = AXIS2_FALSE; + return signed_encrypted_parts; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_signed_encrypted_parts_free( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env) +{ + if(signed_encrypted_parts) + { + if(--(signed_encrypted_parts->ref) > 0) + { + return; + } + + if(signed_encrypted_parts->headers) + { + int i = 0; + for(i = 0; i < axutil_array_list_size(signed_encrypted_parts->headers, env); i++) + { + rp_header_t *header = NULL; + header = (rp_header_t *)axutil_array_list_get(signed_encrypted_parts->headers, env, + i); + if(header) + { + rp_header_free(header, env); + } + } + axutil_array_list_free(signed_encrypted_parts->headers, env); + signed_encrypted_parts->headers = NULL; + } + AXIS2_FREE(env->allocator, signed_encrypted_parts); + signed_encrypted_parts = NULL; + } +} + +/* Implementations */ + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_signed_encrypted_parts_get_body( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env) +{ + return signed_encrypted_parts->body; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_parts_set_body( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env, + axis2_bool_t body) +{ + AXIS2_PARAM_CHECK(env->error, body, AXIS2_FAILURE); + signed_encrypted_parts->body = body; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_signed_encrypted_parts_get_signedparts( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env) +{ + return signed_encrypted_parts->signedparts; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_parts_set_signedparts( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env, + axis2_bool_t signedparts) +{ + signed_encrypted_parts->signedparts = signedparts; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +rp_signed_encrypted_parts_get_headers( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env) +{ + return signed_encrypted_parts->headers; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_parts_add_header( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env, + rp_header_t * header) +{ + AXIS2_PARAM_CHECK(env->error, header, AXIS2_FAILURE); + axutil_array_list_add(signed_encrypted_parts->headers, env, header); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_parts_increment_ref( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env) +{ + signed_encrypted_parts->ref++; + return AXIS2_SUCCESS; +} +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_signed_encrypted_parts_get_attachments( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env) +{ + return signed_encrypted_parts->attachments; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_signed_encrypted_parts_set_attachments( + rp_signed_encrypted_parts_t * signed_encrypted_parts, + const axutil_env_t * env, + axis2_bool_t attachments) +{ + signed_encrypted_parts->attachments = attachments; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/supporting_tokens.c b/neethi/src/secpolicy/model/supporting_tokens.c new file mode 100644 index 0000000..7ec2d7f --- /dev/null +++ b/neethi/src/secpolicy/model/supporting_tokens.c @@ -0,0 +1,300 @@ +/* + * 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 <rp_supporting_tokens.h> + +struct rp_supporting_tokens_t +{ + rp_algorithmsuite_t *algorithmsuite; + axutil_array_list_t *tokens; + rp_signed_encrypted_elements_t *signed_elements; + rp_signed_encrypted_parts_t *signed_parts; + rp_signed_encrypted_elements_t *encrypted_elements; + rp_signed_encrypted_parts_t *encrypted_parts; + int type; + int ref; +}; + +AXIS2_EXTERN rp_supporting_tokens_t *AXIS2_CALL +rp_supporting_tokens_create( + const axutil_env_t * env) +{ + rp_supporting_tokens_t *supporting_tokens = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + supporting_tokens = (rp_supporting_tokens_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_supporting_tokens_t)); + + if(supporting_tokens == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + supporting_tokens->tokens = NULL; + supporting_tokens->tokens = axutil_array_list_create(env, 0); + if(!(supporting_tokens->tokens)) + { + rp_supporting_tokens_free(supporting_tokens, env); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + + supporting_tokens->algorithmsuite = NULL; + supporting_tokens->signed_parts = NULL; + supporting_tokens->signed_elements = NULL; + supporting_tokens->encrypted_parts = NULL; + supporting_tokens->encrypted_elements = NULL; + supporting_tokens->type = 0; + supporting_tokens->ref = 0; + return supporting_tokens; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_supporting_tokens_free( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(supporting_tokens) + { + + if(--(supporting_tokens->ref) > 0) + { + return; + } + + if(supporting_tokens->tokens) + { + int i = 0; + for(i = 0; i < axutil_array_list_size(supporting_tokens->tokens, env); i++) + { + rp_property_t *token = NULL; + token = (rp_property_t *)axutil_array_list_get(supporting_tokens->tokens, env, i); + if(token) + rp_property_free(token, env); + + token = NULL; + } + axutil_array_list_free(supporting_tokens->tokens, env); + supporting_tokens->tokens = NULL; + + } + if(supporting_tokens->algorithmsuite) + { + rp_algorithmsuite_free(supporting_tokens->algorithmsuite, env); + supporting_tokens->algorithmsuite = NULL; + } + if(supporting_tokens->signed_parts) + { + rp_signed_encrypted_parts_free(supporting_tokens->signed_parts, env); + supporting_tokens->signed_parts = NULL; + } + if(supporting_tokens->signed_elements) + { + rp_signed_encrypted_elements_free(supporting_tokens-> signed_elements, env); + supporting_tokens->signed_elements = NULL; + } + if(supporting_tokens->encrypted_parts) + { + rp_signed_encrypted_parts_free(supporting_tokens->encrypted_parts, env); + supporting_tokens->encrypted_parts = NULL; + } + if(supporting_tokens->encrypted_elements) + { + rp_signed_encrypted_elements_free(supporting_tokens-> encrypted_elements, env); + supporting_tokens->encrypted_elements = NULL; + } + AXIS2_FREE(env->allocator, supporting_tokens); + supporting_tokens = NULL; + } + return; +} + +/* Implementations */ + +AXIS2_EXTERN axutil_array_list_t *AXIS2_CALL +rp_supporting_tokens_get_tokens( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return supporting_tokens->tokens; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_add_token( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + rp_property_t * token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, token, AXIS2_FAILURE); + + rp_property_increment_ref(token, env); + axutil_array_list_add(supporting_tokens->tokens, env, token); + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_algorithmsuite_t *AXIS2_CALL +rp_supporting_tokens_get_algorithmsuite( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return supporting_tokens->algorithmsuite; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_set_algorithmsuite( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + rp_algorithmsuite_t * algorithmsuite) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, algorithmsuite, AXIS2_FAILURE); + + rp_algorithmsuite_increment_ref(algorithmsuite, env); + supporting_tokens->algorithmsuite = algorithmsuite; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_signed_encrypted_parts_t *AXIS2_CALL +rp_supporting_tokens_get_signed_parts( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return supporting_tokens->signed_parts; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_set_signed_parts( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + rp_signed_encrypted_parts_t * signed_parts) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_parts, AXIS2_FAILURE); + + supporting_tokens->signed_parts = signed_parts; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_signed_encrypted_elements_t *AXIS2_CALL +rp_supporting_tokens_get_signed_elements( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return supporting_tokens->signed_elements; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_set_signed_elements( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + rp_signed_encrypted_elements_t * signed_elements) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signed_elements, AXIS2_FAILURE); + + supporting_tokens->signed_elements = signed_elements; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_signed_encrypted_parts_t *AXIS2_CALL +rp_supporting_tokens_get_encrypted_parts( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return supporting_tokens->encrypted_parts; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_set_encrypted_parts( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + rp_signed_encrypted_parts_t * encrypted_parts) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encrypted_parts, AXIS2_FAILURE); + + supporting_tokens->encrypted_parts = encrypted_parts; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_signed_encrypted_elements_t *AXIS2_CALL +rp_supporting_tokens_get_encrypted_elements( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return supporting_tokens->encrypted_elements; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_set_encrypted_elements( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + rp_signed_encrypted_elements_t * encrypted_elements) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encrypted_elements, AXIS2_FAILURE); + + supporting_tokens->encrypted_elements = encrypted_elements; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN int AXIS2_CALL +rp_supporting_tokens_get_type( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + return supporting_tokens->type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_set_type( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env, + int type) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + supporting_tokens->type = type; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_supporting_tokens_increment_ref( + rp_supporting_tokens_t * supporting_tokens, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + supporting_tokens->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/symmetric_asymmetric_binding_commons.c b/neethi/src/secpolicy/model/symmetric_asymmetric_binding_commons.c new file mode 100644 index 0000000..06a4188 --- /dev/null +++ b/neethi/src/secpolicy/model/symmetric_asymmetric_binding_commons.c @@ -0,0 +1,192 @@ +/* + * 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 <rp_symmetric_asymmetric_binding_commons.h> + +struct rp_symmetric_asymmetric_binding_commons_t +{ + rp_binding_commons_t *binding_commons; + axis2_char_t *protection_order; + axis2_bool_t signature_protection; + axis2_bool_t token_protection; + axis2_bool_t entire_headers_and_body_signatures; + +}; + +AXIS2_EXTERN rp_symmetric_asymmetric_binding_commons_t *AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_create( + const axutil_env_t * env) +{ + rp_symmetric_asymmetric_binding_commons_t *symmetric_asymmetric_binding_commons = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + symmetric_asymmetric_binding_commons + = (rp_symmetric_asymmetric_binding_commons_t *)AXIS2_MALLOC(env-> allocator, + sizeof(rp_symmetric_asymmetric_binding_commons_t)); + + if(symmetric_asymmetric_binding_commons == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + symmetric_asymmetric_binding_commons->binding_commons = NULL; + symmetric_asymmetric_binding_commons->protection_order = RP_SIGN_BEFORE_ENCRYPTING; + symmetric_asymmetric_binding_commons->signature_protection = AXIS2_FALSE; + symmetric_asymmetric_binding_commons->token_protection = AXIS2_FALSE; + symmetric_asymmetric_binding_commons->entire_headers_and_body_signatures = AXIS2_FALSE; + + return symmetric_asymmetric_binding_commons; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_free( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(symmetric_asymmetric_binding_commons) + { + if(symmetric_asymmetric_binding_commons->binding_commons) + { + rp_binding_commons_free(symmetric_asymmetric_binding_commons-> binding_commons, env); + symmetric_asymmetric_binding_commons->binding_commons = NULL; + } + AXIS2_FREE(env->allocator, symmetric_asymmetric_binding_commons); + symmetric_asymmetric_binding_commons = NULL; + } + return; +} + +/* Implementations */ +AXIS2_EXTERN rp_binding_commons_t *AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_get_binding_commons( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return symmetric_asymmetric_binding_commons->binding_commons; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_set_binding_commons( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env, + rp_binding_commons_t * binding_commons) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, binding_commons, AXIS2_FAILURE); + + symmetric_asymmetric_binding_commons->binding_commons = binding_commons; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_get_signature_protection( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return symmetric_asymmetric_binding_commons->signature_protection; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_set_signature_protection( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env, + axis2_bool_t signature_protection) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signature_protection, AXIS2_FAILURE); + symmetric_asymmetric_binding_commons->signature_protection = signature_protection; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_get_token_protection( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return symmetric_asymmetric_binding_commons->token_protection; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_set_token_protection( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env, + axis2_bool_t token_protection) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, token_protection, AXIS2_FAILURE); + + symmetric_asymmetric_binding_commons->token_protection = token_protection; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_get_entire_headers_and_body_signatures( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return symmetric_asymmetric_binding_commons-> entire_headers_and_body_signatures; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_set_entire_headers_and_body_signatures( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env, + axis2_bool_t entire_headers_and_body_signatures) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, entire_headers_and_body_signatures, AXIS2_FAILURE); + + symmetric_asymmetric_binding_commons->entire_headers_and_body_signatures + = entire_headers_and_body_signatures; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_get_protection_order( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return symmetric_asymmetric_binding_commons->protection_order; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_asymmetric_binding_commons_set_protection_order( + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons, + const axutil_env_t * env, + axis2_char_t * protection_order) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, protection_order, AXIS2_FAILURE); + + symmetric_asymmetric_binding_commons->protection_order = protection_order; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/symmetric_binding.c b/neethi/src/secpolicy/model/symmetric_binding.c new file mode 100644 index 0000000..4d6dc2d --- /dev/null +++ b/neethi/src/secpolicy/model/symmetric_binding.c @@ -0,0 +1,216 @@ +/* + * 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 <rp_symmetric_binding.h> + +struct rp_symmetric_binding_t +{ + rp_symmetric_asymmetric_binding_commons_t *symmetric_asymmetric_binding_commons; + rp_property_t *protection_token; + rp_property_t *signature_token; + rp_property_t *encryption_token; + int ref; +}; + +AXIS2_EXTERN rp_symmetric_binding_t *AXIS2_CALL +rp_symmetric_binding_create( + const axutil_env_t * env) +{ + rp_symmetric_binding_t *symmetric_binding = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + symmetric_binding = (rp_symmetric_binding_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_symmetric_binding_t)); + + if(symmetric_binding == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + symmetric_binding->symmetric_asymmetric_binding_commons = NULL; + symmetric_binding->protection_token = NULL; + symmetric_binding->signature_token = NULL; + symmetric_binding->encryption_token = NULL; + symmetric_binding->ref = 0; + + return symmetric_binding; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_symmetric_binding_free( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(symmetric_binding) + { + if(--(symmetric_binding->ref) > 0) + { + return; + } + + if(symmetric_binding->symmetric_asymmetric_binding_commons) + { + rp_symmetric_asymmetric_binding_commons_free( + symmetric_binding-> symmetric_asymmetric_binding_commons, env); + symmetric_binding->symmetric_asymmetric_binding_commons = NULL; + } + if(symmetric_binding->protection_token) + { + rp_property_free(symmetric_binding->protection_token, env); + symmetric_binding->protection_token = NULL; + } + if(symmetric_binding->encryption_token) + { + rp_property_free(symmetric_binding->encryption_token, env); + symmetric_binding->encryption_token = NULL; + } + if(symmetric_binding->signature_token) + { + rp_property_free(symmetric_binding->signature_token, env); + symmetric_binding->signature_token = NULL; + } + AXIS2_FREE(env->allocator, symmetric_binding); + } + + return; +} + +/* Implementations */ + +AXIS2_EXTERN rp_symmetric_asymmetric_binding_commons_t *AXIS2_CALL +rp_symmetric_binding_get_symmetric_asymmetric_binding_commons( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return symmetric_binding->symmetric_asymmetric_binding_commons; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_binding_set_symmetric_asymmetric_binding_commons( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env, + rp_symmetric_asymmetric_binding_commons_t * symmetric_asymmetric_binding_commons) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, symmetric_asymmetric_binding_commons, AXIS2_FAILURE); + + symmetric_binding->symmetric_asymmetric_binding_commons = symmetric_asymmetric_binding_commons; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_symmetric_binding_get_protection_token( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return symmetric_binding->protection_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_binding_set_protection_token( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env, + rp_property_t * protection_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, protection_token, AXIS2_FAILURE); + if(symmetric_binding->signature_token || symmetric_binding->encryption_token) + { + return AXIS2_FAILURE; + } + rp_property_increment_ref(protection_token, env); + symmetric_binding->protection_token = protection_token; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_binding_set_encryption_token( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env, + rp_property_t * encryption_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, encryption_token, AXIS2_FAILURE); + if(symmetric_binding->protection_token) + { + return AXIS2_FAILURE; + } + rp_property_increment_ref(encryption_token, env); + symmetric_binding->encryption_token = encryption_token; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_symmetric_binding_get_encryption_token( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return symmetric_binding->encryption_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_binding_set_signature_token( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env, + rp_property_t * signature_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, signature_token, AXIS2_FAILURE); + if(symmetric_binding->protection_token) + { + return AXIS2_FAILURE; + } + rp_property_increment_ref(signature_token, env); + symmetric_binding->signature_token = signature_token; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_symmetric_binding_get_signature_token( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return symmetric_binding->signature_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_symmetric_binding_increment_ref( + rp_symmetric_binding_t * symmetric_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + symmetric_binding->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/token.c b/neethi/src/secpolicy/model/token.c new file mode 100644 index 0000000..ccb80e4 --- /dev/null +++ b/neethi/src/secpolicy/model/token.c @@ -0,0 +1,190 @@ +/* + * 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 <rp_token.h> + +struct rp_token_t +{ + axis2_char_t *issuer; + axis2_char_t *inclusion; + axiom_node_t *claim; + axis2_bool_t is_issuer_name; /* shows whether 'issuer' points to issuer name or end point */ + derive_key_type_t derive_key; + derive_key_version_t derive_key_version; + int ref; +}; + +AXIS2_EXTERN rp_token_t *AXIS2_CALL +rp_token_create( + const axutil_env_t * env) +{ + rp_token_t *token = NULL; + token = (rp_token_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_token_t)); + + if(!token) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] Token creation failed. Insufficient memory"); + return NULL; + } + token->issuer = NULL; + token->is_issuer_name = AXIS2_FALSE; + token->claim = NULL; + token->derive_key = DERIVEKEY_NONE; + token->derive_key_version = DERIVEKEY_VERSION_SC13; + token->inclusion = RP_INCLUDE_ALWAYS_SP12; + token->ref = 0; + + return token; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_token_free( + rp_token_t * token, + const axutil_env_t * env) +{ + if(token) + { + if(--(token->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, token); + token = NULL; + } +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_token_get_issuer( + rp_token_t * token, + const axutil_env_t * env) +{ + return token->issuer; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_set_issuer( + rp_token_t * token, + const axutil_env_t * env, + axis2_char_t * issuer) +{ + token->issuer = issuer; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_set_derive_key_version( + rp_token_t *token, + const axutil_env_t *env, + derive_key_version_t version) +{ + token->derive_key_version = version; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN derive_key_version_t AXIS2_CALL +rp_token_get_derive_key_version( + rp_token_t *token, + const axutil_env_t *env) +{ + return token->derive_key_version; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_set_inclusion( + rp_token_t *token, + const axutil_env_t *env, + axis2_char_t *inclusion) +{ + token->inclusion = inclusion; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_token_get_inclusion( + rp_token_t *token, + const axutil_env_t *env) +{ + return token->inclusion; +} + +AXIS2_EXTERN derive_key_type_t AXIS2_CALL +rp_token_get_derivedkey_type( + rp_token_t * token, + const axutil_env_t * env) +{ + return token->derive_key; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_set_derivedkey_type( + rp_token_t * token, + const axutil_env_t * env, + derive_key_type_t derivedkey) +{ + token->derive_key = derivedkey; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_token_get_is_issuer_name( + rp_token_t * token, + const axutil_env_t * env) +{ + return token->is_issuer_name; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_set_is_issuer_name( + rp_token_t * token, + const axutil_env_t * env, + axis2_bool_t is_issuer_name) +{ + token->is_issuer_name = is_issuer_name; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +rp_token_get_claim( + rp_token_t * token, + const axutil_env_t * env) +{ + return token->claim; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_set_claim( + rp_token_t * token, + const axutil_env_t * env, + axiom_node_t *claim) +{ + token->claim = claim; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_token_increment_ref( + rp_token_t * token, + const axutil_env_t * env) +{ + token->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/transport_binding.c b/neethi/src/secpolicy/model/transport_binding.c new file mode 100644 index 0000000..cb84fff --- /dev/null +++ b/neethi/src/secpolicy/model/transport_binding.c @@ -0,0 +1,137 @@ +/* + * 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 <rp_transport_binding.h> + +struct rp_transport_binding_t +{ + rp_binding_commons_t *binding_commons; + rp_property_t *transport_token; + int ref; +}; + +AXIS2_EXTERN rp_transport_binding_t *AXIS2_CALL +rp_transport_binding_create( + const axutil_env_t * env) +{ + rp_transport_binding_t *transport_binding = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + transport_binding = (rp_transport_binding_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_transport_binding_t)); + + if(transport_binding == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + transport_binding->binding_commons = NULL; + transport_binding->transport_token = NULL; + transport_binding->ref = 0; + + return transport_binding; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_transport_binding_free( + rp_transport_binding_t * transport_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(transport_binding) + { + if(--(transport_binding->ref) > 0) + { + return; + } + if(transport_binding->binding_commons) + { + rp_binding_commons_free(transport_binding->binding_commons, env); + transport_binding->binding_commons = NULL; + } + if(transport_binding->transport_token) + { + rp_property_free(transport_binding->transport_token, env); + transport_binding->transport_token = NULL; + } + AXIS2_FREE(env->allocator, transport_binding); + } + + return; +} + +/* Implementations */ + +AXIS2_EXTERN rp_binding_commons_t *AXIS2_CALL +rp_transport_binding_get_binding_commons( + rp_transport_binding_t * transport_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return transport_binding->binding_commons; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_transport_binding_set_binding_commons( + rp_transport_binding_t * transport_binding, + const axutil_env_t * env, + rp_binding_commons_t * binding_commons) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, binding_commons, AXIS2_FAILURE); + + transport_binding->binding_commons = binding_commons; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN rp_property_t *AXIS2_CALL +rp_transport_binding_get_transport_token( + rp_transport_binding_t * transport_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, NULL); + + return transport_binding->transport_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_transport_binding_set_transport_token( + rp_transport_binding_t * transport_binding, + const axutil_env_t * env, + rp_property_t * transport_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, transport_token, AXIS2_FAILURE); + + rp_property_increment_ref(transport_token, env); + transport_binding->transport_token = transport_token; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_transport_binding_increment_ref( + rp_transport_binding_t * transport_binding, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + transport_binding->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/trust10.c b/neethi/src/secpolicy/model/trust10.c new file mode 100644 index 0000000..54d98c8 --- /dev/null +++ b/neethi/src/secpolicy/model/trust10.c @@ -0,0 +1,201 @@ +/* + * 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 <rp_trust10.h> + +struct rp_trust10_t +{ + axis2_bool_t must_support_client_challenge; + axis2_bool_t must_support_server_challenge; + axis2_bool_t require_client_entropy; + axis2_bool_t require_server_entropy; + axis2_bool_t must_support_issued_token; + int ref; +}; + +AXIS2_EXTERN rp_trust10_t *AXIS2_CALL +rp_trust10_create( + const axutil_env_t * env) +{ + rp_trust10_t *trust10 = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + trust10 = (rp_trust10_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_trust10_t)); + + if(trust10 == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + trust10->must_support_client_challenge = AXIS2_FALSE; + trust10->must_support_server_challenge = AXIS2_FALSE; + trust10->require_client_entropy = AXIS2_FALSE; + trust10->require_server_entropy = AXIS2_FALSE; + trust10->must_support_issued_token = AXIS2_FALSE; + trust10->ref = 0; + + return trust10; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_trust10_free( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(trust10) + { + if(--(trust10->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, trust10); + trust10 = NULL; + } + return; +} + +/* Implementations */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_trust10_get_must_support_client_challenge( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return trust10->must_support_client_challenge; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_trust10_set_must_support_client_challenge( + rp_trust10_t * trust10, + const axutil_env_t * env, + axis2_bool_t must_support_client_challenge) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_client_challenge, AXIS2_FAILURE); + trust10->must_support_client_challenge = must_support_client_challenge; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_trust10_get_must_support_server_challenge( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return trust10->must_support_server_challenge; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_trust10_set_must_support_server_challenge( + rp_trust10_t * trust10, + const axutil_env_t * env, + axis2_bool_t must_support_server_challenge) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_server_challenge, AXIS2_FAILURE); + trust10->must_support_server_challenge = must_support_server_challenge; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_trust10_get_require_client_entropy( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return trust10->require_client_entropy; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_trust10_set_require_client_entropy( + rp_trust10_t * trust10, + const axutil_env_t * env, + axis2_bool_t require_client_entropy) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, require_client_entropy, AXIS2_FAILURE); + trust10->require_client_entropy = require_client_entropy; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_trust10_get_require_server_entropy( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return trust10->require_server_entropy; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_trust10_set_require_server_entropy( + rp_trust10_t * trust10, + const axutil_env_t * env, + axis2_bool_t require_server_entropy) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, require_server_entropy, AXIS2_FAILURE); + trust10->require_server_entropy = require_server_entropy; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_trust10_get_must_support_issued_token( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return trust10->must_support_issued_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_trust10_set_must_support_issued_token( + rp_trust10_t * trust10, + const axutil_env_t * env, + axis2_bool_t must_support_issued_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_issued_token, AXIS2_FAILURE); + trust10->must_support_issued_token = must_support_issued_token; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_trust10_increment_ref( + rp_trust10_t * trust10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + trust10->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/ut.c b/neethi/src/secpolicy/model/ut.c new file mode 100644 index 0000000..867e5c1 --- /dev/null +++ b/neethi/src/secpolicy/model/ut.c @@ -0,0 +1,214 @@ +/* + * 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 <rp_username_token.h> +#include <rp_token.h> + +struct rp_username_token_t +{ + axis2_char_t *inclusion; + password_type_t password_type; + axis2_bool_t useUTprofile10; + axis2_bool_t useUTprofile11; + rp_token_t *token; + int ref; +}; + +AXIS2_EXTERN rp_username_token_t *AXIS2_CALL +rp_username_token_create( + const axutil_env_t * env) +{ + rp_username_token_t *username_token = NULL; + username_token = (rp_username_token_t *)AXIS2_MALLOC(env->allocator, + sizeof(rp_username_token_t)); + + if(!username_token) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] User name token creation failed. Insufficient memory"); + return NULL; + } + + username_token->token = rp_token_create(env); + if(!username_token->token) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] User name token creation failed."); + rp_username_token_free(username_token, env); + return NULL; + } + + username_token->inclusion = RP_INCLUDE_ALWAYS; + username_token->password_type = PASSWORD_PLAIN; + username_token->useUTprofile10 = AXIS2_TRUE; + username_token->useUTprofile11 = AXIS2_FALSE; + username_token->ref = 0; + + return username_token; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_username_token_free( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + if(username_token) + { + if(--(username_token->ref) > 0) + { + return; + } + + rp_token_free(username_token->token, env); + AXIS2_FREE(env->allocator, username_token); + username_token = NULL; + } +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_username_token_get_inclusion( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return username_token->inclusion; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_inclusion( + rp_username_token_t * username_token, + const axutil_env_t * env, + axis2_char_t * inclusion) +{ + AXIS2_PARAM_CHECK(env->error, inclusion, AXIS2_FAILURE); + username_token->inclusion = inclusion; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_username_token_get_useUTprofile10( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return username_token->useUTprofile10; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_useUTprofile10( + rp_username_token_t * username_token, + const axutil_env_t * env, + axis2_bool_t useUTprofile10) +{ + username_token->useUTprofile10 = useUTprofile10; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_username_token_get_useUTprofile11( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return username_token->useUTprofile10; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_useUTprofile11( + rp_username_token_t * username_token, + const axutil_env_t * env, + axis2_bool_t useUTprofile11) +{ + username_token->useUTprofile11 = useUTprofile11; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_increment_ref( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + username_token->ref++; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_username_token_get_issuer( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return rp_token_get_issuer(username_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_issuer( + rp_username_token_t * username_token, + const axutil_env_t * env, + axis2_char_t * issuer) +{ + return rp_token_set_issuer(username_token->token, env, issuer); +} + +AXIS2_EXTERN derive_key_type_t AXIS2_CALL +rp_username_token_get_derivedkey_type( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return rp_token_get_derivedkey_type(username_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_derivedkey_type( + rp_username_token_t * username_token, + const axutil_env_t * env, + derive_key_type_t derivedkey) +{ + return rp_token_set_derivedkey_type(username_token->token, env, derivedkey); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_username_token_get_is_issuer_name( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return rp_token_get_is_issuer_name(username_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_is_issuer_name( + rp_username_token_t * username_token, + const axutil_env_t * env, + axis2_bool_t is_issuer_name) +{ + return rp_token_set_is_issuer_name(username_token->token, env, is_issuer_name); +} + +AXIS2_EXTERN axiom_node_t *AXIS2_CALL +rp_username_token_get_claim( + rp_username_token_t * username_token, + const axutil_env_t * env) +{ + return rp_token_get_claim(username_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_username_token_set_claim( + rp_username_token_t * username_token, + const axutil_env_t * env, + axiom_node_t *claim) +{ + return rp_token_set_claim(username_token->token, env, claim); +} diff --git a/neethi/src/secpolicy/model/wss10.c b/neethi/src/secpolicy/model/wss10.c new file mode 100644 index 0000000..2ee451d --- /dev/null +++ b/neethi/src/secpolicy/model/wss10.c @@ -0,0 +1,178 @@ +/* + * 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 <rp_wss10.h> + +struct rp_wss10_t +{ + axis2_bool_t must_support_ref_key_identifier; + axis2_bool_t must_support_ref_issuer_serial; + axis2_bool_t must_support_ref_external_uri; + axis2_bool_t must_support_ref_embedded_token; + axis2_bool_t must_support_direct_reference; + int ref; +}; + +AXIS2_EXTERN rp_wss10_t *AXIS2_CALL +rp_wss10_create( + const axutil_env_t * env) +{ + rp_wss10_t *wss10 = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + wss10 = (rp_wss10_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_wss10_t)); + + if(wss10 == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + wss10->must_support_ref_key_identifier = AXIS2_FALSE; + wss10->must_support_ref_issuer_serial = AXIS2_FALSE; + wss10->must_support_ref_external_uri = AXIS2_FALSE; + wss10->must_support_ref_embedded_token = AXIS2_FALSE; + wss10->must_support_direct_reference = AXIS2_TRUE; + wss10->ref = 0; + + return wss10; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_wss10_free( + rp_wss10_t * wss10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(wss10) + { + if(--(wss10->ref) > 0) + { + return; + } + + AXIS2_FREE(env->allocator, wss10); + wss10 = NULL; + } + return; +} + +/* Implementations */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss10_get_must_support_ref_key_identifier( + rp_wss10_t * wss10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss10->must_support_ref_key_identifier; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss10_set_must_support_ref_key_identifier( + rp_wss10_t * wss10, + const axutil_env_t * env, + axis2_bool_t must_support_ref_key_identifier) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_key_identifier, AXIS2_FAILURE); + wss10->must_support_ref_key_identifier = must_support_ref_key_identifier; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss10_get_must_support_ref_issuer_serial( + rp_wss10_t * wss10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss10->must_support_ref_issuer_serial; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss10_set_must_support_ref_issuer_serial( + rp_wss10_t * wss10, + const axutil_env_t * env, + axis2_bool_t must_support_ref_issuer_serial) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_issuer_serial, AXIS2_FAILURE); + wss10->must_support_ref_issuer_serial = must_support_ref_issuer_serial; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss10_get_must_support_ref_external_uri( + rp_wss10_t * wss10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss10->must_support_ref_external_uri; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss10_set_must_support_ref_external_uri( + rp_wss10_t * wss10, + const axutil_env_t * env, + axis2_bool_t must_support_ref_external_uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_external_uri, AXIS2_FAILURE); + wss10->must_support_ref_external_uri = must_support_ref_external_uri; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss10_get_must_support_ref_embedded_token( + rp_wss10_t * wss10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss10->must_support_ref_embedded_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss10_set_must_support_ref_embedded_token( + rp_wss10_t * wss10, + const axutil_env_t * env, + axis2_bool_t must_support_ref_embedded_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_embedded_token, AXIS2_FAILURE); + wss10->must_support_ref_embedded_token = must_support_ref_embedded_token; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss10_increment_ref( + rp_wss10_t * wss10, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + wss10->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/wss11.c b/neethi/src/secpolicy/model/wss11.c new file mode 100644 index 0000000..552646c --- /dev/null +++ b/neethi/src/secpolicy/model/wss11.c @@ -0,0 +1,256 @@ +/* + * 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 <rp_wss11.h> + +struct rp_wss11_t +{ + axis2_bool_t must_support_ref_key_identifier; + axis2_bool_t must_support_ref_issuer_serial; + axis2_bool_t must_support_ref_external_uri; + axis2_bool_t must_support_ref_embedded_token; + axis2_bool_t must_support_ref_thumbprint; + axis2_bool_t must_support_ref_encryptedkey; + axis2_bool_t require_signature_confirmation; + axis2_bool_t must_support_direct_reference; + int ref; +}; + +AXIS2_EXTERN rp_wss11_t *AXIS2_CALL +rp_wss11_create( + const axutil_env_t * env) +{ + rp_wss11_t *wss11 = NULL; + + AXIS2_ENV_CHECK(env, NULL); + + wss11 = (rp_wss11_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_wss11_t)); + + if(wss11 == NULL) + { + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + wss11->must_support_ref_key_identifier = AXIS2_FALSE; + wss11->must_support_ref_issuer_serial = AXIS2_FALSE; + wss11->must_support_ref_external_uri = AXIS2_FALSE; + wss11->must_support_ref_embedded_token = AXIS2_FALSE; + wss11->must_support_ref_thumbprint = AXIS2_FALSE; + wss11->must_support_ref_encryptedkey = AXIS2_FALSE; + wss11->require_signature_confirmation = AXIS2_FALSE; + wss11->must_support_direct_reference = AXIS2_TRUE; + wss11->ref = 0; + + return wss11; + +} + +AXIS2_EXTERN void AXIS2_CALL +rp_wss11_free( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + + if(wss11) + { + if(--(wss11->ref) > 0) + { + return; + } + AXIS2_FREE(env->allocator, wss11); + wss11 = NULL; + } + return; +} + +/* Implementations */ +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_must_support_ref_key_identifier( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->must_support_ref_key_identifier; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_must_support_ref_key_identifier( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t must_support_ref_key_identifier) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_key_identifier, AXIS2_FAILURE); + wss11->must_support_ref_key_identifier = must_support_ref_key_identifier; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_must_support_ref_issuer_serial( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->must_support_ref_issuer_serial; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_must_support_ref_issuer_serial( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t must_support_ref_issuer_serial) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_issuer_serial, AXIS2_FAILURE); + wss11->must_support_ref_issuer_serial = must_support_ref_issuer_serial; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_must_support_ref_external_uri( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->must_support_ref_external_uri; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_must_support_ref_external_uri( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t must_support_ref_external_uri) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_external_uri, AXIS2_FAILURE); + wss11->must_support_ref_external_uri = must_support_ref_external_uri; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_must_support_ref_embedded_token( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->must_support_ref_embedded_token; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_must_support_ref_embedded_token( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t must_support_ref_embedded_token) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_embedded_token, AXIS2_FAILURE); + wss11->must_support_ref_embedded_token = must_support_ref_embedded_token; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_must_support_ref_thumbprint( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->must_support_ref_thumbprint; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_must_support_ref_thumbprint( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t must_support_ref_thumbprint) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_thumbprint, AXIS2_FAILURE); + wss11->must_support_ref_thumbprint = must_support_ref_thumbprint; + + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_must_support_ref_encryptedkey( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->must_support_ref_encryptedkey; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_must_support_ref_encryptedkey( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t must_support_ref_encryptedkey) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, must_support_ref_encryptedkey, AXIS2_FAILURE); + wss11->must_support_ref_encryptedkey = must_support_ref_encryptedkey; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_wss11_get_require_signature_confirmation( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FALSE); + + return wss11->require_signature_confirmation; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_set_require_signature_confirmation( + rp_wss11_t * wss11, + const axutil_env_t * env, + axis2_bool_t require_signature_confirmation) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + AXIS2_PARAM_CHECK(env->error, require_signature_confirmation, AXIS2_FAILURE); + wss11->require_signature_confirmation = require_signature_confirmation; + + return AXIS2_SUCCESS; + +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_wss11_increment_ref( + rp_wss11_t * wss11, + const axutil_env_t * env) +{ + AXIS2_ENV_CHECK(env, AXIS2_FAILURE); + wss11->ref++; + return AXIS2_SUCCESS; +} diff --git a/neethi/src/secpolicy/model/x509_token.c b/neethi/src/secpolicy/model/x509_token.c new file mode 100644 index 0000000..057af86 --- /dev/null +++ b/neethi/src/secpolicy/model/x509_token.c @@ -0,0 +1,231 @@ +/* + * 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 <rp_x509_token.h> + +struct rp_x509_token_t +{ + rp_token_t *token; + axis2_bool_t require_key_identifier_reference; + axis2_bool_t require_issuer_serial_reference; + axis2_bool_t require_embedded_token_reference; + axis2_bool_t require_thumb_print_reference; + axis2_char_t *token_version_and_type; + int ref; + +}; + +AXIS2_EXTERN rp_x509_token_t *AXIS2_CALL +rp_x509_token_create( + const axutil_env_t * env) +{ + rp_x509_token_t *x509_token = NULL; + x509_token = (rp_x509_token_t *)AXIS2_MALLOC(env->allocator, sizeof(rp_x509_token_t)); + + if(!x509_token) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, + "[neethi] X509 token assertion creation failed. Insufficient memory"); + AXIS2_ERROR_SET(env->error, AXIS2_ERROR_NO_MEMORY, AXIS2_FAILURE); + return NULL; + } + x509_token->require_key_identifier_reference = AXIS2_FALSE; + x509_token->require_issuer_serial_reference = AXIS2_FALSE; + x509_token->require_embedded_token_reference = AXIS2_FALSE; + x509_token->require_thumb_print_reference = AXIS2_FALSE; + x509_token->token_version_and_type = RP_WSS_X509_V3_TOKEN_10; + x509_token->ref = 0; + + x509_token->token = rp_token_create(env); + if(!x509_token->token) + { + AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[neethi] X509 token assertion creation failed."); + rp_x509_token_free(x509_token, env); + return NULL; + } + return x509_token; +} + +AXIS2_EXTERN void AXIS2_CALL +rp_x509_token_free( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + if(x509_token) + { + if(--(x509_token->ref) > 0) + { + return; + } + + rp_token_free(x509_token->token, env); + AXIS2_FREE(env->allocator, x509_token); + x509_token = NULL; + } +} + +/* Implementations */ + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_x509_token_get_inclusion( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return rp_token_get_inclusion(x509_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_inclusion( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + axis2_char_t * inclusion) +{ + return rp_token_set_inclusion(x509_token->token, env, inclusion); +} + +AXIS2_EXTERN derive_key_type_t AXIS2_CALL +rp_x509_token_get_derivedkey( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return rp_token_get_derivedkey_type(x509_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_derivedkey( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + derive_key_type_t derivedkeys) +{ + return rp_token_set_derivedkey_type(x509_token->token, env, derivedkeys); +} + +AXIS2_EXTERN derive_key_version_t AXIS2_CALL +rp_x509_token_get_derivedkey_version( + rp_x509_token_t *x509_token, + const axutil_env_t *env) +{ + return rp_token_get_derive_key_version(x509_token->token, env); +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_derivedkey_version( + rp_x509_token_t *x509_token, + const axutil_env_t *env, + derive_key_version_t version) +{ + return rp_token_set_derive_key_version(x509_token->token, env, version); +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_x509_token_get_require_key_identifier_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return x509_token->require_key_identifier_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_require_key_identifier_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + axis2_bool_t require_key_identifier_reference) +{ + x509_token->require_key_identifier_reference = require_key_identifier_reference; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_x509_token_get_require_issuer_serial_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return x509_token->require_issuer_serial_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_require_issuer_serial_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + axis2_bool_t require_issuer_serial_reference) +{ + x509_token->require_issuer_serial_reference = require_issuer_serial_reference; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_x509_token_get_require_embedded_token_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return x509_token->require_embedded_token_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_require_embedded_token_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + axis2_bool_t require_embedded_token_reference) +{ + x509_token->require_embedded_token_reference = require_embedded_token_reference; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_bool_t AXIS2_CALL +rp_x509_token_get_require_thumb_print_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return x509_token->require_thumb_print_reference; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_require_thumb_print_reference( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + axis2_bool_t require_thumb_print_reference) +{ + x509_token->require_thumb_print_reference = require_thumb_print_reference; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_char_t *AXIS2_CALL +rp_x509_token_get_token_version_and_type( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + return x509_token->token_version_and_type; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_set_token_version_and_type( + rp_x509_token_t * x509_token, + const axutil_env_t * env, + axis2_char_t * token_version_and_type) +{ + x509_token->token_version_and_type = token_version_and_type; + return AXIS2_SUCCESS; +} + +AXIS2_EXTERN axis2_status_t AXIS2_CALL +rp_x509_token_increment_ref( + rp_x509_token_t * x509_token, + const axutil_env_t * env) +{ + x509_token->ref++; + return AXIS2_SUCCESS; +} |