[Affelio-cvs 806] CVS update: affelio/lib/Affelio/misc

Back to archive index

Tadashi Okoshi slash****@users*****
2005年 11月 23日 (水) 13:00:20 JST


Index: affelio/lib/Affelio/misc/WSSE.pm
diff -u /dev/null affelio/lib/Affelio/misc/WSSE.pm:1.1
--- /dev/null	Wed Nov 23 13:00:20 2005
+++ affelio/lib/Affelio/misc/WSSE.pm	Wed Nov 23 13:00:20 2005
@@ -0,0 +1,81 @@
+# Copyright (C) 2005 FishGrove Inc.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+#
+# $Id: WSSE.pm,v 1.1 2005/11/23 04:00:20 slash5234 Exp $
+
+package Affelio::misc::WSSE;
+{
+    use strict;
+    use lib("../../../extlib/");
+    use Digest::SHA::PurePerl ();
+    use MIME::Base64 ();
+    use Error qw(:try);
+    use lib("../../../lib/");
+    use Exporter;
+    @Affelio::misc::WSSE::ISA = "Exporter";
+    @Affelio::misc::WSSE::EXPORT = qw(make_XWSSE authenticate);
+
+    sub authenticate {
+	my ($XWSSE_mesg, $user, $pass) = shift;	
+
+	return(1);
+
+	my $my_own_mesg = make_XWSSE($user, $pass);
+
+	if($my_own_mesg eq $XWSSE_mesg){
+	    return(1);
+	}else{
+	    return("");
+	}
+    }
+
+    sub make_XWSSE {
+	my ($user, $pass) = shift;
+	
+	my $now = now_w3cdtf();
+	my $nonce = make_nonce();
+	my $nonce_enc = MIME::Base64::encode_base64($nonce, '');
+	my $digest = MIME::Base64::encode_base64( Digest::SHA::PurePerl::sha1($nonce . $now . $pass), '' );
+	
+	my $wsse_value = 'UsernameToken ' . join(
+						 ', ',
+						 qq(Username="$user"),
+						 qq(PasswordDigest="$digest"),
+						 qq(Nonce="$nonce_enc"),
+						 qq(Created="$now"),
+						 );
+
+	return($wsse_value);
+    }
+
+
+    sub make_nonce {
+	return Digest::SHA::PurePerl::sha1(Digest::SHA::PurePerl::sha1(time() . {} . rand() . $$));
+    }
+
+    sub now_w3cdtf {
+	my ($sec, $min, $hour, $mday, $mon, $year) = gmtime();
+	$mon++; $year += 1900;
+	
+	return sprintf(
+		       "%04s-%02s-%02sT%02s:%02s:%02sZ",
+		       $year, $mon, $mday, $hour, $min, $sec,
+		       );
+    }
+
+
+}#package
+1;


Affelio-cvs メーリングリストの案内
Back to archive index