コード例 #1
0
bool XmlHelper::getAttributeValueAsBool(DOMElement* element,const char* const name)
{
	if( XMLString::compareIString(getAttributeValueAsString(element, name).c_str(),"true") == 0  )
		return true;
	else
		return false;
}
コード例 #2
0
ファイル: http.c プロジェクト: ic-hep/emi3
/************************************************
Function:    constructResponse
Parameters:  xacml_response_t * response
Description:
             The XACML response message is constructed here.
             This implementation will use the Unix UID, Primary GID and
             multiple Secondary GIDs as input to contruct the obligations and
             its attributes. 
************************************************/
int constructResponse (xacml_response_t * response){

  /* Mapping Information Translated */
  aos_context_t*       context         = NULL;
  aos_attribute_t*     attribute       = NULL;
  xacml_obligation_t   tmp_obligation  = NULL;
  char*                attribute_name  = NULL;
  char*                attribute_value = NULL;
  char*                obligation_id   = NULL;

  rewindContexts();
  while((context = getNextContext(OBLIGATION, NULL)) != NULL){
    rewindAttributes(context);
    obligation_id = getContextObligationId(context),
    xacml_obligation_init(&tmp_obligation,
                          obligation_id,
                          XACML_EFFECT_Permit);
    /*printf("Obligation: %s at %p", obligation_id, tmp_obligation);*/
    /*EEF_log(LOG_DEBUG, "Obligation %s", obligation_id);*/
    while((attribute = getNextAttribute(context)) != NULL){
      attribute_name = getAttributeId(attribute);
      attribute_value = getAttributeValueAsString(attribute);
      if(attribute_name && attribute_value){
        /*EEF_log(LOG_DEBUG, "\t%s=%s\n", attribute_name, attribute_value);*/

        /* uid */
        xacml_obligation_add_attribute(tmp_obligation,
                                       attribute_name,
                                       XACML_DATATYPE_STRING,
                                       attribute_value);
        /*printf("Added obligation at: %p type %s\n", tmp_obligation, XACML_DATATYPE_STRING);*/
      }   
    }   
    xacml_response_add_obligation(*response, tmp_obligation);
    xacml_obligation_destroy(tmp_obligation);
    tmp_obligation = NULL;
  }

  /*********** E: Obligation UIDGID ***********/


  xacml_response_set_saml_status_code  (*response, SAML_STATUS_Success);
  xacml_response_set_xacml_status_code (*response, XACML_STATUS_ok);
  xacml_response_set_xacml_decision    (*response, XACML_DECISION_Permit);

  return 0;
}
コード例 #3
0
Scene* SceneLoader::loadScene(Ogre::DataStreamPtr &data)
{
    TiXmlDocument* doc = loadDocument(data);
    TiXmlElement* root = doc->RootElement();
    Scene* scene = new Scene(getAttributeValueAsString(root, "name"));
    
    for (TiXmlNode* cur = root->FirstChild(); cur; cur = cur->NextSibling())
    {
        if (cur->Type() == TiXmlNode::ELEMENT)
        {
            TiXmlElement* elem = cur->ToElement();
            if (hasNodeName(elem, "map"))
            {
                scene->addMap(getAttributeValueAsStdString(elem, "file"));
            }
        }
    }

    delete doc;

    return scene;
}
コード例 #4
0
PropertyEntry XmlPropertyReader::processProperty(XERCES_CPP_NAMESPACE::DOMElement* domElem) const
{
    if (!hasAttribute(domElem, "type"))
    {
        return std::make_pair("", Property(0));
    }

    Ogre::String key = "";
	if (hasAttribute(domElem, "name"))
	{
		key = getAttributeValueAsStdString(domElem, "name");
	}
	Ogre::String type = getAttributeValueAsStdString(domElem, "type");
    CeGuiString value = "";
    if (hasAttribute(domElem, "data"))
    {
        value = getAttributeValueAsString(domElem, "data");
    }

    Property prop;
    if (type == "STRING")
    {
        prop = Property(value);
    }
    else if (type == "INT")
    {
        const int intVal = CEGUI::PropertyHelper::stringToInt(value);
        prop = Property(intVal);
    }
    else if (type == "REAL" || type == "FLOAT")
    {
        const Ogre::Real realVal = CEGUI::PropertyHelper::stringToFloat(value);
        prop = Property(realVal);
    }
    else if (type == "VECTOR3")
    {
        CeGuiString::size_type comma1 = value.find(",");
        CeGuiString::size_type comma2 = value.find(",", comma1 + 1);

        Ogre::Vector3 vec(Ogre::Vector3::ZERO);
        if (comma1 != CeGuiString::npos && comma2 != CeGuiString::npos)
        {
            vec.x = CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1));
            vec.y = CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1));
            vec.z = CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1));
        }
        prop = Property(vec);
    }
    else if (type == "QUATERNION")
    {
        CeGuiString::size_type comma1 = value.find(",");
        CeGuiString::size_type comma2 = value.find(",", comma1 + 1);
        CeGuiString::size_type comma3 = value.find(",", comma2 + 1);

        Ogre::Quaternion quat(Ogre::Quaternion::IDENTITY);
        if (comma1 != CeGuiString::npos 
            && comma2 != CeGuiString::npos 
            && comma3 != CeGuiString::npos)
        {
            quat.w = CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1));
            quat.x = CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1));
            quat.y = CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1, comma3 - comma2 - 1));
            quat.z = CEGUI::PropertyHelper::stringToFloat(value.substr(comma3 + 1));
        }
        else if (comma1 != CeGuiString::npos 
            && comma2 != CeGuiString::npos 
            && comma3 == CeGuiString::npos)
        {
            Quaternion rotX, rotY, rotZ;

            rotX.FromAngleAxis(
			    Ogre::Degree(CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1))), 
			    Ogre::Vector3::UNIT_X);
            rotY.FromAngleAxis(
			    Ogre::Degree(CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1))), 
			    Ogre::Vector3::UNIT_Y);
            rotZ.FromAngleAxis(
			    Ogre::Degree(CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1))), 
			    Ogre::Vector3::UNIT_Z);

            quat = rotX * rotY * rotZ;
        }
        prop = Property(quat);
    }
    else if (type == "BOOL")
    {
        const bool boolVal = CEGUI::PropertyHelper::stringToBool(value);
        prop = Property(boolVal);
    }
	else if (type == "ARRAY")
	{
		std::vector<Property> vecVal;
		for (DOMNode* curChild  = domElem->getFirstChild(); curChild != NULL;
			curChild = curChild->getNextSibling())
		{
			if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
			{
				PropertyEntry entry = processProperty(static_cast<DOMElement*>(curChild));
				vecVal.push_back(entry.second);
			}
		}
		prop = Property(vecVal);
	}
	else if (type == "INTPAIR")
    {
        CeGuiString::size_type comma1 = value.find(",");

		std::pair<int,int> intpairVal = std::make_pair(0, 0);
        if (comma1 != CeGuiString::npos)
        {
			intpairVal = std::make_pair(
				CEGUI::PropertyHelper::stringToInt(value.substr(0, comma1)),
				CEGUI::PropertyHelper::stringToInt(value.substr(comma1 + 1)));
        }
        prop = Property(intpairVal);
    }
    else if (type == "INTTRIPLE")
    {
        CeGuiString::size_type comma1 = value.find(",");
        CeGuiString::size_type comma2 = value.find(",", comma1 + 1);

        Tripel<int> intTripel(0,0,0);
        if (comma1 != CeGuiString::npos && comma2 != CeGuiString::npos)
        {
            intTripel.first = CEGUI::PropertyHelper::stringToFloat(value.substr(0, comma1));
            intTripel.second = CEGUI::PropertyHelper::stringToFloat(value.substr(comma1 + 1, comma2 - comma1 - 1));
            intTripel.third = CEGUI::PropertyHelper::stringToFloat(value.substr(comma2 + 1));
        }
        prop = Property(intTripel);
    }
	else if (type == "MAP")
	{
		PropertyMap mapVal;
		for (DOMNode* curChild  = domElem->getFirstChild(); curChild != NULL;
			curChild = curChild->getNextSibling())
		{
			if (curChild->getNodeType() == DOMNode::ELEMENT_NODE)
			{
				DOMElement* curElem = static_cast<DOMElement*>(curChild);
				CeGuiString key = getAttributeValueAsString(curElem, "name");
				PropertyEntry entry = processProperty(curElem);
				mapVal[key] = entry.second;
			}
		}
		prop = Property(mapVal);
	}

    return std::make_pair(key, prop);
}