You are viewing a plain text version of this content. The canonical link for it is here.
Posted to rampart-dev@ws.apache.org by mi...@apache.org on 2007/12/16 15:48:08 UTC
svn commit: r604629 [2/2] - in
/webservices/rampart/scratch/c/trust/c/src/trust: Makefile.am claims.c
context.c entropy.c life_time.c rst.c rstr.c sts_client.c util.c
Modified: webservices/rampart/scratch/c/trust/c/src/trust/sts_client.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/trust/c/src/trust/sts_client.c?rev=604629&r1=604628&r2=604629&view=diff
==============================================================================
--- webservices/rampart/scratch/c/trust/c/src/trust/sts_client.c (original)
+++ webservices/rampart/scratch/c/trust/c/src/trust/sts_client.c Sun Dec 16 06:48:07 2007
@@ -24,28 +24,12 @@
struct trust_sts_client
{
- /*WS Trust version */
- int version;
-
- /* Key size */
- int key_size;
-
/* Algorithm Suite for Entropy */
rp_algorithmsuite_t *algo_suite;
/* Trust 1.0 Assertions */
rp_trust10_t *trust10;
- /* Requestor Entropy */
- axis2_char_t *requestor_entropy;
-
- axis2_char_t *appliesto;
-
- axis2_char_t *token_type;
-
- /* Time To Live */
- int ttl;
-
/* Issuer Address */
axis2_char_t *issuer_address;
@@ -67,13 +51,7 @@
sts_client = (trust_sts_client_t *) AXIS2_MALLOC(env->allocator, sizeof(trust_sts_client_t));
- sts_client->version = TRUST_VERSION_05_02;
- sts_client->key_size = 0;
- sts_client->ttl = 0;
- sts_client->requestor_entropy = NULL;
sts_client->trust10 = NULL;
- sts_client->appliesto = NULL;
- sts_client->token_type = NULL;
sts_client->home_dir = NULL;
sts_client->issuer_address = NULL;
sts_client->issuer_policy_location = NULL;
@@ -100,20 +78,20 @@
trust_sts_client_request_security_token(
trust_sts_client_t * sts_client,
const axutil_env_t * env,
- axis2_char_t * applies_to,
- axis2_char_t * token_type)
+ trust_context_t *trust_context)
{
axis2_svc_client_t *svc_client = NULL;
neethi_policy_t *issuer_policy = NULL;
neethi_policy_t *service_policy = NULL;
axis2_status_t status = AXIS2_SUCCESS;
+ axiom_node_t *rst_node = NULL;
axiom_node_t *return_node = NULL;
- sts_client->appliesto = applies_to;
- sts_client->token_type = token_type;
-
+ /*Action Logic*/
+ trust_rst_t *rst = NULL;
+ axis2_char_t *request_type = NULL;
+
issuer_policy = neethi_util_create_policy_from_file(env, sts_client->issuer_policy_location);
-
service_policy = neethi_util_create_policy_from_file(env, sts_client->service_policy_location);
if (!issuer_policy || !service_policy)
@@ -125,10 +103,26 @@
trust_sts_client_process_policies(sts_client, env, issuer_policy, service_policy);
}
- /* TODO : Fix action logic */
- svc_client =
- trust_sts_client_get_svc_client(sts_client, env,
- "http://schemas.xmlsoap.org/ws/2005/02/RST/issue");
+
+ /*Action Logic - RequestType - used for specify the requesting action*/
+ rst = trust_context_get_rst(env, trust_context);
+ if(NULL == rst)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RST is NULL: Created RST_CTX may not set to TrustContest");
+ return;
+ }
+
+ request_type = trust_rst_get_request_type(rst, env);
+
+ if(NULL == request_type)
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RST-RequestType is NOT set. RST MUST have a RequestType");
+ return;
+ }
+
+ svc_client =
+ trust_sts_client_get_svc_client(sts_client, env, request_type);
+
if (status == AXIS2_SUCCESS)
{
@@ -137,13 +131,17 @@
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "Policy setting failed.");
}
-
- return_node =
- axis2_svc_client_send_receive(svc_client, env,
- trust_sts_client_create_issue_request(sts_client, env,
- "/Issue",
- applies_to,
- token_type));
+ /*Building the RST */
+ rst_node = trust_context_build_rst_node(env, trust_context);
+ if(rst_node)
+ {
+ return_node = axis2_svc_client_send_receive(svc_client, env, rst_node);
+ }
+ else
+ {
+ AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI, "[trust] RST-Not send -> RST Node building failed");
+ return;
+ }
}
if (svc_client)
{
@@ -208,6 +206,8 @@
return AXIS2_SUCCESS;
}
+
+/*
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
trust_sts_client_create_issue_request(
trust_sts_client_t * sts_client,
@@ -223,10 +223,10 @@
rst_node = trust_util_create_rst_element(env, sts_client->version, NULL);
- /* Setting up the request type */
+
trust_util_create_request_type_element(env, sts_client->version, rst_node, request_type);
- /* Setting up the token type */
+
if (token_type)
{
trust_util_create_token_type_element(env, sts_client->version, rst_node, token_type);
@@ -263,35 +263,7 @@
return rst_node;
}
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL
-trust_sts_client_create_renew_request(
- trust_sts_client_t *sts_client,
- const axutil_env_t *env,
- axis2_char_t *token_type,
- axis2_char_t *request_type,
- axiom_node_t *renew_target,
- axis2_bool_t allow_postdating,
- trust_allow_t renew_allow,
- trust_ok_t ok_flag)
-{
- axiom_node_t *rst_node = NULL;
-
- rst_node = trust_util_create_rst_element(env, sts_client->version, NULL);
-
- if(token_type)
- {
- trust_util_create_token_type_element(env, sts_client->version, rst_node, token_type);
- }
- trust_util_create_request_type_element(env, sts_client->version, rst_node, request_type);
-
- if(renew_target)
- {
- trust_util_create_renew_traget_element(env, sts_client->version, rst_node, renew_target);
- }
- else
- {
- return NULL;
- }
+
if(allow_postdating)
{
@@ -302,229 +274,7 @@
return rst_node;
}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL
-tust_sts_client_create_cancel_request(
- trust_sts_client_t *sts_client,
- const axutil_env_t *env,
- axis2_char_t *request_type,
- axiom_node_t *cancel_target)
-{
- axiom_node_t *rst_node = NULL;
-
- rst_node = trust_util_create_rst_element(env, sts_client->version, NULL);
-
- trust_util_create_request_type_element(env, sts_client->version, rst_node, request_type);
-
- if(cancel_target)
- {
- if(!trust_util_create_cancel_target_element(env, sts_client->version, rst_node, cancel_target))
- {
- return NULL;
- }
- }
- else
- {
- return NULL;
- }
-
- return rst_node;
-}
-
-AXIS2_EXTERN axiom_node_t * AXIS2_CALL
-trust_sts_client_create_validate_request(
- trust_sts_client_t *sts_client,
- const axutil_env_t *env,
- axis2_char_t *token_type,
- axis2_char_t *request_type)
-{
- axiom_node_t *rst_node = NULL;
-
- rst_node = trust_util_create_rst_element(env, sts_client->version, NULL);
-
- if(token_type)
- {
- trust_util_create_token_type_element(env, sts_client->version, rst_node, token_type);
- }
-
- if(request_type)
- {
- trust_util_create_request_type_element(env, sts_client->version, rst_node, request_type);
- }
-
- return rst_node;
-}
-/* Process ISSUE RESPONSE */
-AXIS2_EXTERN trust_token_t *AXIS2_CALL
-trust_sts_client_process_issue_response(
- trust_sts_client_t * sts_client,
- const axutil_env_t * env,
- int wst_version,
- axiom_node_t * response_node,
- axiom_node_t * payload_sent)
-{
- /* Token */
- trust_token_t *token = NULL;
-
- /* RSTR */
- axiom_node_t *rstr_node = NULL;
- axiom_element_t *rstr_ele = NULL;
-
- axis2_char_t *wst_ns_uri = NULL;
-
- /* Attached Reference */
- axiom_node_t *attached_ref_node = NULL;
- axiom_element_t *attached_ref_ele = NULL;
- axutil_qname_t *attached_ref_qname = NULL;
- axiom_node_t *req_attached_ref_node = NULL;
-
- /* Unattached Reference */
- axiom_node_t *unattached_ref_node = NULL;
- axiom_element_t *unattached_ref_ele = NULL;
- axutil_qname_t *unattached_ref_qname = NULL;
- axiom_node_t *req_unattached_ref_node = NULL;
-
- /*Requsted Security Token */
- axiom_node_t *req_sec_token_node = NULL;
- axiom_element_t *req_sec_token_ele = NULL;
- axutil_qname_t *req_sec_token_qname = NULL;
- axiom_node_t *sec_token = NULL;
-
- /* Life Time */
- axiom_node_t *life_time_node = NULL;
- axiom_element_t *life_time_ele = NULL;
- axutil_qname_t *life_time_qname = NULL;
-
- rstr_node = response_node;
-
- if (TRUST_VERSION_05_12 == wst_version)
- {
- rstr_node = axiom_node_get_first_element(rstr_node, env);
- }
-
- wst_ns_uri = trust_util_get_wst_ns(env, wst_version);
- rstr_ele = axiom_node_get_data_element(rstr_node, env);
-
- /* Extract Attached Reference */
-
- attached_ref_qname =
- axutil_qname_create(env, TRUST_REQUESTED_ATTACHED_REFERENCE, wst_ns_uri, TRUST_WST);
-
- attached_ref_ele =
- axiom_element_get_first_child_with_qname(rstr_ele, env, attached_ref_qname, rstr_node,
- &attached_ref_node);
-
- if (attached_ref_ele)
- {
- req_attached_ref_node = axiom_node_get_first_element(attached_ref_node, env);
- }
-
- /* Extract unattached Reference */
- unattached_ref_qname =
- axutil_qname_create(env, TRUST_REQUESTED_UNATTACHED_REFERENCE, wst_ns_uri, TRUST_WST);
-
- unattached_ref_ele =
- axiom_element_get_first_child_with_qname(rstr_ele, env, unattached_ref_qname, rstr_node,
- &unattached_ref_node);
- if (unattached_ref_ele)
- {
- req_unattached_ref_node = axiom_node_get_first_element(unattached_ref_node, env);
- }
-
- /* Extract Requested Security Token */
- req_sec_token_qname =
- axutil_qname_create(env, TRUST_REQUESTED_SECURITY_TOKEN, wst_ns_uri, TRUST_WST);
- req_sec_token_ele =
- axiom_element_get_first_child_with_qname(rstr_ele, env, req_sec_token_qname, rstr_node,
- &req_sec_token_node);
-
- if (req_sec_token_node)
- {
- sec_token = axiom_node_get_first_element(req_sec_token_node, env);
- }
- else
- {
- /*Requsted Token Missing - Handle */
- }
-
- /* Extract Life Time */
- life_time_qname = axutil_qname_create(env, TRUST_LIFE_TIME, wst_ns_uri, TRUST_WST);
- life_time_ele =
- axiom_element_get_first_child_with_qname(rstr_ele, env, life_time_qname, rstr_node,
- &life_time_node);
-
- if (NULL == life_time_ele)
- {
- /* Handle NULL - life time ele */
- }
-
- /* TOKEN Creation */
- /* FIX id- NULL :-> ID should be computed here */
- token = trust_token_create(env, NULL, sec_token, life_time_node);
-
- return token;
-
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-trust_sts_client_find_identifier(
- trust_sts_client_t * sts_client,
- axiom_node_t * req_att_ref_node,
- axiom_node_t * req_unatt_ref_node,
- axiom_node_t * sec_token_node,
- const axutil_env_t * env)
-{
- axis2_char_t *id_str = NULL;
-
- if (req_att_ref_node)
- {
- id_str = trust_sts_client_get_id_from_str(sts_client, req_att_ref_node, env);
- }
- else if (req_unatt_ref_node)
- {
- id_str = trust_sts_client_get_id_from_str(sts_client, req_unatt_ref_node, env);
- }
- else
- {
- /* FIX : WSConstants based wsu:Id */
-
- }
- return id_str;
-}
-
-AXIS2_EXTERN axis2_char_t *AXIS2_CALL
-trust_sts_client_get_id_from_str(
- trust_sts_client_t * sts_client,
- axiom_node_t * ref_node,
- const axutil_env_t * env)
-{
- /*FIX : implementation requires WS.Consatants paramaters */
- return NULL;
-}
-
-AXIS2_EXTERN axis2_status_t AXIS2_CALL
-trust_sts_client_set_ttl(
- trust_sts_client_t * sts_client,
- const axutil_env_t * env,
- int ttl)
-{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
- AXIS2_PARAM_CHECK(env->error, ttl, AXIS2_FAILURE);
-
- sts_client->ttl = ttl;
-
- return AXIS2_SUCCESS;
-}
-
-AXIS2_EXTERN int AXIS2_CALL
-trust_sts_client_get_ttl(
- trust_sts_client_t * sts_client,
- const axutil_env_t * env)
-{
- AXIS2_ENV_CHECK(env, AXIS2_FAILURE);
-
- return sts_client->ttl;
-}
+ */
AXIS2_EXTERN axis2_status_t AXIS2_CALL
trust_sts_client_set_issuer_address(
Modified: webservices/rampart/scratch/c/trust/c/src/trust/util.c
URL: http://svn.apache.org/viewvc/webservices/rampart/scratch/c/trust/c/src/trust/util.c?rev=604629&r1=604628&r2=604629&view=diff
==============================================================================
--- webservices/rampart/scratch/c/trust/c/src/trust/util.c (original)
+++ webservices/rampart/scratch/c/trust/c/src/trust/util.c Sun Dec 16 06:48:07 2007
@@ -334,19 +334,26 @@
trust_util_create_requested_security_token_element(
const axutil_env_t * env,
int wst_version,
- axiom_node_t * parent_node)
+ axiom_node_t * parent_node,
+ axiom_node_t * sec_token_node)
{
axis2_char_t *wst_ns_uri = NULL;
axiom_node_t *requested_token_node = NULL;
axiom_element_t *requested_token_ele = NULL;
axiom_namespace_t *wst_ns = NULL;
+
wst_ns_uri = trust_util_get_wst_ns(env, wst_version);
wst_ns = axiom_namespace_create(env, wst_ns_uri, TRUST_WST);
requested_token_ele =
axiom_element_create(env, parent_node, TRUST_REQUESTED_SECURITY_TOKEN, wst_ns,
&requested_token_node);
+
+ if(sec_token_node)
+ {
+ axiom_node_add_child(requested_token_node, env, sec_token_node);
+ }
if (!requested_token_ele)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
@@ -610,6 +617,7 @@
{
type = axutil_stracat(env, wst_ns_uri, key_type);
status = axiom_element_set_text(key_type_ele, env, type, key_type_node);
+
if (status == AXIS2_FAILURE)
{
AXIS2_LOG_ERROR(env->log, AXIS2_LOG_SI,
@@ -623,13 +631,12 @@
}
AXIS2_EXTERN axiom_node_t *AXIS2_CALL
-trust_util_create_life_time_element(
- const axutil_env_t * env,
- axiom_node_t * parent_node,
- int wst_version,
- int ttl)
+ trust_util_create_life_time_element(
+ const axutil_env_t * env,
+ axiom_node_t * parent_node,
+ int wst_version,
+ int ttl)
{
- axis2_char_t *wst_ns_uri = NULL;
axiom_node_t *life_time_node = NULL;
axiom_node_t *created_node = NULL;
axiom_node_t *expires_node = NULL;
@@ -643,8 +650,7 @@
axutil_date_time_t *dt = NULL;
axis2_status_t status = AXIS2_SUCCESS;
- wst_ns_uri = trust_util_get_wst_ns(env, wst_version);
- wst_ns = axiom_namespace_create(env, wst_ns_uri, TRUST_WSU);
+ wst_ns = axiom_namespace_create(env, TRUST_WST_XMLNS, TRUST_WST);
wsu_ns = axiom_namespace_create(env, TRUST_WSU_XMLNS, TRUST_WSU);
life_time_ele =
@@ -1038,9 +1044,9 @@
switch (wst_version)
{
case TRUST_VERSION_05_02:
- return TRUST_WST_XMLNS_05_02;
+ return axutil_strdup(env, TRUST_WST_XMLNS_05_02);
case TRUST_VERSION_05_12:
- return TRUST_WST_XMLNS_05_12;
+ return axutil_strdup(env, TRUST_WST_XMLNS_05_12);
default:
return NULL;
}