org.openid4java.message.sreg.SRegResponse Java Examples
The following examples show how to use
org.openid4java.message.sreg.SRegResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ConsumerServlet.java From openid4java with Apache License 2.0 | 6 votes |
/** * @param httpReq * @param authSuccess * @throws MessageException */ private void receiveSimpleRegistration(HttpServletRequest httpReq, 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); } } } }
Example #2
Source File: CustomOpenIdProcessor.java From OpenID-Attacker with GNU General Public License v2.0 | 6 votes |
private Message processSRegExtension(Message token, final AuthRequest authRequest) throws MessageException { String sregNamespace = detectSRegVersion(authRequest); if (sregNamespace != null) { MessageExtension ext = authRequest.getExtension(sregNamespace); if (ext instanceof SRegRequest) { SRegRequest sregReq = (SRegRequest) ext; SRegResponse sregResp = SRegResponse.createSRegResponse(sregReq, getValidUser().getUserDataMap()); token.addExtension(sregResp, "sreg"); } else if (ext instanceof SRegResponse) { // what to do here? } else { final String message = String.format("TODO - Support of '%s'", ext.getClass().getCanonicalName()); throw new UnsupportedOperationException(message); } } return token; }
Example #3
Source File: OpenIDSimpleReg.java From carbon-identity with Apache License 2.0 | 6 votes |
/** * 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. * * @param response Simple Registration response. * @param claimValues Claim values. * @throws MessageException */ protected void setSimpleAttributeRegistrationValues(SRegResponse response, Map<String, OpenIDClaimDTO> claimValues) throws MessageException { Iterator<Entry<String, OpenIDClaimDTO>> iterator = null; OpenIDClaimDTO claim = null; Entry<String, OpenIDClaimDTO> entry = null; iterator = claimValues.entrySet().iterator(); while (iterator.hasNext()) { entry = iterator.next(); claim = entry.getValue(); response.addAttribute(claim.getClaimUri(), claim.getClaimValue()); } }
Example #4
Source File: SampleConsumer.java From openid4java with Apache License 2.0 | 4 votes |
public Identifier verifyResponse(HttpServletRequest httpReq) { try { // extract the parameters from the authentication response // (which comes in as a HTTP request from the OpenID provider) ParameterList response = new ParameterList(httpReq.getParameterMap()); // retrieve the previously stored discovery information DiscoveryInformation discovered = (DiscoveryInformation) httpReq.getSession().getAttribute("openid-disc"); // extract the receiving URL from the HTTP request StringBuffer receivingURL = httpReq.getRequestURL(); String queryString = httpReq.getQueryString(); if (queryString != null && queryString.length() > 0) receivingURL.append("?").append(httpReq.getQueryString()); // verify the response; ConsumerManager needs to be the same // (static) instance used to place the authentication request VerificationResult verification = manager.verify( receivingURL.toString(), response, discovered); // examine the verification result and extract the verified identifier Identifier verified = verification.getVerifiedId(); if (verified != null) { AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse(); HttpSession session = httpReq.getSession(true); session.setAttribute("openid_identifier", authSuccess.getIdentity()); if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) { 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) { // present error to the user throw new RuntimeException("wrap:" + e.getMessage(), e); } return null; }