So what are the challenges faced by different categories of systems when it comes to adaptation? What are the challenges in designing such systems? Following is a brief of such challenges categorized in terms of different types of software systems.
When random thoughts collide...



policy_content = {"encrypt"=> true,
"algorithm_suite" => "Basic256Rsa15",
"security_token_reference" => "IssuerSerial"}
policy = WSPolicy.new({"security" => policy_content}
security_options = {"private_key" => pvt_key,
"receiver_certificate" => rec_cert}
security_token = WSSecurityToken.new(security_options)
options = {"use_wsa" => true,
"policy" => policy,
"security_token" => security_token}
client = WSClient.new(options, LOG_FILE)
res_message = client.request(payload)
require 'wsf'
require 'rexml/document'
include WSO2::WSF
include WSO2::Util
#This is your pay load
req_payload = << XML
Hello World!
XML
begin
LOG_FILE = "security_sample.log"
ACTION = "http://php.axis2.org/samples/echoString"
END_POINT = "http://localhost:3000/encryption/encryption"
message_properties = {"to" => END_POINT,
"action" => ACTION}
#Load certificates and keys from the disk
rec_cert = WSUtil::ws_get_cert_from_file("../keys/bob_cert.cert")
pvt_key = WSUtil::ws_get_key_from_file("../keys/alice_key.pem")
#The payload or the body of the SOAP message
payload = WSMessage.new(req_payload,
nil,
message_properties)
#Create the security policy
policy_content = {"encrypt"=> true,
"algorithm_suite" => "Basic256Rsa15",
"security_token_reference" => "IssuerSerial"}
policy = WSPolicy.new({"security" => policy_content})
#Create the security token
security_options = {"private_key" => pvt_key,
"receiver_certificate" => rec_cert}
security_token = WSSecurityToken.new(security_options)
#Create option for the client
options = {"use_wsa" => true,
"policy" => policy,
"security_token" => security_token}
#Create a client instance
client = WSClient.new(options, LOG_FILE)
#Request
res_message = client.request(payload)
if not res_message.nil? then
puts "Received OM: "<< "\n" << res_message.payload_to_s << "\n\n"
puts "Client invocation SUCCESSFUL !!!"
else
puts "Client invocation FAILED !!!"
end
#If SOAP fault, print the details
rescue WSFault => wsfault
puts "Client invocation FAILED !!!\n"
puts "WSFault : "
puts wsfault.xml
puts "----------"
puts wsfault.code
puts "----------"
puts wsfault.reason
puts "----------"
puts wsfault.role
puts "----------"
puts wsfault.detail
puts "----------"
rescue => exception
puts "Client invocation FAILED !!!\n"
puts "Exception : " << exception
end

%./configure --with-apache2=/path/to/apache2 --prefix=/your/wsfc_home/directory
%make
%make install
LoadModule axis2_module modules/libmod_axis2.so
Axis2RepoPath /your/path/to/wsf/c/home
Axis2LogFile /tmp/apache_axis2.log
Axis2LogLevel debug
Axis2MaxLogFileSize 32
<Location /axis2>
SetHandler axis2_module
</Location>
%./httpd -k start
Listen 8080
http://localhost:8080/axis2/services
#!/bin/bash
ls -R | grep ":$" | sed -e 's/:$//' -e 's/[^-][^\/]*\//--/g' -e 's/^/ /' -e 's/-/|/'
% chmod +x /usr/local/bin/gr
% gr
.
|-core
|-data
|-handlers
|-omxmlsec
|---c14n
|---openssl
|---saml
|---tokens
|-secconv
|-trust
|-util
%./CA.pl -newca
%./CA.pl -sign
openssl req -x509 -nodes -days 365 -newkey rsa:1024 \
-keyout mykey.pem -out mycert.pem
Country Name (2 letter code) [AU]:
State or Province Name (full name) [Some-State]:
Locality Name (eg, city) []:
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (eg, YOUR name) []:
Email Address []:
%openssl genrsa -out x.key 1024
%openssl req -new -key x.key -out request.pem
-----BEGIN CERTIFICATE REQUEST-----
(Base64 encoded certificate request data)
-----END CERTIFICATE REQUEST-----
%openssl req -noout -text -in request.pem
%openssl req -noout -verify -key x.key -in request.pem

svc_client = axis2_svc_client_create(env, client_home);
options = axis2_options_create(env);
axis2_options_set_to(options, env, endpoint_ref);
axis2_options_set_action(options, env,"http://example.com/ws/2004/09/policy/Test/EchoRequest");
axis2_svc_client_set_options(svc_client, env, options);
policy = neethi_util_create_policy_from_file(env, policy_file_name);
axis2_svc_client_set_policy(svc_client, env, policy)
axis2_svc_client_engage_module(svc_client, env, "rampart");payload = build_om_payload_for_echo_svc(env);
ret_node = axis2_svc_client_send_receive(svc_client, env, payload);
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
SENDING DATA..
/* sending time = 10:58:13*/
---------------------
POST /axis2/services/echo HTTP/1.1
User-Agent: Axis2/C
Content-Length: 512
Content-Type: application/soap+xml;charset=UTF-8
Host: localhost:9090
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:To>http://localhost:9090/axis2/services/echo</wsa:To>
<wsa:Action>http://ws.apache.org/axis2/c/samples/echoString</wsa:Action>
<wsa:MessageID>02973ea8-bb4f-1dc1-2693-000000000000</wsa:MessageID>
</soapenv:Header>
<soapenv:Body>
<ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/services/echo">
<text>Hello World!</text>
</ns1:echoString>
</soapenv:Body>
</soapenv:Envelope>
= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
RETRIEVING DATA..
/* retrieving time = 10:58:13*/
/* time throughput = 0 sec(s)*/
---------------------
HTTP/1.1 200 OK
Content-Type: application/soap+xml;charset=UTF-8
Content-Length: 672
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsa:Action>http://ws.apache.org/axis2/c/samples/echoString</wsa:Action>
<wsa:From>
<wsa:Address>http://localhost:9090/axis2/services/echo</wsa:Address>
</wsa:From>
<wsa:MessageID>02983114-bb4f-1dc1-3856-000000000000</wsa:MessageID>
<wsa:RelatesTo wsa:RelationshipType="http://www.w3.org/2005/08/addressing/reply">02973ea8-bb4f-1dc1-2693-000000000000</wsa:RelatesTo>
</soapenv:Header>
<soapenv:Body>
<ns1:echoString xmlns:ns1="http://ws.apache.org/axis2/c/samples">
<text>Hello World!</text>
</ns1:echoString>
</soapenv:Body>
</soapenv:Envelope>


<?php
$reqPayloadString = <<<XML
<ns1:Privacy xmlns:ns1="http://privacy.abc.com/privacy"><Info>MyConfidentialInfo</Info></ns1:Privacy>
XML;
try {
/* 1. Load certificates*/
$rec_cert = ws_get_cert_from_file('your/path/to/certificate.cert');
$pvt_key = ws_get_key_from_file('your/path/to/private_key.pem');
/* 2. Create a new message request*/
$reqMessage = new WSMessage($reqPayloadString,
array("to"=>"http://privacy.abc.com/your/privacy_service.php",
"action" => "http://privacy.abc.com/privacy"));
/* 3. Create a security array to keep security properties*/
$sec_array = array("encrypt"=>TRUE,
"algorithmSuite" => "Basic256Rsa15",
"securityTokenReference" => "EmbeddedToken");
/* 4. Create a policy using the security array*/
$policy = new WSPolicy(array("security"=>$sec_array));
/* 5. Create a new security token*/
$sec_token = new WSSecurityToken(array("privateKey" => $pvt_key,
"receiverCertificate" => $rec_cert));
/* 6. Create a new web service client*/
$client = new WSClient(array("useWSA" => TRUE,
"policy" => $policy,
"securityToken" => $sec_token));
/* 7. Request*/
$resMessage = $client->request($reqMessage);
} catch (Exception $e) {
if ($e instanceof WSFault) {
printf("Soap Fault: %s\n", $e->Reason);
} else {
printf("Message = %s\n",$e->getMessage());
}
}
?>

