text
stringlengths
0
2.2M
}
return markers["@Body"].at(markers["@Body"].size()-1);
}
else if(markers.find("@MultipartContent")!=markers.end())
{
if(markers["@MultipartContent"].size()>1)
{
logger << ("Found more than one @MultipartContent marker, only the last defined marker will be considered, ignoring others..") << std::endl;
}
return markers["@MultipartContent"].at(markers["@MultipartContent"].size()-1);
}
return Marker();
}
void ConfigurationHandler::handleRestControllerMarker(ClassStructure& cs, const std::string& appName)
{
Logger logger = LoggerFactory::getLogger("ConfigurationHandler");
Marker restcnt = cs.markers["@RestController"].at(cs.markers["@RestController"].size()-1);
if(cs.markers["@RestController"].size()>1)
{
logger << ("Found more than one @RestController marker, only the last defined marker will be considered, ignoring others..") << std::endl;
}
std::string url = restcnt.getAttributeValue("path");
std::string scope = restcnt.getAttributeValue("scope");
std::string clas = cs.getFullyQualifiedClassName();
StringUtil::trim(url);
bool isClasSecure = false;
if(cs.markers.find("@Secure")!=cs.markers.end())
{
int totl = cs.markers["@Secure"].size();
SecureAspect aspect;
aspect.role = cs.markers["@Secure"].at(totl-1).getAttributeValue("role");
aspect.path = url;
bool valid = true;
if(StringUtil::trimCopy(aspect.role)=="")
{
logger << ("No role defined for Secure path, skipping...") << std::endl;
valid = false;
}
normalizeUrl(appName, aspect.path);
if(cs.markers["@Secure"].size()>1)
{
logger << ("Found more than one @Secure marker, only the last defined marker will be considered, ignoring others..") << std::endl;
}
std::string provName = cs.markers["@Secure"].at(totl-1).getAttributeValue("providerName");
if(StringUtil::trimCopy(provName)=="")
{
logger << ("No providerName defined for Secure path, skipping...") << std::endl;
valid = false;
}
if(valid && ConfigurationData::getInstance()->securityObjectMap[appName].find(provName)
!=ConfigurationData::getInstance()->securityObjectMap[appName].end())
{
Security securityObject = ConfigurationData::getInstance()->securityObjectMap[appName][provName];
if(securityObject.addAspect(aspect))
{
ConfigurationData::getInstance()->securityObjectMap[appName][provName] = securityObject;
isClasSecure = true;
logger << ("Security: Adding Secure Path => " + aspect.path + " , role => " + aspect.role) << std::endl;
}
}
else if(valid)
{
logger << ("Security Provider " + provName + " not found, skipping...") << std::endl;
}
}
for (int var = 0; var < (int)cs.pubms.size(); ++var) {
MethStructure ms = cs.pubms.at(var);
Marker m = getRestFunctionMarker(ms.markers);
if(m.getName()!="")
{
RestFunction restfunction;
restfunction.appName = appName;
restfunction.name = cs.pubms.at(var).name;
restfunction.rtype = cs.pubms.at(var).retType;
CryptoHandler::deSanitizeHtml(restfunction.rtype);
restfunction.serOpt = SerializeBase::identifySerOption(cs.pubms.at(var).retType);
restfunction.path = m.getAttributeValue("path");
restfunction.statusCode = m.getAttributeValue("statusCode");
if(restfunction.statusCode!="")
{
try {
CastUtil::toInt(restfunction.statusCode);
} catch(const std::exception& e) {
logger << "Rest: invalid response statusCode specified, defaulting to 200.." << std::endl;
restfunction.statusCode = "200";
}
}
restfunction.clas = clas;
restfunction.meth = StringUtil::toUpperCopy(m.getName().substr(1));
restfunction.unmapped = StringUtil::toLowerCopy(m.getAttributeValue("unmapped"))=="true";
restfunction.icontentType = m.getAttributeValue("icontentType");
restfunction.ocontentType = m.getAttributeValue("ocontentType");
if(restfunction.ocontentType=="") {
restfunction.ocontentType = ContentTypes::CONTENT_TYPE_TEXT_PLAIN;
}
if(StringUtil::toLowerCopy(restfunction.ocontentType).find(ContentTypes::CONTENT_TYPE_APPLICATION_JSON)==0) {
restfunction.serOpt += 1000;