本文整理汇总了Java中org.openid4java.message.DirectError.createDirectError方法的典型用法代码示例。如果您正苦于以下问题:Java DirectError.createDirectError方法的具体用法?Java DirectError.createDirectError怎么用?Java DirectError.createDirectError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.openid4java.message.DirectError
的用法示例。
在下文中一共展示了DirectError.createDirectError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: handleError
import org.openid4java.message.DirectError; //导入方法依赖的package包/类
public void handleError(HttpServletResponse response, HttpServletRequest request, final String errorMessage, final int ERROR_CODE) throws IOException {
LOG.info("--> BEGIN handleError");
Message openidResponse = DirectError.createDirectError(errorMessage);
response.setStatus(ERROR_CODE);
response.setContentType("text/html;charset=utf-8");
String responseText = openidResponse.keyValueFormEncoding();
response.getWriter().println(responseText);
String requestContent = String.format("%s %s\n\nParameters:\n\n%s",
request.getMethod(),
request.getRequestURL(),
new ParameterList(request.getParameterMap()));
RequestLogger.getInstance().add(RequestType.ERROR, errorMessage, requestContent, errorMessage, idpType);
LOG.info("--> END handleError");
}
示例2: processRequest
import org.openid4java.message.DirectError; //导入方法依赖的package包/类
/**
* Process the request.
*
* @param httpReq
* the HTTP request
* @param httpResp
* the HTTp resposne
* @return process result string
* @throws Exception
* indicate authenticate error
*/
private String processRequest(final HttpServletRequest httpReq,
final HttpServletResponse httpResp) throws MessageException,
IOException {
Domain domain = this.getDomain(httpReq);
if (getLog().isDebugEnabled()) {
getLog().debug("domain: " + domain);
}
ServerManager serverManager =
this.getJosService().getServerManager(domain);
// extract the parameters from the request
ParameterList request = new ParameterList(httpReq.getParameterMap());
String mode = request.getParameterValue("openid.mode");
Message response;
String responseText;
if ("associate".equals(mode)) {
// --- process an association request ---
response = serverManager.associationResponse(request);
responseText = response.keyValueFormEncoding();
} else if ("checkid_setup".equals(mode)
|| "checkid_immediate".equals(mode)) {
AuthRequest authReq = AuthRequest.createAuthRequest(request,
serverManager.getRealmVerifier());
new ApprovingRequestProcessor(httpReq, httpResp, getJosService(),
serverManager, new ApprovingRequest(authReq)).checkId();
responseText = null;
} else if ("check_authentication".equals(mode)) {
// --- processing a verification request ---
response = serverManager.verify(request);
responseText = response.keyValueFormEncoding();
} else {
// --- error response ---
response = DirectError.createDirectError("Unknown request");
responseText = response.keyValueFormEncoding();
}
// return the result to the user
return responseText;
}
示例3: verify
import org.openid4java.message.DirectError; //导入方法依赖的package包/类
public Message verify(ParameterList requestParams) {
if(log.isDebugEnabled()) {
log.debug("Processing verification request...");
}
boolean isVersion2 = true;
try {
// build request message from response params (+ ntegrity check)
VerifyRequest vrfyReq = VerifyRequest.createVerifyRequest(requestParams);
isVersion2 = vrfyReq.isVersion2();
String handle = vrfyReq.getHandle();
boolean verified = false;
Association assoc = getPrivateAssociations().load(handle);
String sigMod = null;
if (assoc != null) { // verify the signature
if (log.isDebugEnabled()) {
log.debug("Loaded private association; handle: " + handle);
}
sigMod = vrfyReq.getSignature().replaceAll("\\s", "+");
verified = assoc.verifySignature(vrfyReq.getSignedText(), sigMod);
// remove the association so that the request
// cannot be verified more than once
getPrivateAssociations().remove(handle);
} else {
log.error("No association loaded from the database; handle: " + handle);
}
VerifyResponse vrfyResp =
VerifyResponse.createVerifyResponse(!vrfyReq.isVersion2());
vrfyResp.setSignatureVerified(verified);
if (verified) {
String invalidateHandle = vrfyReq.getInvalidateHandle();
if (invalidateHandle != null &&
getSharedAssociations().load(invalidateHandle) == null) {
if (log.isDebugEnabled()) {
log.debug("Shared association invalidated; handle: " + invalidateHandle);
}
vrfyResp.setInvalidateHandle(invalidateHandle);
}
} else {
log.error("Signature verification failed. handle : " + handle +
" , signed text : " + vrfyReq.getSignedText() +
" , signature : " + sigMod);
}
if (log.isDebugEnabled()) {
log.debug("Responding with " + (verified ? "positive" : "negative") + " verification response");
}
return vrfyResp;
} catch (OpenIDException e) {
log.error("Error processing verification request; responding with verification error", e);
return DirectError.createDirectError(e, !isVersion2);
}
}