Search in sources :

Example 11 with PermitAll

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;
}
Also used : DataTable(io.irontest.models.DataTable) UserDefinedProperty(io.irontest.models.UserDefinedProperty) PropertyExtractor(io.irontest.models.propertyextractor.PropertyExtractor) PropertyExtractorRunner(io.irontest.core.propertyextractor.PropertyExtractorRunner) IOException(java.io.IOException) PropertyExtractionResult(io.irontest.models.propertyextractor.PropertyExtractionResult) PermitAll(javax.annotation.security.PermitAll)

Example 12 with PermitAll

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();
}
Also used : RegularTestcaseRunner(io.irontest.core.testcase.RegularTestcaseRunner) Testcase(io.irontest.models.Testcase) TestcaseRunner(io.irontest.core.testcase.TestcaseRunner) DataDrivenTestcaseRunner(io.irontest.core.testcase.DataDrivenTestcaseRunner) RegularTestcaseRunner(io.irontest.core.testcase.RegularTestcaseRunner) DataDrivenTestcaseRunner(io.irontest.core.testcase.DataDrivenTestcaseRunner) JsonView(com.fasterxml.jackson.annotation.JsonView) PermitAll(javax.annotation.security.PermitAll)

Example 13 with PermitAll

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;
}
Also used : AssertionVerifier(io.irontest.core.assertion.AssertionVerifier) DataTable(io.irontest.models.DataTable) MQRFH2Header(io.irontest.models.teststep.MQRFH2Header) UserDefinedProperty(io.irontest.models.UserDefinedProperty) IOException(java.io.IOException) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) PermitAll(javax.annotation.security.PermitAll)

Example 14 with PermitAll

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;
}
Also used : RolesAllowed(javax.annotation.security.RolesAllowed) AnnotatedElement(java.lang.reflect.AnnotatedElement) PermitAll(javax.annotation.security.PermitAll)

Example 15 with PermitAll

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);
    }
}
Also used : Category(org.rembx.jeeshop.catalog.model.Category) ArrayList(java.util.ArrayList) Catalog(org.rembx.jeeshop.catalog.model.Catalog) PermitAll(javax.annotation.security.PermitAll)

Aggregations

PermitAll (javax.annotation.security.PermitAll)36 ArrayList (java.util.ArrayList)8 User (org.traccar.model.User)8 POST (javax.ws.rs.POST)7 GET (javax.ws.rs.GET)6 Path (javax.ws.rs.Path)6 HashMap (java.util.HashMap)5 RolesAllowed (javax.annotation.security.RolesAllowed)5 DataTable (io.irontest.models.DataTable)4 UserDefinedProperty (io.irontest.models.UserDefinedProperty)4 Date (java.util.Date)4 Produces (javax.ws.rs.Produces)4 WebApplicationException (javax.ws.rs.WebApplicationException)4 Catalog (org.rembx.jeeshop.catalog.model.Catalog)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3 Testcase (io.irontest.models.Testcase)3 HashSet (java.util.HashSet)3 LinkedHashMap (java.util.LinkedHashMap)3 JsonView (com.fasterxml.jackson.annotation.JsonView)2 Environment (io.irontest.models.Environment)2