Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
modUserServer for Antville
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Michael Platzer  
View profile  
 More options Jul 11 2005, 12:32 pm
From: Michael Platzer <michael.plat...@knallgrau.at>
Date: Mon, 11 Jul 2005 18:32:31 +0200
Local: Mon, Jul 11 2005 12:32 pm
Subject: modUserServer for Antville

The Helma code-snippets provided here
http://www.sorua.net/stories/776023/ are just intented for demonstration
purpose, and are not expected to work out-of-the-box. I attached the
adapted UserServer, which hopefully works for Antville-installations.

So you probably need the following steps to enable UserServer for Antville:
* download the commons-httpclient-3.0-rc2.jar from
http://jakarta.apache.org/site/downloads/downloads_commons-httpclient...
and put it into your code-repository (or to [HelmaDir]/lib/ext)
* put the attacht file modSoruaUserServer.js into [AntvilleDir]/MemberMgr
* Adapt function Root.modSoruaUserServerGetArrayOfKnownAuthServers to
define your list of known AuthServers.
* Include the following lines somewhere into the MemberMgr/login Skin:
----------------------
<tr>
  <td valign="top"><% input id="isusersorua" type="radio" name="isuser"
value="sorua" %></td>
  <td>
    I am registered at another Service with
<b>SORUA</b>-Authentification.<br />
    <% MemberMgr.modSoruaUserServerKnownAuthServers width="100"
as="dropdown"
onChange="document.getElementById('isusersorua').checked='checked'" %>
  </td>
</tr>
----------------------
* And include the following lines into the MemberMgr/login_action:
--------------------
function login_action() {
  ...
   if (req.data.login && req.data.isuser == "sorua") {
      var redUrl = this.href("modSoruaUserServer") + "?submit=1";
      if (req.data.name) redUrl += "&name=" + req.data.name;
      redUrl += "&authuri=" + escape(req.data.modSoruaAuthServerAuthUri);
      if (req.data.remember || req.data.remembersorua) redUrl +=
"&remember=1";
      res.redirect(redUrl);
   }else if (req.data.login) {
  ...
--------------------

hope this works, but cant tell for sure.

greets,
  michi

--

DI Michael Platzer
technical director
--------------------------------------
knallgrau new media solutions gmbh
pezzlgasse 7|1, A-1170 wien
phone: +43 - 1 - 522 76 37
fax: +43 - 1 - 522 76 38
http://www.knallgrau.at

weitere News im Knallgrau Weblog:
  http://www.knallgrau.at/company/weblog

[ modSoruaUserServer.js 7K ]

/**
 * SORUA UserServer
 * Handles submitted login form, which performs redirect to AuthServer for authentication.
 * Handles returned UserClient and asks AuthServer for verification.
 *
 */
function modSoruaUserServer_action() {

   // UserClient is returned by AuthServer
   if (req.data.token && session.data.modSoruaAuthUri) {

      // use the Apache-Commons-HTTPClient for the verification request
      var pkg = Packages.org.apache.commons.httpclient;
      var client = new pkg.HttpClient();
      // create a GET request
      var authUri = session.data.modSoruaAuthUri;
      var ch = (authUri.indexOf("?") != -1) ? "&" : "?";
      authUri += ch + "sorua-action=verify";
      var returnUrl = this.href("modSoruaUserServer") + "?token=" + req.data.token;
      if (req.data.remember) returnUrl += "&remember=" + req.data.remember;
      authUri += "&sorua-return-url=" + escape(returnUrl);
      var method = new pkg.methods.GetMethod(authUri);
      // send the GET request
      client.executeMethod(method);
      // get the status code
      var status = method.getStatusCode();
      if (status == 200) {      // handle successful authentication
         var responseBody = method.getResponseBodyAsString();
         if (responseBody && responseBody.substring(0, 5) == "user:") {
            var responseLines = responseBody.split("\n");
            // fetch userName from response
            var userName = responseLines[0].substring(5);
            // read additional (optional) user data from response
            var userData = new Object();
            if (responseLines.length > 1) {
               for (var i=0; i<responseLines.length-1; i++) {
                  var line = responseLines[i+1];
                  if (line.contains(":") == false) continue;
                  userData[line.substring(0, line.indexOf(":"))] = line.substring(line.indexOf(":") + 1);
               }
            }
            var authServerName = this.modSoruaUserServerGetNameForAuthUri(session.data.modSoruaAuthUri);
            var userId = authServerName + ":" +userName;
            if (root.users.get(userId)) {
               var msg = this.evalLogin(root.users.get(userId).name, root.users.get(userId).password);
            } else {
               var newUser = this.modSoruaUserServerNewUser(session.data.modSoruaAuthUri, authServerName, userName);
               var msg = this.evalLogin(newUser.name, newUser.password);
            }
            if (userData.email != null) session.user.email = userData.email;  // set 'email:'-value from response
            if (userData.url != null) session.user.url = userData.url;        // set 'url:'-value from response
            res.message = msg;
         }
      } else if (status == 403) {
         ;
      }
      session.data.modSoruaAuthUri = null;
      method.releaseConnection();
      method.recycle();
      // perform redirect
      if (session.data.referrer) {
         var url = session.data.referrer;
         session.data.referrer = null;
      } else {
         var url = this._parent.href();
      }
      res.redirect(url);

   // UserClient submits loginForm
   } else if (req.data.submit && req.data.authuri) {

      var authuri = req.data.authuri;
      var returnUrl = this.href("modSoruaUserServer") + "?token=SORUA-AUTH-TOKEN";
      if (req.data.remember) returnUrl += "&remember=" + req.data.remember;
      session.data.modSoruaAuthUri = authuri;
      var redUrl = authuri + "?sorua-action=authenticate";
      if (req.data.name) redUrl += "&sorua-user=" + req.data.name;
      redUrl += "&sorua-return-url=" + escape(returnUrl);
      res.redirect(redUrl);

   // handle wrong call
   } else {

      res.redirect(this.href("login"));

   }

}

/**
 * Renders skin MemberMgr.modSoruaUserServerLogin
 */
function modSoruaUserServerLogin_macro() {
   this.renderSkin("modSoruaUserServerLogin");
   return;

}

/**
 * Returns the name/id for a given authuri.
 * The name is either defined via modSoruaUserServerKnownAuthServers or extracted from the authuri itself
 *
 * @param authuri String
 * @return String
 */
function modSoruaUserServerGetNameForAuthUri(authuri) {
   if (!authuri) return;
   var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
   for (var i in knownAuthServers) {
      if (authuri == knownAuthServers[i][0]) {
         return knownAuthServers[i][1];
      }
   }
   // extract the domain from the authuri
   return authuri.substring(authuri.indexOf("/") + 2,
                            authuri.indexOf("/", authuri.indexOf("/") + 2));

}

/**
 * Creates and adds a new User.
 *
 * @param authUri
 * @param authServerName
 * @param userName
 * @return User
 */
function modSoruaUserServerNewUser(authUri, authServerName, userName) {
   var newUser = new User();
   newUser.name = authServerName + ":" + userName;
   newUser.password = (Math.random()).toString().md5(); // generate random password
   newUser.registered = new Date();
   root.users.add(newUser);
   return newUser;

}

/**
 * Renders a list of known AuthServers.
 * Either as textarea (as="editor") for the SysMgr.setup
 * Or as DropDown, Radiobuttons or Links
 *
 * @param as String "editor", "dropdown", "radio", "links"
 * @return String
 */
function modSoruaUserServerKnownAuthServers_macro(param) {
   if (param.as == "dropdown") {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      param.name = "modSoruaAuthServerAuthUri";
      Html.dropDown(param, knownAuthServers, null, param.firstOption);

   } else if (param.as == "radios") {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      param.name = "modSoruaAuthServerAuthUri";
      for (var i in knownAuthServers) {
         param.value = knownAuthServers[i][0];
         Html.radioButton(param, knownAuthServers, null, param.firstOption);
         res.write(" " + knownAuthServers[i][1]);
      }

   } else if (param.as == "links") {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      param.name = "modSoruaAuthServerAuthUri";
      for (var i in knownAuthServers) {
         var url = root.members.href("modSoruaUserServer") + "?action=login" +
                     "&modSoruaAuthServerAuthUri=" + escape(knownAuthServers[i][0]);
         Html.link({href: url}, knownAuthServers[i][1]);
      }

   } else {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      res.write(knownAuthServers.toSource());

   }
   return;

}

/**
 * Returns Array of Array representations of known AuthServers.
 * arr[n][0] is the authuri;
 * arr[n][1] is the name;
 *
 * @param str Optional String, if not Root.modSoruaUserServerKnownAuthServers should be parsed
 *
 * @return Array of Arrays representing AuthServers
 */
function modSoruaUserServerGetArrayOfKnownAuthServers(str) {
   var arr = [];

   var server = [];
   server[0] = "http://www.twoday.net/members/modSoruaAuthServer";
   server[1] = "twoday.net";
   arr.push(server);

   var server = [];
   server[0] = "http://www.blogger.de/members/modSoruaAuthServer";
   server[1] = "blogger.de";
   arr.push(server);

   var server = [];
   server[0] = "http://www.sorua.net/typekey";
   server[1] = "typekey.com";
   arr.push(server);

   var server = [];
   server[0] = "http://twoday.tuwien.ac.at/members/modSoruaAuthServer";
   server[1] = "twoday.tuwien.ac.at";
   arr.push(server);

   return arr;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Platzer  
View profile  
 More options Jul 12 2005, 1:43 am
From: Michael Platzer <michael.plat...@knallgrau.at>
Date: Tue, 12 Jul 2005 07:43:16 +0200
Local: Tues, Jul 12 2005 1:43 am
Subject: Re: [sorua] modUserServer for Antville
i forgot to mention that a recent commons-codec-library is also
necessary. you can download that from
http://jakarta.apache.org/site/downloads/downloads_commons-codec.cgi

greets,
  michi

Michael Platzer schrieb:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
night  
View profile  
 More options Jul 12 2005, 4:30 am
From: "night" <nighth...@gmail.com>
Date: Tue, 12 Jul 2005 08:30:00 -0000
Subject: Re: modUserServer for Antville
ok i placed the jar in the lib/ext/ directory aswell and now i'm
getting the following error:

Exception in Transactor[null]: helma.scripting.ScriptingException:
[object Object]

:(


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Platzer  
View profile  
 More options Jul 12 2005, 5:09 am
From: Michael Platzer <michael.plat...@knallgrau.at>
Date: Tue, 12 Jul 2005 11:09:09 +0200
Local: Tues, Jul 12 2005 5:09 am
Subject: Re: [sorua] Re: modUserServer for Antville

* Did you restart Helma? Which Helma-version are you using?
* Can you set debug=true in app.properties and send the full error trace
* Can you trace down the line that particular bug occurs by inserting
res.debug-statements into the action/functions. That is necessary for me
to be able to tell you what is going wrong.

  michi

night schrieb:

--

DI Michael Platzer
technical director
--------------------------------------
knallgrau new media solutions gmbh
pezzlgasse 7|1, A-1170 wien
phone: +43 - 1 - 522 76 37
fax: +43 - 1 - 522 76 38
http://www.knallgrau.at

weitere News im Knallgrau Weblog:
  http://www.knallgrau.at/company/weblog


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
night  
View profile  
 More options Jul 12 2005, 5:38 am
From: "night" <nighth...@gmail.com>
Date: Tue, 12 Jul 2005 09:38:12 -0000
Local: Tues, Jul 12 2005 5:38 am
Subject: Re: modUserServer for Antville

>> * Did you restart Helma? Which Helma-version are you using?

yes, i did restart it and helma is using both commons extensions. the
helmaversion is 1.4.3 on java 1.5.0_02.

>> * Can you set debug=true in app.properties and send the full error trace

yes. here (prefixed with > to prevent linewraps by google groups):

>Error in Script: [object Object]
>org.mozilla.javascript.JavaScriptException: anmeldung fehlgeschlagen! hast du dich vertippt? (antville:MemberMgr/objectFunctions.js#12)
>        at org.mozilla.javascript.gen.c98._c1(antville:MemberMgr/objectFunctions.js:12 )
>        at org.mozilla.javascript.gen.c98.call(antville:MemberMgr/objectFunctions.js)
>        at org.mozilla.javascript.ScriptRuntime.call(ScriptRuntime.java:1442)
>        at org.mozilla.javascript.gen.c101._c1(antville:MemberMgr/modSoruaUserServer.j s:49)
>        at org.mozilla.javascript.gen.c101.call(antville:MemberMgr/modSoruaUserServer. js)
>        at helma.scripting.rhino.RhinoEngine.invoke(RhinoEngine.java:283)
>        at helma.framework.core.RequestEvaluator.run(RequestEvaluator.java:346)
>        at java.lang.Thread.run(Thread.java:595)

i would assume that the error occurs in line 49 of
modSoruaUserServer.js which is the following:

>               var msg = this.evalLogin(newUser.name, newUser.password);
>> * Can you trace down the line that particular bug occurs by inserting res.debug-statements into the action/functions. That is necessary for me to be able to tell you what is going wrong.

just like "res.debug('1');" or something like that? where would those
debug messages appear? in the console output? or in the eventlog?

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Michael Platzer  
View profile  
 More options Jul 12 2005, 6:49 am
From: Michael Platzer <michael.plat...@knallgrau.at>
Date: Tue, 12 Jul 2005 12:49:30 +0200
Local: Tues, Jul 12 2005 6:49 am
Subject: Re: [sorua] Re: modUserServer for Antville

night schrieb:

>i would assume that the error occurs in line 49 of
>modSoruaUserServer.js which is the following:

attached you will find a new version of MemberMgr/modSoruaUserServer.js
which is hopefully less dependent on the existence/logic of other
functions. hopefully it will work out now.

>>* Can you trace down the line that particular bug occurs by inserting res.debug-statements into the action/functions. That is necessary for me to be able to tell you what is going wrong.

>just like "res.debug('1');" or something like that? where would those
>debug messages appear? in the console output? or in the eventlog?

yes, shtg like that. a yellow message would then appear at the end of
the response itself. but this is not necessary, since the error trace
had all the necessary information.

  michi

[ modSoruaUserServer.js 7K ]

/**
 * SORUA UserServer
 * Handles submitted login form, which performs redirect to AuthServer for authentication.
 * Handles returned UserClient and asks AuthServer for verification.
 *
 */
function modSoruaUserServer_action() {

   // UserClient is returned by AuthServer
   if (req.data.token && session.data.modSoruaAuthUri) {

      // use the Apache-Commons-HTTPClient for the verification request
      var pkg = Packages.org.apache.commons.httpclient;
      var client = new pkg.HttpClient();
      // create a GET request
      var authUri = session.data.modSoruaAuthUri;
      var ch = (authUri.indexOf("?") != -1) ? "&" : "?";
      authUri += ch + "sorua-action=verify";
      var returnUrl = this.href("modSoruaUserServer") + "?token=" + req.data.token;
      if (req.data.remember) returnUrl += "&remember=" + req.data.remember;
      authUri += "&sorua-return-url=" + escape(returnUrl);
      var method = new pkg.methods.GetMethod(authUri);
      // send the GET request
      client.executeMethod(method);
      // get the status code
      var status = method.getStatusCode();
      if (status == 200) {      // handle successful authentication
         var responseBody = method.getResponseBodyAsString();
         if (responseBody && responseBody.substring(0, 5) == "user:") {
            var responseLines = responseBody.split("\n");
            // fetch userName from response
            var userName = responseLines[0].substring(5);
            // read additional (optional) user data from response
            var userData = new Object();
            if (responseLines.length > 1) {
               for (var i=0; i<responseLines.length-1; i++) {
                  var line = responseLines[i+1];
                  if (line.contains(":") == false) continue;
                  userData[line.substring(0, line.indexOf(":"))] = line.substring(line.indexOf(":") + 1);
               }
            }
            var authServerName = this.modSoruaUserServerGetNameForAuthUri(session.data.modSoruaAuthUri);
            var userId = authServerName + ":" +userName;
            var usr = root.users.get(userId);
            if (!usr) {
               var usr = this.modSoruaUserServerNewUser(session.data.modSoruaAuthUri, authServerName, userName);
            }
            session.login(usr);
            session.user.lastVisit = new Date();
            if (req.data.remember) {
               res.setCookie("avUsr", session.user.name, 365);
               res.setCookie("avPw", Packages.helma.util.MD5Encoder.encode(session.user.password+req.data.http_r emotehost), 365);
            }
            if (userData.email != null) session.user.email = userData.email;  // set 'email:'-value from response
            if (userData.url != null) session.user.url = userData.url;        // set 'url:'-value from response
            res.message = new Message("welcome", [res.handlers.context.getTitle(), session.user.name]);
         }
      } else if (status == 403) {
         ;
      }
      session.data.modSoruaAuthUri = null;
      method.releaseConnection();
      method.recycle();
      // perform redirect
      if (session.data.referrer) {
         var url = session.data.referrer;
         session.data.referrer = null;
      } else {
         var url = this._parent.href();
      }
      res.redirect(url);

   // UserClient submits loginForm
   } else if (req.data.submit && req.data.authuri) {

      var authuri = req.data.authuri;
      var returnUrl = this.href("modSoruaUserServer") + "?token=SORUA-AUTH-TOKEN";
      if (req.data.remember) returnUrl += "&remember=" + req.data.remember;
      session.data.modSoruaAuthUri = authuri;
      var redUrl = authuri + "?sorua-action=authenticate";
      if (req.data.name) redUrl += "&sorua-user=" + req.data.name;
      redUrl += "&sorua-return-url=" + escape(returnUrl);
      res.redirect(redUrl);

   // handle wrong call
   } else {

      res.redirect(this.href("login"));

   }

}

/**
 * Renders skin MemberMgr.modSoruaUserServerLogin
 */
function modSoruaUserServerLogin_macro() {
   this.renderSkin("modSoruaUserServerLogin");
   return;

}

/**
 * Returns the name/id for a given authuri.
 * The name is either defined via modSoruaUserServerKnownAuthServers or extracted from the authuri itself
 *
 * @param authuri String
 * @return String
 */
function modSoruaUserServerGetNameForAuthUri(authuri) {
   if (!authuri) return;
   var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
   for (var i in knownAuthServers) {
      if (authuri == knownAuthServers[i][0]) {
         return knownAuthServers[i][1];
      }
   }
   // extract the domain from the authuri
   return authuri.substring(authuri.indexOf("/") + 2,
                            authuri.indexOf("/", authuri.indexOf("/") + 2));

}

/**
 * Creates and adds a new User.
 *
 * @param authUri
 * @param authServerName
 * @param userName
 * @return User
 */
function modSoruaUserServerNewUser(authUri, authServerName, userName) {
   var newUser = new User();
   newUser.name = authServerName + ":" + userName;
   newUser.password = (Math.random()).toString().md5(); // generate random password
   newUser.registered = new Date();
   root.users.add(newUser);
   return newUser;

}

/**
 * Renders a list of known AuthServers.
 * Either as textarea (as="editor") for the SysMgr.setup
 * Or as DropDown, Radiobuttons or Links
 *
 * @param as String "editor", "dropdown", "radio", "links"
 * @return String
 */
function modSoruaUserServerKnownAuthServers_macro(param) {
   if (param.as == "dropdown") {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      param.name = "modSoruaAuthServerAuthUri";
      Html.dropDown(param, knownAuthServers, null, param.firstOption);

   } else if (param.as == "radios") {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      param.name = "modSoruaAuthServerAuthUri";
      for (var i in knownAuthServers) {
         param.value = knownAuthServers[i][0];
         Html.radioButton(param, knownAuthServers, null, param.firstOption);
         res.write(" " + knownAuthServers[i][1]);
      }

   } else if (param.as == "links") {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      param.name = "modSoruaAuthServerAuthUri";
      for (var i in knownAuthServers) {
         var url = root.members.href("modSoruaUserServer") + "?action=login" +
                     "&modSoruaAuthServerAuthUri=" + escape(knownAuthServers[i][0]);
         Html.link({href: url}, knownAuthServers[i][1]);
      }

   } else {
      var knownAuthServers = this.modSoruaUserServerGetArrayOfKnownAuthServers();
      res.write(knownAuthServers.toSource());

   }
   return;

}

/**
 * Returns Array of Array representations of known AuthServers.
 * arr[n][0] is the authuri;
 * arr[n][1] is the name;
 *
 * @param str Optional String, if not Root.modSoruaUserServerKnownAuthServers should be parsed
 *
 * @return Array of Arrays representing AuthServers
 */
function modSoruaUserServerGetArrayOfKnownAuthServers(str) {
   var arr = [];

   var server = [];
   server[0] = "http://www.twoday.net/members/modSoruaAuthServer";
   server[1] = "twoday.net";
   arr.push(server);

   var server = [];
   server[0] = "http://www.blogger.de/members/modSoruaAuthServer";
   server[1] = "blogger.de";
   arr.push(server);

   var server = [];
   server[0] = "http://www.sorua.net/typekey";
   server[1] = "typekey.com";
   arr.push(server);

   var server = [];
   server[0] = "http://twoday.tuwien.ac.at/members/modSoruaAuthServer";
   server[1] = "twoday.tuwien.ac.at";
   arr.push(server);

   return arr;


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
night  
View profile  
 More options Jul 12 2005, 9:23 am
From: "night" <nighth...@gmail.com>
Date: Tue, 12 Jul 2005 06:23:22 -0700
Local: Tues, Jul 12 2005 9:23 am
Subject: Re: modUserServer for Antville

> attached you will find a new version of MemberMgr/modSoruaUserServer.js
> which is hopefully less dependent on the existence/logic of other
> functions. hopefully it will work out now.

yes! i just tested it and it works fine! thanks!

> yes, shtg like that. a yellow message would then appear at the end of
> the response itself. but this is not necessary, since the error trace
> had all the necessary information.

ah.. that would have been kinda not helpful then, since the response
was not really shown to the user.. the client got just redirected to
another page.

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »