本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}