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 2008/02/07 05:07:39 UTC

svn commit: r619252 - in /webservices/rampart/trunk/c/samples: ./ client/ client/sts_client/ server/ server/saml_sts/

Author: milinda
Date: Wed Feb  6 20:07:38 2008
New Revision: 619252

URL: http://svn.apache.org/viewvc?rev=619252&view=rev
Log:
Adding trust sample from scratch to trunk. Also chaned the build script to work with current Axis2/c Trunk.

Added:
    webservices/rampart/trunk/c/samples/client/sts_client/
    webservices/rampart/trunk/c/samples/client/sts_client/Makefile.am
    webservices/rampart/trunk/c/samples/client/sts_client/client.c
    webservices/rampart/trunk/c/samples/client/sts_client/client.xml
    webservices/rampart/trunk/c/samples/client/sts_client/service.xml
    webservices/rampart/trunk/c/samples/server/saml_sts/
    webservices/rampart/trunk/c/samples/server/saml_sts/Makefile.am
    webservices/rampart/trunk/c/samples/server/saml_sts/issuer.c
    webservices/rampart/trunk/c/samples/server/saml_sts/saml_issuer.h
    webservices/rampart/trunk/c/samples/server/saml_sts/saml_skeleton.c
    webservices/rampart/trunk/c/samples/server/saml_sts/services.xml
Modified:
    webservices/rampart/trunk/c/samples/build.sh
    webservices/rampart/trunk/c/samples/client/Makefile.am
    webservices/rampart/trunk/c/samples/server/Makefile.am

Modified: webservices/rampart/trunk/c/samples/build.sh
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/build.sh?rev=619252&r1=619251&r2=619252&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/build.sh (original)
+++ webservices/rampart/trunk/c/samples/build.sh Wed Feb  6 20:07:38 2008
@@ -1,6 +1,6 @@
 #!/bin/bash
 ./autogen.sh
-./configure --prefix=${AXIS2C_HOME} --enable-static=no --with-axis2=${AXIS2C_HOME}/include/axis2-1.2
+./configure --prefix=${AXIS2C_HOME} --enable-static=no --with-axis2=${AXIS2C_HOME}/include/axis2-1.3.0
 make
 make install
 cd client/sec_echo

Modified: webservices/rampart/trunk/c/samples/client/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/client/Makefile.am?rev=619252&r1=619251&r2=619252&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/client/Makefile.am (original)
+++ webservices/rampart/trunk/c/samples/client/Makefile.am Wed Feb  6 20:07:38 2008
@@ -1,3 +1,3 @@
 TESTS =
-SUBDIRS = sec_echo
+SUBDIRS = sec_echo sts_client
 

Added: webservices/rampart/trunk/c/samples/client/sts_client/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/client/sts_client/Makefile.am?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/client/sts_client/Makefile.am (added)
+++ webservices/rampart/trunk/c/samples/client/sts_client/Makefile.am Wed Feb  6 20:07:38 2008
@@ -0,0 +1,27 @@
+prgbindir=$(prefix)/bin/samples/rampart/client/sts_client
+prgbin_PROGRAMS = sts_client 
+datadir=$(prefix)/bin/samples/rampart/client/sts_client
+data_DATA= client.xml service.xml
+sts_client_SOURCES = client.c 
+
+sts_client_LDADD   = $(LDFLAGS) \
+                    -L$(AXIS2C_HOME)/lib \
+		    -L$(AXIS2C_HOME)/modules/rampart \	
+		    -lmod_rampart \
+		    -ltrust \
+					-laxutil \
+                    -laxis2_axiom \
+					-lneethi \
+                    -laxis2_engine \
+                    -laxis2_parser \
+                    -lpthread \
+                    -laxis2_http_sender \
+                    -laxis2_http_receiver \
+                    $(GUTHTHILA_LIBS) \
+                    $(LIBXML2_LIBS)
+
+INCLUDES = @AXIS2INC@ \
+		   -I$(AXIS2C_HOME)/include \
+            -I ../../../include 
+
+EXTRA_DIST = client.xml service.xml

Added: webservices/rampart/trunk/c/samples/client/sts_client/client.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/client/sts_client/client.c?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/client/sts_client/client.c (added)
+++ webservices/rampart/trunk/c/samples/client/sts_client/client.c Wed Feb  6 20:07:38 2008
@@ -0,0 +1,101 @@
+#include <trust_sts_client.h>
+#include <trust_context.h>
+#include <trust_rst.h>
+#include <trust_rstr.h>
+#include <axutil_env.h>
+#include <rampart_constants.h>
+#include <neethi_util.h>
+#include <neethi_policy.h>
+
+int main(
+    int argc, 
+    char **argv)
+{
+    trust_sts_client_t *sts_client = NULL;
+    const axutil_env_t *env = NULL;
+    const axis2_char_t *address = NULL;
+    const axis2_char_t *client_home = NULL;
+    
+    axis2_char_t *file_name = NULL;
+    axis2_char_t *file_name2 = NULL;
+    
+    axis2_char_t *appliesto = "http://oasis.open.org";
+    axis2_char_t *token = "oasis:names:tc:SAML:1.0:assertion";
+    axis2_char_t *request_type = "http://schemas.xmlsoap.org/ws/2005/02/RST/Issue";
+
+    trust_context_t *trust_ctx = NULL;
+    trust_rst_t *rst = NULL;
+	
+
+    /* Set up the environment */
+    env = axutil_env_create_all("sts.log", AXIS2_LOG_LEVEL_TRACE);
+
+    /* Set end point reference of echo service */
+    address = "http://localhost:9090/axis2/services/saml_sts";
+    client_home = "/home/milinda/Projects/axis2c/deploy/client_repo";
+    
+    file_name = "./client.xml";
+    file_name2 = "./service.xml";
+    /*http://131.107.72.15/Security_Federation_SecurityTokenService_Indigo/Asymmetric.svc*/
+    
+    sts_client = trust_sts_client_create(env);
+   
+
+    trust_sts_client_set_home_dir(sts_client, env, client_home);
+    trust_sts_client_set_issuer_address(sts_client, env, address);
+    trust_sts_client_set_issuer_policy_location(sts_client, env, file_name);
+    trust_sts_client_set_service_policy_location(sts_client, env, file_name2);
+    
+    trust_ctx = trust_context_create(env);
+    rst = trust_rst_create(env);
+    trust_rst_set_wst_ns_uri(rst, env, "http://schemas.xmlsoap.org/ws/2005/02/trust");
+    trust_rst_set_token_type(rst, env, token);
+    trust_rst_set_appliesto(rst, env, appliesto);
+    trust_rst_set_request_type(rst, env, request_type);
+
+    trust_context_set_rst(env, trust_ctx, rst);
+
+    trust_sts_client_request_security_token(sts_client, env, trust_ctx);
+
+
+	/*Acquire Sec Token*/
+	if(trust_context_get_rstr(env, trust_ctx))
+	{
+		if(trust_rstr_get_requested_security_token(
+					trust_context_get_rstr(env, trust_ctx),
+					env))
+		{
+			printf("\n\nReceived Sec Token : %s\n",
+					axiom_node_to_string(trust_rstr_get_requested_security_token(
+							trust_context_get_rstr(env, trust_ctx),
+							env), env)
+					);
+		}
+	}
+    
+    trust_sts_client_free(sts_client, env);
+    
+	return 0;
+}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+

Added: webservices/rampart/trunk/c/samples/client/sts_client/client.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/client/sts_client/client.xml?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/client/sts_client/client.xml (added)
+++ webservices/rampart/trunk/c/samples/client/sts_client/client.xml Wed Feb  6 20:07:38 2008
@@ -0,0 +1,42 @@
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+    <wsp:ExactlyOne>
+        <wsp:All>
+            <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <wsp:Policy>
+                    <sp:InitiatorToken>
+                        <wsp:Policy>
+                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                                <wsp:Policy>
+                                    <sp:WssX509V3Token10/>
+                                </wsp:Policy>
+                            </sp:X509Token>
+                        </wsp:Policy>
+                    </sp:InitiatorToken>
+                    <sp:RecipientToken>
+                        <wsp:Policy>
+                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+                                <wsp:Policy>
+                                    <sp:WssX509V3Token10/>
+                                </wsp:Policy>
+                            </sp:X509Token>
+                        </wsp:Policy>
+                    </sp:RecipientToken>
+					<sp:AlgorithmSuite>
+                        <wsp:Policy>
+                            <sp:Basic256Rsa15/>
+                        </wsp:Policy>
+                    </sp:AlgorithmSuite>
+					<sp:Layout>
+                        <wsp:Policy>
+                            <sp:Strict/>
+                        </wsp:Policy>
+                    </sp:Layout>
+                    <sp:IncludeTimestamp/>
+                </wsp:Policy>
+            </sp:AsymmetricBinding>
+            <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+                <rampc:TimeToLive>360</rampc:TimeToLive>
+            </rampc:RampartConfig>
+        </wsp:All>
+    </wsp:ExactlyOne>
+</wsp:Policy>

Added: webservices/rampart/trunk/c/samples/client/sts_client/service.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/client/sts_client/service.xml?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/client/sts_client/service.xml (added)
+++ webservices/rampart/trunk/c/samples/client/sts_client/service.xml Wed Feb  6 20:07:38 2008
@@ -0,0 +1,77 @@
+<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+    <wsp:ExactlyOne>
+        <wsp:All>
+            <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <wsp:Policy>
+                    <sp:InitiatorToken>
+                        <wsp:Policy>
+                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                                <wsp:Policy>
+                                    <sp:WssX509V3Token10/>
+                                </wsp:Policy>
+                            </sp:X509Token>
+                        </wsp:Policy>
+                    </sp:InitiatorToken>
+                    <sp:RecipientToken>
+                        <wsp:Policy>
+                            <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+                                <wsp:Policy>
+                                    <sp:WssX509V3Token10/>
+                                </wsp:Policy>
+                            </sp:X509Token>
+                        </wsp:Policy>
+                    </sp:RecipientToken>
+                    <sp:AlgorithmSuite>
+                        <wsp:Policy>
+                            <sp:Basic256Rsa15/>
+                        </wsp:Policy>
+                    </sp:AlgorithmSuite>
+                    <sp:Layout>
+                        <wsp:Policy>
+                            <sp:Strict/>
+                        </wsp:Policy>
+                    </sp:Layout>
+                    <sp:IncludeTimestamp/>
+                    <sp:EncryptSignature/>
+                    <sp:EncryptBeforeSigning/>
+                </wsp:Policy>
+            </sp:AsymmetricBinding>
+            <sp:SignedSupportingTokens xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+            <wsp:Policy>
+                <sp:UsernameToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Always"/>
+            </wsp:Policy>
+            </sp:SignedSupportingTokens>
+            <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <wsp:Policy>
+                    <sp:MustSupportRefKeyIdentifier/>
+                    <sp:MustSupportRefEmbeddedToken/>
+                    <sp:MustSupportRefIssuerSerial/>
+                </wsp:Policy>
+            </sp:Wss10>
+			<sp:Trust10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+				<wsp:Policy>
+					<sp:MustSupportIssuedTokens/>
+					<sp:RequireClientEntropy/>
+					<sp:RequireServerEntropy/>
+				</wsp:Policy>
+			</sp:Trust10>
+            <sp:EncryptedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <sp:Body/>
+            </sp:EncryptedParts>
+            <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                <sp:Body/>
+                <sp:Header Namespace="http://www.w3.org/2005/08/addressing"/>
+            </sp:SignedParts>
+            <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+                <rampc:User>Alice</rampc:User>
+                <rampc:TimeToLive>360</rampc:TimeToLive>
+                <rampc:EncryptionUser>a</rampc:EncryptionUser>
+                <rampc:PasswordType>Digest</rampc:PasswordType>
+                <rampc:PasswordCallbackClass>AXIS2C_HOME/bin/samples/rampart/callback/libpwcb.so</rampc:PasswordCallbackClass>
+                <rampc:ReceiverCertificate>AXIS2C_HOME/bin/samples/rampart/keys/ahome/bob_cert.cert</rampc:ReceiverCertificate>
+                <rampc:Certificate>AXIS2C_HOME/bin/samples/rampart/keys/ahome/alice_cert.cert</rampc:Certificate>
+                <rampc:PrivateKey>AXIS2C_HOME/bin/samples/rampart/keys/ahome/alice_key.pem</rampc:PrivateKey>
+            </rampc:RampartConfig>
+        </wsp:All>
+    </wsp:ExactlyOne>
+</wsp:Policy>

Modified: webservices/rampart/trunk/c/samples/server/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/server/Makefile.am?rev=619252&r1=619251&r2=619252&view=diff
==============================================================================
--- webservices/rampart/trunk/c/samples/server/Makefile.am (original)
+++ webservices/rampart/trunk/c/samples/server/Makefile.am Wed Feb  6 20:07:38 2008
@@ -1,5 +1,5 @@
 samplesdir=$(prefix)/samples/server
 #SUBDIRS = sec_echo manuf
-SUBDIRS = sec_echo 
+SUBDIRS = sec_echo saml_sts
 #EXTRA_DIST = axis2.xml axis2.log
 #samples_DATA=  Makefile.am Makefile.in

Added: webservices/rampart/trunk/c/samples/server/saml_sts/Makefile.am
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/server/saml_sts/Makefile.am?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/server/saml_sts/Makefile.am (added)
+++ webservices/rampart/trunk/c/samples/server/saml_sts/Makefile.am Wed Feb  6 20:07:38 2008
@@ -0,0 +1,20 @@
+prglibdir=$(prefix)/services/saml_sts
+samplesdir=$(prefix)/samples/server/saml_sts
+prglib_LTLIBRARIES = libsaml_sts.la
+samples_DATA=issuer.c saml_skeleton.c saml_issuer.h services.xml Makefile.am 
+prglib_DATA= services.xml
+EXTRA_DIST = services.xml saml_issuer.h 
+noinst_HEADERS = saml_issuer.h 
+SUBDIRS =
+libsaml_sts_la_SOURCES = issuer.c saml_skeleton.c
+libsaml_sts_la_LIBADD   = $(LDFLAGS) \
+                    -L$(AXIS2C_HOME)/lib \
+                    -L$(AXIS2C_HOME)/modules/rampart \
+		    -lmod_rampart \
+		    -lsaml \
+		    -ltrust	
+
+
+INCLUDES = @AXIS2INC@ \
+	-I$(AXIS2C_HOME)/include \
+	            -I ../../../include

Added: webservices/rampart/trunk/c/samples/server/saml_sts/issuer.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/server/saml_sts/issuer.c?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/server/saml_sts/issuer.c (added)
+++ webservices/rampart/trunk/c/samples/server/saml_sts/issuer.c Wed Feb  6 20:07:38 2008
@@ -0,0 +1,156 @@
+/*
+ * 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 "saml_issuer.h"
+
+#include <axis2_op_ctx.h>
+#include <axis2_msg_ctx.h>
+
+axiom_node_t *
+create_saml_token(axutil_env_t *env);
+
+saml_condition_t *
+create_condition(axutil_env_t *env);
+
+saml_stmt_t *
+create_auth_statement(axutil_env_t *env);
+
+saml_auth_binding_t *
+create_autherity_binding(axutil_env_t *env);
+
+saml_subject_t * 
+create_subject(axutil_env_t *env);
+
+axiom_node_t *axis2_saml_issuer_issue(
+    const axutil_env_t * env, 
+    trust_context_t *trust_ctx)
+{
+    axis2_char_t *token_type = NULL;
+    axiom_node_t *issued_saml_token = NULL;    
+    axiom_node_t *rstr_node = NULL;
+    axiom_node_t *requested_sec_token_node = NULL;
+
+	trust_rst_t *rst = NULL;	/*Created RST Context*/
+	trust_rstr_t *rstr = NULL;	/*Used for Creating RSTR*/
+    
+	rst = trust_context_get_rst(env, trust_ctx);
+	
+
+    token_type = trust_rst_get_token_type(rst, env);
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] token type %s..!", token_type);
+    
+    if (axutil_strcmp(token_type, SAML_TOKEN))
+    {
+        AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] token type not equal..!");
+        return NULL;
+    }
+    
+    rstr = trust_rstr_create(env);
+    
+	
+	
+    issued_saml_token = create_saml_token(env);	
+	trust_rstr_set_requested_security_token(rstr, env, issued_saml_token);
+    trust_rstr_set_wst_ns_uri(rstr, env, "http://schemas.xmlsoap.org/ws/2005/02/trust");
+	trust_rstr_set_requested_proof_token(rstr, env, trust_util_create_random_session_key_proof_token_element(env, 
+				"http://schemas.xmlsoap.org/ws/2005/02/trust")
+			);
+
+	trust_context_set_rstr(env, trust_ctx, rstr);
+	rstr_node = trust_context_build_rstr_node(env, trust_ctx);
+   	
+    return rstr_node;
+}
+
+axiom_node_t *
+create_saml_token(axutil_env_t *env)
+{
+	axutil_date_time_t *time = NULL;
+	saml_assertion_t *assertion = NULL;
+	axiom_node_t *node = NULL;
+	time = axutil_date_time_create(env);
+	assertion = saml_assertion_create(env);
+	if (assertion)	
+	{
+		saml_assertion_set_minor_version(assertion, env, 1);		
+		saml_assertion_set_issue_instant(assertion, env, time);
+		saml_assertion_set_issuer(assertion, env, "http://ws.apache.org/rampart/c");	
+		saml_assertion_add_condition(assertion, env, create_condition(env));
+		saml_assertion_set_not_before(assertion, env, axutil_date_time_create(env));
+		saml_assertion_add_statement(assertion, env, create_auth_statement(env));
+	}	
+	node = saml_assertion_to_om(assertion, NULL, env);	 
+	saml_assertion_free(assertion, env);
+	return node;
+}
+
+saml_condition_t *
+create_condition(axutil_env_t *env)
+{
+	saml_audi_restriction_cond_t *arc = NULL;
+	saml_condition_t *condition = AXIS2_MALLOC(env->allocator, sizeof(saml_condition_t));	
+	arc = saml_audi_restriction_cond_create(env);
+	saml_audi_restriction_cond_add_audience(arc, env, "www.samle.com");	
+	return condition;
+}
+
+saml_stmt_t *
+create_auth_statement(axutil_env_t *env)
+{
+	saml_auth_stmt_t *a_stmt = NULL;	
+	saml_stmt_t *stmt = saml_stmt_create(env);
+	a_stmt = saml_auth_stmt_create(env);
+	saml_stmt_set_stmt(stmt, env, a_stmt, SAML_STMT_AUTHENTICATIONSTATEMENT);
+
+	saml_auth_stmt_set_auth_method(a_stmt, env, SAML_AUTH_METHOD_URI_PASSWORD);
+	saml_auth_stmt_set_auth_instant(a_stmt, env, axutil_date_time_create(env));
+	
+	saml_auth_stmt_set_subject(a_stmt, env, create_subject(env));	
+	saml_auth_stmt_set_subject_dns(a_stmt, env,  "192.148.5.8");
+	saml_auth_stmt_set_subject_ip(a_stmt, env,  "128.5.6.4");
+	saml_auth_stmt_add_auth_binding(a_stmt, env, create_autherity_binding(env));
+	return stmt;	
+}
+
+saml_auth_binding_t *
+create_autherity_binding(axutil_env_t *env)
+{
+	saml_auth_binding_t *bind = NULL;
+	bind = saml_auth_binding_create(env);
+	saml_auth_binding_set_authority_kind(bind, env, "abc:aa:aa");
+	saml_auth_binding_set_binding(bind, env, "SOAP");
+	saml_auth_binding_set_location(bind, env, "http://myhome.com/sevices/echo");
+	return bind;
+}
+
+saml_subject_t *
+create_subject(axutil_env_t *env)
+{
+	saml_subject_t *subject = NULL;
+	saml_named_id_t *id = NULL;		
+	subject = saml_subject_create(env);
+	
+	id = saml_named_id_create(env);
+	saml_named_id_set_name(id, env, "Computer Science & Engineering Department");
+	saml_named_id_set_format(id, env, SAML_EMAIL_ADDRESS);
+	saml_named_id_set_name_qualifier(id, env, "University of Moratuwa");
+	saml_subject_set_named_id(subject, env, id);
+
+	saml_subject_add_confirmation(subject, env, SAML_SUB_CONFIRMATION_ARTIFACT);
+	saml_subject_add_confirmation(subject, env, SAML_SUB_CONFIRMATION_BEARER);	
+	return subject;
+}

Added: webservices/rampart/trunk/c/samples/server/saml_sts/saml_issuer.h
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/server/saml_sts/saml_issuer.h?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/server/saml_sts/saml_issuer.h (added)
+++ webservices/rampart/trunk/c/samples/server/saml_sts/saml_issuer.h Wed Feb  6 20:07:38 2008
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef SAML_ISSUER_H
+#define SAML_ISSUER_H
+
+#include <axis2_svc_skeleton.h>
+#include <axutil_log_default.h>
+#include <axutil_error_default.h>
+#include <axiom_text.h>
+#include <axiom_node.h>
+#include <axiom_element.h>
+#include <trust_context.h>
+#include <trust_rst.h>
+#include <trust_rstr.h>
+#include <saml.h>
+
+#define SAML_TOKEN		"oasis:names:tc:SAML:1.0:assertion"
+
+axiom_node_t *axis2_saml_issuer_issue(
+    const axutil_env_t * env, 
+    trust_context_t *trust_ctx);
+
+#endif                          

Added: webservices/rampart/trunk/c/samples/server/saml_sts/saml_skeleton.c
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/server/saml_sts/saml_skeleton.c?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/server/saml_sts/saml_skeleton.c (added)
+++ webservices/rampart/trunk/c/samples/server/saml_sts/saml_skeleton.c Wed Feb  6 20:07:38 2008
@@ -0,0 +1,155 @@
+/*
+ * 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 <axis2_svc_skeleton.h>
+#include "saml_issuer.h"
+#include <axutil_array_list.h>
+#include <axis2_op_ctx.h>
+#include <axis2_msg_ctx.h>
+#include <axis2_const.h>
+#include <trust_context.h>
+#include <trust_rst.h>
+#include <trust_rstr.h>
+
+#include <stdio.h>
+
+int AXIS2_CALL saml_issuer_free(
+    axis2_svc_skeleton_t *svc_skeleton,
+    const axutil_env_t *env);
+
+axiom_node_t *AXIS2_CALL saml_issuer_invoke(
+    axis2_svc_skeleton_t *svc_skeleton,
+    const axutil_env_t *env,
+    axiom_node_t *node,
+    axis2_msg_ctx_t *msg_ctx);
+
+int AXIS2_CALL saml_issuer_init(
+    axis2_svc_skeleton_t *svc_skeleton,
+    const axutil_env_t *env);
+
+axiom_node_t * AXIS2_CALL
+saml_issuer_on_fault(
+        axis2_svc_skeleton_t *svc_skel,
+        const axutil_env_t *env,
+        axiom_node_t *node);
+
+static const axis2_svc_skeleton_ops_t saml_issuer_svc_skeleton_ops_var = {
+    saml_issuer_init,
+    saml_issuer_invoke,
+    saml_issuer_on_fault,
+    saml_issuer_free
+};
+
+AXIS2_EXTERN axis2_svc_skeleton_t *AXIS2_CALL
+axis2_saml_issuer_create(
+    const axutil_env_t *env)
+{
+    axis2_svc_skeleton_t *svc_skeleton = NULL;
+    svc_skeleton = AXIS2_MALLOC(env->allocator, sizeof(axis2_svc_skeleton_t));
+    svc_skeleton->ops = &saml_issuer_svc_skeleton_ops_var;
+    svc_skeleton->func_array = NULL;
+    return svc_skeleton;
+}
+
+int AXIS2_CALL
+saml_issuer_init(
+    axis2_svc_skeleton_t *svc_skeleton,
+    const axutil_env_t *env)
+{
+    return AXIS2_SUCCESS;
+}
+
+int AXIS2_CALL
+saml_issuer_free(
+    axis2_svc_skeleton_t *svc_skeleton,
+    const axutil_env_t *env)
+{
+    if (svc_skeleton)
+    {
+        AXIS2_FREE(env->allocator, svc_skeleton);
+        svc_skeleton = NULL;
+    }
+    return AXIS2_SUCCESS;
+}
+
+axiom_node_t *AXIS2_CALL
+saml_issuer_invoke(
+    axis2_svc_skeleton_t *svc_skeleton,
+    const axutil_env_t *env,
+    axiom_node_t *node,
+    axis2_msg_ctx_t *msg_ctx)
+{  
+    axis2_msg_ctx_t *in_msg_ctx = NULL;
+    axis2_op_ctx_t *op_ctx = NULL;
+    
+	trust_context_t *trust_ctx = NULL;
+	    
+	printf("RST Received\n");
+    op_ctx = axis2_msg_ctx_get_op_ctx(msg_ctx, env);
+    in_msg_ctx = axis2_op_ctx_get_msg_ctx(op_ctx, env, AXIS2_WSDL_MESSAGE_LABEL_IN);
+    
+    AXIS2_LOG_DEBUG(env->log, AXIS2_LOG_SI, "[sts] create data..!");
+
+	trust_ctx = trust_context_create(env);/*Trust Version is passed */
+	
+
+	/*Populating RST*/
+	if(AXIS2_FAILURE == trust_context_process_rst(env, trust_ctx, in_msg_ctx))
+	{
+		printf("RST Processing Failed!\n");
+	}
+
+		
+
+    
+    return axis2_saml_issuer_issue(env, trust_ctx);  
+}
+
+axiom_node_t * AXIS2_CALL
+saml_issuer_on_fault(
+        axis2_svc_skeleton_t *svc_skel,
+        const axutil_env_t *env,
+        axiom_node_t *node)
+{
+    return NULL;
+}
+
+AXIS2_EXPORT int
+axis2_get_instance(
+    struct axis2_svc_skeleton **inst,
+    const axutil_env_t * env)
+{
+    *inst = axis2_saml_issuer_create(env);
+    if (!(*inst))
+    {
+        return AXIS2_FAILURE;
+    }
+    return AXIS2_SUCCESS;
+}
+
+AXIS2_EXPORT int
+axis2_remove_instance(
+    axis2_svc_skeleton_t *inst,
+    const axutil_env_t *env)
+{
+    axis2_status_t status = AXIS2_FAILURE;
+    if (inst)
+    {
+        status = AXIS2_SVC_SKELETON_FREE(inst, env);
+    }
+    return status;
+}

Added: webservices/rampart/trunk/c/samples/server/saml_sts/services.xml
URL: http://svn.apache.org/viewvc/webservices/rampart/trunk/c/samples/server/saml_sts/services.xml?rev=619252&view=auto
==============================================================================
--- webservices/rampart/trunk/c/samples/server/saml_sts/services.xml (added)
+++ webservices/rampart/trunk/c/samples/server/saml_sts/services.xml Wed Feb  6 20:07:38 2008
@@ -0,0 +1,51 @@
+<service name="sts">
+    <parameter name="ServiceClass" locked="xsd:false">saml_sts</parameter>
+
+   <description>
+        This is a testing service , to test the system is working or not
+   </description>
+    <module ref="rampart"/>
+
+    <operation name="issue">
+            <!--messageReceiver class="axis2_receivers" /-->
+            <parameter name="wsamapping" >http://schemas.xmlsoap.org/ws/2005/02/RST/Issue</parameter>
+    </operation>
+ <wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
+        <wsp:ExactlyOne>
+            <wsp:All>
+                <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+                    <wsp:Policy>
+                        <sp:InitiatorToken>
+                            <wsp:Policy>
+                                <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+                                    <wsp:Policy>
+                                        <sp:WssX509V3Token10/>
+                                    </wsp:Policy>
+                                </sp:X509Token>
+                            </wsp:Policy>
+                        </sp:InitiatorToken>
+                        <sp:RecipientToken>
+                            <wsp:Policy>
+                                <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+                                    <wsp:Policy>
+                                        <sp:WssX509V3Token10/>
+                                    </wsp:Policy>
+                                </sp:X509Token>
+                            </wsp:Policy>
+                        </sp:RecipientToken>
+                        <sp:Layout>
+                            <wsp:Policy>
+                                <sp:Strict/>
+                            </wsp:Policy>
+                        </sp:Layout>
+                        <sp:IncludeTimestamp/>
+                    </wsp:Policy>
+                </sp:AsymmetricBinding>
+                <rampc:RampartConfig xmlns:rampc="http://ws.apache.org/rampart/c/policy">
+                    <!--rampc:TimeToLive>360</rampc:TimeToLive-->
+                </rampc:RampartConfig>
+            </wsp:All>
+        </wsp:ExactlyOne>
+    </wsp:Policy>
+
+</service>