node.js + XACML wso2is


cd WSO2IS_HOME
subl wso2is-4.5.0/repository/conf/carbon.xml
HideAdminServiceWSDLs -> false

./bin/wso2server.sh

npm install soap
mkdir wso2is-nodejs
cd wso2is-nodejs/
subl soap-clinet.js

process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0';

var soap = require('soap');
var url = 'https://localhost:9444/services/EntitlementService?wsdl';
var args = {subject:'admin',
resource:'http://localhost:9766/services/RestService/POST',
action:'POST'
};
soap.createClient(url, function(err, client) {
client.setSecurity(new soap.BasicAuthSecurity('admin', 'admin'));
client.getDecisionByAttributes(args, function(err, result) {
console.log(result.statusCode);
console.log(result.body);
});
});

node soap-clinet.js

200
<Response xmlns="urn:oasis:names:tc:xacml:3.0:core:schema:wd-17"><Result><Decision>Permit</Decision><Status><StatusCode Value="urn:oasis:names:tc:xacml:1.0:status:ok"/></Status></Result></Response>

Advertisements

node.js + cassandra

// install cassandra from http://www.datastax.com/documentation/cassandra/2.1/cassandra/install/install_cassandraTOC.html

cqlsh

CREATE KEYSPACE testkeystore WITH replication = {'class':'SimpleStrategy', 'replication_factor':3};

CREATE TYPE testkeystore.address (
number int,
street text,
code int,
city text
);

CREATE TABLE testkeystore.person(
person_id text PRIMARY KEY,
firstname text,
lastname text,
age int,
address set< frozen

>,
phones map,
);

exit

sudo npm install -g cassandra-driver

subl cassadnra.js

var cassandra = require('cassandra-driver');

var client = new cassandra.Client({contactPoints: ['host1', '127.0.0.1'], keyspace: 'testkeystore'});

var cassandra = require('cassandra-driver');

var client = new cassandra.Client({contactPoints: ['host1', '127.0.0.1'], keyspace: 'testkeystore'});

var query = 'INSERT INTO testkeystore.person(person_id,firstname,lastname,age,address,phones) VALUES(?, ?, ?, ?, {{number:123,street:\'samplestreet\',code:4569,city:\'samplecity\'}},{\'home\':\'9764\'});'
var params = ['1', 'bob', 'bob', 35];

client.execute(query, params, {prepare: true}, function(err) {

if(err)
console.log('ERROR '+err);
else
console.log('Row inserted on the cluster');
});

nodejs cassadnra.js

nodejs-express4-mysql in 2 minutes

a sample application that shows how can be created a restful api service with node.js + express4 + mysql.

just clone the following project and follow its readme.

git clone https://github.com/pjanaya/nodejs-express4-mysql

and test with:

curl –data “username=irman&password=123456&press=%20OK%20” http://localhost:8080/api/users/

{“message”:”User created!”}

curl -XGET “http://localhost:8080/api/users/4&#8243; -d ”

{“id”:4,”username”:”irman”,”password”:”7c4a8d09ca3762af61e59520943dc26494f8941b”}