本文整理汇总了Java中com.mendix.m2ee.api.IMxRuntimeResponse类的典型用法代码示例。如果您正苦于以下问题:Java IMxRuntimeResponse类的具体用法?Java IMxRuntimeResponse怎么用?Java IMxRuntimeResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IMxRuntimeResponse类属于com.mendix.m2ee.api包,在下文中一共展示了IMxRuntimeResponse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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);
}
}
}
示例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();
}
示例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();
}
示例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
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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");
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
}