Search in sources :

Example 6 with ErrorMsg

use of com.xebia.vulnmanager.models.net.ErrorMsg in project vulnmanager by xebia-research.

the class CompanyController method getCompanyTeams.

/**
 * Get the teams of a specific company
 * @param authKey The auth key of the company used to auth the request
 * @param companyName The name of the company
 * @return A list of teams within the team
 */
@RequestMapping(method = RequestMethod.GET)
@ResponseBody
ResponseEntity<?> getCompanyTeams(@RequestHeader(value = "auth", defaultValue = "nope") String authKey, @PathVariable("company") String companyName) {
    AuthenticationChecker authChecker = new AuthenticationChecker();
    boolean authIsGood = authChecker.checkCompanyAuthKey(companyName, authKey);
    MockCompanyFactory compFact = new MockCompanyFactory();
    if (authIsGood) {
        Company foundComp = compFact.findCompanyByName(companyName);
        return new ResponseEntity<Company>(foundComp, HttpStatus.OK);
    }
    return new ResponseEntity<ErrorMsg>(new ErrorMsg("Wrong auth key or company not found"), HttpStatus.NOT_FOUND);
}
Also used : Company(com.xebia.vulnmanager.models.company.Company) ResponseEntity(org.springframework.http.ResponseEntity) AuthenticationChecker(com.xebia.vulnmanager.auth.AuthenticationChecker) MockCompanyFactory(com.xebia.vulnmanager.data.MockCompanyFactory) ErrorMsg(com.xebia.vulnmanager.models.net.ErrorMsg)

Aggregations

ErrorMsg (com.xebia.vulnmanager.models.net.ErrorMsg)6 ResponseEntity (org.springframework.http.ResponseEntity)6 File (java.io.File)4 AuthenticationChecker (com.xebia.vulnmanager.auth.AuthenticationChecker)3 MockCompanyFactory (com.xebia.vulnmanager.data.MockCompanyFactory)3 Company (com.xebia.vulnmanager.models.company.Company)3 Team (com.xebia.vulnmanager.models.company.Team)2 OpenvasReport (com.xebia.vulnmanager.models.openvas.objects.OpenvasReport)2 NMapReport (com.xebia.vulnmanager.models.nmap.objects.NMapReport)1 ReportType (com.xebia.vulnmanager.util.ReportType)1 IOException (java.io.IOException)1 MultipartFile (org.springframework.web.multipart.MultipartFile)1