本文整理汇总了Java中com.mendix.m2ee.api.IMxRuntimeResponse类的典型用法代码示例。如果您正苦于以下问题:Java IMxRuntimeResponse类的具体用法?Java IMxRuntimeResponse怎么用?Java IMxRuntimeResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMxRuntimeResponse类属于com.mendix.m2ee.api包,在下文中一共展示了IMxRuntimeResponse类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: handleXrds
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void handleXrds(IMxRuntimeResponse resp) throws IOException {
LOG.info("Found local discovery of RP return_url endpoint.");
resp.setContentType("application/xrds+xml; charset=UTF-8");
resp.getWriter().write(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<xrds:XRDS xmlns:xrds=\"xri://$xrds\" xmlns=\"xri://$xrd*($v*2.0)\"" +
" xmlns:openid=\"http://openid.net/xmlns/1.0\">" +
"<XRD>" +
"<Service>" +
"<Type>http://specs.openid.net/auth/2.0/return_to</Type>" +
"<URI>" + OPENID_RETURN_URL + "</URI>" +
"</Service>" +
"</XRD>" +
"</xrds:XRDS>");
resp.getWriter().close();
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:18,代码来源:OpenIDHandler.java
示例2: redirectToIndex
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
public static void redirectToIndex(IMxRuntimeResponse resp, String continuation)
{
resp.setStatus(IMxRuntimeResponse.SEE_OTHER);
//no continuation provided, use index
if (continuation == null)
resp.addHeader("location", OpenIDHandler.INDEX_PAGE);
else {
if (continuation.trim().startsWith("javascript:")) {
throw new IllegalArgumentException("Javascript injection detected!");
} else if (!continuation.startsWith("http://") && !continuation.startsWith("https://")) {
resp.addHeader("location", OpenIDUtils.APPLICATION_ROOT_URL + continuation);
} else {
resp.addHeader("location", continuation);
}
}
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:18,代码来源:SessionInitializer.java
示例3: handleXrds
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void handleXrds(IMxRuntimeResponse resp) throws IOException {
log.info("Found local discovery of RP return_url endpoint.");
resp.setContentType("application/xrds+xml; charset=UTF-8");
resp.getWriter().write(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<xrds:XRDS xmlns:xrds=\"xri://$xrds\" xmlns=\"xri://$xrd*($v*2.0)\"" +
" xmlns:openid=\"http://openid.net/xmlns/1.0\">" +
"<XRD>" +
"<Service>" +
"<Type>http://specs.openid.net/auth/2.0/return_to</Type>" +
"<URI>" + OpenIDReturnURL + "</URI>" +
"</Service>" +
"</XRD>" +
"</xrds:XRDS>");
resp.getWriter().close();
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:18,代码来源:OpenIDHandler.java
示例4: writeGetResult
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void writeGetResult(RestServiceRequest rsr, String key, JSONObject result, String eTag) {
if (eTag.equals(rsr.getETag())) {
rsr.setStatus(IMxRuntimeResponse.NOT_MODIFIED);
rsr.close();
return;
}
rsr.response.setHeader(RestServices.HEADER_ETAG, eTag);
rsr.startDoc();
if (rsr.getResponseContentType() == ResponseType.HTML)
rsr.write("<h1>").write(getRelativeUrl()).write("/").write(key).write("</h1>");
rsr.datawriter.value(result);
rsr.endDoc();
}
开发者ID:mendix,项目名称:RestServices,代码行数:17,代码来源:DataService.java
示例5: serveChanges
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
public void serveChanges(RestServiceRequest rsr, boolean asFeed) throws IOException, CoreException, RestPublishException {
if (!service.def.getEnableChangeLog())
throw new RestPublishException(RestExceptionType.METHOD_NOT_ALLOWED, "Change tracking is not enabled for this service");
rsr.response.setStatus(IMxRuntimeResponse.OK);
rsr.response.flushBuffer();
long since = 0;
rsr.startDoc();
if (rsr.request.getParameter(RestServices.PARAM_SINCE) != null)
since = Long.parseLong(rsr.request.getParameter(RestServices.PARAM_SINCE));
if (asFeed) {
String longPollMaxDuration = rsr.request.getParameter(RestServices.PARAM_TIMEOUT);
serveChangesFeed(rsr, since, Utils.isEmpty(longPollMaxDuration) ? RestServices.LONGPOLL_MAXDURATION : Long.valueOf(longPollMaxDuration));
}
else {
serveChangesList(rsr, since);
rsr.endDoc(); //Changes Feed doc ends async
}
}
开发者ID:mendix,项目名称:RestServices,代码行数:25,代码来源:ChangeLogManager.java
示例6: onCompleteAnonymousLogin
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
public void onCompleteAnonymousLogin(String continuation, IMxRuntimeRequest req, IMxRuntimeResponse resp)
throws CoreException, IllegalStateException, IOException
{
try {
/** Setting up guest sessions is not the responsibility of this module, but otherwise:
if (Core.getConfiguration().getEnableGuestLogin()) {
ISession session = Core.initializeGuestSession();
SessionInitializer.writeSessionCookies(resp, session);
}
*/
SessionInitializer.redirectToIndex(resp, continuation);
} catch (Exception e) {
OpenIDHandler.error(resp, ResponseType.INTERNAL_SERVER_ERROR, "Failed to initialize session", e);
}
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:16,代码来源:DefaultLoginHandler.java
示例7: callback
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void callback(IMxRuntimeRequest req, IMxRuntimeResponse resp) throws Exception {
LOG.debug("Callback from OpenID provider, evaluating..");
HttpServletRequest origreq = req.getHttpServletRequest();
//verification request?
if (origreq.getMethod().equals("HEAD")) {
handleHeadRequest(resp);
} else if (req.getHeader("Accept") != null && req.getHeader("Accept").contains("application/xrds+xml")) {
handleXrds(resp);
} else {
ParameterList openidResp = new ParameterList(origreq.getParameterMap());
String mxid2Continuation = req.getParameter("mxid2.continuation");
detectContinuationJsInjection(mxid2Continuation);
String mode = openidResp.getParameter("openid.mode").getValue();
if ("setup_needed".equalsIgnoreCase(mode)) {
/*
* original request mode is immediate, because checkid setup would not have returned id_res without verified ID.
* Return to return url, but without identity.
*
* @See http://openid.net/specs/openid-authentication-2_0.html#negative_assertions
*/
if (LOG.isDebugEnabled())
LOG.debug("Immediate authentication responded with setup_needed. Assuming that the app should continue as anonymous. ");
loginHandler.onCompleteAnonymousLogin(mxid2Continuation, req, resp);
} else if ("id_res".equals(mode)) {
handleIdRes(req, resp, origreq, openidResp, mxid2Continuation);
} else if ("cancel".equals(mode)) {
LOG.warn("OpenId login failed: cancelled");
resp.setStatus(IMxRuntimeResponse.UNAUTHORIZED);
error(resp, ResponseType.UNAUTHORIZED, "OpenId login failed. Please try again later.", null);
} else
throw new IllegalStateException("Unexpected OpenID callback mode: " + mode);
}
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:39,代码来源:OpenIDHandler.java
示例8: handleIdRes
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的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);
}
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:31,代码来源:OpenIDHandler.java
示例9: login
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void login(IMxRuntimeRequest req, IMxRuntimeResponse resp) throws Exception {
String continuation = req.getParameter(CONTINUATION_PARAM);
detectContinuationJsInjection(continuation);
//special case 1: already a valid session, do not bother with a new login
ISession session = this.getSessionFromRequest(req);
if (session != null && !session.getUser().isAnonymous()) {
//Logout old session and initialize new session. This will allow for role changes to take effect.
String userId = session.getUser().getName();
lockOpenID(userId);
try {
loginHandler.onCompleteLogin(userId, continuation, req, resp);
Core.logout(session);
} finally {
unlockOpenID(userId);
}
} else if (!started) {
//special case 2: no OpenID provider discovered
LOG.warn("OpenId handler is in state 'NOT STARTED'. Falling back to default login.html");
redirect(resp, FALLBACK_LOGINPAGE);
} else {
LOG.debug("Incoming login request, redirecting to OpenID provider");
AuthRequest authReq = manager.authenticate(discovered, OPENID_RETURN_URL);
authReq.setImmediate("true".equalsIgnoreCase(req.getParameter(IMMEDIATE_PARAM)));
String url = authReq.getDestinationUrl(true);
//MWE: publish the url which can be used to sign off
if (SINGLESIGNOFF_ENABLED)
url += "&mxid2.logoffcallback=" + OpenIDUtils.urlEncode(OPENID_LOGOFF_URL);
if (continuation != null)
url += "&mxid2.continuation=" + OpenIDUtils.urlEncode(continuation);
redirect(resp, url);
}
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:40,代码来源:OpenIDHandler.java
示例10: forceLogoff
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void forceLogoff(IMxRuntimeRequest req, IMxRuntimeResponse resp) {
String username = req.getParameter("openid");
String fingerprint = req.getParameter("fingerprint");
if (SINGLESIGNOFF_ENABLED)
forceSessionLogoff(username, fingerprint);
else
LOG.warn("Received force_logoff request, but single sign off is not unabled in the configuration!");
resp.setStatus(IMxRuntimeResponse.OK);
resp.setContentType("text/plain");
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:13,代码来源:OpenIDHandler.java
示例11: logoff
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void logoff(IMxRuntimeRequest req, IMxRuntimeResponse resp) throws CoreException {
if (SINGLESIGNOFF_ENABLED) {
resp.addCookie(getSessionCookieName(), "", "/", "", 0, true);
resp.addCookie(SessionInitializer.XASID_COOKIE, "", "/", "", 0, true);
resp.setStatus(IMxRuntimeResponse.SEE_OTHER);
resp.addHeader("location", OPENID_PROVIDER + "/../" + LOGOFF);
} else {
ISession ses = this.getSessionFromRequest(req);
if (ses != null) {
Core.logout(ses);
}
redirect(resp, INDEX_PAGE);
}
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:15,代码来源:OpenIDHandler.java
示例12: error
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
public static void error(IMxRuntimeResponse resp, ResponseType responseType, String message, Throwable e) throws IOException {
resp.setStatus(responseType.status);
resp.getWriter().write(
INTERNAL_SERVER_ERROR_MESSAGE
.replace("{{message}}", StringEscapeUtils.escapeHtml(message))
.replace("{{title}}", StringEscapeUtils.escapeHtml(responseType.title))
);
if (e != null)
LOG.error("Error while handling OpenID request: " + responseType.title + ":\n" + message + ": " + e.getMessage(), e);
else
LOG.error("Error while handling OpenID request: " + responseType.title + ":\n" + message);
}
开发者ID:mendix,项目名称:IBM-Watson-Connector-Suite,代码行数:13,代码来源:OpenIDHandler.java
示例13: callback
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void callback(IMxRuntimeRequest req, IMxRuntimeResponse resp) throws Exception {
log.debug("Callback from OpenID provider, evaluating..");
HttpServletRequest origreq = req.getHttpServletRequest();
//verification request?
if (origreq.getMethod().equals("HEAD")) {
handleHeadRequest(resp);
} else if (req.getHeader("Accept") != null && req.getHeader("Accept").contains("application/xrds+xml")) {
handleXrds(resp);
} else {
ParameterList openidResp = new ParameterList(origreq.getParameterMap());
String mxid2Continuation = req.getParameter("mxid2.continuation");
detectContinuationJsInjection(mxid2Continuation);
String mode = openidResp.getParameter("openid.mode").getValue();
if ("setup_needed".equalsIgnoreCase(mode)) {
/*
* original request mode is immediate, because checkid setup would not have returned id_res without verified ID.
* Return to return url, but without identity.
*
* @See http://openid.net/specs/openid-authentication-2_0.html#negative_assertions
*/
if (log.isDebugEnabled())
log.debug("Immediate authentication responded with setup_needed. Assuming that the app should continue as anonymous. ");
loginHandler.onCompleteAnonymousLogin(mxid2Continuation, req, resp);
} else if ("id_res".equals(mode)) {
handleIdRes(req, resp, origreq, openidResp, mxid2Continuation);
} else if ("cancel".equals(mode)) {
log.warn("OpenId login failed: cancelled");
resp.setStatus(IMxRuntimeResponse.UNAUTHORIZED);
error(resp, ResponseType.UNAUTHORIZED, "OpenId login failed. Please try again later.", null);
} else
throw new IllegalStateException("Unexpected OpenID callback mode: " + mode);
}
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:39,代码来源:OpenIDHandler.java
示例14: handleIdRes
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的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);
}
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:31,代码来源:OpenIDHandler.java
示例15: login
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void login(IMxRuntimeRequest req, IMxRuntimeResponse resp) throws Exception {
String continuation = req.getParameter(CONTINUATION_PARAM);
detectContinuationJsInjection(continuation);
//special case 1: already a valid session, do not bother with a new login
ISession session = this.getSessionFromRequest(req);
if (session != null && !session.getUser().isAnonymous()) {
//Logout old session and initialize new session. This will allow for role changes to take effect.
String userId = session.getUser().getName();
lockOpenID(userId);
try {
loginHandler.onCompleteLogin(userId, continuation, req, resp);
Core.logout(session);
} finally {
unlockOpenID(userId);
}
} else if (!started) {
//special case 2: no OpenID provider discovered
log.warn("OpenId handler is in state 'NOT STARTED'. Falling back to default login.html");
redirect(resp, FALLBACK_LOGINPAGE);
} else {
log.debug("Incoming login request, redirecting to OpenID provider");
AuthRequest authReq = manager.authenticate(discovered, OpenIDReturnURL);
authReq.setImmediate("true".equalsIgnoreCase(req.getParameter(IMMEDIATE_PARAM)));
String url = authReq.getDestinationUrl(true);
//MWE: publish the url which can be used to sign off
if (SINGLESIGNOFF_ENABLED)
url += "&mxid2.logoffcallback=" + OpenIDUtils.urlEncode(OpenIDLogoffURL);
if (continuation != null)
url += "&mxid2.continuation=" + OpenIDUtils.urlEncode(continuation);
redirect(resp, url);
}
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:40,代码来源:OpenIDHandler.java
示例16: forceLogoff
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void forceLogoff(IMxRuntimeRequest req, IMxRuntimeResponse resp) {
String username = req.getParameter("openid");
String fingerprint = req.getParameter("fingerprint");
if (SINGLESIGNOFF_ENABLED)
forceSessionLogoff(username, fingerprint);
else
log.warn("Received force_logoff request, but single sign off is not unabled in the configuration!");
resp.setStatus(IMxRuntimeResponse.OK);
resp.setContentType("text/plain");
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:13,代码来源:OpenIDHandler.java
示例17: logoff
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void logoff(IMxRuntimeRequest req, IMxRuntimeResponse resp) throws CoreException {
if (SINGLESIGNOFF_ENABLED) {
resp.addCookie(Core.getConfiguration().getSessionIdCookieName(), "", "/", "", 0, true);
resp.addCookie(SessionInitializer.XASID_COOKIE, "", "/", "", 0, true);
resp.setStatus(IMxRuntimeResponse.SEE_OTHER);
resp.addHeader("location", OPENID_PROVIDER + "/../" + LOGOFF);
} else {
ISession ses = this.getSessionFromRequest(req);
if (ses != null) {
Core.logout(ses);
}
redirect(resp, INDEX_PAGE);
}
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:15,代码来源:OpenIDHandler.java
示例18: error
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
public static void error(IMxRuntimeResponse resp, ResponseType responseType, String message, Throwable e) throws IOException {
resp.setStatus(responseType.status);
resp.getWriter().write(
INTERNAL_SERVER_ERROR_MESSAGE
.replace("{{message}}", StringEscapeUtils.escapeHtml(message))
.replace("{{title}}", StringEscapeUtils.escapeHtml(responseType.title))
);
if (e != null)
log.error("Error while handling OpenID request: " + responseType.title + ":\n" + message + ": " + e.getMessage(), e);
else
log.error("Error while handling OpenID request: " + responseType.title + ":\n" + message);
}
开发者ID:mendix,项目名称:EmailModuleWithTemplates,代码行数:13,代码来源:OpenIDHandler.java
示例19: RestServiceRequest
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
public RestServiceRequest(HttpServletRequest request, HttpServletResponse response, IMxRuntimeResponse mxresponse, String relpath) {
this.request = request;
this.response = response;
this.mxresponse = mxresponse;
this.relpath = relpath;
this.requestContentType = determineRequestContentType(request);
this.responseContentType = determineResponseContentType(request);
try {
this.datawriter = new DataWriter(response.getOutputStream(), responseContentType == ResponseType.HTML ? DataWriter.HTML : responseContentType == ResponseType.XML ? DataWriter.XML : DataWriter.JSON);
} catch (IOException e) {
throw new RuntimeException(e);
}
}
开发者ID:mendix,项目名称:RestServices,代码行数:16,代码来源:RestServiceRequest.java
示例20: serveGetFromIndex
import com.mendix.m2ee.api.IMxRuntimeResponse; //导入依赖的package包/类
private void serveGetFromIndex(RestServiceRequest rsr, String key) throws Exception {
ChangeItem source = getObjectStateByKey(rsr.getContext(), key);
if (source == null || source.getIsDeleted() || source.get_IsDirty())
throw new RestPublishException(RestExceptionType.NOT_FOUND, getRelativeUrl() + "/" + key);
if (Utils.isNotEmpty(rsr.getETag()) && rsr.getETag().equals(source.getEtag())) {
rsr.setStatus(IMxRuntimeResponse.NOT_MODIFIED);
rsr.close();
return;
}
writeGetResult(rsr,key, new JSONObject(source.getJson()), source.getEtag());
}
开发者ID:mendix,项目名称:RestServices,代码行数:14,代码来源:DataService.java
注:本文中的com.mendix.m2ee.api.IMxRuntimeResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论