本文整理汇总了C++中HTTPResponse::sendRedirect方法的典型用法代码示例。如果您正苦于以下问题:C++ HTTPResponse::sendRedirect方法的具体用法?C++ HTTPResponse::sendRedirect怎么用?C++ HTTPResponse::sendRedirect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HTTPResponse
的用法示例。
在下文中一共展示了HTTPResponse::sendRedirect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: metadataLocker
pair<bool,long> AssertionConsumerService::processMessage(
const Application& application, const HTTPRequest& httpRequest, HTTPResponse& httpResponse
) const
{
#ifndef SHIBSP_LITE
// Locate policy key.
pair<bool,const char*> policyId = getString("policyId", m_configNS.get()); // namespace-qualified if inside handler element
if (!policyId.first)
policyId = application.getString("policyId"); // unqualified in Application(s) element
// Access policy properties.
const PropertySet* settings = application.getServiceProvider().getPolicySettings(policyId.second);
pair<bool,bool> validate = settings->getBool("validate");
// Lock metadata for use by policy.
Locker metadataLocker(application.getMetadataProvider());
// Create the policy.
shibsp::SecurityPolicy policy(application, &m_role, validate.first && validate.second);
string relayState;
try {
// Decode the message and process it in a protocol-specific way.
auto_ptr<XMLObject> msg(m_decoder->decode(relayState, httpRequest, policy));
if (!msg.get())
throw BindingException("Failed to decode an SSO protocol response.");
recoverRelayState(application, httpRequest, httpResponse, relayState);
implementProtocol(application, httpRequest, httpResponse, policy, settings, *msg.get());
auto_ptr_char issuer(policy.getIssuer() ? policy.getIssuer()->getName() : NULL);
// History cookie.
if (issuer.get() && *issuer.get())
maintainHistory(application, httpRequest, httpResponse, issuer.get());
// Now redirect to the state value. By now, it should be set to *something* usable.
return make_pair(true, httpResponse.sendRedirect(relayState.c_str()));
}
catch (XMLToolingException& ex) {
if (!relayState.empty())
ex.addProperty("RelayState", relayState.c_str());
throw;
}
#else
throw ConfigurationException("Cannot process message using lite version of shibsp library.");
#endif
}
示例2: postjan
pair<bool,long> AssertionConsumerService::finalizeResponse(
const Application& application, const HTTPRequest& httpRequest, HTTPResponse& httpResponse, string& relayState
) const
{
DDF postData = recoverPostData(application, httpRequest, httpResponse, relayState.c_str());
DDFJanitor postjan(postData);
recoverRelayState(application, httpRequest, httpResponse, relayState);
application.limitRedirect(httpRequest, relayState.c_str());
// Now redirect to the state value. By now, it should be set to *something* usable.
// First check for POST data.
if (!postData.islist()) {
m_log.debug("ACS returning via redirect to: %s", relayState.c_str());
return make_pair(true, httpResponse.sendRedirect(relayState.c_str()));
}
else {
m_log.debug("ACS returning via POST to: %s", relayState.c_str());
return make_pair(true, sendPostResponse(application, httpResponse, relayState.c_str(), postData));
}
}
示例3: metadataLocker
pair<bool,long> AssertionConsumerService::processMessage(
const Application& application, const HTTPRequest& httpRequest, HTTPResponse& httpResponse
) const
{
#ifndef SHIBSP_LITE
// Locate policy key.
pair<bool,const char*> prop = getString("policyId", m_configNS.get()); // may be namespace-qualified if inside handler element
if (!prop.first)
prop = getString("policyId"); // try unqualified
if (!prop.first)
prop = application.getString("policyId"); // unqualified in Application(s) element
// Lock metadata for use by policy.
Locker metadataLocker(application.getMetadataProvider());
// Create the policy.
scoped_ptr<opensaml::SecurityPolicy> policy(
application.getServiceProvider().getSecurityPolicyProvider()->createSecurityPolicy(
application, &IDPSSODescriptor::ELEMENT_QNAME, prop.second
)
);
string relayState;
scoped_ptr<XMLObject> msg;
try {
// Decode the message and process it in a protocol-specific way.
msg.reset(m_decoder->decode(relayState, httpRequest, *(policy.get())));
if (!msg)
throw BindingException("Failed to decode an SSO protocol response.");
implementProtocol(application, httpRequest, httpResponse, *policy, nullptr, *msg);
// History cookie.
auto_ptr_char issuer(policy->getIssuer() ? policy->getIssuer()->getName() : nullptr);
if (issuer.get() && *issuer.get())
maintainHistory(application, httpRequest, httpResponse, issuer.get());
const EntityDescriptor* entity =
dynamic_cast<const EntityDescriptor*>(policy->getIssuerMetadata() ? policy->getIssuerMetadata()->getParent() : nullptr);
prop = application.getRelyingParty(entity)->getString("sessionHook");
if (prop.first) {
string hook(prop.second);
httpRequest.absolutize(hook);
// Compute the return URL. We use a self-referential link plus a hook indicator to break the cycle
// and the relay state.
const URLEncoder* encoder = XMLToolingConfig::getConfig().getURLEncoder();
string returnURL = httpRequest.getRequestURL();
returnURL = returnURL.substr(0, returnURL.find('?')) + "?hook=1";
if (!relayState.empty())
returnURL += "&target=" + encoder->encode(relayState.c_str());
if (hook.find('?') == string::npos)
hook += '?';
else
hook += '&';
hook += "return=" + encoder->encode(returnURL.c_str());
// Add the translated target resource in case it's of interest.
if (!relayState.empty()) {
try {
recoverRelayState(application, httpRequest, httpResponse, relayState, false);
hook += "&target=" + encoder->encode(relayState.c_str());
}
catch (std::exception& ex) {
m_log.warn("error recovering relay state: %s", ex.what());
}
}
return make_pair(true, httpResponse.sendRedirect(hook.c_str()));
}
return finalizeResponse(application, httpRequest, httpResponse, relayState);
}
catch (XMLToolingException& ex) {
// Recover relay state.
if (!relayState.empty()) {
try {
recoverRelayState(application, httpRequest, httpResponse, relayState, false);
}
catch (std::exception& rsex) {
m_log.warn("error recovering relay state: %s", rsex.what());
relayState.erase();
recoverRelayState(application, httpRequest, httpResponse, relayState, false);
}
}
// Check for isPassive error condition.
const char* sc2 = ex.getProperty("statusCode2");
if (sc2 && !strcmp(sc2, "urn:oasis:names:tc:SAML:2.0:status:NoPassive")) {
pair<bool,bool> ignore = getBool("ignoreNoPassive", m_configNS.get()); // may be namespace-qualified inside handler element
if (!ignore.first)
ignore = getBool("ignoreNoPassive"); // try unqualified
if (ignore.first && ignore.second && !relayState.empty()) {
m_log.debug("ignoring SAML status of NoPassive and redirecting to resource...");
return make_pair(true, httpResponse.sendRedirect(relayState.c_str()));
}
}
if (!relayState.empty()) {
ex.addProperty("RelayState", relayState.c_str());
}
//.........这里部分代码省略.........