Author: prabath
Date: Tue Dec 18 00:16:18 2007
New Revision: 11341
Log:
moved the logic to OpenIdConsumer
Modified:
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdInfoCardSubmitAction.java
Modified:
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdInfoCardSubmitAction.java
==============================================================================
---
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdInfoCardSubmitAction.java
(original)
+++
branches/solutions/identity/openid-poc/modules/user-ui/src/main/java/org/wso2/solutions/identity/user/ui/action/OpenIdInfoCardSubmitAction.java
Tue Dec 18 00:16:18 2007
@@ -26,6 +26,7 @@
import org.wso2.solutions.identity.IdentityConstants;
import org.wso2.solutions.identity.admin.RegisteredInfoCardInfoAdmin;
import org.wso2.solutions.identity.admin.ReportAdmin;
+import org.wso2.solutions.identity.openid.relyingparty.OpenIdConsumer;
import org.wso2.solutions.identity.persistence.dataobject.ActionDO;
import
org.wso2.solutions.identity.persistence.dataobject.RegisteredInfoCardInfoDO;
import org.wso2.solutions.identity.relyingparty.TokenVerifierConstants;
@@ -38,123 +39,28 @@
private static final long serialVersionUID = 264026108621800214L;
- private static final String LOGGEDIN = "loggedin";
-
- private ConsumerManager consumerManager = null;
-
- // attribute typeUri -> "nice label / alias"
- private static HashMap<String, String> attributes = new HashMap<String,
String>();
-
- static {
- attributes.put("http://axschema.org/contact/email", "Email");
- attributes.put("http://axschema.org/namePerson/first",
"FirstName");
- attributes.put("http://axschema.org/namePerson/last",
"LastName");
- attributes.put("http://axschema.org/contact/phone/default",
"Phone");
- attributes.put("http://axschema.org/contact/postalAddress/home",
- "Address");
- attributes.put("http://axschema.org/contact/city/home", "City");
- attributes
-
.put("http://axschema.org/contact/postalCode/home", "ZipCode");
- attributes.put("http://axschema.org/contact/country/home",
"Country");
- attributes.put("http://axschema.org/contact/web/blog", "Blog");
- }
-
public String execute() throws Exception {
ActionContext context = ActionContext.getContext();
HttpServletRequest request = (HttpServletRequest) context
.get(StrutsStatics.HTTP_REQUEST);
- HttpSession session = request.getSession();
- String xmlToken = request.getParameter("xmlToken");
+ OpenIdConsumer consumer = OpenIdConsumer.getInstance();
- if (xmlToken != null) {
+ try {
- consumerManager = new ConsumerManager();
+ Map map = ActionContext.getContext().getSession();
- // received an xmlToken from an identity selector
- ParameterList openidResp =
extractFromInfocardPost(request);
- processOpenIDResp(request, session, openidResp);
+ consumer.setInfocardSessionAttributes(request);
+ map = ActionContext.getContext().getSession();
+ map.put(UIConstants.USER, (String) request
+ .getAttribute(UIConstants.NICK_NAME));
+
+ } catch (Exception e) {
+
+ return ERROR;
}
return SUCCESS;
- }
-
- private ParameterList extractFromInfocardPost(HttpServletRequest
request)
- throws InfocardException {
-
- String xmlToken = request.getParameter("xmlToken");
-
- request.getSession().setAttribute("openidAssertion", xmlToken);
-
- OpenIDToken token = OpenIDToken.createFromXmlToken(xmlToken);
-
- return token.getOpenIDParams();
- }
-
- private void processOpenIDResp(HttpServletRequest request,
- HttpSession session, ParameterList openidResp)
- throws OpenIDException {
-
- // retrieve the previously stored discovery information
- DiscoveryInformation discovered = (DiscoveryInformation) session
- .getAttribute("discovered");
-
- StringBuffer receivingURL = new
StringBuffer("https://localhost:12443/OpenIdInfoCardLogin.action");//request.getRequestURL();
- String queryString = request.getQueryString();
-
- if (queryString != null && queryString.length() > 0)
-
receivingURL.append("?").append(request.getQueryString());
-
- // verify the response
- VerificationResult verification =
consumerManager.verify(receivingURL
- .toString(), openidResp, discovered);
-
- verification.getVerifiedId();
-
- Message authResponse = verification.getAuthResponse();
-
- if (authResponse instanceof AuthSuccess) {
-
- Identifier verified = verification.getVerifiedId();
- String identifier = null;
-
- if (verified != null) {
- identifier = verified.getIdentifier();
- }
-
- AuthSuccess authSuccess = (AuthSuccess) authResponse;
-
- FetchResponse fetchResp = null;
-
-/* Map<String, String> attributes = new
LinkedHashMap<String, String>();
-
- MessageExtension ext = authSuccess
- .getExtension(AxMessage.OPENID_NS_AX);
-
- if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)
- && ext instanceof FetchResponse) {
- fetchResp = (FetchResponse) ext;
-
- // extract the rest of the optional attributes
- List aliases = fetchResp.getAttributeAliases();
- Map types = fetchResp.getAttributeTypes();
- String alias;
- List values;
- for (Object a : aliases) {
- alias = (String) a;
- values =
fetchResp.getAttributeValues(alias);
-
attributes.put(attributes.get(types.get(alias)), values
- .size() > 0 ? (String)
values.get(0) : null);
- }
- }
-
- session.setAttribute(LOGGEDIN, "");
-
- session.setAttribute("attributes", attributes);
- session.setAttribute("identifier", identifier);
- session.setAttribute("message", fetchResp);*/
-
- }
}
_______________________________________________
Identity-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/identity-dev