当前位置: 首页>>代码示例>>Java>>正文


Java VerificationResult.getAuthResponse方法代码示例

本文整理汇总了Java中org.openid4java.consumer.VerificationResult.getAuthResponse方法的典型用法代码示例。如果您正苦于以下问题:Java VerificationResult.getAuthResponse方法的具体用法?Java VerificationResult.getAuthResponse怎么用?Java VerificationResult.getAuthResponse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.openid4java.consumer.VerificationResult的用法示例。


在下文中一共展示了VerificationResult.getAuthResponse方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retrieveUserProfile

import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
@Override
protected U retrieveUserProfile(final OpenIdCredentials credentials, final WebContext context) throws HttpAction {
    final ParameterList parameterList = credentials.getParameterList();
    final DiscoveryInformation discoveryInformation = credentials.getDiscoveryInformation();
    logger.debug("parameterList: {}", parameterList);
    logger.debug("discoveryInformation: {}", discoveryInformation);

    try {
        // verify the response
        final VerificationResult verification = this.consumerManager.verify(computeFinalCallbackUrl(context), parameterList,
                discoveryInformation);

        // examine the verification result and extract the verified identifier
        final Identifier verified = verification.getVerifiedId();
        if (verified != null) {
            final AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();
            logger.debug("authSuccess: {}", authSuccess);

            final U profile = createProfile(authSuccess);
            profile.setId(verified.getIdentifier());
            logger.debug("profile: {}", profile);
            return profile;
        }
    } catch (final OpenIDException e) {
        throw new TechnicalException("OpenID exception", e);
    }

    final String message = "No verifiedId found";
    throw new TechnicalException(message);
}
 
开发者ID:yaochi,项目名称:pac4j-plus,代码行数:31,代码来源:BaseOpenIdClient.java

示例2: verifyResponse

import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
public Identifier verifyResponse(Request httpReq, Map<Object, Object> model, ParameterList params)
		throws ServletException {
	try {
		
		// extract the parameters from the authentication response
           // (which comes in as a HTTP request from the OpenID provider)
           ParameterList parameterList = new ParameterList(httpReq.params());
           parameterList.addParams(params);
		
		// retrieve the previously stored discovery information
		DiscoveryInformation discovered = httpReq.session().attribute("openid-disc");

		// extract the receiving URL from the HTTP request
		StringBuffer receivingURL = httpReq.raw().getRequestURL();
		String queryString = httpReq.queryString();
		if (queryString != null && queryString.length() > 0)
			receivingURL.append("?").append(queryString);

		// verify the response; ConsumerManager needs to be the same
		// (static) instance used to place the authentication request
		VerificationResult verification = manager.verify(receivingURL.toString(), parameterList, discovered);

		// examine the verification result and extract the verified
		// identifier
		Identifier verified = verification.getVerifiedId();
		if (verified != null) {
			AuthSuccess authSuccess = (AuthSuccess) verification.getAuthResponse();

			receiveAttributeExchange(model, authSuccess);
			return verified; // success
		}
	} catch (OpenIDException e) {
		// present error to the user
		throw new ServletException(e);
	}
	return null;
}
 
开发者ID:AveryRegier,项目名称:club-tracker,代码行数:38,代码来源:ConsumerService.java

示例3: isAuthenticationValid

import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
/**
 * Validates the authentication.
 * 
 * @param a_oRequest The request containing the authentication information.
 * @return true if the authentication is valid, otherwise false.
 * @throws OpenIDException
 * @author zschwenk
 */
public String isAuthenticationValid(HttpServletRequest a_oRequest) 
    throws OpenIDException
{
    
    String identifier = null;
    
    // extract the parameters from the authentication response
    // (which comes in as a HTTP request from the OpenID provider)
    ParameterList lstResponse =
            new ParameterList(a_oRequest.getParameterMap());

    // retrieve the previously stored discovery information
    DiscoveryInformation discovered = (DiscoveryInformation)a_oRequest.getSession().getAttribute("openid-disc");

    // extract the receiving URL from the HTTP request
    StringBuffer receivingURL = a_oRequest.getRequestURL();
    String queryString = a_oRequest.getQueryString();
    if (queryString != null && queryString.length() > 0)
        receivingURL.append("?").append(a_oRequest.getQueryString());

    // verify the response; ConsumerManager needs to be the same
    // (static) instance used to place the authentication request
    VerificationResult verification = m_oManager.verify(
            receivingURL.toString(),
            lstResponse, discovered);

    // examine the verification result and extract the verified identifier
    Identifier verified = verification.getVerifiedId();
    
    if (verified != null)
    {
        AuthSuccess authSuccess =
                (AuthSuccess) verification.getAuthResponse();

        if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX))
        {
            FetchResponse fetchResp = (FetchResponse) authSuccess
                    .getExtension(AxMessage.OPENID_NS_AX);
            
            if (fetchResp.getAttributeValue("email") != null) {
                this.email = fetchResp.getAttributeValue("email");
            }
            if (fetchResp.getAttributeValue("altemail") != null && this.email == null) {
                this.email = fetchResp.getAttributeValue("altemail");                    
            }
            
            if (fetchResp.getAttributeValue("first") != null) {
                this.name = fetchResp.getAttributeValue("first");                    
            }
            
            String userName = (this.name == null) ? "" : this.name+" ";
            if (fetchResp.getAttributeValue("last") != null) {
                userName += fetchResp.getAttributeValue("last");
                this.name = userName;
            }                
        }
        
        identifier = verified.getIdentifier();
    }
    
    return identifier;
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:71,代码来源:OpenIdAuthenticator.java

示例4: verifyResponse

import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
public Identifier verifyResponse(HttpServletRequest httpReq)
		throws ServletException {
	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();

			receiveSimpleRegistration(httpReq, authSuccess);

			receiveAttributeExchange(httpReq, authSuccess);

			return verified; // success
		}
	} catch (OpenIDException e) {
		// present error to the user
		throw new ServletException(e);
	}

	return null;
}
 
开发者ID:jbufu,项目名称:openid4java,代码行数:44,代码来源:ConsumerServlet.java

示例5: verifyResponse

import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
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(OpenIdConstants.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();

			if (authSuccess.hasExtension(AxMessage.OPENID_NS_AX)) {
				FetchResponse fetchResp = (FetchResponse) authSuccess.getExtension(AxMessage.OPENID_NS_AX);

				List<?> emails = fetchResp.getAttributeValues("email");
				String email = (String) emails.get(0);
				
				httpReq.getSession().setAttribute(OpenIdConstants.OPENID_SESSION_VAR, new OpenIDUser(email));
			}

			return verified; // success
		}
	} catch (OpenIDException e) {
		// present error to the user
	}

	return null;
}
 
开发者ID:hburgmeier,项目名称:jerseyoauth2,代码行数:43,代码来源:OpenIdConsumer.java


注:本文中的org.openid4java.consumer.VerificationResult.getAuthResponse方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。