Author: prabath
Date: Mon Mar 10 05:41:39 2008
New Revision: 14655
Log:
added a mapping between axchema attributes and schema.openid.net
Modified:
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDExtension.java
Modified:
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
==============================================================================
---
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
(original)
+++
trunk/solutions/identity/modules/base/src/main/java/org/wso2/solutions/identity/IdentityConstants.java
Mon Mar 10 05:41:39 2008
@@ -124,8 +124,8 @@
public final static String NO_OPENID_FOUND = "noOpenIDFound";
public final static String CARD_ISSUER_INIT_FAILURE =
"cardIssuerInitializationFailure";
public final static String PROFILE_RETRIEVAL_FAILURE =
"profileRetrievalError";
- public final static String
INVALID_USERNAME_FOR_OPENID="invalidUserNameForOpenID";
- public final static String
INVALID_OPENID_RETURNTO="invalidOpenIDReturnTo";
+ public final static String INVALID_USERNAME_FOR_OPENID =
"invalidUserNameForOpenID";
+ public final static String INVALID_OPENID_RETURNTO =
"invalidOpenIDReturnTo";
}
/**
@@ -159,12 +159,11 @@
public static final String AUTHENTICATED_AND_APPROVED =
"authenticatedAndApproved";
public final static String CANCEL = "cancel";
public final static String PARAM_LIST = "parameterlist";
-
- public static class PapeAttributes
- {
+
+ public static class PapeAttributes {
public final static String AUTH_POLICIES =
"auth_policies";
public final static String NIST_AUTH_LEVEL =
"nist_auth_level";
- public final static String AUTH_AGE = "auth_age";
+ public final static String AUTH_AGE = "auth_age";
}
public static class SimpleRegAttributes {
@@ -212,6 +211,15 @@
public final static String LANGUAGE_NS = NS +
"/pref/language";
public final static String TIMEZONE_NS = NS +
"/pref/timezone";
+ public final static String NICK_NAME_NS2 =
"http://schema.openid.net/namePerson/friendly";
+ public final static String EMAIL_NS2 =
"http://schema.openid.net/contact/email";
+ public final static String FULL_NAME_NS2 =
"http://schema.openid.net/namePerson";
+ public final static String DOB_NS2 =
"http://schema.openid.net/birthDate";
+ public final static String GENDER_NS2 =
"http://schema.openid.net/person/gender";
+ public final static String POSTAL_CODE_NS2 =
"http://schema.openid.net/contact/postalCode/home";
+ public final static String COUNTRY_NS2 =
"http://schema.openid.net/contact/country/home";
+ public final static String LANGUAGE_NS2 =
"http://schema.openid.net/pref/language";
+ public final static String TIMEZONE_NS2 =
"http://schema.openid.net/pref/timezone";
}
}
}
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDAttributeExchange.java
Mon Mar 10 05:41:39 2008
@@ -25,6 +25,33 @@
private static Log log = LogFactory.getLog(OpenIDAttributeExchange.class);
+ private static Map<String, String> axMapping = new HashMap<String,
String>();
+
+ static {
+ axMapping.put(
+ IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.POSTAL_CODE_NS);
+ axMapping.put(
+ IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.NICK_NAME_NS);
+ axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.LANGUAGE_NS);
+ axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.GENDER_NS);
+ axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.COUNTRY_NS);
+ axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.DOB_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.DOB_NS);
+ axMapping.put(
+ IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.FULL_NAME_NS);
+ axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.TIMEZONE_NS);
+ axMapping.put(IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS2,
+ IdentityConstants.OpenId.ExchangeAttributes.EMAIL_NS);
+
+ }
+
/**
* Constructed during building the response
* @param request An instance of OpenIDAuthenticationRequest
@@ -55,7 +82,7 @@
Map required = null;
Map optional = null;
- FetchRequest fetchRequest = null;
+ FetchRequest fetchRequest = null;
Map<String, OpenIDClaim> claimValues = null;
fetchRequest = (FetchRequest) extensions;
@@ -80,11 +107,11 @@
new HashMap());
claimValues = populateAttributeValues(required, userId,
profileName);
- setAttributeExchangeValues(fetchResponse, claimValues);
- }
-
+ setAttributeExchangeValues(fetchResponse, claimValues);
+ }
+
return fetchResponse;
-
+
} catch (MessageException e) {
throw new IdentityProviderException(
IdentityConstants.ErrorCodes.OPENID_RESP_GENERATION_FAILED,
@@ -117,20 +144,25 @@
for (int i = 0; i < supportedClaims.length; i++) {
ClaimDO temp = supportedClaims[i];
- if (temp.getOpenIDTag() != null)
+ if (temp.getOpenIDTag() != null) {
claims.put(temp.getOpenIDTag(), temp);
+ }
}
iterator = requiredClaims.entrySet().iterator();
map = new HashMap<String, String>();
String val = null;
+ String tag = null;
while (iterator.hasNext()) {
entry = iterator.next();
- val = (String) entry.getValue();
- map.put(claimsAdmin.getMappedOpenIDTag(val), (String) entry
- .getKey());
+ val = getMappedAxSchema((String) entry.getValue());
+ tag = claimsAdmin.getMappedOpenIDTag(val);
+ if (tag != null) {
+ claims.get(tag).setUri((String) entry.getValue());
+ map.put(tag, (String) entry.getKey());
+ }
}
return populateAttributeValues(map.keySet(), userId, claims, map,
@@ -138,6 +170,20 @@
}
/**
+ * This provides a mapping between http://schema.openid.net/ and
+ * http://axschema.org
+ * @param val schema name-space URL
+ * @return mapped value
+ */
+ protected String getMappedAxSchema(String val) {
+ if (axMapping.containsKey(val)) {
+ return axMapping.get(val);
+ }
+
+ return val;
+ }
+
+ /**
* Populate the response with claim values. If we can't find the required
* values with us, we simply avoid sending them. An Identity Provider MAY
* return any subset of the following fields in response to the query.
Modified:
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDExtension.java
==============================================================================
---
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDExtension.java
(original)
+++
trunk/solutions/identity/modules/identity-provider/src/main/java/org/wso2/solutions/identity/openid/extensions/OpenIDExtension.java
Mon Mar 10 05:41:39 2008
@@ -44,6 +44,9 @@
Iterator<String> iterator = null;
List<String> list = null;
+ if (claims == null || claims.isEmpty())
+ return null;
+
connector = UserStore.getInstance();
// Get the column names for the URIs
@@ -65,7 +68,7 @@
}
}
- Map<String,String> mapValues = null;
+ Map<String, String> mapValues = null;
OpenIDClaim openIDClaim = null;
String profile = null;
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev