Search in sources :

Example 96 with ObjectFactory

use of org.geotoolkit.sampling.xml.v100.ObjectFactory in project ddf by codice.

the class XacmlClientTest method testEvaluateroleuseractionquerycitizenshipUS.

@Test
public void testEvaluateroleuseractionquerycitizenshipUS() throws Exception {
    LOGGER.debug("\n\n\n##### testEvaluate_role_user_action_query_citizenship_US");
    // Setup
    File destDir = folder.newFolder(TEMP_DIR_NAME);
    LOGGER.debug("Making directory: {}", destDir.getPath());
    if (destDir.mkdir()) {
        File srcFile = new File(projectHome + File.separator + RELATIVE_POLICIES_DIR + File.separator + POLICY_FILE);
        FileUtils.copyFileToDirectory(srcFile, destDir);
        RequestType xacmlRequestType = new RequestType();
        xacmlRequestType.setCombinedDecision(false);
        xacmlRequestType.setReturnPolicyIdList(false);
        AttributesType actionAttributes = new AttributesType();
        actionAttributes.setCategory(ACTION_CATEGORY);
        AttributeType actionAttribute = new AttributeType();
        actionAttribute.setAttributeId(ACTION_ID);
        actionAttribute.setIncludeInResult(false);
        AttributeValueType actionValue = new AttributeValueType();
        actionValue.setDataType(STRING_DATA_TYPE);
        actionValue.getContent().add(QUERY_ACTION);
        actionAttribute.getAttributeValue().add(actionValue);
        actionAttributes.getAttribute().add(actionAttribute);
        AttributesType subjectAttributes = new AttributesType();
        subjectAttributes.setCategory(SUBJECT_CATEGORY);
        AttributeType subjectAttribute = new AttributeType();
        subjectAttribute.setAttributeId(SUBJECT_ID);
        subjectAttribute.setIncludeInResult(false);
        AttributeValueType subjectValue = new AttributeValueType();
        subjectValue.setDataType(STRING_DATA_TYPE);
        subjectValue.getContent().add(TEST_USER_1);
        subjectAttribute.getAttributeValue().add(subjectValue);
        subjectAttributes.getAttribute().add(subjectAttribute);
        AttributeType roleAttribute = new AttributeType();
        roleAttribute.setAttributeId(ROLE_CLAIM);
        roleAttribute.setIncludeInResult(false);
        AttributeValueType roleValue = new AttributeValueType();
        roleValue.setDataType(STRING_DATA_TYPE);
        roleValue.getContent().add(ROLE);
        roleAttribute.getAttributeValue().add(roleValue);
        subjectAttributes.getAttribute().add(roleAttribute);
        AttributesType categoryAttributes = new AttributesType();
        categoryAttributes.setCategory(PERMISSIONS_CATEGORY);
        AttributeType citizenshipAttribute = new AttributeType();
        citizenshipAttribute.setAttributeId(CITIZENSHIP_ATTRIBUTE);
        citizenshipAttribute.setIncludeInResult(false);
        AttributeValueType citizenshipValue = new AttributeValueType();
        citizenshipValue.setDataType(STRING_DATA_TYPE);
        citizenshipValue.getContent().add(US_COUNTRY);
        citizenshipAttribute.getAttributeValue().add(citizenshipValue);
        categoryAttributes.getAttribute().add(citizenshipAttribute);
        xacmlRequestType.getAttributes().add(actionAttributes);
        xacmlRequestType.getAttributes().add(subjectAttributes);
        xacmlRequestType.getAttributes().add(categoryAttributes);
        XacmlClient pdp = new XacmlClient(destDir.getCanonicalPath(), new XmlParser(), mock(SecurityLogger.class));
        // Perform Test
        ResponseType xacmlResponse = pdp.evaluate(xacmlRequestType);
        // Verify
        JAXBContext jaxbContext = JAXBContext.newInstance(ResponseType.class);
        Marshaller marshaller = jaxbContext.createMarshaller();
        ObjectFactory objectFactory = new ObjectFactory();
        Writer writer = new StringWriter();
        marshaller.marshal(objectFactory.createResponse(xacmlResponse), writer);
        LOGGER.debug("\nXACML 3.0 Response:\n{}", writer.toString());
        assertEquals(xacmlResponse.getResult().get(0).getDecision(), DecisionType.PERMIT);
        // Cleanup
        LOGGER.debug("Deleting directory: {}", destDir);
        FileUtils.deleteDirectory(destDir);
    } else {
        LOGGER.debug("Could not create directory: {}", destDir);
    }
}
Also used : XmlParser(org.codice.ddf.parser.xml.XmlParser) Marshaller(javax.xml.bind.Marshaller) AttributeValueType(oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType) JAXBContext(javax.xml.bind.JAXBContext) ResponseType(oasis.names.tc.xacml._3_0.core.schema.wd_17.ResponseType) ObjectFactory(oasis.names.tc.xacml._3_0.core.schema.wd_17.ObjectFactory) StringWriter(java.io.StringWriter) AttributeType(oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeType) AttributesType(oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributesType) File(java.io.File) StringWriter(java.io.StringWriter) Writer(java.io.Writer) RequestType(oasis.names.tc.xacml._3_0.core.schema.wd_17.RequestType) SecurityLogger(ddf.security.audit.SecurityLogger) Test(org.junit.Test)

Example 97 with ObjectFactory

use of org.geotoolkit.sampling.xml.v100.ObjectFactory in project cxf by apache.

the class AbstractSequenceTest method testIdentifierEquals.

@Test
public void testIdentifierEquals() {
    Identifier id1 = null;
    Identifier id2 = null;
    assertTrue(AbstractSequence.identifierEquals(id1, id2));
    ObjectFactory factory = new ObjectFactory();
    id1 = factory.createIdentifier();
    id1.setValue("seq1");
    assertFalse(AbstractSequence.identifierEquals(id1, id2));
    id2 = factory.createIdentifier();
    id2.setValue("seq2");
    assertFalse(AbstractSequence.identifierEquals(id1, id2));
    id2.setValue("seq1");
    assertTrue(AbstractSequence.identifierEquals(id1, id2));
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ObjectFactory(org.apache.cxf.ws.rm.v200702.ObjectFactory) Test(org.junit.Test)

Example 98 with ObjectFactory

use of org.geotoolkit.sampling.xml.v100.ObjectFactory in project cxf by apache.

the class RMSoapOutInterceptorTest method setUpOutbound.

private void setUpOutbound() {
    ObjectFactory factory = new ObjectFactory();
    s1 = factory.createSequenceType();
    Identifier sid = factory.createIdentifier();
    sid.setValue("sequence1");
    s1.setIdentifier(sid);
    s1.setMessageNumber(ONE);
    s2 = factory.createSequenceType();
    sid = factory.createIdentifier();
    sid.setValue("sequence2");
    s2.setIdentifier(sid);
    s2.setMessageNumber(TEN);
    ack1 = factory.createSequenceAcknowledgement();
    SequenceAcknowledgement.AcknowledgementRange r = factory.createSequenceAcknowledgementAcknowledgementRange();
    r.setLower(ONE);
    r.setUpper(ONE);
    ack1.getAcknowledgementRange().add(r);
    ack1.setIdentifier(s1.getIdentifier());
    ack2 = factory.createSequenceAcknowledgement();
    r = factory.createSequenceAcknowledgementAcknowledgementRange();
    r.setLower(ONE);
    r.setUpper(TEN);
    ack2.getAcknowledgementRange().add(r);
    ack2.setIdentifier(s2.getIdentifier());
    ar1 = factory.createAckRequestedType();
    ar1.setIdentifier(s1.getIdentifier());
    ar2 = factory.createAckRequestedType();
    ar2.setIdentifier(s2.getIdentifier());
}
Also used : Identifier(org.apache.cxf.ws.rm.v200702.Identifier) ObjectFactory(org.apache.cxf.ws.rm.v200702.ObjectFactory) SequenceAcknowledgement(org.apache.cxf.ws.rm.v200702.SequenceAcknowledgement)

Example 99 with ObjectFactory

use of org.geotoolkit.sampling.xml.v100.ObjectFactory in project cxf by apache.

the class AbstractTypeTestClient2 method testChoiceWithSubstitutionGroupAbstract.

@Test
public void testChoiceWithSubstitutionGroupAbstract() throws Exception {
    if (!shouldRunTest("ChoiceWithSubstitutionGroupAbstract")) {
        return;
    }
    SgDerivedTypeB derivedB = new SgDerivedTypeB();
    derivedB.setVarInt(new BigInteger("32"));
    derivedB.setVarString("foo");
    SgDerivedTypeC derivedC = new SgDerivedTypeC();
    derivedC.setVarInt(new BigInteger("32"));
    derivedC.setVarFloat(3.14f);
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<? extends SgBaseTypeA> elementB = objectFactory.createSg03DerivedElementB(derivedB);
    JAXBElement<? extends SgBaseTypeA> elementC = objectFactory.createSg03DerivedElementC(derivedC);
    ChoiceWithSubstitutionGroupAbstract x = new ChoiceWithSubstitutionGroupAbstract();
    x.setSg03AbstractBaseElementA(elementC);
    ChoiceWithSubstitutionGroupAbstract yOrig = new ChoiceWithSubstitutionGroupAbstract();
    yOrig.setSg03AbstractBaseElementA(elementB);
    Holder<ChoiceWithSubstitutionGroupAbstract> y = new Holder<>(yOrig);
    Holder<ChoiceWithSubstitutionGroupAbstract> z = new Holder<>();
    ChoiceWithSubstitutionGroupAbstract ret;
    if (testDocLiteral) {
        ret = docClient.testChoiceWithSubstitutionGroupAbstract(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testChoiceWithSubstitutionGroupAbstract(x, y, z);
    } else {
        ret = rpcClient.testChoiceWithSubstitutionGroupAbstract(x, y, z);
    }
    if (!perfTestOnly) {
        assertTrue("testChoiceWithSubstitutionGroupAbstract(): Incorrect value for inout param", equals(x, y.value));
        assertTrue("testChoiceWithSubstitutionGroupAbstract(): Incorrect value for out param", equals(yOrig, z.value));
        assertTrue("testChoiceWithSubstitutionGroupAbstract(): Incorrect return value", equals(x, ret));
    }
}
Also used : SgDerivedTypeB(org.apache.type_test.types3.SgDerivedTypeB) ObjectFactory(org.apache.type_test.types3.ObjectFactory) Holder(javax.xml.ws.Holder) BigInteger(java.math.BigInteger) ChoiceWithSubstitutionGroupAbstract(org.apache.type_test.types3.ChoiceWithSubstitutionGroupAbstract) SgDerivedTypeC(org.apache.type_test.types3.SgDerivedTypeC) Test(org.junit.Test)

Example 100 with ObjectFactory

use of org.geotoolkit.sampling.xml.v100.ObjectFactory in project cxf by apache.

the class AbstractTypeTestClient2 method testStructWithSubstitutionGroupAbstract.

@Test
public void testStructWithSubstitutionGroupAbstract() throws Exception {
    if (!shouldRunTest("StructWithSubstitutionGroupAbstract")) {
        return;
    }
    SgDerivedTypeB derivedB = new SgDerivedTypeB();
    derivedB.setVarInt(new BigInteger("32"));
    derivedB.setVarString("foo");
    ObjectFactory objectFactory = new ObjectFactory();
    JAXBElement<SgDerivedTypeB> elementB = objectFactory.createSg03DerivedElementB(derivedB);
    SgDerivedTypeC derivedC = new SgDerivedTypeC();
    derivedC.setVarInt(new BigInteger("32"));
    derivedC.setVarFloat(3.14f);
    JAXBElement<SgDerivedTypeC> elementC = objectFactory.createSg03DerivedElementC(derivedC);
    StructWithSubstitutionGroupAbstract x = new StructWithSubstitutionGroupAbstract();
    x.setSg03AbstractBaseElementA(elementC);
    StructWithSubstitutionGroupAbstract yOrig = new StructWithSubstitutionGroupAbstract();
    yOrig.setSg03AbstractBaseElementA(elementB);
    Holder<StructWithSubstitutionGroupAbstract> y = new Holder<>(yOrig);
    Holder<StructWithSubstitutionGroupAbstract> z = new Holder<>();
    StructWithSubstitutionGroupAbstract ret;
    if (testDocLiteral) {
        ret = docClient.testStructWithSubstitutionGroupAbstract(x, y, z);
    } else if (testXMLBinding) {
        ret = xmlClient.testStructWithSubstitutionGroupAbstract(x, y, z);
    } else {
        ret = rpcClient.testStructWithSubstitutionGroupAbstract(x, y, z);
    }
    if (!perfTestOnly) {
        assertTrue("testStructWithSubstitutionGroupAbstract(): Incorrect value for inout param", equals(x, y.value));
        assertTrue("testStructWithSubstitutionGroupAbstract(): Incorrect value for out param", equals(yOrig, z.value));
        assertTrue("testStructWithSubstitutionGroupAbstract(): Incorrect return value", equals(x, ret));
    }
}
Also used : SgDerivedTypeB(org.apache.type_test.types3.SgDerivedTypeB) ObjectFactory(org.apache.type_test.types3.ObjectFactory) Holder(javax.xml.ws.Holder) BigInteger(java.math.BigInteger) StructWithSubstitutionGroupAbstract(org.apache.type_test.types3.StructWithSubstitutionGroupAbstract) SgDerivedTypeC(org.apache.type_test.types3.SgDerivedTypeC) Test(org.junit.Test)

Aggregations

JAXBElement (javax.xml.bind.JAXBElement)32 Test (org.junit.Test)26 ArrayList (java.util.ArrayList)25 Marshaller (javax.xml.bind.Marshaller)22 ObjectFactory (net.opengis.cat.csw.v_2_0_2.ObjectFactory)20 StringWriter (java.io.StringWriter)18 QueryType (net.opengis.cat.csw.v_2_0_2.QueryType)18 GetRecordsType (net.opengis.cat.csw.v_2_0_2.GetRecordsType)17 ObjectFactory (no.seres.xsd.nav.inntektsmelding_m._20181211.ObjectFactory)16 JAXBContext (javax.xml.bind.JAXBContext)14 QName (javax.xml.namespace.QName)13 CswRecordCollection (org.codice.ddf.spatial.ogc.csw.catalog.common.CswRecordCollection)13 XStream (com.thoughtworks.xstream.XStream)12 ByteArrayInputStream (java.io.ByteArrayInputStream)12 GetRecordsResponseType (net.opengis.cat.csw.v_2_0_2.GetRecordsResponseType)12 SearchResultsType (net.opengis.cat.csw.v_2_0_2.SearchResultsType)12 ObjectFactory (slash.navigation.kml.binding22.ObjectFactory)12 ObjectFactory (com.opensymphony.xwork2.ObjectFactory)11 BigInteger (java.math.BigInteger)11 ElementSetNameType (net.opengis.cat.csw.v_2_0_2.ElementSetNameType)11