Author: prabath
Date: Fri Jan 11 12:20:56 2008
New Revision: 12156
Log:
added new methods related to OpenID
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/OpenIDProvider.java
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/OpenIDProvider.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/OpenIDProvider.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/OpenIDProvider.java
Fri Jan 11 12:20:56 2008
@@ -11,7 +11,11 @@
import javax.servlet.http.HttpSession;
import org.wso2.solutions.identity.UserStore;
+import org.openid4java.OpenIDException;
+import org.openid4java.association.Association;
+import org.openid4java.association.AssociationException;
import org.openid4java.message.AuthRequest;
+import org.openid4java.message.AuthSuccess;
import org.openid4java.message.DirectError;
import org.openid4java.message.Message;
import org.openid4java.message.MessageException;
@@ -21,6 +25,8 @@
import org.openid4java.message.ax.FetchResponse;
import org.openid4java.message.sreg.SRegRequest;
import org.openid4java.message.sreg.SRegResponse;
+import org.openid4java.server.IncrementalNonceGenerator;
+import org.openid4java.server.NonceGenerator;
import org.openid4java.server.ServerException;
import org.openid4java.server.ServerManager;
import org.wso2.solutions.identity.IdentityConstants;
@@ -54,6 +60,8 @@
private final static String GENDER = "gender";
private final static String LANGUAGE = "language";
+ private final static int EXPIRES_IN = 1000;
+
private static String opAddress = null;
/**
@@ -77,6 +85,53 @@
/**
*
+ * @return
+ * @throws AssociationException
+ */
+ public static Association getAssocHandle() throws AssociationException {
+ Association association = null;
+
+ return manager.getPrivateAssociations().generate(
+ org.openid4java.association.Association.TYPE_HMAC_SHA1,
+ EXPIRES_IN);
+ }
+
+ /**
+ *
+ * @return
+ */
+ public static String getNonce() {
+
+ return manager.getNonceGenerator().next();
+ }
+
+ /**
+ *
+ * @param endPoint
+ * @param claimedID
+ * @param compat
+ * @param returnTo
+ * @param nonce
+ * @param assoc
+ * @return
+ * @throws MessageException
+ * @throws AssociationException
+ */
+ public static String getSignature(String endPoint, String claimedID,
+ boolean compat, String returnTo, String nonce, Association assoc)
+ throws MessageException, AssociationException {
+ AuthSuccess openidResp;
+
+ openidResp = AuthSuccess.createAuthSuccess(endPoint, claimedID,
+ claimedID, compat, returnTo, nonce, null, assoc, true);
+
+ // sign the message
+ return openidResp.getSignature();
+
+ }
+
+ /**
+ *
* @param httpReq
* HttpServletRequest
* @param httpResp
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev