Frage

I'm currently trying to integrate the CAS (Central Authentication Service) client into a web application that I built off of Sails.js. It seems that the CAS client that I need to integrate into my web app is Java-based or PHP-based. Are there any options to integrate CAS into my web app?

I tried searching for solutions but only found a node-java module for Node.js, which I'm not sure is completely compatible with Sails.js (are all Node.js modules compatible with Sails.js since Sails is just a framework for Node.js?).

War es hilfreich?

Lösung

sails is a npm package for node.js, and so, works with any npm packages, including node-java. I have created a small demo for you using sails.js and a simple java class.

Note that I had to import the jar file into Java's classpath, then I invoked the method in a synchronous way.

module.exports = {

/**
* Action blueprints:
*    `/gettoken/get`
*/
get: function (req, res) {

// Send a JSON response

  var java = require('java')
   java.classpath.push("C:/Users/cleuton/proj/sails.js/testProject/api/controllers/jsondao.jar")
  var javaObject = java.newInstanceSync("com.obomprogramador.sails.test.SampleJava")


    return res.json({
      hello: javaObject.getTokenSync()
    });
},


/**
* Overrides for the settings in `config/controllers.js`
* (specific to GetTokenController)
*/
_config: {}

};
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top