Package org.openid4java.message.sreg

Examples of org.openid4java.message.sreg.SRegResponse


      AuthSuccess authSuccess) throws MessageException {
    if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
      MessageExtension ext = authSuccess
          .getExtension(SRegMessage.OPENID_NS_SREG);
      if (ext instanceof SRegResponse) {
        SRegResponse sregResp = (SRegResponse) ext;
        for (Iterator iter = sregResp.getAttributeNames()
            .iterator(); iter.hasNext();) {
          String name = (String) iter.next();
          String value = sregResp.getParameterValue(name);
          httpReq.setAttribute(name, value);
        }
      }
    }
  }
View Full Code Here


                if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
                    logger.info("resp contains SREG extension");
                    MessageExtension ext = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
                    if (ext instanceof SRegResponse) {
                        logger.info("got a sreg response");
                        SRegResponse sregResp = (SRegResponse) ext;
                        Map sregmap = sregResp.getAttributes();
                        request.setAttribute(sregmapAttrName,  sregmap);
                    }
                }

                if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
View Full Code Here

   */
  public void setSessionAttributes(List<ClaimDTO> claimList) throws IdentityException {

    try {

      SRegResponse sregResp = null;
      Iterator iterator = null;
      Map attributes = null;
      Entry entry = null;

      if (authSuccess.hasExtension(SRegResponse.OPENID_NS_SREG)) {
        sregResp = (SRegResponse) authSuccess.getExtension(SRegResponse.OPENID_NS_SREG);
      } else if (authSuccess
          .hasExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG)) {
        sregResp = (SRegResponse) authSuccess
            .getExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG);

      } else if (authSuccess
          .hasExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG_1)) {
        sregResp = (SRegResponse) authSuccess
            .getExtension(IdentityConstants.OpenId.SimpleRegAttributes.NS_SREG_1);
      }

      if (sregResp != null) {
        ClaimDTO claim = null;
        attributes = sregResp.getAttributes();
        iterator = attributes.entrySet().iterator();
        while (iterator.hasNext()) {
          entry = (Entry) iterator.next();   
          claim = new ClaimDTO();
          claim.setClaimUri((String) entry.getKey());
View Full Code Here

    public MessageExtension getMessageExtension(String userId, String profileName)
            throws IdentityException {

        MessageExtension extension = null;
        AuthRequest authRequest = null;
        SRegResponse response = null;

        try {
            authRequest = request.getAuthRequest();

            if (authRequest.hasExtension(SRegRequest.OPENID_NS_SREG)) {
View Full Code Here

                {
                    // data released by the user
                    Map userDataSReg = new HashMap();
                    userDataSReg.put("email", "user@example.com");

                    SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, userDataSReg);
                    // (alternatively) manually add attribute values
                    //sregResp.addAttribute("email", email);
                    messageResponse.addExtension(sregResp);
                }
            }
View Full Code Here

                    FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                    session.setAttribute("emailFromFetch", fetchResp.getAttributeValues("email").get(0));
                }
                if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG))
                {
                    SRegResponse sregResp = (SRegResponse) authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
                    session.setAttribute("emailFromSReg", sregResp.getAttributeValue("email"));
                }
                return verified;  // success
            }
        }
        catch (OpenIDException e)
View Full Code Here

      }
      return;
    }

    final Message authRsp = result.getAuthResponse();
    SRegResponse sregRsp = null;
    FetchResponse fetchRsp = null;

    if (0 <= papeMaxAuthAge) {
      PapeResponse ext;
      boolean unsupported = false;

      try {
        ext = (PapeResponse) authRsp.getExtension(PapeMessage.OPENID_NS_PAPE);
      } catch (MessageException err) {
        // Far too many providers are unable to provide PAPE extensions
        // right now. Instead of blocking all of them log the error and
        // let the authentication complete anyway.
        //
        log.error("Invalid PAPE response " + openidIdentifier + ": " + err);
        unsupported = true;
        ext = null;
      }
      if (!unsupported && ext == null) {
        log.error("No PAPE extension response from " + openidIdentifier);
        cancelWithError(req, rsp, "OpenID provider does not support PAPE.");
        return;
      }
    }

    if (authRsp.hasExtension(SRegMessage.OPENID_NS_SREG)) {
      final MessageExtension ext =
          authRsp.getExtension(SRegMessage.OPENID_NS_SREG);
      if (ext instanceof SRegResponse) {
        sregRsp = (SRegResponse) ext;
      }
    }

    if (authRsp.hasExtension(AxMessage.OPENID_NS_AX)) {
      final MessageExtension ext = authRsp.getExtension(AxMessage.OPENID_NS_AX);
      if (ext instanceof FetchResponse) {
        fetchRsp = (FetchResponse) ext;
      }
    }

    final com.google.gerrit.server.account.AuthRequest areq =
        new com.google.gerrit.server.account.AuthRequest(openidIdentifier);

    if (sregRsp != null) {
      areq.setDisplayName(sregRsp.getAttributeValue("fullname"));
      areq.setEmailAddress(sregRsp.getAttributeValue("email"));

    } else if (fetchRsp != null) {
      final String firstName = fetchRsp.getAttributeValue("FirstName");
      final String lastName = fetchRsp.getAttributeValue("LastName");
      final StringBuilder n = new StringBuilder();
View Full Code Here

                        {
                            // data released by the user
                            Map userDataSReg = new HashMap();
                            //userData.put("email", "user@example.com");

                            SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, userDataSReg);
                            // (alternatively) manually add attribute values
                            sregResp.addAttribute("email", email);
                            response.addExtension(sregResp);
                        }
                    }
                    else
                    {
View Full Code Here

                    FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
                    session.setAttribute("emailFromFetch", fetchResp.getAttributeValues("email").get(0));
                }
                if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG))
                {
                    SRegResponse sregResp = (SRegResponse) authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
                    session.setAttribute("emailFromSReg", sregResp.getAttributeValue("email"));
                }
                return verified;  // success
            }
        }
        catch (OpenIDException e)
View Full Code Here

        authSuccess.getExtensions();

        if (authSuccess.hasExtension(SRegMessage.OPENID_NS_SREG)) {
          MessageExtension ext = authSuccess.getExtension(SRegMessage.OPENID_NS_SREG);
          if (ext instanceof SRegResponse) {
            SRegResponse sregResp = (SRegResponse) ext;
            for (Iterator iter = sregResp.getAttributeNames().iterator(); iter.hasNext();) {
              String name = (String) iter.next();
              if (LOG.isDebugEnabled())
                LOG.debug(name + " : " + sregResp.getParameterValue(name));
              principal.setMetadataValue(AXSchemaType.valueOfNamespace(name), sregResp.getParameterValue(name));
            }
          }
        }
        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
          FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);
View Full Code Here

TOP

Related Classes of org.openid4java.message.sreg.SRegResponse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.