private void showDetailsForSpringMvcController(SpringMvcController springMvcController, bool openPageWhenControllerIsSelected)
        {
            if (springMvcController != null)
            {
                if (openPageWhenControllerIsSelected)
                {                    
                    tbUrlToSubmit.Text = string.Format("{0}{1}", urlOfWebApplicationRoot,
                                                       springMvcController.HttpRequestUrl);
                    cbSubmitMethod.Text = springMvcController.HttpRequestMethod;
                    foreach (var autoWiredObject in springMvcController.AutoWiredJavaObjects)
                    {
                        if (autoWiredObject.name != null)
                            addVariableToParametersDataGridView(autoWiredObject.name);
                    }
                }

                springMvcAutoBindClassesView.clearLoadedData();
                springMvcAutoBindClassesView.setHideOrShowGetAndSetStrings(true);                
                foreach(var autoWiredJavaObject in springMvcController.AutoWiredJavaObjects)
                {
                    if (autoWiredJavaObject.className != null)
                        if (springMvcMappings.cirData.dClasses_bySignature.ContainsKey(autoWiredJavaObject.className))
                            springMvcAutoBindClassesView.mapClass(springMvcMappings.cirData.dClasses_bySignature[autoWiredJavaObject.className], springMvcMappings.cirData, false);
                }
                if (springMvcController.HttpMappingParameter != null && springMvcController.HttpMappingParameter != "")
                {
                    dataGridViewWithParameters.Rows.Clear();
                    dataGridViewWithParameters.Rows.Add(new object[] { springMvcController.HttpMappingParameter, "SPRING MVC method mapping" }); ;
                }
            }

        }
예제 #2
0
        private static void mapMethods(method[] methodsToMap,string javaClassName, SpringMvcController controllerForCurrentClass, List<SpringMvcController> springMvcControllers, string fileName)
        {
            if (methodsToMap != null)            
                foreach(var methodToMap in methodsToMap)
                {
                    var mappedController = getRequestMapping(methodToMap);
                    if (mappedController != null) // || controllerForCurrentClass != null) 
                    {
                        if (mappedController.HttpRequestUrl == null && controllerForCurrentClass!=null)
                            mappedController.HttpRequestUrl = controllerForCurrentClass.HttpRequestUrl;

                        mappedController.JavaClass = javaClassName;
                        mappedController.JavaFunction = (FilteredSignature.createFilteredSignatureFromJavaMethod(mappedController.JavaClass, methodToMap.name, methodToMap.descriptor).sFunctionNameAndParamsAndReturnClass);
                        mappedController.JavaClassAndFunction = string.Format("{0}.{1}", mappedController.JavaClass, mappedController.JavaFunction);
                        mappedController.AutoWiredJavaObjects = getAutoWiredJavaObjects(methodToMap);
                        mappedController.FileName = fileName;
                        mappedController.LineNumber = (uint)methodToMap.lineNumber;
                        springMvcControllers.Add(mappedController);
                    }

                    //springMvcController.URL = ;
                    //methodToMap.attribute
                    // methodToMap.SpringMvcMapping
                }            
        }
 public void showDetailsForSpringMvcController(SpringMvcController springMvcController)
 {
     //var mappedLineNumber = ViewHelpers.GetMappedLineNumber(springMvcController.JavaFunction, springMvcController.)
     sourceCodeEditor_withController.gotoLine(springMvcController.FileName, (int)springMvcController.LineNumber);
     findingsViewerWith_JoinResults.setFilter1Value("Source");
     findingsViewerWith_JoinResults.setFilter2Value("Sink");
     findingsViewerWith_JoinResults.setFilter1TextValue(springMvcController.JavaClassAndFunction,true);
     findingsViewerWith_JoinResults.expandAllNodes();
 }
        /*    private bool loadCirDataFile(string fileOrFolder)
            {
                if (File.Exists(fileOrFolder) && Path.GetExtension(fileOrFolder) == ".CirData")
                {
                    loadedCirDataFile = "";
                    springMvcMappings.cirData = null;
                    {
                        var loadedCirDataObject = CirLoad.loadFile(fileOrFolder);
                        if (loadedCirDataObject != null)
                        {
                            loadedCirDataFile = fileOrFolder;
                            springMvcMappings.cirData = loadedCirDataObject;
                        }
                    }
                    setLoadedCirDataFile();
                    return true;
                }
            
                return false;
            }

            private void setLoadedCirDataFile()
            {
                this.invokeOnThread(() => lbLoadedCirDataFile.Text = loadedCirDataFile);
            }
            */
        /* public void loadFileOrFolder(string fileOrFolder)
         {
             //var workingOnTaskForm = O2AscxGUI.openWorkingOnTaskForm("Running Jython Script to map Java class files");
             var tempFolderForAnnotationsXmlFiles = AnnotationsHelper.createAnnotationsXmlFilesFromJavaClassFileOrFolder(fileOrFolder);
             this.invokeOnThread(
                 () =>
                     {
                         foreach (var file in Files.getFilesFromDir_returnFullPath(tempFolderForAnnotationsXmlFiles))
                             lboxClassFilesAnalysed.Items.Add(file);
                         convertXmlAttributeFilesToSpringMvcControllersObjects(tempFolderForAnnotationsXmlFiles);
               //          if (workingOnTaskForm != null)
               //              workingOnTaskForm.close();
                     });
         }

         public void convertXmlAttributeFilesToSpringMvcControllersObjects(string tempFolderForAnnotationsXmlFiles)
         {
             var springMvcControllers = new List<SpringMvcController>();
             foreach (var xmlAttributeFile in Files.getFilesFromDir_returnFullPath(tempFolderForAnnotationsXmlFiles))            
                 springMvcControllers.AddRange(LoadSpringMvcData.createSpringMvcControllersFromXmlAttributeFile(xmlAttributeFile));
             showSpringMvcControllers(springMvcControllers);
         }*/

      

       

        

        private void showDetailsForSpringMvcController(SpringMvcController springMvcController)
        {
            if (springMvcController != null)
            {
                //var methodSignature = string.Format("{0}.{1}", springMvcController.JavaClass,springMvcController.JavaMethod);
                var methodSignature = springMvcController.JavaClassAndFunction;
                if (springMvcMappings.cirData != null && springMvcMappings.cirData.dFunctions_bySignature.ContainsKey(methodSignature))
                {
                    cirFunctionDetails.viewCirFunction(springMvcMappings.cirData.dFunctions_bySignature[methodSignature]);
                }
                else
                    DI.log.error("in showDetailsForSpringMvcController, loaded cirData did not contained signature :{0}", methodSignature);
                // load sourceCode file
                sourceCodeView.gotoLine(springMvcController.FileName, (int)springMvcController.LineNumber - 1);

                showFindingsDetailsForSpringMvcController(springMvcController.JavaClassAndFunction);

                //O2Messages.fileOrFolderSelected(springMvcController.FileName, (int)springMvcController.LineNumber);
            }
        }
예제 #5
0
        public static SpringMvcController getRequestMapping(annotation javaAnnotation)
        {
            if (javaAnnotation != null)
            {
                var newController = new SpringMvcController();
                if (javaAnnotation.member != null)
                    foreach (var member in javaAnnotation.member)
                        switch (member.memberName)
                        {
                            case "method":
                                newController.HttpRequestMethod = member.memberValue;
                                newController.HttpRequestMethod = newController.HttpRequestMethod.Replace("{org.springframework.web.bind.annotation.RequestMethod.", "").Replace("}", "");
                                break;
                            case "value":
                                newController.HttpRequestUrl = decodeString(member.memberValue);
                                newController.HttpRequestUrl = newController.HttpRequestUrl.Replace("{\"", "").Replace("\"}", "");
                                break;
                            case "params":
                                newController.HttpMappingParameter = decodeString(member.memberValue);
                                newController.HttpMappingParameter = newController.HttpMappingParameter.Replace("{\"", "").Replace("\"}", "");

                                break;
                        }
                return newController;
            }
            return null;
        }
 public static bool doesControllerFunctionCallFunction(ICirData cirData, SpringMvcController springMcvController, List<string> functionsToSearch, bool recursiveFunctionSearch)
 {
     if (cirData == null)
         return false;
     if (cirData.dFunctions_bySignature.ContainsKey(springMcvController.JavaClassAndFunction))
     {
         var cirFunction = cirData.dFunctions_bySignature[springMcvController.JavaClassAndFunction];
         var targetFunctions = recursiveFunctionSearch ? CirSearch.calculateListOfAllFunctionsCalled(cirFunction) : cirFunction.FunctionsCalledUniqueList;
         DI.log.info("{0} called functions in {1}", targetFunctions.Count, cirFunction.FunctionSignature);
         foreach (var calledCirFunction in targetFunctions)
         {
             if (functionsToSearch.Contains(calledCirFunction.FunctionSignature))
                 return true;
         }
     }
     else
         DI.log.error("could not find function: {0}", springMcvController.JavaClassAndFunction);
     return false;
 }
 public static SpringMvcParameter getMethodUsedInController(SpringMvcController springMcvController, string methodToFind)
 {
     foreach (var springMvcParameter in springMcvController.AutoWiredJavaObjects)
         if (springMvcParameter.autoWiredMethodUsed == methodToFind)
             return springMvcParameter;
     return null;
 }
 public static bool isMethodUsedInController(SpringMvcController springMcvController, string methodToFind)
 {
     foreach (var springMvcParameter in springMcvController.AutoWiredJavaObjects)
         if (springMvcParameter.autoWiredMethodUsed == methodToFind)
             return true;
     return false;
 }