Search in sources :

Example 1 with Target

use of org.w3._2007.rif.Assert.Target in project hale by halestudio.

the class ModelRifToRifTranslator method createTargetInstanceMembershipFormula.

private Assert createTargetInstanceMembershipFormula(Actions actions, ModelSentence sentence, RifVariable instanceVariable) {
    Assert assert1 = factory.createAssert();
    Target target = factory.createAssertTarget();
    Member member = factory.createMember();
    Instance instance = factory.createInstance();
    Var var = factory.createVar();
    var.getContent().add(instanceVariable.getName());
    instance.setVar(var);
    member.setInstance(instance);
    org.w3._2007.rif.Class clazz = factory.createClass();
    Const const1 = factory.createConst();
    // $NON-NLS-1$
    const1.setType("rif:iri");
    const1.getContent().add(instanceVariable.getClassName());
    clazz.setConst(const1);
    member.setClazz(clazz);
    target.setMember(member);
    assert1.setTarget(target);
    return assert1;
}
Also used : Target(org.w3._2007.rif.Assert.Target) Assert(org.w3._2007.rif.Assert) Instance(org.w3._2007.rif.Instance) ActionVar(org.w3._2007.rif.Do.ActionVar) Var(org.w3._2007.rif.Var) Const(org.w3._2007.rif.Const) Member(org.w3._2007.rif.Member)

Example 2 with Target

use of org.w3._2007.rif.Assert.Target in project hale by halestudio.

the class ModelRifToRifTranslator method processChildren.

private void processChildren(ModelSentence s, final Exists exists, Do do1) {
    Formula existsFormula = factory.createFormula();
    And and = factory.createAnd();
    existsFormula.setAnd(and);
    exists.setFormula(existsFormula);
    Actions actions = factory.createDoActions();
    do1.setActions(actions);
    for (RifVariable instanceVariable : s.getVariables(Type.INSTANCE)) {
        // source instance variables
        if (!instanceVariable.isActionVar()) {
            recurseChildren(exists, do1, instanceVariable, s, true);
        } else // target instance variables
        {
            recurseChildren(exists, do1, instanceVariable, s, false);
        }
    }
    Map<RifVariable, Frame> map = new LinkedHashMap<RifVariable, Frame>();
    for (PropertyMapping mapping : s.getPropertyMappings()) {
        RifVariable contextVariable = mapping.getTarget().getContextVariable();
        Frame match = map.get(contextVariable);
        if (match == null) {
            map.put(contextVariable, initialiseFrame(contextVariable));
        }
    }
    for (StaticAssignment staticAssignment : s.getStaticAssignments()) {
        RifVariable contextVariable = staticAssignment.getTarget().getContextVariable();
        Frame match = map.get(contextVariable);
        if (match == null) {
            map.put(contextVariable, initialiseFrame(contextVariable));
        }
    }
    for (PropertyMapping mapping : s.getPropertyMappings()) {
        Frame frame = map.get(mapping.getTarget().getContextVariable());
        createAssignmentSlot(mapping, frame);
    }
    for (StaticAssignment staticAssignment : s.getStaticAssignments()) {
        Frame frame = map.get(staticAssignment.getTarget().getContextVariable());
        createStaticAssignmentSlot(staticAssignment, frame);
    }
    for (ModelRifMappingCondition mappingCondition : s.getMappingConditions()) {
        createFilter(exists.getFormula().getAnd().getFormula(), mappingCondition);
    }
    for (Frame frame : map.values()) {
        Assert assert1 = factory.createAssert();
        Target target = factory.createAssertTarget();
        target.setFrame(frame);
        assert1.setTarget(target);
        actions.getACTION().add(assert1);
    }
}
Also used : Formula(org.w3._2007.rif.Formula) StaticAssignment(com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment) Frame(org.w3._2007.rif.Frame) Target(org.w3._2007.rif.Assert.Target) Assert(org.w3._2007.rif.Assert) Actions(org.w3._2007.rif.Do.Actions) And(org.w3._2007.rif.And) ModelRifMappingCondition(com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition) PropertyMapping(com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping) RifVariable(com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable) LinkedHashMap(java.util.LinkedHashMap)

Example 3 with Target

use of org.w3._2007.rif.Assert.Target in project cxf by apache.

the class XKMSTest method testRegisterUnitTest.

@org.junit.Test
public void testRegisterUnitTest() throws Exception {
    SpringBusFactory bf = new SpringBusFactory();
    URL busFile = XKMSTest.class.getResource("client.xml");
    Bus bus = bf.createBus(busFile.toString());
    BusFactory.setDefaultBus(bus);
    BusFactory.setThreadDefaultBus(bus);
    // XKMSTest.class.getResource("xkms.wsdl");
    URL wsdl = new URL("https://localhost:" + PORT2 + "/XKMS?wsdl");
    String ns = "http://www.w3.org/2002/03/xkms#wsdl";
    QName serviceQName = new QName(ns, "XKMSService");
    Service service = Service.create(wsdl, serviceQName);
    QName portQName = new QName(NAMESPACE, "XKMSPort");
    XKMSPortType port = service.getPort(portQName, XKMSPortType.class);
    // updateAddressPort(port, PORT2);
    // First try to locate - which should fail
    LocateRequestType locateRequest = new LocateRequestType();
    locateRequest.setId("_xyz");
    locateRequest.setService("http://cxf.apache.org/services/XKMS/");
    QueryKeyBindingType queryKeyBinding = new QueryKeyBindingType();
    UseKeyWithType useKeyWithType = new UseKeyWithType();
    useKeyWithType.setApplication("urn:ietf:rfc:2459");
    useKeyWithType.setIdentifier("CN=client");
    queryKeyBinding.getUseKeyWith().add(useKeyWithType);
    locateRequest.setQueryKeyBinding(queryKeyBinding);
    LocateResultType locateResultType = port.locate(locateRequest);
    assertTrue(locateResultType.getResultMajor().endsWith("Success"));
    assertTrue(locateResultType.getResultMinor().endsWith("NoMatch"));
    // Now register
    RegisterRequestType registerRequest = new RegisterRequestType();
    registerRequest.setId("_xyz");
    registerRequest.setService("http://cxf.apache.org/services/XKMS/");
    PrototypeKeyBindingType prototypeKeyBinding = new PrototypeKeyBindingType();
    CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
    InputStream certInputStream = ClassLoaderUtils.getResourceAsStream("xkmstest.cer", this.getClass());
    Certificate certificate = certificateFactory.generateCertificate(certInputStream);
    KeyInfoType keyInfo = X509Utils.getKeyInfo((X509Certificate) certificate);
    prototypeKeyBinding.setKeyInfo(keyInfo);
    prototypeKeyBinding.getUseKeyWith().add(useKeyWithType);
    registerRequest.setPrototypeKeyBinding(prototypeKeyBinding);
    RegisterResultType registerResult = port.register(registerRequest);
    assertTrue(registerResult.getResultMajor().endsWith("Success"));
    assertFalse(registerResult.getKeyBinding().isEmpty());
    // Now locate again - which should work
    locateResultType = port.locate(locateRequest);
    assertTrue(locateResultType.getResultMajor().endsWith("Success"));
    assertFalse(locateResultType.getUnverifiedKeyBinding().isEmpty());
    // Delete the certificate so that the test works when run again
    Path path = FileSystems.getDefault().getPath("target/test-classes/certs/xkms/CN-client.cer");
    Files.delete(path);
}
Also used : Path(java.nio.file.Path) Bus(org.apache.cxf.Bus) RegisterResultType(org.apache.cxf.xkms.model.xkms.RegisterResultType) PrototypeKeyBindingType(org.apache.cxf.xkms.model.xkms.PrototypeKeyBindingType) QName(javax.xml.namespace.QName) InputStream(java.io.InputStream) RegisterRequestType(org.apache.cxf.xkms.model.xkms.RegisterRequestType) UseKeyWithType(org.apache.cxf.xkms.model.xkms.UseKeyWithType) Service(javax.xml.ws.Service) XKMSPortType(org.w3._2002._03.xkms_wsdl.XKMSPortType) LocateRequestType(org.apache.cxf.xkms.model.xkms.LocateRequestType) CertificateFactory(java.security.cert.CertificateFactory) URL(java.net.URL) KeyInfoType(org.apache.cxf.xkms.model.xmldsig.KeyInfoType) SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) QueryKeyBindingType(org.apache.cxf.xkms.model.xkms.QueryKeyBindingType) LocateResultType(org.apache.cxf.xkms.model.xkms.LocateResultType) X509Certificate(java.security.cert.X509Certificate) Certificate(java.security.cert.Certificate)

Example 4 with Target

use of org.w3._2007.rif.Assert.Target in project airavata by apache.

the class StorageCreator method createStorage.

// The target site must have storage factory deployed with bes factory
public StorageClient createStorage() throws Exception {
    if (factoryUrl == null) {
        throw new Exception("Cannot create Storage Factory Url");
    }
    EndpointReferenceType sfEpr = WSUtilities.makeServiceEPR(factoryUrl, StorageFactory.SMF_PORT);
    String dn = findServerName(factoryUrl, sfEpr);
    WSUtilities.addServerIdentity(sfEpr, dn);
    secProps.getETDSettings().setReceiver(new X500Principal(dn));
    secProps.getETDSettings().setIssuerCertificateChain(secProps.getCredential().getCertificateChain());
    // TODO: remove it afterwards
    if (userName != null) {
        secProps.getETDSettings().getRequestedUserAttributes2().put("xlogin", new String[] { userName });
    }
    StorageFactoryClient sfc = new StorageFactoryClient(sfEpr, secProps);
    if (log.isDebugEnabled()) {
        log.debug("Using storage factory at <" + sfc.getUrl() + ">");
    }
    StorageClient sc = null;
    try {
        sc = sfc.createSMS(getCreateSMSDocument());
        String addr = sc.getEPR().getAddress().getStringValue();
        log.info(addr);
    } catch (Exception ex) {
        log.error("Could not create storage", ex);
        throw new Exception(ex);
    }
    return sc;
}
Also used : EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) X500Principal(javax.security.auth.x500.X500Principal) StorageClient(de.fzj.unicore.uas.client.StorageClient) StorageFactoryClient(de.fzj.unicore.uas.client.StorageFactoryClient)

Example 5 with Target

use of org.w3._2007.rif.Assert.Target in project airavata by apache.

the class StorageCreator method createStorage.

// The target site must have storage factory deployed with bes factory
public StorageClient createStorage() throws Exception {
    if (factoryUrl == null) {
        throw new Exception("Cannot create Storage Factory Url");
    }
    EndpointReferenceType sfEpr = WSUtilities.makeServiceEPR(factoryUrl, StorageFactory.SMF_PORT);
    String dn = findServerName(factoryUrl, sfEpr);
    WSUtilities.addServerIdentity(sfEpr, dn);
    secProps.getETDSettings().setReceiver(new X500Principal(dn));
    secProps.getETDSettings().setIssuerCertificateChain(secProps.getCredential().getCertificateChain());
    // TODO: remove it afterwards
    if (userName != null) {
        secProps.getETDSettings().getRequestedUserAttributes2().put("xlogin", new String[] { userName });
    }
    StorageFactoryClient sfc = new StorageFactoryClient(sfEpr, secProps);
    if (log.isDebugEnabled()) {
        log.debug("Using storage factory at <" + sfc.getUrl() + ">");
    }
    StorageClient sc = null;
    try {
        sc = sfc.createSMS(getCreateSMSDocument());
        String addr = sc.getEPR().getAddress().getStringValue();
        log.info(addr);
    } catch (Exception ex) {
        log.error("Could not create storage", ex);
        throw new Exception(ex);
    }
    return sc;
}
Also used : EndpointReferenceType(org.w3.x2005.x08.addressing.EndpointReferenceType) X500Principal(javax.security.auth.x500.X500Principal) StorageClient(de.fzj.unicore.uas.client.StorageClient) StorageFactoryClient(de.fzj.unicore.uas.client.StorageFactoryClient)

Aggregations

StorageClient (de.fzj.unicore.uas.client.StorageClient)2 StorageFactoryClient (de.fzj.unicore.uas.client.StorageFactoryClient)2 X500Principal (javax.security.auth.x500.X500Principal)2 Assert (org.w3._2007.rif.Assert)2 Target (org.w3._2007.rif.Assert.Target)2 EndpointReferenceType (org.w3.x2005.x08.addressing.EndpointReferenceType)2 ModelRifMappingCondition (com.onespatial.jrc.tns.oml_to_rif.model.rif.ModelRifMappingCondition)1 PropertyMapping (com.onespatial.jrc.tns.oml_to_rif.model.rif.PropertyMapping)1 StaticAssignment (com.onespatial.jrc.tns.oml_to_rif.model.rif.StaticAssignment)1 RifVariable (com.onespatial.jrc.tns.oml_to_rif.translate.context.RifVariable)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 Path (java.nio.file.Path)1 Certificate (java.security.cert.Certificate)1 CertificateFactory (java.security.cert.CertificateFactory)1 X509Certificate (java.security.cert.X509Certificate)1 LinkedHashMap (java.util.LinkedHashMap)1 QName (javax.xml.namespace.QName)1 Service (javax.xml.ws.Service)1 Bus (org.apache.cxf.Bus)1