use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class PropertyExtractorResource method extract.
/**
* This is a stateless operation, i.e. not persisting anything in database.
* @param propertyExtractionRequest
* @return
*/
@POST
@Path("propertyExtractors/{propertyExtractorId}/extract")
@PermitAll
public PropertyExtractionResult extract(PropertyExtractionRequest propertyExtractionRequest) throws IOException {
PropertyExtractor propertyExtractor = propertyExtractionRequest.getPropertyExtractor();
// gather referenceable string properties
long testcaseId = propertyExtractorDAO.findTestcaseIdById(propertyExtractor.getId());
List<UserDefinedProperty> testcaseUDPs = udpDAO.findByTestcaseId(testcaseId);
Map<String, String> referenceableStringProperties = IronTestUtils.udpListToMap(testcaseUDPs);
Set<String> udpNames = referenceableStringProperties.keySet();
DataTable dataTable = dataTableDAO.getTestcaseDataTable(testcaseId, true);
if (dataTable.getRows().size() > 0) {
IronTestUtils.checkDuplicatePropertyNameBetweenDataTableAndUPDs(udpNames, dataTable);
referenceableStringProperties.putAll(dataTable.getStringPropertiesInRow(0));
}
PropertyExtractorRunner propertyExtractorRunner = PropertyExtractorRunnerFactory.getInstance().create(propertyExtractor, referenceableStringProperties);
String propertyExtractionInput = propertyExtractionRequest.getInput();
PropertyExtractionResult result = new PropertyExtractionResult();
try {
result.setPropertyValue(propertyExtractorRunner.extract(propertyExtractionInput));
} catch (Exception e) {
LOGGER.error("Failed to extract property", e);
result.setError(e.getMessage());
}
return result;
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class TestcaseRunResource method create.
@POST
@Path("testcaseruns")
@PermitAll
@JsonView(ResourceJsonViews.TestcaseRunResultOnTestcaseEditView.class)
public TestcaseRun create(@QueryParam("testcaseId") long testcaseId) throws IOException {
Testcase testcase = testcaseDAO.findById_Complete(testcaseId);
TestcaseRunner testcaseRunner;
if (testcase.getDataTable().getRows().isEmpty()) {
testcaseRunner = new RegularTestcaseRunner(testcase, utilsDAO, testcaseRunDAO, wireMockServer);
} else {
testcaseRunner = new DataDrivenTestcaseRunner(testcase, utilsDAO, testcaseRunDAO, wireMockServer);
}
return testcaseRunner.run();
}
use of javax.annotation.security.PermitAll in project irontest by zheng-wang.
the class AssertionResource method verify.
/**
* This is a stateless operation, i.e. not persisting anything in database.
* @param assertionVerificationRequest
* @return
*/
@POST
@Path("assertions/{assertionId}/verify")
@PermitAll
public AssertionVerificationResult verify(AssertionVerificationRequest assertionVerificationRequest) throws IOException {
Assertion assertion = assertionVerificationRequest.getAssertion();
// populate xsd file bytes for JSONValidAgainstJSONSchema or XMLValidAgainstXSD assertion which are not passed from UI to this method
if (Assertion.TYPE_JSON_VALID_AGAINST_JSON_SCHEMA.equals(assertion.getType()) || Assertion.TYPE_XML_VALID_AGAINST_XSD.equals(assertion.getType())) {
assertion.setOtherProperties(assertionDAO.findById(assertion.getId()).getOtherProperties());
}
// gather referenceable string properties
long testcaseId = teststepDAO.findTestcaseIdById(assertion.getTeststepId());
List<UserDefinedProperty> testcaseUDPs = udpDAO.findByTestcaseId(testcaseId);
Map<String, String> referenceableStringProperties = IronTestUtils.udpListToMap(testcaseUDPs);
Set<String> udpNames = referenceableStringProperties.keySet();
DataTable dataTable = dataTableDAO.getTestcaseDataTable(testcaseId, true);
if (dataTable.getRows().size() > 0) {
IronTestUtils.checkDuplicatePropertyNameBetweenDataTableAndUPDs(udpNames, dataTable);
referenceableStringProperties.putAll(dataTable.getStringPropertiesInRow(0));
}
AssertionVerifier assertionVerifier = AssertionVerifierFactory.getInstance().create(assertion, referenceableStringProperties);
Object assertionInput = assertionVerificationRequest.getInput();
if (Assertion.TYPE_HAS_AN_MQRFH2_FOLDER_EQUAL_TO_XML.equals(assertion.getType())) {
assertionInput = new ObjectMapper().convertValue(assertionInput, MQRFH2Header.class);
}
AssertionVerificationResult result;
try {
result = assertionVerifier.verify(assertionInput);
} catch (Exception e) {
LOGGER.error("Failed to verify assertion", e);
result = new AssertionVerificationResult();
result.setResult(TestResult.FAILED);
result.setError(e.getMessage());
}
return result;
}
use of javax.annotation.security.PermitAll in project Payara by payara.
the class AbstractAuthAnnotationHandler method validateAccessControlAnnotations.
/**
* This method checks whether annotations are compatible.
* One cannot have two or more of the @DenyAll, @PermitAll, @RoleAllowed.
*
* @param ainfo
* @return validity
*/
private boolean validateAccessControlAnnotations(AnnotationInfo ainfo) throws AnnotationProcessorException {
boolean validity = true;
AnnotatedElement ae = (AnnotatedElement) ainfo.getAnnotatedElement();
int count = 0;
boolean hasDenyAll = false;
count += (ae.isAnnotationPresent(RolesAllowed.class) ? 1 : 0);
if (ae.isAnnotationPresent(DenyAll.class)) {
count += 1;
hasDenyAll = true;
}
// continue the checking if not already more than one
if (count < 2 && ae.isAnnotationPresent(PermitAll.class)) {
count++;
}
if (count > 1) {
log(Level.SEVERE, ainfo, localStrings.getLocalString("enterprise.deployment.annotation.handlers.morethanoneauthannotation", "One cannot have more than one of @RolesAllowed, @PermitAll, @DenyAll in the same AnnotatedElement."));
validity = false;
}
return validity;
}
use of javax.annotation.security.PermitAll in project jeeshop by remibantos.
the class Catalogs method findCategories.
@GET
@Path("/{catalogId}/categories")
@Produces(MediaType.APPLICATION_JSON)
@PermitAll
public List<Category> findCategories(@Context SecurityContext securityContext, @PathParam("catalogId") @NotNull Long catalogId, @QueryParam("locale") String locale) {
Catalog catalog = entityManager.find(Catalog.class, catalogId);
checkNotNull(catalog);
List<Category> rootCategories = catalog.getRootCategories();
if (rootCategories.isEmpty()) {
return new ArrayList<>();
}
if (isAdminUser(securityContext) || isOwner(securityContext, catalog.getOwner())) {
return rootCategories;
} else {
return catalogItemFinder.findVisibleCatalogItems(category, rootCategories, locale);
}
}
Aggregations