本文整理汇总了Java中org.openid4java.message.DirectError类的典型用法代码示例。如果您正苦于以下问题:Java DirectError类的具体用法?Java DirectError怎么用?Java DirectError使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DirectError类属于org.openid4java.message包,在下文中一共展示了DirectError类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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");
}
开发者ID:RUB-NDS,项目名称:OpenID-Attacker,代码行数:15,代码来源:CustomOpenIdProviderHandler.java
示例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;
}
开发者ID:sutra,项目名称:openid-server,代码行数:54,代码来源:ServerController.java
示例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);
}
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:64,代码来源:OpenIDServerManager.java
示例4: getErrorResponseText
import org.openid4java.message.DirectError; //导入依赖的package包/类
/**
* Return the error response message based on the given message
*
* @param message Error message
* @return Direct error
*/
private String getErrorResponseText(String message) {
log.error(message);
return DirectError.createDirectError(message).keyValueFormEncoding();
}
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:11,代码来源:OpenIDHandler.java
注:本文中的org.openid4java.message.DirectError类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论