Author: prabath
Date: Mon Jan 7 00:50:35 2008
New Revision: 11917
Log:
OpenID integration
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
Mon Jan 7 00:50:35 2008
@@ -49,6 +49,11 @@
private final static String ZIP_CODE = "zipcode";
private final static String COUNTRY = "country";
private final static String BLOG = "blog";
+ private final static String TIMEZONE = "timezone";
+ private final static String POSTAL_CODE = "postalcode";
+ private final static String DOB = "dob";
+ private final static String GENDER = "gender";
+ private final static String LANGUAGE = "language";
/**
* Configure the OpenID Provider's end-point URL.
@@ -66,7 +71,7 @@
// This is the OpenID provider server url, right now on https - also
can
// be on http.
- odpAddress = "https://" + host + ":" + httpsPort + "/admin/server/";
+ odpAddress = "http://" + host + ":" + httpsPort + "/server/";
manager.setOPEndpointUrl(odpAddress);
}
@@ -89,9 +94,11 @@
session = httpReq.getSession();
- if (IdentityProviderConstants.OpenId.COMPLETE
.equals(httpReq.getParameter(IdentityProviderConstants.OpenId.ACTION))) {
+ if (IdentityProviderConstants.OpenId.COMPLETE.equals(httpReq
+ .getParameter(IdentityProviderConstants.OpenId.ACTION))) {
// Authentication completed.
- request = (ParameterList)
session.getAttribute(IdentityProviderConstants.OpenId.PARAM_LIST);
+ request = (ParameterList) session
+ .getAttribute(IdentityProviderConstants.OpenId.PARAM_LIST);
} else {
// Extract the parameters from the request.
// Authentication not completed.
@@ -123,8 +130,9 @@
if (!authenticatedAndApproved) {
// Not authenticated, redirect to the authentication page.
-
session.setAttribute(IdentityProviderConstants.OpenId.PARAM_LIST, request);
- httpResp.sendRedirect(authPage);
+ session.setAttribute(
+ IdentityProviderConstants.OpenId.PARAM_LIST, request);
+ return authPage;
}
// Process an authentication request.
@@ -139,10 +147,10 @@
if (message instanceof DirectError)
return directResponse(httpResp,
message.keyValueFormEncoding());
else {
- if (authReq.hasExtension(AxMessage.OPENID_NS_AX)) {
+ if (authReq.hasExtension(IdentityConstants.OpenId.NS_AX)) {
MessageExtension extensions = authReq
- .getExtension(AxMessage.OPENID_NS_AX);
+ .getExtension(IdentityConstants.OpenId.NS_AX);
if (extensions instanceof FetchRequest) {
@@ -165,10 +173,10 @@
throw new UnsupportedOperationException("TODO");
}
}
- if (authReq.hasExtension(SRegMessage.OPENID_NS_SREG)) {
+ if (authReq.hasExtension(IdentityConstants.OpenId.NS_SREG)) {
MessageExtension extension = authReq
- .getExtension(SRegMessage.OPENID_NS_SREG);
+ .getExtension(IdentityConstants.OpenId.NS_SREG);
if (extension instanceof SRegRequest) {
@@ -195,6 +203,7 @@
}
return message.getDestinationUrl(true);
+
}
} else if (IdentityConstants.OpenId.CHECK_AUTHENTICATION.equals(mode))
{
// Processing a verification request.
@@ -207,7 +216,7 @@
}
// Return the result to the user.
- return responseText;
+ return directResponse(httpResp, responseText);
}
/**
@@ -241,44 +250,39 @@
.get(FULL_NAME));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.LAST_NAME)) {
- response.addAttribute(
- IdentityConstants.OpenId.Attributes.LAST_NAME, claimValues
- .get(LAST_NAME));
+ if (required.contains(IdentityConstants.OpenId.Attributes.COUNTRY)) {
+ response.addAttribute(IdentityConstants.OpenId.Attributes.COUNTRY,
+ claimValues.get(COUNTRY));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.FIRST_NAME))
{
+ if
(required.contains(IdentityConstants.OpenId.Attributes.POSTAL_CODE)) {
response.addAttribute(
- IdentityConstants.OpenId.Attributes.FIRST_NAME, claimValues
- .get(FIRST_NAME));
+ IdentityConstants.OpenId.Attributes.POSTAL_CODE,
+ claimValues.get(POSTAL_CODE));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.ADDRESS)) {
- response.addAttribute(IdentityConstants.OpenId.Attributes.ADDRESS,
- claimValues.get(ADDRESS));
+ if (required.contains(IdentityConstants.OpenId.Attributes.DOB)) {
+ response.addAttribute(IdentityConstants.OpenId.Attributes.DOB,
+ claimValues.get(DOB));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.CITY)) {
- response.addAttribute(IdentityConstants.OpenId.Attributes.CITY,
- claimValues.get(CITY));
+ if (required.contains(IdentityConstants.OpenId.Attributes.GENDER)) {
+ response.addAttribute(IdentityConstants.OpenId.Attributes.GENDER,
+ claimValues.get(GENDER));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.BLOG)) {
- response.addAttribute(IdentityConstants.OpenId.Attributes.BLOG,
- claimValues.get(BLOG));
+ if (required.contains(IdentityConstants.OpenId.Attributes.LANGUAGE)) {
+ response.addAttribute(IdentityConstants.OpenId.Attributes.LANGUAGE,
+ claimValues.get(LANGUAGE));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.COUNTRY)) {
- response.addAttribute(IdentityConstants.OpenId.Attributes.COUNTRY,
- claimValues.get(COUNTRY));
- }
- if (required.contains(IdentityConstants.OpenId.Attributes.PHONE)) {
- response.addAttribute(IdentityConstants.OpenId.Attributes.PHONE,
- claimValues.get(PHONE));
+ if (required.contains(IdentityConstants.OpenId.Attributes.TIMEZONE)) {
+ response.addAttribute(IdentityConstants.OpenId.Attributes.TIMEZONE,
+ claimValues.get(TIMEZONE));
}
- if (required.contains(IdentityConstants.OpenId.Attributes.ZIP_CODE)) {
- response.addAttribute(IdentityConstants.OpenId.Attributes.ZIP_CODE,
- claimValues.get(ZIP_CODE));
+ if (required.contains(IdentityConstants.OpenId.Attributes.BLOG)) {
+ response.addAttribute(IdentityConstants.OpenId.Attributes.BLOG,
+ claimValues.get(BLOG));
}
}
@@ -464,7 +468,7 @@
claimValues.put(FIRST_NAME, (String) mapValues
.get(IdentityConstants.CLAIM_GIVEN_NAME));
else
- claimValues.put(FIRST_NAME, null);
+ claimValues.put(FIRST_NAME, "none");
// last name
if (mapValues
@@ -472,12 +476,12 @@
claimValues.put(LAST_NAME, (String) mapValues
.get(IdentityConstants.CLAIM_SURNAME));
else
- claimValues.put(LAST_NAME, null);
+ claimValues.put(LAST_NAME, "none");
// full name
- if (claimValues
+ if (mapValues
.containsKey(IdentityConstants.CLAIM_GIVEN_NAME)
- && claimValues
+ && mapValues
.containsKey(IdentityConstants.CLAIM_SURNAME))
claimValues
.put(
@@ -487,26 +491,26 @@
+ " "
+ (String) mapValues
.get(IdentityConstants.CLAIM_SURNAME));
- else if (claimValues
+ else if (mapValues
.containsKey(IdentityConstants.CLAIM_GIVEN_NAME)
- && !claimValues
+ && !mapValues
.containsKey(IdentityConstants.CLAIM_SURNAME))
claimValues.put(FULL_NAME, (String) mapValues
.get(IdentityConstants.CLAIM_GIVEN_NAME));
- else if (!claimValues
+ else if (!mapValues
.containsKey(IdentityConstants.CLAIM_GIVEN_NAME)
- && claimValues
+ && mapValues
.containsKey(IdentityConstants.CLAIM_SURNAME))
claimValues.put(FULL_NAME, (String) mapValues
.get(IdentityConstants.CLAIM_SURNAME));
else
- claimValues.put(FULL_NAME, null);
+ claimValues.put(FULL_NAME, "none");
// nick name
claimValues.put(NICK_NAME, user);
// email address
- if (claimValues
+ if (mapValues
.containsKey(IdentityConstants.CLAIM_EMAIL_ADDRESS))
claimValues
.put(
@@ -514,18 +518,18 @@
(String) mapValues
.get(IdentityConstants.CLAIM_EMAIL_ADDRESS));
else
- claimValues.put(EMAIL, null);
+ claimValues.put(EMAIL, "none");
// phone
- if (claimValues
+ if (mapValues
.containsKey(IdentityConstants.CLAIM_HOME_PHONE))
claimValues.put(PHONE, (String) mapValues
.get(IdentityConstants.CLAIM_HOME_PHONE));
else
- claimValues.put(PHONE, null);
+ claimValues.put(PHONE, "none");
// address
- if (claimValues
+ if (mapValues
.containsKey(IdentityConstants.CLAIM_STREET_ADDRESS))
claimValues
.put(
@@ -533,34 +537,43 @@
(String) mapValues
.get(IdentityConstants.CLAIM_STREET_ADDRESS));
else
- claimValues.put(ADDRESS, null);
+ claimValues.put(ADDRESS, "none");
// city
- if (claimValues
- .containsKey(IdentityConstants.CLAIM_CITY))
+ if
(mapValues.containsKey(IdentityConstants.CLAIM_CITY))
claimValues.put(CITY, (String) mapValues
.get(IdentityConstants.CLAIM_CITY));
else
- claimValues.put(CITY, null);
+ claimValues.put(CITY, "none");
// zipcode
- if (claimValues
-
.containsKey(IdentityConstants.CLAIM_POSTAL_CODE))
+ if (mapValues
+
.containsKey(IdentityConstants.CLAIM_POSTAL_CODE)) {
claimValues.put(ZIP_CODE, (String) mapValues
.get(IdentityConstants.CLAIM_POSTAL_CODE));
- else
- claimValues.put(ZIP_CODE, null);
+ claimValues.put(POSTAL_CODE, (String) mapValues
+ .get(IdentityConstants.CLAIM_POSTAL_CODE));
+ } else {
+ claimValues.put(ZIP_CODE, "none");
+ claimValues.put(POSTAL_CODE, "none");
+ }
// country
- if (claimValues
+ if (mapValues
.containsKey(IdentityConstants.CLAIM_COUNTRY))
claimValues.put(COUNTRY, (String) mapValues
.get(IdentityConstants.CLAIM_COUNTRY));
else
- claimValues.put(COUNTRY, null);
+ claimValues.put(COUNTRY, "none");
// blog - currently we don't have a claim for this
- claimValues.put(BLOG, null);
+ claimValues.put(BLOG, "none");
+
+ // TODO: Add values
+ claimValues.put(TIMEZONE, "none");
+ claimValues.put(DOB, "none");
+ claimValues.put(GENDER, "none");
+ claimValues.put(LANGUAGE, "none");
break;
}
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev