Projet

Général

Profil

« Précédent | Suivant » 

Révision 96454bcd

Ajouté par Sylvain Sauvage il y a plus de 11 ans

Version 1.9-mock

This is version 1.9-mock. 1.9 because the API still have changes pending
(principally relative to the Discovery Services). “mock” because TLS
configuration is not yet available and the signatures (SigMa) are not fully
implemented.

  • All:
    - code cleaned and refactored
    - lots of bugs fixed
    - dependencies checked and trimmed
    - documentation added
    - Identity handling added
  • New library modules (Mu, Nu)
  • New signature modules (SigMa)
  • Access Layer and User interfaces (ALfA and OMeGa):
    - code refactored
    - new, better APIs
    - Identity handling added
    - use EPCglobal and DS events (no proxy types anymore)
  • New tempororay DSeTa web service (pending new DS)
  • ETa corrected and added to the IoTa-Installer
    - ETa-Callback modules are now available as web applications
    - filtering rules: if a part of an event is not allowed, now the whole
    event is deleted from the result (before only the rejectd part was)
  • CaPPa: overall refactoring of XACML handling
    - new temporary User web service
    - new Xi module: XACML Interrogation web service (was two modules: TCP and
    servlet)
  • PSi now signs its events
  • Installer, now also installs or configures:
    - ETa and its Callback modules
    - ActiveMQ
    - SigMa
    - certificate/signing key
  • Greyc letters figures:
    - new simplified figures (sans IoTa and simplified IoTa)
    - new figure for ETa modules
    - show 3rd party clients
    - data flows specified
    - TLS and link security added
    - IDs and trusted IDs added
    - color adjusted for printing
    - GREYC logo added

Voir les différences:

ETa/ETa-Callback/ETa-Callback-Receiver/src/main/java/fr/unicaen/iota/eta/callback/receiver/CallbackOperationsModule.java
/*
* This program is a part of the IoTa Project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2011-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2011 Orange Labs
*
* This program is free software: you can redistribute it and/or modify
......
import java.io.IOException;
import java.io.InputStream;
import java.io.StringWriter;
import java.util.Properties;
import javax.jms.*;
import javax.xml.XMLConstants;
import javax.xml.parsers.DocumentBuilder;
......
import javax.xml.validation.Schema;
import javax.xml.validation.SchemaFactory;
import javax.xml.validation.Validator;
import org.apache.activemq.ActiveMQConnection;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
......
*/
public class CallbackOperationsModule {
private final String PROP_EPCIS_SCHEMA_FILE = "/wsdl/EPCglobal-epcis-query-1_0.xsd";
private final String PROPERTY_FILE = "/application.properties";
private Properties properties;
private Schema schema;
/*
* Properties of the message broker
*/
private String queueName = "queueToFilter";
private final String PROP_QUEUENAME = "connection.queueName";
private final String PROP_USER = "connection.user";
private final String PROP_PASSWORD = "connection.password";
private final String PROP_URL = "connection.url";
private String user = ActiveMQConnection.DEFAULT_USER;
private String password = ActiveMQConnection.DEFAULT_PASSWORD;
private String url = ActiveMQConnection.DEFAULT_BROKER_URL;
private static final Log LOG = LogFactory.getLog(CallbackOperationsModule.class);
private Schema schema;
public CallbackOperationsModule() {
this.properties = loadProperties(PROPERTY_FILE);
this.schema = initEpcisSchema(PROP_EPCIS_SCHEMA_FILE);
queueName = properties.getProperty(PROP_QUEUENAME, queueName);
url = properties.getProperty(PROP_URL, ActiveMQConnection.DEFAULT_BROKER_URL);
user = properties.getProperty(PROP_USER, ActiveMQConnection.DEFAULT_USER);
password = properties.getProperty(PROP_PASSWORD, ActiveMQConnection.DEFAULT_PASSWORD);
this.schema = initEpcisSchema(Constants.EPCIS_SCHEMA_PATH);
}
/**
......
return null;
}
/**
* Gets ActiveMQ password.
*
* @return The ActiveMQ password.
*/
public String getPassword() {
return password;
}
/**
* Gets the name of the queue.
*
* @return The name of the queue.
*/
public String getQueueName() {
return queueName;
}
/**
* Gets the destination URL.
*
* @return The destination URL.
*/
public String getUrl() {
return url;
}
/**
* Gets the user name.
*
* @return The user name.
*/
public String getUser() {
return user;
}
/**
* Parses and validates the payload as XML document.
*
......
transformer.transform(new DOMSource(document), new StreamResult(writer));
String xml = writer.toString();
if (xml.length() > 100 * 1024) {
// too large, do not log
xml = null;
} else {
LOG.debug("Incoming contents:\n\n" + writer.toString() + "\n");
xml = "[too large, not logged]";
}
LOG.debug("Incoming contents:\n\n" + xml + "\n");
} catch (Exception e) {
// never mind ... do not log
}
......
throw e;
}
}
LOG.debug("Incoming capture request was successfully validated against the EPCISDocument schema");
LOG.debug("Incoming result was successfully validated against the EPCISDocument schema");
} else {
LOG.warn("Schema validator unavailable. Unable to validate EPCIS capture event against schema!");
LOG.warn("Schema validator unavailable. Unable to validate EPCIS event against schema!");
}
} catch (ParserConfigurationException e) {
......
return document;
}
/**
* Loads the application's properties file from the class path.
*
* @return A populated Properties instance.
*/
private Properties loadProperties(String file) {
// read application properties from classpath
InputStream is = this.getClass().getResourceAsStream(file);
Properties prop = new Properties();
try {
prop.load(is);
is.close();
} catch (IOException e) {
LOG.error("Unable to load application properties from classpath:" + file + " ("
+ this.getClass().getResource(file) + ")", e);
}
return prop;
}
/**
* Sends message to the message broker.
*
* @param msg The message to send.
* @throws JMSException If a sending message error occurred.
*/
public void send(String msg) throws JMSException {
public void send(String msg) throws JMSException, Exception {
ActiveMQConnectionFactory factory;
if (user != null && password != null && !user.isEmpty() && !password.isEmpty()) {
factory = new ActiveMQConnectionFactory(user, password, url);
if (Constants.ACTIVEMQ_LOGIN != null && Constants.ACTIVEMQ_PASSWORD != null
&& !Constants.ACTIVEMQ_LOGIN.isEmpty() && !Constants.ACTIVEMQ_PASSWORD.isEmpty()) {
factory = new ActiveMQConnectionFactory(Constants.ACTIVEMQ_LOGIN, Constants.ACTIVEMQ_PASSWORD, Constants.ACTIVEMQ_URL);
} else {
factory = new ActiveMQConnectionFactory(url);
factory = new ActiveMQConnectionFactory(Constants.ACTIVEMQ_URL);
}
Connection connection = factory.createConnection();
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE);
Destination destination = session.createQueue(queueName);
MessageProducer producer = session.createProducer(destination);
connection.start();
try {
TextMessage message = session.createTextMessage();
message.setText(msg);
producer.send(message);
Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
try {
Destination destination = session.createQueue(Constants.ACTIVEMQ_QUEUE_NAME);
MessageProducer producer = session.createProducer(destination);
TextMessage message = session.createTextMessage();
message.setText(msg);
producer.send(message);
} finally {
session.close();
}
} finally {
connection.close();
}

Formats disponibles : Unified diff