本文整理汇总了Java中org.openid4java.consumer.VerificationResult.getVerifiedId方法的典型用法代码示例。如果您正苦于以下问题:Java VerificationResult.getVerifiedId方法的具体用法?Java VerificationResult.getVerifiedId怎么用?Java VerificationResult.getVerifiedId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openid4java.consumer.VerificationResult
的用法示例。
在下文中一共展示了VerificationResult.getVerifiedId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: handleIdRes
import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
private void handleIdRes(IMxRuntimeRequest req, IMxRuntimeResponse resp, HttpServletRequest origreq,
ParameterList openidResp, String mxid2Continuation) throws Exception {
// extract the receiving URL from the HTTP request
StringBuffer receivingURL = new StringBuffer(OPENID_RETURN_URL);
String queryString = origreq.getQueryString();
if (queryString != null && queryString.length() > 0)
receivingURL.append("?").append(origreq.getQueryString());
// verify the response
LOG.info("[OpenID Verify Response] receivingurl: " + receivingURL + "; to: " + openidResp.getParameter("openid.return_to"));
VerificationResult verification = manager.verify(receivingURL.toString(), openidResp, discovered);
// examine the verification result and extract the verified identifier
Identifier verified = verification.getVerifiedId();
if (verified != null) {
String userId = verified.getIdentifier();
lockOpenID(userId);
try {
loginHandler.onCompleteLogin(userId, mxid2Continuation, req, resp);
} finally {
unlockOpenID(userId);
}
} else {
LOG.warn("OpenId authentication failed: " + verification.getStatusMsg());
resp.setStatus(IMxRuntimeResponse.UNAUTHORIZED);
error(resp, ResponseType.UNAUTHORIZED, "OpenId authentication request failed. Please try again later.", null);
}
}
示例3: handleIdRes
import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
private void handleIdRes(IMxRuntimeRequest req, IMxRuntimeResponse resp, HttpServletRequest origreq,
ParameterList openidResp, String mxid2Continuation) throws Exception {
// extract the receiving URL from the HTTP request
StringBuffer receivingURL = new StringBuffer(OpenIDReturnURL);
String queryString = origreq.getQueryString();
if (queryString != null && queryString.length() > 0)
receivingURL.append("?").append(origreq.getQueryString());
// verify the response
log.info("[OpenID Verify Response] receivingurl: " + receivingURL + "; to: " + openidResp.getParameter("openid.return_to"));
VerificationResult verification = manager.verify(receivingURL.toString(), openidResp, discovered);
// examine the verification result and extract the verified identifier
Identifier verified = verification.getVerifiedId();
if (verified != null) {
String userId = verified.getIdentifier();
lockOpenID(userId);
try {
loginHandler.onCompleteLogin(userId, mxid2Continuation, req, resp);
} finally {
unlockOpenID(userId);
}
} else {
log.warn("OpenId authentication failed: " + verification.getStatusMsg());
resp.setStatus(IMxRuntimeResponse.UNAUTHORIZED);
error(resp, ResponseType.UNAUTHORIZED, "OpenId authentication request failed. Please try again later.", null);
}
}
示例4: enter
import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
/**
* SiteView constructSite occurred.
*/
@Override
public void enter(final String parameterString) {
final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
final Company company = getSite().getSiteContext().getObject(Company.class);
try {
final VerificationResult verification = OpenIdUtil.getVerificationResult(company.getUrl(), "openidlink");
final Identifier identifier = verification.getVerifiedId();
if (identifier != null) {
final String userEmailAddress = getSite().getSecurityProvider().getUser();
final User user = UserDao.getUser(entityManager, company, userEmailAddress);
user.setOpenIdIdentifier(identifier.getIdentifier());
SecurityService.updateUser(getSite().getSiteContext(), user);
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "account",
"OpenID authenticated user as: " + identifier.getIdentifier(),
Notification.Type.HUMANIZED_MESSAGE);
}else {
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "account",
"OpenID authentication failed:" + verification.getStatusMsg(),
Notification.Type.ERROR_MESSAGE);
}
} catch (final Exception exception) {
LOGGER.error("Error linking OpenID account.", exception);
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "account",
"Error linking OpenID account.",
Notification.Type.ERROR_MESSAGE);
}
}
示例5: 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;
}
示例6: showAnswer
import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
@RequestMapping(value = "/openidAnswer", method = GET)
public ModelAndView showAnswer(HttpServletRequest request) throws Exception {
ParameterList response = new ParameterList(request.getParameterMap());
// retrieve the previously stored discovery information
DiscoveryInformation discovered =
(DiscoveryInformation) request.getSession().getAttribute(DISCOVERY_SESSION_KEY);
// extract the receiving URL from the HTTP request
StringBuffer receivingURL = request.getRequestURL();
String queryString = request.getQueryString();
if (queryString != null && queryString.length() > 0) {
receivingURL.append("?").append(request.getQueryString());
}
// verify the response
VerificationResult verification = manager.verify(
receivingURL.toString(),
response, discovered);
// examine the verification result and extract the verified identifier
Identifier identifier = verification.getVerifiedId();
ModelAndView modelAndView = new ModelAndView("answer");
modelAndView.addObject("identifier", identifier);
if (identifier != null) {
modelAndView.addObject("uniqueId", getUniqueId(identifier.getIdentifier()));
} else {
modelAndView.addObject("uniqueId", "no Id received");
}
return modelAndView;
}
示例7: 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;
}
示例8: 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;
}
示例9: enter
import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
/**
* SiteView constructSite occurred.
*/
@Override
public void enter(final String parameterString) {
final EntityManager entityManager = getSite().getSiteContext().getObject(EntityManager.class);
final Company company = getSite().getSiteContext().getObject(Company.class);
final HttpServletRequest request = ((VaadinServletRequest) VaadinService.getCurrentRequest())
.getHttpServletRequest();
try {
final VerificationResult verification = OpenIdUtil.getVerificationResult(company.getUrl(), "openidlogin");
final Identifier identifier = verification.getVerifiedId();
if (identifier == null) {
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
getSite().localize("message-login-failed")
+ ":" + verification.getStatusMsg(),
Notification.Type.ERROR_MESSAGE
);
}
final User user = UserDao.getUserByOpenIdIdentifier(entityManager, company, identifier.getIdentifier());
if (user == null) {
LOGGER.warn("User OpenID login failed due to not registered Open ID identifier: "
+ identifier.getIdentifier()
+ " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
getSite().localize("message-login-failed"),
Notification.Type.WARNING_MESSAGE);
return;
}
if (user.isLockedOut()) {
LOGGER.warn("User login failed due to user being locked out: " + user.getEmailAddress()
+ " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
getSite().localize("message-login-failed"),
Notification.Type.WARNING_MESSAGE);
return;
}
LOGGER.info("User login: " + user.getEmailAddress()
+ " (IP: " + request.getRemoteHost() + ":" + request.getRemotePort() + ")");
AuditService.log(getSite().getSiteContext(), "openid password login");
final List<Group> groups = UserDao.getUserGroups(entityManager, company, user);
SecurityService.updateUser(getSite().getSiteContext(), user);
((SecurityProviderSessionImpl) getSite().getSecurityProvider()).setUser(user, groups);
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(),
getSite().getCurrentNavigationVersion().getDefaultPageName(),
getSite().localize("message-login-success") + " (" + user.getEmailAddress() + ")",
Notification.Type.HUMANIZED_MESSAGE);
} catch (final Exception exception) {
LOGGER.error("Error logging in OpenID user.", exception);
((AbstractSiteUI) UI.getCurrent()).redirectTo(company.getUrl(), "login",
getSite().localize("message-login-error"),
Notification.Type.ERROR_MESSAGE);
}
}
示例10: doPost
import org.openid4java.consumer.VerificationResult; //导入方法依赖的package包/类
@Override
protected void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException {
// auth response info
Map<Object, Object> ri = new HashMap<Object, Object>();
// requested URL
String url = req.getRequestURL().toString();
// parameter map
Map<String, String> pm = new HashMap<String, String>();
for (String p : req.getParameterMap().keySet()) {
if (req.getParameterMap().get(p).length == 1) {
pm.put(p, req.getParameterMap().get(p)[0]);
} else {
pm.put(p, Arrays.toString(req.getParameterMap().get(p)));
}
}
// view info
ri.put("return_url", url);
ri.put("return_parameters", pm);
req.setAttribute("info", ri);
try {
DiscoveryInformation di = (DiscoveryInformation) req.getSession().getAttribute("openid4java-rp-sample.discovery");
VerificationResult vr = cm.verify(url, new ParameterList(req.getParameterMap()), di);
Identifier i = vr.getVerifiedId();
ri.put("verified", i != null);
if (i != null) {
ri.put("id", i.getIdentifier());
}
ri.put("return_parameters", vr.getAuthResponse().getParameterMap());
// reseting session
req.getSession().removeAttribute("openid4java-rp-sample.discovery");
} catch (Throwable t) {
// view error
req.setAttribute("error", t.getMessage());
}
// show view
req.getRequestDispatcher("WEB-INF/return.jsp").forward(req, res);
}
示例11: 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;
}