Projet

Général

Profil

« Précédent | Suivant » 

Révision 675e977d

Ajouté par Remy Menard il y a plus de 11 ans

  • ID 675e977d6baa946d508d77b8721408cbe9155a8e
  • Parent 8fd1d584

Version 2.1

  • All:
    - a few bugs fixed!
  • DELTa:
    - uses the new DS events
  • EpcisPHI, DiscoveryPHI:
    - improves the session management
    - the account creation by the web interface adds access policies to
    the interface ("admin" policies), this is always done even if a
    corresponding account exists in the LDAP directory
  • YPSilon:
    - simplifies the service
  • Installer:
    - upgrades Apache Tomcat to 7.0.42

Voir les différences:

ALfA/ALfA-PI/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>alfa-pi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>ALfA-PI</name>
ALfA/ALfA-RMI/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>alfa-rmi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>ALfA-RMI</name>
ALfA/ALfA/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>alfa</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>ALfA</name>
BETa/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>beta</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>BETa</name>
CaPPa/DS-Xi-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>ds-xi-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>DS-Xi-Client</name>
CaPPa/EPCIS-Xi-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>epcis-xi-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>EPCIS-Xi-Client</name>
CaPPa/EPCIS-Xi-Client/src/main/java/fr/unicaen/iota/xi/client/UserPEP.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2012 Orange Labs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xi.client;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.xacml.policy.Module;
import fr.unicaen.iota.xacml.request.EventRequest;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class UserPEP extends PEP {
private static final Log log = LogFactory.getLog(UserPEP.class);
public UserPEP(String url, String pksFilename, String pksPassword, String trustPksFilename, String trustPksPassword) {
super(url, pksFilename, pksPassword, trustPksFilename, trustPksPassword);
}
public int userLookup(String userId, String partner) {
log.debug("process userLookup policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "userLookup", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int userCreate(String userId, String partner) {
log.debug("process userCreate policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "userCreate", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int userInfo(String userId, String partner) {
log.debug("process userInfo policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "userInfo", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int userUpdate(String userId, String partner) {
log.debug("process userUpdate policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "userUpdate", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int userDelete(String userId, String partner) {
log.debug("process userDelete policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "userDelete", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int partnerUpdate(String userId, String partner) {
log.debug("process partnerUpdate policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "partnerUpdate", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int partnerLookup(String userId, String partner) {
log.debug("process partnerLookup policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "partnerLookup", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int partnerDelete(String userId, String partner) {
log.debug("process partnerDelete policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "partnerDelete", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public int partnerCreate(String userId, String partner) {
log.debug("process partnerCreate policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "partnerCreate", partner, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest);
}
public boolean isRootAccess(String userId, String partnerId) {
log.trace("process checkRootAccess policy for user: " + userId);
EventRequest eventRequest = new EventRequest(userId, "superadmin", partnerId, Module.administrationModule.getValue());
return processXACMLRequest(eventRequest) == Result.DECISION_PERMIT;
}
}
DELTa/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>delta</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>DELTa</name>
......
</build>
<!--
<repositories>
<repository>
<id>fosstrak</id>
......
<url>https://oss.sonatype.org/content/repositories/public</url>
</repository>
</repositories>
-->
</project>
DELTa/src/main/java/fr/unicaen/iota/validator/AnalyserResult.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.validator.listener.AnalyserListener;
import fr.unicaen.iota.validator.model.BaseEvent;
import fr.unicaen.iota.validator.model.EPC;
DELTa/src/main/java/fr/unicaen/iota/validator/ResultRaw.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.validator.model.BaseEvent;
import fr.unicaen.iota.validator.model.EPC;
import java.util.ArrayList;
DELTa/src/main/java/fr/unicaen/iota/validator/gui/DetailsDialog.form
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="353" max="32767" attributes="0"/>
<EmptySpace pref="374" max="32767" attributes="0"/>
<Component id="jButton6" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
......
<Component id="jLabel8" min="-2" pref="13" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel9" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="33" max="32767" attributes="0"/>
<Component id="jButton5" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jButton1" min="-2" max="-2" attributes="0"/>
......
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="19" max="32767" attributes="0"/>
<EmptySpace pref="14" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jButton5" alignment="3" min="-2" max="-2" attributes="0"/>
......
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="1" max="32767" attributes="0"/>
<Component id="jTabbedPane1" alignment="1" pref="678" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jTabbedPane1" alignment="0" max="32767" attributes="0"/>
<Component id="jTabbedPane1" alignment="0" pref="314" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
......
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="649" max="32767" attributes="0"/>
<Component id="jScrollPane1" alignment="0" pref="646" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="jButton9" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
......
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane1" pref="241" max="32767" attributes="0"/>
<Component id="jScrollPane1" pref="216" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/>
......
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane2" alignment="0" pref="649" max="32767" attributes="0"/>
<Component id="jScrollPane2" alignment="0" pref="646" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="jButton8" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
......
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane2" pref="241" max="32767" attributes="0"/>
<Component id="jScrollPane2" pref="216" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton3" alignment="3" min="-2" max="-2" attributes="0"/>
......
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jScrollPane3" alignment="0" pref="649" max="32767" attributes="0"/>
<Component id="jScrollPane3" alignment="0" pref="646" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Component id="jButton7" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
......
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jScrollPane3" pref="241" max="32767" attributes="0"/>
<Component id="jScrollPane3" pref="216" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jButton4" alignment="3" min="-2" max="-2" attributes="0"/>
DELTa/src/main/java/fr/unicaen/iota/validator/gui/DetailsDialog.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.gui;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.application.rmi.AccessInterface;
import fr.unicaen.iota.application.AccessInterface;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.validator.AnalyserResult;
import fr.unicaen.iota.validator.Configuration;
import fr.unicaen.iota.validator.IOTA;
......
for (DSEvent dsEvent : container.getDsToEPCISReferentList(resultRaw.getContainerList())) {
i++;
DefaultTableModel model = (DefaultTableModel) (jTable2.getModel());
model.addRow(new String[]{i + "", dsEvent.getBizStep(), dsEvent.getReferenceAddress(), eventNotFound.contains(dsEvent) ? "MISSING" : "FOUND"});
model.addRow(new String[]{i + "", dsEvent.getBizStep(), dsEvent.getServiceAddress(), eventNotFound.contains(dsEvent) ? "MISSING" : "FOUND"});
}
}
if (showDStoDSResults) {
......
for (DSEvent dsEvent : container.getDsToDsReferentList()) {
i++;
DefaultTableModel model = (DefaultTableModel) (jTable3.getModel());
model.addRow(new String[]{i + "", dsEvent.getBizStep(), dsEvent.getReferenceAddress(), eventNotFound.contains(dsEvent) ? "MISSING" : "FOUND"});
model.addRow(new String[]{i + "", dsEvent.getBizStep(), dsEvent.getServiceAddress(), eventNotFound.contains(dsEvent) ? "MISSING" : "FOUND"});
}
}
}
DELTa/src/main/java/fr/unicaen/iota/validator/gui/GUI.form
<Component id="jCheckBox2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="jCheckBox3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="136" max="32767" attributes="0"/>
<EmptySpace pref="112" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel11" min="-2" pref="12" max="-2" attributes="0"/>
DELTa/src/main/java/fr/unicaen/iota/validator/gui/GUI.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.gui;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.tau.model.Identity;
import fr.unicaen.iota.validator.*;
import fr.unicaen.iota.validator.listener.AnalyserListener;
DELTa/src/main/java/fr/unicaen/iota/validator/listener/AnalyserListener.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.listener;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.validator.model.BaseEvent;
import fr.unicaen.iota.validator.model.EPC;
import java.util.EventListener;
DELTa/src/main/java/fr/unicaen/iota/validator/listener/AnalyserStatus.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.listener;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.validator.model.BaseEvent;
import fr.unicaen.iota.validator.model.EPC;
import java.util.List;
DELTa/src/main/java/fr/unicaen/iota/validator/model/EPC.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
package fr.unicaen.iota.validator.model;
import fr.unicaen.iota.ds.model.*;
import org.fosstrak.epcis.model.EPCISEventType;
import fr.unicaen.iota.validator.Configuration;
import fr.unicaen.iota.validator.IOTA;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.fosstrak.epcis.model.EPCISEventType;
/**
*
......
private static final Log log = LogFactory.getLog(EPC.class);
private String epc;
private List<BaseEvent> eventList;
private List<TEventItem> dsToDsReferentList;
private List<DSEvent> dsToDsReferentList;
private String parentId;
public EPC(String epc) {
......
return res;
}
public List<TEventItem> getDSEvents(List<EPC> containerList) throws Exception {
public List<DSEvent> getDSEvents(List<EPC> containerList) throws Exception {
List<BaseEvent> eventListClone = new ArrayList<BaseEvent>();
eventListClone.addAll(this.eventList);
if (this.parentId != null) {
BaseEvent parentEvent = getParentEvent(parentId, containerList);
eventListClone.add(parentEvent);
}
List<TEventItem> events = new ArrayList<TEventItem>();
List<DSEvent> events = new ArrayList<DSEvent>();
for (BaseEvent be : eventListClone) {
TEventItem evt = new TEventItem();
TServiceItemList serviceList = new TServiceItemList();
TServiceItem service = new TServiceItem();
service.setUri(be.getInfrastructure().getServiceAddress());
serviceList.getService().add(service);
evt.setServiceList(serviceList);
evt.setC(epc);
evt.setLcs(be.getBizStep());
DSEvent evt = new DSEvent();
evt.setEpc(this.epc);
evt.setServiceAddress(be.getInfrastructure().getServiceAddress());
evt.setBizStep(be.getBizStep());
events.add(evt);
//new DSEvent(this.epc,
// be.getInfrastructure().getServiceAddress(),
// be.getBizStep(),
// null));
}
return events;
}
public Iterable<TEventItem> getDSToDSEvents(List<EPC> containerList) {
public Iterable<DSEvent> getDSToDSEvents(List<EPC> containerList) {
throw new UnsupportedOperationException("Not yet implemented");
}
......
boolean found = false;
for (DSEvent dsEvent : list) {
if (dsEvent.getBizStep().equals(be.getBizStep())
&& dsEvent.getEPC().equals(this.epc)
&& dsEvent.getReferenceAddress().equals(formatAddress(be.getInfrastructure().getServiceAddress()))) {
&& dsEvent.getEpc().equals(this.epc)
&& dsEvent.getServiceAddress().equals(formatAddress(be.getInfrastructure().getServiceAddress()))) {
found = true;
break;
}
}
if (!found) {
events.add(new DSEvent(this.epc, be.getInfrastructure().getServiceAddress(), be.getBizStep(), null));
DSEvent evt = new DSEvent();
evt.setEpc(epc);
evt.setBizStep(be.getBizStep());
evt.setServiceAddress(be.getInfrastructure().getServiceAddress());
events.add(evt);
}
}
if (Configuration.DEBUG) {
......
return res;
}
public List<BaseEvent> reverseVerifyEPCISEvents(List<EPCISEvent> list) {
public List<BaseEvent> reverseVerifyEPCISEvents(List<EPCISEventType> list) {
List<BaseEvent> res = new ArrayList<BaseEvent>();
for (BaseEvent be : this.eventList) {
if (!be.isContainedIn(list)) {
......
log.debug("#");
for (DSEvent dsEvent : list) {
log.debug("# " + dsEvent.getBizStep());
log.debug("# " + dsEvent.getEPC());
log.debug("# " + dsEvent.getReferenceAddress());
log.debug("# " + dsEvent.getEpc());
log.debug("# " + dsEvent.getServiceAddress());
log.debug("#");
}
log.debug("# # # # # # # Event found in the XML file # # # # # # #");
......
public List<DSEvent> getDsToEPCISReferentList(List<EPC> containerList) {
List<DSEvent> result = new ArrayList<DSEvent>();
for (BaseEvent event : eventList) {
result.add(new DSEvent(epc, event.getInfrastructure().getServiceAddress(), event.getBizStep(), null));
DSEvent evt = new DSEvent();
evt.setEpc(this.epc);
evt.setServiceAddress(event.getInfrastructure().getServiceAddress());
evt.setBizStep(event.getBizStep());
result.add(evt);
}
if (this.parentId != null) {
BaseEvent parentEvent = null;
......
} catch (Exception ex) {
log.fatal(null, ex);
}
result.add(new DSEvent(epc, parentEvent.getInfrastructure().getServiceAddress(), parentEvent.getBizStep(), null));
DSEvent evt = new DSEvent();
evt.setEpc(this.epc);
evt.setServiceAddress(parentEvent.getInfrastructure().getServiceAddress());
evt.setBizStep(parentEvent.getBizStep());
result.add(evt);
}
return result;
}
DELTa/src/main/java/fr/unicaen/iota/validator/model/ObjectEvent.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
package fr.unicaen.iota.validator.model;
import fr.unicaen.iota.mu.EPCISEventTypeHelper;
import org.fosstrak.epcis.model.EPCISEventType;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.fosstrak.epcis.model.ActionType;
import org.fosstrak.epcis.model.EPCISEventType;
import org.jdom.Element;
/**
......
public boolean isContainedIn(Collection<EPCISEventType> list) {
for (EPCISEventType evt : list) {
EPCISEventTypeHelper event = new EPCISEventTypeHelper(evt);
for (String epc : event.getEpcs()) {
for (String epc : event.getEpcList()) {
if (!getEpcList().contains(epc)) {
return false;
}
DELTa/src/main/java/fr/unicaen/iota/validator/operations/Analyser.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.operations;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.application.rmi.AccessInterface;
import fr.unicaen.iota.application.AccessInterface;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.tau.model.Identity;
import fr.unicaen.iota.validator.Configuration;
import fr.unicaen.iota.validator.Controler;
......
private final Identity identity;
private ThreadManager threadManager;
private final AnalyserStatus analyserStatus;
private static final Log log = LogFactory.getLog(Analyser.class);
public Analyser(String XMLPath, Identity identity, IOTA iota, AnalyserStatus analyserStatus) {
DELTa/src/main/java/fr/unicaen/iota/validator/operations/DSEntryComparator.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.operations;
import fr.unicaen.iota.application.model.DSEvent;
import fr.unicaen.iota.application.rmi.AccessInterface;
import fr.unicaen.iota.application.AccessInterface;
import fr.unicaen.iota.ds.model.DSEvent;
import fr.unicaen.iota.nu.ONSEntryType;
import fr.unicaen.iota.tau.model.Identity;
import fr.unicaen.iota.validator.Configuration;
import fr.unicaen.iota.validator.IOTA;
......
}
tmp.add(link.getDsAddress());
Date d1 = new Date();
eventList.addAll(applicationLevelInterface.queryDS(container.getEpc(),
link.getDsAddress(), identity, Configuration.DS_SERVICE_TYPE_FOR_EPCIS));
eventList.addAll(applicationLevelInterface.queryDS(identity, container.getEpc(),
link.getDsAddress(), ONSEntryType.epcis));
Date d2 = new Date();
link.addTimeResponse(d2.getTime() - d1.getTime());
}
......
}
if (link.getDsAddress().equals(referentDS)) {
Date d1 = new Date();
List<DSEvent> list = applicationLevelInterface.queryDS(container.getEpc(), link.getDsAddress(), identity, Configuration.DS_SERVICE_TYPE_FOR_DS);
List<DSEvent> list = applicationLevelInterface.queryDS(identity, container.getEpc(),
link.getDsAddress(), ONSEntryType.ds);
Date d2 = new Date();
link.addTimeResponse(d2.getTime() - d1.getTime());
for (DSEvent dSEvent : list) {
if (Configuration.DEBUG) {
log.debug("found address: " + dSEvent.getReferenceAddress());
log.debug("found address: " + dSEvent.getServiceAddress());
}
if (dsEventList.contains(dSEvent)) {
continue;
......
}
for (DSEvent dSEvent : dsEventList) {
if (!dsLinks.contains(dSEvent.getReferenceAddress())) {
if (!dsLinks.contains(dSEvent.getServiceAddress())) {
res.add(dSEvent);
}
}
DELTa/src/main/java/fr/unicaen/iota/validator/operations/EPCISEntryComparator.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
......
*/
package fr.unicaen.iota.validator.operations;
import fr.unicaen.iota.application.rmi.AccessInterface;
import fr.unicaen.iota.application.AccessInterface;
import fr.unicaen.iota.tau.model.Identity;
import fr.unicaen.iota.validator.Configuration;
import fr.unicaen.iota.validator.IOTA;
DS/DS-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>ds-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>DS-Client</name>
DS/DS-Commons/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>ds-commons</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>DS-Commons</name>
DS/DS/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>ds</artifactId>
<packaging>war</packaging>
<version>2.0</version>
<version>2.1</version>
<name>DS</name>
DSeTa/DSeTa-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>dseta-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>DSeTa-Client</name>
DSeTa/DSeTa/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>dseta</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>DSeTa</name>
DSeTa/DiscoveryPHI/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>discovery-phi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>DiscoveryPHI</name>
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/auth/User.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.auth;
public class User {
private String userID;
private String ownerID;
public User() {
}
public User(String userID, String ownerID) {
this.userID = userID;
this.ownerID = ownerID;
}
public String getOwnerID() {
return ownerID;
}
public void setOwnerID(String ownerID) {
this.ownerID = ownerID;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/auth/User.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.auth;
public class User {
private String userID;
private String ownerID;
public User() {
}
public User(String userID, String ownerID) {
this.userID = userID;
this.ownerID = ownerID;
}
public String getOwnerID() {
return ownerID;
}
public void setOwnerID(String ownerID) {
this.ownerID = ownerID;
}
public String getUserID() {
return userID;
}
public void setUserID(String userID) {
this.userID = userID;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/utils/Constants.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2011-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public final class Constants {
private Constants() {
}
private static Log log = LogFactory.getLog(Constants.class);
public static final String YPSILON_ADDRESS;
public static final String PKS_FILENAME;
public static final String PKS_PASSWORD;
public static final String TRUST_PKS_FILENAME;
public static final String TRUST_PKS_PASSWORD;
static {
Properties properties = new Properties();
InputStream is = Constants.class.getClassLoader().getResourceAsStream("application.properties");
log.info("Chargement des propriétés de l'application");
try {
properties.load(is);
} catch (IOException ex) {
log.fatal(null, ex);
}
YPSILON_ADDRESS = properties.getProperty("ypsilon-url");
PKS_FILENAME = properties.getProperty("pks-filename", "privatekeys.jks");
PKS_PASSWORD = properties.getProperty("pks-password", "changeit");
TRUST_PKS_FILENAME = properties.getProperty("trust-pks-filename", "publickeys.jks");
TRUST_PKS_PASSWORD = properties.getProperty("trust-pks-password", "changeit");
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/utils/HTMLUtilities.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.utils;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import fr.unicaen.iota.xacml.pep.MethodNamesCapture;
import fr.unicaen.iota.xacml.pep.MethodNamesQuery;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public final class HTMLUtilities {
private static final String[] SERVICES = {"ds", "ided_ds", "epcis", "ided_epcis", "html", "ws", "xmlrpc"};
private static final String[] TYPES = {"object", "aggregation", "quantity", "transaction"};
private HTMLUtilities() {
}
public static String createOwnerSelect() {
StringBuilder res = new StringBuilder();
res.append("<select class=\"ownerSelector\" id=\"groupOwnerName\">");
for (String ownerId : listAllOwners()) {
res.append("<option label=\"owner: ");
res.append(ownerId);
res.append("\" value=\"");
res.append(ownerId);
res.append("\">");
res.append(ownerId);
res.append("</option>");
}
res.append("</select>");
return res.toString();
}
public static String createMethodSelect(Module m) {
StringBuilder res = new StringBuilder();
switch (m) {
case adminModule:
res.append("<select class=\"methodSelector\" id=\"methodNameAdmin\">");
for (Method method1 : MethodNamesAdmin.class.getMethods()) {
res.append("<option label=\"method: ");
res.append(method1.getName());
res.append("\" value=\"");
res.append(method1.getName());
res.append("\">");
res.append(method1.getName());
res.append("</option>");
}
break;
case captureModule:
res.append("<select class=\"methodSelector\" id=\"methodNameCapture\">");
for (Method method2 : MethodNamesCapture.class.getMethods()) {
res.append("<option label=\"method: ");
res.append(method2.getName());
res.append("\" value=\"");
res.append(method2.getName());
res.append("\">");
res.append(method2.getName());
res.append("</option>");
}
break;
case queryModule:
res.append("<select class=\"methodSelector\" id=\"methodNameQuery\">");
for (Method method3 : MethodNamesQuery.class.getMethods()) {
res.append("<option label=\"method: ");
res.append(method3.getName());
res.append("\" value=\"");
res.append(method3.getName());
res.append("\">");
res.append(method3.getName());
res.append("</option>");
}
break;
}
res.append("</select>");
return res.toString();
}
public static String createSelectServiceType(String serviceType, String idSuffix) {
StringBuilder res = new StringBuilder();
res.append("<select id=\"serviceType");
res.append(idSuffix);
res.append("\" >");
for (String s : SERVICES) {
res.append("<option ");
res.append(serviceType.equals(s) ? "selected" : "");
res.append(" value=\"");
res.append(s);
res.append("\">");
res.append(s);
res.append("</option>");
}
res.append("</select>");
return res.toString();
}
public static String createSelectEventTypeFilter() {
StringBuilder res = new StringBuilder();
res.append("<select id=\"eventTypeFilterName\" >");
for (String s : TYPES) {
res.append("<option value=\"");
res.append(s);
res.append("\">");
res.append(s);
res.append("</option>");
}
res.append("</select>");
return res.toString();
}
private static Iterable<String> listAllOwners() {
// TODO: TODOTODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
List<String> ownerIdList = new ArrayList<String>();
ownerIdList.add("owner1");
ownerIdList.add("owner2");
ownerIdList.add("owner3");
ownerIdList.add("owner4");
ownerIdList.add("owner5");
return ownerIdList;
}
private static Iterable<String> listAllMethods() {
// TODO: TODOTODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
List<String> methodList = new ArrayList<String>();
methodList.add("m1");
methodList.add("m2");
methodList.add("m3");
methodList.add("m4");
methodList.add("m5");
return methodList;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/utils/InterfaceHelper.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.utils;
import fr.unicaen.iota.xacml.AccessPolicyManagerSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class InterfaceHelper {
private static final Log log = LogFactory.getLog(InterfaceHelper.class);
// TODO @SLS public field!
public AccessPolicyManagerSession APMSession;
public InterfaceHelper(String owner) {
log.info("InterfaceHelper instanciated");
APMSession = MapSessions.APM.getInstance(owner);
}
public void updateAPM() {
MapSessions.APM.updateAPMSession(APMSession);
}
public void updateQueryAPM() {
MapSessions.APM.updateAPMQuerySession(APMSession);
}
public void updateCaptureAPM() {
MapSessions.APM.updateAPMCaptureSession(APMSession);
}
public void updateAdminAPM() {
MapSessions.APM.updateAPMAdminSession(APMSession);
}
public void reload() {
log.info("RELAOD DSPDP");
APMSession.initDSPDP(APMSession.getOwner());
APMSession.initFinderModule();
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/utils/MapSessions.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.utils;
import fr.unicaen.iota.xacml.AccessPolicyManager;
import fr.unicaen.iota.xacml.finder.MyPolicyCollection;
import fr.unicaen.iota.xacml.finder.MyPolicyFinderModule;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public final class MapSessions {
private MapSessions() {
}
private final static Log log = LogFactory.getLog(MapSessions.class);
// TODO: SLS public hence not procected by synchronized
public final static AccessPolicyManager APM = new AccessPolicyManager();
private final static Map<String, InterfaceHelper> APMSessions = new HashMap<String, InterfaceHelper>();
public static synchronized String AdminAPMtoString() {
StringBuilder res = new StringBuilder();
for (Object o : APM.getDspdp().getPolicyFinder().getModules()) {
if (o instanceof MyPolicyFinderModule) {
MyPolicyFinderModule mod = (MyPolicyFinderModule) o;
MyPolicyCollection col = mod.getPolicies();
Map<String, OwnerPolicies> map = col.getAdminPolicies();
for (String key : map.keySet()) {
res.append(key);
res.append(" \n");
OwnerPolicies ownerPolicies = map.get(key);
//TODO: SLS and?
}
}
}
return res.toString();
}
public static synchronized InterfaceHelper getAPMSession(String userId, String ownerId) {
if (APMSessions.containsKey(userId)) {
return APMSessions.get(userId);
} else {
InterfaceHelper IH = new InterfaceHelper(ownerId);
APMSessions.put(userId, IH);
return IH;
}
}
public static synchronized void releaseSession(String userId) {
APMSessions.remove(userId);
}
public static synchronized void init() {
APM.init();
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/utils/PEPRequester.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.utils;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.auth.User;
import fr.unicaen.iota.dphi.xacml.pep.DSPEP;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public final class PEPRequester {
private static final Log log = LogFactory.getLog(PEPRequester.class);
private PEPRequester() {
}
private static Object runMethod(Object obj, Object[] args, String methodName) {
try {
Class<?>[] paramTypes = null;
if (args != null) {
paramTypes = new Class<?>[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
} catch (IllegalAccessException ex) {
log.fatal(null, ex);
} catch (IllegalArgumentException ex) {
log.fatal(null, ex);
} catch (InvocationTargetException ex) {
log.fatal(null, ex);
} catch (NoSuchMethodException ex) {
log.fatal(null, ex);
} catch (SecurityException ex) {
log.fatal(null, ex);
}
return Result.DECISION_DENY;
}
public static int checkAccess(User user, String methodName) {
String userS = user.getUserID();
String owner = user.getOwnerID();
ArrayList<String> args = new ArrayList<String>();
args.add(userS);
args.add(owner);
DSPEP dspep = new DSPEP();
return (Integer) runMethod(dspep, args.toArray(), methodName);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/Mode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm;
/**
*
*/
public enum Mode {
Assert_Mode,
Create_Mode;
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/Module.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm;
/**
*
*/
public enum Module {
queryModule,
captureModule,
adminModule
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/NodeType.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm;
/**
*
*/
public enum NodeType {
policiesNode,
policyNode,
bizStepFilterNode,
epcFilterNode,
eventTypeFilterNode,
eventTimeFilterNode,
methodFilterNode,
bizStepFilterGroupNode,
epcFilterGroupNode,
eventTypeFilterGroupNode,
eventTimeFilterGroupNode,
methodFilterGroupNode,
rulesNode,
userNode,
usersNode;
public boolean isFilter() {
return this == bizStepFilterNode
|| this == epcFilterNode
|| this == eventTypeFilterNode
|| this == eventTimeFilterNode
|| this == methodFilterNode;
}
public boolean isFilterGroup() {
return this == bizStepFilterGroupNode
|| this == epcFilterGroupNode
|| this == eventTypeFilterGroupNode
|| this == eventTimeFilterGroupNode
|| this == methodFilterGroupNode;
}
public boolean isExpandable() {
return this == bizStepFilterGroupNode
|| this == epcFilterGroupNode
|| this == eventTypeFilterGroupNode
|| this == eventTimeFilterGroupNode
|| this == policyNode
|| this == policiesNode
|| this == rulesNode
|| this == usersNode
|| this == methodFilterGroupNode;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/TreeFactory.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm;
/**
*
*/
public class TreeFactory {
private Mode mode;
public TreeFactory(Mode mode) {
this.mode = mode;
}
public String createTree(TreeNode treeNode) {
StringBuilder result = new StringBuilder();
String button = treeNode.getNodeType() == NodeType.policyNode && this.mode == Mode.Create_Mode
? "<a href=\"#\" onclick=\"expand(this);\" class=\"icon_tree expanderButton2\"></a>"
: "<a href=\"#\" onclick=\"expand(this);\" class=\"icon_tree expanderButton\"></a>";
String img = treeNode.getNodeType() == NodeType.userNode ? "user"
: (treeNode.getNodeType().isFilter() ? "filter" : "");
String desc = createTitleDescription(treeNode);
String icon = "<div class=\"icon_tree icon_tree_" + img + "\">&nbsp;</div>";
if (treeNode.getNodeType() == NodeType.policiesNode) {
result.append("<div class=\"rootzone\" id=\"root");
result.append(treeNode.getModule());
result.append("\">\n");
}
result.append("<div class=\"TreeNodeBlock\"><div class=\"TreeNodeTitle ");
result.append(treeNode.getNodeType());
result.append("\">");
result.append(treeNode.getNodeType().isExpandable() ? button : icon);
result.append("<a href=\"#\" class=\"TreeNodeTitleInnerHtml\" onclick=\"selectBoxNode(this);\"><span class=\"TreeNodeTitleInnerHtmlDesc\">");
result.append(desc);
result.append("</span><span class=\"TreeNodeTitleInnerHtmlValue\">");
result.append(treeNode.getLabel());
result.append("</span></a>");
result.append(createCommand(treeNode));
result.append("</div>\n");
if (!treeNode.getChildren().isEmpty()) {
result.append("<div class=\"TreeNodeContent\" ");
result.append((treeNode.getNodeType() == NodeType.policyNode && this.mode == Mode.Create_Mode) ? "style=\"display:none\" " : "");
result.append(">\n");
for (TreeNode node : treeNode.getChildren()) {
result.append(createTree(node));
}
result.append("</div>\n");
} else if (treeNode.getNodeType().isFilterGroup()
|| treeNode.getNodeType() == NodeType.usersNode
|| treeNode.getNodeType() == NodeType.policiesNode) {
result.append("<div class=\"TreeNodeContent\">\n</div>\n");
}
result.append("</div>\n");
if (treeNode.getNodeType() == NodeType.policiesNode) {
result.append("</div>\n");
}
return result.toString();
}
private String createCommand(TreeNode treeNode) {
String command_start = "<div class=\"nodeCommand\">";
String command_end = "</div>";
String switchPolicy = "<a class=\"switch\" href=\"#\" onclick=\"processSwitchPolicy('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + treeNode.getObjectID() + "',this,'" + treeNode.getModule() + "');\"></a>";
String create = "<a class=\"add\" href=\"#\" onclick=\"processRequestCreate('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + treeNode.getObjectID() + "',this,'" + treeNode.getModule() + "');\"></a>";
String remove = "<a class=\"remove\" href=\"#\" onclick=\"processRequestRemove('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + escapeRegExp(treeNode.getObjectID()) + "',this,'" + treeNode.getModule() + "');\"></a>";
String update = "<a class=\"update\" href=\"#\" onclick=\"processRequestUpdate('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + treeNode.getObjectID() + "',this,'" + treeNode.getModule() + "');\"></a>";
if (treeNode.getNodeType().isFilter()) {
return command_start + remove + command_end;
}
if (treeNode.getNodeType().isFilterGroup()) {
if (treeNode.getNodeType() == NodeType.methodFilterGroupNode) {
return command_start + create + command_end;
} else {
return command_start + switchPolicy + create + command_end;
}
}
switch (treeNode.getNodeType()) {
case rulesNode:
return command_start + command_end;
case usersNode:
return command_start + switchPolicy + create + command_end;
case userNode:
return command_start + remove + command_end;
case policyNode:
return command_start + update + remove + command_end;
case policiesNode:
return command_start + create + command_end;
default:
break;
}
return command_start + remove + create + update + command_end;
}
private String createTitleDescription(TreeNode treeNode) {
switch (treeNode.getNodeType()) {
case usersNode:
return "users / default policy: ";
case policyNode:
return "Group name: ";
case bizStepFilterGroupNode:
return "BizStep Filters / default policy: ";
case epcFilterGroupNode:
return "EPC Filters / default policy: ";
case eventTypeFilterGroupNode:
return "Event Class Filters / default policy: ";
case eventTimeFilterGroupNode:
return "Event Time Filters / default policy: ";
case rulesNode:
return "Restricted filters";
case policiesNode:
return "Group list";
case methodFilterGroupNode:
return "Method filters";
case methodFilterNode:
return "method: ";
case userNode:
return "user id: ";
case bizStepFilterNode:
return "bizStep filter: ";
case eventTimeFilterNode:
return "period filter: ";
case eventTypeFilterNode:
return "Event class filter: ";
case epcFilterNode:
return "EPC filter: ";
default:
return "";
}
}
private String escapeRegExp(String objectID) {
if (objectID == null) {
return "null";
}
return objectID.replaceAll("\\\\", "\\\\\\\\");
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/TreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm;
import java.util.List;
/**
*
*/
public interface TreeNode {
public String getLabel();
public NodeType getNodeType();
public List<TreeNode> getChildren();
public String getObjectID();
public Module getModule();
public String getGroupID();
public void addChild(TreeNode child);
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/AccessPolicies.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.utils.InterfaceHelper;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
public class AccessPolicies {
private List<TreeNode> policiesQuery = new ArrayList<TreeNode>();
private List<TreeNode> policiesAdmin = new ArrayList<TreeNode>();
private List<TreeNode> policiesCapture = new ArrayList<TreeNode>();
public AccessPolicies() {
}
public AccessPolicies(String userId, String owner) {
this.createQueryPolicies(userId, owner);
this.createCapturePolicies(userId, owner);
this.createAdminPolicies(userId, owner);
}
public AccessPolicies(String userId, String owner, Module module) {
switch (module) {
case adminModule:
this.createAdminPolicies(userId, owner);
break;
case queryModule:
this.createQueryPolicies(userId, owner);
break;
case captureModule:
this.createCapturePolicies(userId, owner);
break;
}
}
private synchronized void createQueryPolicies(String userId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(userId, owner).APMSession.getQueryPolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.queryModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
if (ogp instanceof GroupPolicy) {
GroupPolicy gp = (GroupPolicy) ogp;
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), Module.queryModule);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), Module.queryModule);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), Module.queryModule);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
Node filters = new Node("", NodeType.rulesNode, null, Module.queryModule, "id_group_query_1"); // NATIVE
BizStepRuleTreeNode bizStepRuleTreeNode = new BizStepRuleTreeNode(gp.getBizStepsFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getBizSteps()) {
String value = (String) ob;
BizStepTreeNode treeNode = new BizStepTreeNode(value, value, gp.getId().toString(), Module.queryModule);
bizStepRuleTreeNode.addChild(treeNode);
}
filters.addChild(bizStepRuleTreeNode);
EventTypeRuleTreeNode eventTypeRuleTreeNode = new EventTypeRuleTreeNode(gp.getEventTypesFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getEventTypes()) {
String value = (String) ob;
EventTypeTreeNode treeNode = new EventTypeTreeNode(value, value, gp.getId().toString(), Module.queryModule);
eventTypeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTypeRuleTreeNode);
EpcsRuleTreeNode epcRuleTreeNode = new EpcsRuleTreeNode(gp.getEpcsFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getEpcs()) {
String value = (String) ob;
EpcTreeNode treeNode = new EpcTreeNode(value, value, gp.getId().toString(), Module.queryModule);
epcRuleTreeNode.addChild(treeNode);
}
filters.addChild(epcRuleTreeNode);
EventTimeRuleTreeNode eventTimeRuleTreeNode = new EventTimeRuleTreeNode(gp.getEventTimesFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getEventTimes()) {
List value = (List) ob;
EventTimeTreeNode treeNode = new EventTimeTreeNode((Date) value.get(0), (Date) value.get(1), gp.getId().toString(), Module.queryModule);
eventTimeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTimeRuleTreeNode);
gptn.addChild(filters);
policies.addChild(gptn);
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(userId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.queryModule);
ih.APMSession.addQueryPolicy(ownerPolicies);
ih.APMSession.saveQueryPolicies(owner);
ih.updateAPM();
}
getPoliciesQuery().add(policies);
}
private synchronized void createCapturePolicies(String userId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(userId, owner).APMSession.getCapturePolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.captureModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
if (ogp instanceof GroupPolicy) {
GroupPolicy gp = (GroupPolicy) ogp;
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), Module.captureModule);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), Module.captureModule);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), Module.captureModule);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
Node filters = new Node("", NodeType.rulesNode, null, Module.captureModule, "id_group_capture_1"); // NATIVE
BizStepRuleTreeNode bizStepRuleTreeNode = new BizStepRuleTreeNode(gp.getBizStepsFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getBizSteps()) {
String value = (String) ob;
BizStepTreeNode treeNode = new BizStepTreeNode(value, value, gp.getId().toString(), Module.captureModule);
bizStepRuleTreeNode.addChild(treeNode);
}
filters.addChild(bizStepRuleTreeNode);
EventTypeRuleTreeNode eventTypeRuleTreeNode = new EventTypeRuleTreeNode(gp.getEventTypesFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getEventTypes()) {
String value = (String) ob;
EventTypeTreeNode treeNode = new EventTypeTreeNode(value, value, gp.getId().toString(), Module.captureModule);
eventTypeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTypeRuleTreeNode);
EpcsRuleTreeNode epcRuleTreeNode = new EpcsRuleTreeNode(gp.getEpcsFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getEpcs()) {
String value = (String) ob;
EpcTreeNode treeNode = new EpcTreeNode(value, value, gp.getId().toString(), Module.captureModule);
epcRuleTreeNode.addChild(treeNode);
}
filters.addChild(epcRuleTreeNode);
EventTimeRuleTreeNode eventTimeRuleTreeNode = new EventTimeRuleTreeNode(gp.getEventTimesFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getEventTimes()) {
List value = (List) ob;
EventTimeTreeNode treeNode = new EventTimeTreeNode((Date) value.get(0), (Date) value.get(1), gp.getId().toString(), Module.captureModule);
eventTimeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTimeRuleTreeNode);
gptn.addChild(filters);
policies.addChild(gptn);
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(userId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.captureModule);
ih.APMSession.addCapturePolicy(ownerPolicies);
ih.APMSession.saveCapturePolicies(owner);
ih.updateAPM();
}
getPoliciesCapture().add(policies);
}
private synchronized void createAdminPolicies(String userId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(userId, owner).APMSession.getAdminPolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.adminModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
if (ogp instanceof GroupPolicy) {
GroupPolicy gp = (GroupPolicy) ogp;
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), Module.adminModule);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), Module.adminModule);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), Module.adminModule);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), Module.adminModule);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), Module.adminModule);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
policies.addChild(gptn);
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(userId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.administrationModule);
ih.APMSession.addAdminPolicy(ownerPolicies);
ih.APMSession.saveAdminPolicies(owner);
ih.updateAPM();
}
getPoliciesAdmin().add(policies);
}
public synchronized TreeNode createGroupPolicy(GroupPolicy gp, Module module) {
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), module);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), module);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), module);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), module);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
if (!module.equals(Module.adminModule)) {
Node filters = new Node("", NodeType.rulesNode, null, module, "id_group_query_1"); // NATIVE
BizStepRuleTreeNode bizStepRuleTreeNode = new BizStepRuleTreeNode(gp.getBizStepsFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getBizSteps()) {
String value = (String) ob;
BizStepTreeNode treeNode = new BizStepTreeNode(value, value, gp.getId().toString(), module);
bizStepRuleTreeNode.addChild(treeNode);
}
filters.addChild(bizStepRuleTreeNode);
EventTypeRuleTreeNode eventTypeRuleTreeNode = new EventTypeRuleTreeNode(gp.getEventTypesFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getEventTypes()) {
String value = (String) ob;
EventTypeTreeNode treeNode = new EventTypeTreeNode(value, value, gp.getId().toString(), module);
eventTypeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTypeRuleTreeNode);
EpcsRuleTreeNode epcRuleTreeNode = new EpcsRuleTreeNode(gp.getEpcsFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getEpcs()) {
String value = (String) ob;
EpcTreeNode treeNode = new EpcTreeNode(value, value, gp.getId().toString(), module);
epcRuleTreeNode.addChild(treeNode);
}
filters.addChild(epcRuleTreeNode);
EventTimeRuleTreeNode eventTimeRuleTreeNode = new EventTimeRuleTreeNode(gp.getEventTimesFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getEventTimes()) {
List value = (List) ob;
EventTimeTreeNode treeNode = new EventTimeTreeNode((Date) value.get(0), (Date) value.get(1), gp.getId().toString(), module);
eventTimeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTimeRuleTreeNode);
gptn.addChild(filters);
}
return gptn;
}
/**
* @return the policiesQuery
*/
public synchronized List<TreeNode> getPoliciesQuery() {
return policiesQuery;
}
/**
* @param policiesQuery the policiesQuery to set
*/
public synchronized void setPoliciesQuery(List<TreeNode> policiesQuery) {
this.policiesQuery = policiesQuery;
}
/**
* @return the policiesAdmin
*/
public synchronized List<TreeNode> getPoliciesAdmin() {
return policiesAdmin;
}
/**
* @param policiesAdmin the policiesAdmin to set
*/
public synchronized void setPoliciesAdmin(List<TreeNode> policiesAdmin) {
this.policiesAdmin = policiesAdmin;
}
/**
* @return the policiesCapture
*/
public synchronized List<TreeNode> getPoliciesCapture() {
return policiesCapture;
}
/**
* @param policiesCapture the policiesCapture to set
*/
public synchronized void setPoliciesCapture(List<TreeNode> policiesCapture) {
this.policiesCapture = policiesCapture;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/ActionTargetTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class ActionTargetTreeNode implements TreeNode {
private List<TreeNode> children;
private String id;
private Module module;
private String groupID;
public ActionTargetTreeNode(String gID, Module m) {
children = new ArrayList<TreeNode>();
this.id = "Actions";
this.module = m;
this.groupID = gID;
}
@Override
public String getLabel() {
return "";
}
@Override
public NodeType getNodeType() {
return NodeType.methodFilterGroupNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/ActionTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class ActionTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public ActionTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.methodFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/BizStepRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCBizStepRule;
/**
*
*/
public class BizStepRuleTreeNode extends RuleTreeNode {
public BizStepRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCBizStepRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/BizStepTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class BizStepTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public BizStepTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.bizStepFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/EpcTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class EpcTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public EpcTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.epcFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/EpcsRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCEPCsRule;
/**
*
*/
public class EpcsRuleTreeNode extends RuleTreeNode {
public EpcsRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCEPCsRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/EventTimeRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCEventTimeRule;
/**
*
*/
public class EventTimeRuleTreeNode extends RuleTreeNode {
public EventTimeRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCEventTimeRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/EventTimeTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
*
*/
public class EventTimeTreeNode implements TreeNode {
private Date minDate;
private Date maxDate;
private List<TreeNode> children;
private String groupID;
private Module module;
private String id;
public Date getMaxDate() {
return maxDate;
}
public void setMaxDate(Date maxDate) {
this.maxDate = maxDate;
}
public Date getMinDate() {
return minDate;
}
public void setMinDate(Date minDate) {
this.minDate = minDate;
}
public EventTimeTreeNode(Date minD, Date maxD, String gID, Module m) {
maxDate = maxD;
minDate = minD;
this.id = getLabel();
this.groupID = gID;
this.module = m;
this.children = new ArrayList<TreeNode>();
}
@Override
public String getLabel() {
Calendar calMin = Calendar.getInstance();
calMin.setTime(minDate);
Calendar calMax = Calendar.getInstance();
calMax.setTime(maxDate);
return String.format("%1$tm/%1$td/%1$tY -> %2$tm/%2$td/%2$tY", calMin, calMax);
}
@Override
public NodeType getNodeType() {
return NodeType.eventTimeFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
this.children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/EventTypeRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCEventTypeRule;
/**
*
*/
public class EventTypeRuleTreeNode extends RuleTreeNode {
public EventTypeRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCEventTypeRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/EventTypeTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class EventTypeTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public EventTypeTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.eventTypeFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/GroupPolicyTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class GroupPolicyTreeNode implements TreeNode {
private GroupPolicy groupPolicy;
private List nodeChildren;
private String groupID;
private Module module;
public GroupPolicy getGroupPolicy() {
return groupPolicy;
}
public GroupPolicyTreeNode(GroupPolicy gp, String groupID, Module module) {
this.groupPolicy = gp;
this.groupID = groupID;
this.module = module;
this.nodeChildren = new ArrayList();
}
@Override
public String getLabel() {
return groupPolicy.getName();
}
@Override
public NodeType getNodeType() {
return NodeType.policyNode;
}
@Override
public List<TreeNode> getChildren() {
return nodeChildren;
}
@Override
public String getObjectID() {
return groupID;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
nodeChildren.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/Node.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class Node implements TreeNode {
private String value;
private NodeType nodeType;
private List<TreeNode> children;
private String objectID;
private Module module;
private String groupID;
public Node(String value, NodeType type, String id, Module module, String groupID) {
this.value = value;
this.nodeType = type;
this.children = new ArrayList<TreeNode>();
this.objectID = id;
this.module = module;
this.groupID = groupID;
}
@Override
public void addChild(TreeNode node) {
children.add(node);
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return nodeType;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return objectID;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/Policies.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class Policies {
public List<TreeNode> policiesQuery = new ArrayList<TreeNode>();
public List<TreeNode> policiesAdmin = new ArrayList<TreeNode>();
public List<TreeNode> policiesCapture = new ArrayList<TreeNode>();
public Policies() {
createQueryPolicies();
createAdminPolicies();
createCapturePolicies();
}
private void createQueryPolicies() {
Node policy1 = new Node("group_query_1", NodeType.policyNode, null, Module.queryModule, "id_group_query_1");
Node users = new Node("Associated users:", NodeType.usersNode, null, Module.queryModule, "id_group_query_1"); // NATIVE
users.addChild(new Node("user1", NodeType.userNode, null, Module.queryModule, "id_group_query_1"));
users.addChild(new Node("user2", NodeType.userNode, null, Module.queryModule, "id_group_query_1"));
users.addChild(new Node("user3", NodeType.userNode, null, Module.queryModule, "id_group_query_1"));
Node filters = new Node("Restricted filters", NodeType.rulesNode, null, Module.queryModule, "id_group_query_1"); // NATIVE
Node rule1 = new Node("ACCEPT", NodeType.bizStepFilterGroupNode, null, Module.queryModule, "id_group_query_1");
Node filter1 = new Node("blablabla", NodeType.bizStepFilterNode, null, Module.queryModule, "id_group_query_1");
Node filter2 = new Node("bliblibli", NodeType.bizStepFilterNode, null, Module.queryModule, "id_group_query_1");
Node filter3 = new Node("blobloblo", NodeType.bizStepFilterNode, null, Module.queryModule, "id_group_query_1");
rule1.addChild(filter1);
rule1.addChild(filter2);
rule1.addChild(filter3);
Node rule2 = new Node("DROP", NodeType.epcFilterGroupNode, null, Module.queryModule, "id_group_query_1");
Node filter21 = new Node("clacclac", NodeType.epcFilterNode, null, Module.queryModule, "id_group_query_1");
Node filter22 = new Node("clicclic", NodeType.epcFilterNode, null, Module.queryModule, "id_group_query_1");
rule2.addChild(filter21);
rule2.addChild(filter22);
Node rule3 = new Node("DROP", NodeType.eventTypeFilterGroupNode, null, Module.queryModule, "id_group_query_1");
Node rule4 = new Node("DROP", NodeType.eventTimeFilterGroupNode, null, Module.queryModule, "id_group_query_1");
filters.addChild(rule1);
filters.addChild(rule2);
filters.addChild(rule3);
filters.addChild(rule4);
policy1.addChild(users);
policy1.addChild(filters);
Node policy2 = new Node("group_query_2", NodeType.policyNode, null, Module.queryModule, "id_group_query_2");
Node users2 = new Node("Associated users:", NodeType.usersNode, null, Module.queryModule, "id_group_query_2");
users2.addChild(new Node("userx", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("usery", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("userz", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("useru", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("userv", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("userw", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
policy2.addChild(users2);
Node policies = new Node("Groups", NodeType.policiesNode, null, Module.queryModule, null); // NATIVE
policies.addChild(policy1);
policies.addChild(policy2);
policiesQuery.add(policies);
}
private void createAdminPolicies() {
Node policy1 = new Node("group_admin_1", NodeType.policyNode, null, Module.adminModule, "id_group_admin_1");
Node users = new Node("Associated users", NodeType.usersNode, null, Module.adminModule, "id_group_admin_1");
users.addChild(new Node("user1", NodeType.userNode, null, Module.adminModule, "id_group_admin_1"));
users.addChild(new Node("user3", NodeType.userNode, null, Module.adminModule, "id_group_admin_1"));
Node rule1 = new Node("ACCEPT", NodeType.methodFilterGroupNode, null, Module.adminModule, "id_group_admin_1");
Node filter1 = new Node("eventCreate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_1");
Node filter2 = new Node("filterCreate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_1");
rule1.addChild(filter1);
rule1.addChild(filter2);
policy1.addChild(users);
policy1.addChild(rule1);
Node policy2 = new Node("group_admin_2", NodeType.policyNode, null, Module.adminModule, "id_group_admin_2");
Node users2 = new Node("Associated users", NodeType.usersNode, null, Module.adminModule, "id_group_admin_2");
users2.addChild(new Node("userx", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("userz", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("useru", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("userv", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("userw", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
Node rule2 = new Node("DROP", NodeType.methodFilterGroupNode, null, Module.adminModule, "id_group_admin_2");
Node filter21 = new Node("groupCreate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_2");
Node filter22 = new Node("groupUpdate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_2");
rule2.addChild(filter21);
rule2.addChild(filter22);
policy2.addChild(rule2);
policy2.addChild(users2);
Node policies = new Node("Groups", NodeType.policiesNode, null, Module.adminModule, null);
policies.addChild(policy1);
policies.addChild(policy2);
policiesAdmin.add(policies);
}
private void createCapturePolicies() {
Node policies = new Node("Groups", NodeType.policiesNode, null, Module.captureModule, null);
policiesCapture.add(policies);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/RuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import fr.unicaen.iota.xacml.policy.*;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class RuleTreeNode implements TreeNode {
private OneOrGlobalFunction function;
protected String id;
private List<TreeNode> children;
private Module module;
private String groupID;
public String getId() {
return id;
}
public OneOrGlobalFunction getFunction() {
return function;
}
public RuleTreeNode(OneOrGlobalFunction f, String groupID, Module m) {
this.function = f;
this.groupID = groupID;
this.module = m;
this.children = new ArrayList<TreeNode>();
}
@Override
public String getLabel() {
if (function.getFunctionName().equals(OneOrGlobalFunction.NAME_GLOBAL_PERMIT)) {
return "ACCEPT";
} else if (function.getFunctionName().equals(OneOrGlobalFunction.NAME_GLOBAL_DENY)) {
return "DENY";
}
return "";
}
@Override
public NodeType getNodeType() {
if (SCBizStepRule.RULEFILTER.equals(id)) {
return NodeType.bizStepFilterGroupNode;
} else if (SCEventTypeRule.RULEFILTER.equals(id)) {
return NodeType.eventTypeFilterGroupNode;
} else if (SCEPCsRule.RULEFILTER.equals(id)) {
return NodeType.epcFilterGroupNode;
} else if (SCEventTimeRule.RULEFILTER.equals(id)) {
return NodeType.eventTimeFilterGroupNode;
} else if (SCgroupRule.RULEFILTER.equals(id)) {
return NodeType.usersNode;
}
return null;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
this.children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/UserGroupRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCgroupRule;
/**
*
*/
public class UserGroupRuleTreeNode extends RuleTreeNode {
public UserGroupRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCgroupRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/factory/UserTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.factory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class UserTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public UserTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.userNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/AccessResponse.form
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
<Component id="responseLabel" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="responseLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="responseLabel">
<Properties>
<Property name="text" type="java.lang.String" value="Response"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Access Response"/>
</Properties>
</Component>
</SubComponents>
</Form>
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/AccessResponse.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
/**
*
*/
public class AccessResponse extends javax.swing.JDialog {
/**
* Creates new form AccessResponse
*/
public AccessResponse(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
responseLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
responseLabel.setText("Response");
responseLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Access Response");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(responseLabel)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(responseLabel)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
AccessResponse dialog = new AccessResponse(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel responseLabel;
// End of variables declaration//GEN-END:variables
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/AccessResponseDialog.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
/**
*
*/
public class AccessResponseDialog extends javax.swing.JDialog {
/**
* Creates new form AccessResponse
*/
public AccessResponseDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
public void setResponse(String response) {
responseLabel.setText(response);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
responseLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
responseLabel.setText("Response");
jLabel2.setText("Access Response");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addComponent(jLabel2)).addGroup(layout.createSequentialGroup().addGap(38, 38, 38).addComponent(responseLabel))).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(responseLabel).addContainerGap(29, Short.MAX_VALUE)));
pack();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
AccessResponseDialog dialog = new AccessResponseDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel responseLabel;
// End of variables declaration
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/AdminModuleClient.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.utils.InterfaceHelper;
import fr.unicaen.iota.dphi.xacml.pep.DSPEP;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class AdminModuleClient extends javax.swing.JFrame {
private static final Log log = LogFactory.getLog(AdminModuleClient.class);
private String ownerName;
/**
* Creates new form CaptureModule
*/
public AdminModuleClient(String ownerName) {
this.ownerName = ownerName;
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Admin Module");
jLabel2.setText("User: ");
jLabel3.setText("Owner: ");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
InterfaceHelper IH = new InterfaceHelper(ownerName);
IH.reload();
sendButtonActionPerformed(evt);
}
});
ArrayList actions = new ArrayList();
for (Method m : MethodNamesAdmin.class.getMethods()) {
actions.add(m.getName());
}
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(actions.toArray()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel3)).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel8))).addGap(20, 20, 20).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE).addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE).addComponent(actionComboBox, 0, 231, Short.MAX_VALUE).addComponent(jLabel1))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(273, Short.MAX_VALUE).addComponent(sendButton))).addContainerGap()));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(12, 12, 12).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel2)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(sendButton).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack();
}
private Object runMethod(Object obj, Object[] args, String methodName) throws Exception {
Class[] paramTypes = null;
if (args != null) {
paramTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
}
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
String action = (String) actionComboBox.getSelectedItem();
ArrayList args = new ArrayList();
args.add(userField.getText());
args.add(ownerField.getText());
try {
DSPEP dspep = new DSPEP();
int response = (Integer) runMethod(dspep, args.toArray(), action);
String res = (response == Result.DECISION_PERMIT)? "ACCEPT": "DENY";
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse(res);
dialog.setVisible(true);
} catch (InvocationTargetException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (NullPointerException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (Exception ex) {
log.fatal(null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String owner = "anonymous";
new AdminModuleClient(owner).setVisible(true);
}
});
}
private javax.swing.JComboBox actionComboBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/CaptureModule.form
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="userField" alignment="0" pref="239" max="32767" attributes="0"/>
<Component id="ownerField" alignment="0" pref="239" max="32767" attributes="0"/>
<Component id="actionComboBox" alignment="0" pref="239" max="32767" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="261" max="32767" attributes="0"/>
<Component id="sendButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="userField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="ownerField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="actionComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="sendButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Capture Module"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="User: "/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Owner:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="Action: "/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="sendButton">
<Properties>
<Property name="text" type="java.lang.String" value="Send"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sendButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="actionComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="userField">
</Component>
<Component class="javax.swing.JTextField" name="ownerField">
</Component>
</SubComponents>
</Form>
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/CaptureModule.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
/**
*
*/
public class CaptureModule extends javax.swing.JFrame {
/**
* Creates new form CaptureModule
*/
public CaptureModule() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Capture Module");
jLabel2.setText("User: ");
jLabel3.setText("Owner:");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendButtonActionPerformed(evt);
}
});
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel8))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
.addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
.addComponent(actionComboBox, 0, 239, Short.MAX_VALUE)
.addComponent(jLabel1)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 261, Short.MAX_VALUE)
.addComponent(sendButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(sendButton)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
}//GEN-LAST:event_sendButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new CaptureModule().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox actionComboBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
// End of variables declaration//GEN-END:variables
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/CaptureModuleClient.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.utils.InterfaceHelper;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.dphi.xacml.pep.DSPEP;
import fr.unicaen.iota.xacml.pep.MethodNamesCapture;
import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class CaptureModuleClient extends javax.swing.JFrame {
private static final Log log = LogFactory.getLog(CaptureModuleClient.class);
private String ownerName;
public CaptureModuleClient(String ownerName) {
this.ownerName = ownerName;
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
epcField = new javax.swing.JTextField();
eventTypeField = new javax.swing.JTextField();
bizStepField = new javax.swing.JTextField();
eventTimeDayBox = new javax.swing.JComboBox();
eventTimeMonthBox = new javax.swing.JComboBox();
eventTimeYearBox = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Capture Module");
jLabel2.setText("User: ");
jLabel3.setText("Owner: ");
jLabel4.setText("EPC: ");
jLabel5.setText("EventType: ");
jLabel6.setText("BizStep: ");
jLabel7.setText("EventTime: ");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
InterfaceHelper IH = new InterfaceHelper(ownerName);
IH.reload();
sendButtonActionPerformed(evt);
}
});
ArrayList actions = new ArrayList();
for (Method m : MethodNamesCapture.class.getMethods()) {
actions.add(m.getName());
}
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(actions.toArray()));
String[] days = new String[31];
for (int i = 1; i <= 31; i++) {
days[i - 1] = "" + i;
}
eventTimeDayBox.setModel(new javax.swing.DefaultComboBoxModel(days));
String[] months = new String[12];
for (int i = 1; i <= 12; i++) {
months[i - 1] = "" + i;
}
eventTimeMonthBox.setModel(new javax.swing.DefaultComboBoxModel(months));
ArrayList years = new ArrayList();
for (int i = 1970; i <= 2020; i++) {
years.add("" + i);
}
eventTimeYearBox.setModel(new javax.swing.DefaultComboBoxModel(years.toArray()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(jLabel3).addComponent(jLabel8).addComponent(jLabel4).addComponent(jLabel5).addComponent(jLabel6).addComponent(jLabel7)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeMonthBox, 0, 51, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)).addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(actionComboBox, 0, 212, Short.MAX_VALUE).addComponent(epcField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(eventTypeField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(bizStepField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(jLabel1))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(254, Short.MAX_VALUE).addComponent(sendButton))).addContainerGap()));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(12, 12, 12).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(epcField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel4)).addGap(7, 7, 7).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(eventTypeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel5)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(bizStepField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel6)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7).addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeMonthBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(sendButton).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack();
}
private Date convertStringToDate(String day, String month, String year) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
return cal.getTime();
}
private Object runMethod(Object obj, Object[] args, String methodName) throws Exception {
Class[] paramTypes = null;
if (args != null) {
paramTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
}
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
Date eventTime = convertStringToDate((String) eventTimeDayBox.getSelectedItem(), (String) eventTimeMonthBox.getSelectedItem(), (String) eventTimeYearBox.getSelectedItem());
String action = (String) actionComboBox.getSelectedItem();
ArrayList args = new ArrayList();
args.add(MapSessions.APM);
args.add(userField.getText());
args.add(ownerField.getText());
if (!"hello".equals(action)) {
XACMLDSEvent xacmldse = new XACMLDSEvent(ownerField.getText(), bizStepField.getText(), epcField.getText(), eventTypeField.getText(), eventTime);
args.add(xacmldse);
}
try {
DSPEP dspep = new DSPEP();
int response = (Integer) runMethod(dspep, args.toArray(), action);
String res = (response == Result.DECISION_PERMIT)? "ACCEPT": "DENY";
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse(res);
dialog.setVisible(true);
} catch (InvocationTargetException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (NullPointerException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (Exception ex) {
log.fatal(null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String owner = "ownerDeTest";
new CaptureModuleClient(owner).setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox actionComboBox;
private javax.swing.JTextField bizStepField;
private javax.swing.JTextField eventTypeField;
private javax.swing.JTextField epcField;
private javax.swing.JComboBox eventTimeDayBox;
private javax.swing.JComboBox eventTimeMonthBox;
private javax.swing.JComboBox eventTimeYearBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
// End of variables declaration
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/QueryModuleClient.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.utils.InterfaceHelper;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.dphi.xacml.pep.DSPEP;
import fr.unicaen.iota.xacml.pep.MethodNamesQuery;
import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class QueryModuleClient extends javax.swing.JFrame {
private static final Log log = LogFactory.getLog(QueryModuleClient.class);
private String ownerName;
public QueryModuleClient(String ownerName) {
this.ownerName = ownerName;
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
epcField = new javax.swing.JTextField();
eventTypeField = new javax.swing.JTextField();
bizStepField = new javax.swing.JTextField();
eventTimeDayBox = new javax.swing.JComboBox();
eventTimeMonthBox = new javax.swing.JComboBox();
eventTimeYearBox = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Query Module");
jLabel2.setText("Owner: ");
jLabel3.setText("Owner Partner: ");
jLabel4.setText("EPC: ");
jLabel5.setText("EventType: ");
jLabel6.setText("BizStep: ");
jLabel7.setText("EventTime: ");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
InterfaceHelper IH = new InterfaceHelper(ownerName);
IH.reload();
sendButtonActionPerformed(evt);
}
});
ArrayList actions = new ArrayList();
for (Method m : MethodNamesQuery.class.getMethods()) {
actions.add(m.getName());
}
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(actions.toArray()));
String[] days = new String[31];
for (int i = 1; i <= 31; i++) {
days[i - 1] = "" + i;
}
eventTimeDayBox.setModel(new javax.swing.DefaultComboBoxModel(days));
String[] months = new String[12];
for (int i = 1; i <= 12; i++) {
months[i - 1] = "" + i;
}
eventTimeMonthBox.setModel(new javax.swing.DefaultComboBoxModel(months));
ArrayList years = new ArrayList();
for (int i = 1970; i <= 2020; i++) {
years.add("" + i);
}
eventTimeYearBox.setModel(new javax.swing.DefaultComboBoxModel(years.toArray()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(jLabel3).addComponent(jLabel8).addComponent(jLabel4).addComponent(jLabel5).addComponent(jLabel6).addComponent(jLabel7)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeMonthBox, 0, 51, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)).addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(actionComboBox, 0, 212, Short.MAX_VALUE).addComponent(epcField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(eventTypeField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(bizStepField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(jLabel1))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(254, Short.MAX_VALUE).addComponent(sendButton))).addContainerGap()));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(12, 12, 12).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(epcField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel4)).addGap(7, 7, 7).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(eventTypeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel5)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(bizStepField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel6)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7).addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeMonthBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(sendButton).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack();
}
private Date convertStringToDate(String day, String month, String year) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
return cal.getTime();
}
private Object runMethod(Object obj, Object[] args, String methodName) throws Exception {
Class[] paramTypes = null;
if (args != null) {
paramTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
}
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
Date eventTime = convertStringToDate((String) eventTimeDayBox.getSelectedItem(), (String) eventTimeMonthBox.getSelectedItem(), (String) eventTimeYearBox.getSelectedItem());
String action = (String) actionComboBox.getSelectedItem();
ArrayList args = new ArrayList();
args.add(MapSessions.APM);
args.add(userField.getText());
args.add(ownerField.getText());
if (!"hello".equals(action)) {
XACMLDSEvent xacmldse = new XACMLDSEvent(ownerField.getText(), bizStepField.getText(), epcField.getText(), eventTypeField.getText(), eventTime);
args.add(xacmldse);
}
try {
DSPEP dspep = new DSPEP();
int response = (Integer) runMethod(dspep, args.toArray(), action);
String res = (response == Result.DECISION_PERMIT)? "ACCEPT": "DENY";
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse(res);
dialog.setVisible(true);
} catch (InvocationTargetException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (NullPointerException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (Exception ex) {
log.fatal(null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String owner = "anonymous";
new QueryModuleClient(owner).setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox actionComboBox;
private javax.swing.JTextField bizStepField;
private javax.swing.JTextField eventTypeField;
private javax.swing.JTextField epcField;
private javax.swing.JComboBox eventTimeDayBox;
private javax.swing.JComboBox eventTimeMonthBox;
private javax.swing.JComboBox eventTimeYearBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
// End of variables declaration
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/ihm/test/TestPEP.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
//import fr.unicaen.iota.utils.InterfaceHelper;
//import fr.unicaen.iota.xacml.pep.DSPEP;
//import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
//import fr.unicaen.iota.xacml.pep.XACMLResponse;
/**
*
*/
public class TestPEP {
public static void main(String[] args) {
// DSPEP dspep = InterfaceHelper.APM.getDspep();
// XACMLResponse res = dspep.hello(InterfaceHelper.APM, "owner2", "OwnerDeTest");
// System.out.println(res.toString());
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/pep/DSPEP.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.pep;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.ResponseCtx;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import fr.unicaen.iota.xacml.policy.Module;
import fr.unicaen.iota.xacml.request.EventRequest;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class DSPEP implements MethodNamesAdmin {
private static final Log log = LogFactory.getLog(DSPEP.class);
//####################################################
//################## Authentication ##################
//####################################################
@Override
public int hello(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "hello", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userLookup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userLookup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userCreate(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userCreate", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userInfo(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userInfo", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userUpdate(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userUpdate", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userDelete(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userDelete", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int ownerUpdate(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "ownerUpdate", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int ownerDelete(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "ownerDelete", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
//####################################################
//############## Admin Module Section ################
//####################################################
public int superadmin(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "superadmin", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
public int allAdminMethods(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "allAdminMethods", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
public int allQueryMethods(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "allQueryMethods", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
public int allCaptureMethods(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "allCaptureMethods", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int createAdminOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "createAdminOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int deleteAdminOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "deleteAdminOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addAdminOwnerToGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addAdminOwnerToGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeAdminOwnerFromGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeAdminOwnerFromGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchAdminUserPermissionPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchAdminUserPermissionPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeAdminUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeAdminUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addAdminUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addAdminUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int updateAdminGroupName(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "updateAdminGroupName", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int saveAdminPolicyOwner(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "saveAdminPolicyOwner", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
//####################################################
//################# Modules Section ##################
//####################################################
@Override
public int createOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "createOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int deleteOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "deleteOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addOwnerToGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addOwnerToGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeOwnerFromGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeOwnerFromGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addBizStepRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addBizStepRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeBizStepRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeBizStepRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addEPCRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addEPCRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeEPCRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeEPCRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addEventTypeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addEventTypeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeEventTypeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeEventTypeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addTimeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addTimeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeTimeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeTimeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchBizStepPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchBizStepPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchEPCPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchEPCPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchEventTypePolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchEventTypePolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchTimePolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchTimePolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchUserPermissionPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchUserPermissionPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int updateGroupName(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "updateGroupName", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int savePolicyOwner(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "savePolicyOwner", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
private int processResult(ResponseCtx result) {
Iterator it = result.getResults().iterator();
while (it.hasNext()) {
Result res = (Result) it.next();
if (res != null) {
return res.getDecision();
}
}
return Result.DECISION_DENY;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/AccessControlPolicy.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
import fr.unicaen.iota.dphi.xacml.ihm.NodeType;
import fr.unicaen.iota.dphi.xacml.ihm.TreeNode;
import fr.unicaen.iota.dphi.xacml.ihm.Mode;
import fr.unicaen.iota.dphi.xacml.ihm.TreeFactory;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.dphi.auth.User;
import fr.unicaen.iota.mu.Utils;
import fr.unicaen.iota.dphi.utils.InterfaceHelper;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.dphi.xacml.ihm.factory.AccessPolicies;
import fr.unicaen.iota.dphi.xacml.ihm.factory.Node;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class AccessControlPolicy extends HttpServlet {
private Services services = new Services();
private static final Log log = LogFactory.getLog(AccessControlPolicy.class);
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
StringBuilder html = new StringBuilder();
try {
// ************************** CREATE *********************************
try {
if (request.getSession().getAttribute("user") == null || request.getSession().getAttribute("cert") == null) {
throw new ServiceException("Session expired you have to reconnect !", ServiceErrorType.ds);
}
String dn = (request.getUserPrincipal() != null) ? request.getUserPrincipal().getName() : null;
if (request.getSession().getAttribute("cert") != null) {
String cert = (String) request.getSession().getAttribute("cert");
if (!cert.equals(Utils.formatId(dn))) {
throw new ServiceException("Don't change your certificate!", ServiceErrorType.unknown);
}
}
User user = (User) request.getSession().getAttribute("user");
Module module = (request.getParameter("d") != null) ? Module.valueOf(request.getParameter("d")) : null;
String objectId = request.getParameter("b");
String groupId = request.getParameter("e");
String userId = user.getUserID();
String a = request.getParameter("a");
// ************************** CREATE *********************************
if ("createOwnerGroup".equals(a)) {
String newValue = request.getParameter("c");
String resp = services.createOwnerGroup(userId, user, module, newValue);
TreeNode node = createEmptyPolicies(user, newValue, module, resp);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
}
else if ("addOwnerToGroup".equals(a)) {
String newValue = request.getParameter("c");
services.addOwnerToGroup(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.userNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
}
else if ("addBizStepRestriction".equals(a)) {
String newValue = request.getParameter("c");
services.addBizStepRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.bizStepFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
}
else if ("addEPCRestriction".equals(a)) {
String newValue = request.getParameter("c");
services.addEPCRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.epcFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
}
else if ("addEventTypeRestriction".equals(a)) {
String newValue = request.getParameter("c");
services.addEventTypeRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.eventTypeFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
}
else if ("addTimeRestriction".equals(a)) {
String d1 = request.getParameter("d1");
String d2 = request.getParameter("d2");
services.addTimeRestriction(userId, user, module, objectId, groupId, d1, d2);
TreeNode node = new Node(d1 + " -> " + d2, NodeType.eventTimeFilterNode, d1 + " -> " + d2, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
}
else if ("addUserPermission".equals(a)) {
String newValue = request.getParameter("c");
services.addUserPermission(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.methodFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} // ************************** SWITCH *********************************
else if ("switchBizStepPolicy".equals(a)) {
html.append(services.switchBizStepPolicy(userId, user, module, objectId, groupId));
}
else if ("switchEPCPolicy".equals(a)) {
html.append(services.switchEPCPolicy(userId, user, module, objectId, groupId));
}
else if ("switchEventTypePolicy".equals(a)) {
html.append(services.switchEventTypePolicy(userId, user, module, objectId, groupId));
}
else if ("switchTimePolicy".equals(a)) {
html.append(services.switchTimePolicy(userId, user, module, objectId, groupId));
}
else if ("switchPermissionPolicy".equals(a)) {
html.append(services.switchUserPermissionPolicy(userId, user, module, objectId, groupId));
} // ************************** REMOVE *********************************
else if ("removeBizStepRestriction".equals(a)) {
services.removeBizStepRestriction(userId, user, module, objectId, groupId);
}
else if ("removeEPCRestriction".equals(a)) {
services.removeEPCRestriction(userId, user, module, objectId, groupId);
}
else if ("removeEventTypeRestriction".equals(a)) {
services.removeEventTypeRestriction(userId, user, module, objectId, groupId);
}
else if ("removeTimeRestriction".equals(a)) {
services.removeTimeRestriction(userId, user, module, objectId, groupId);
}
else if ("removeUserPermission".equals(a)) {
services.removeUserPermission(userId, user, module, objectId, groupId);
}
else if ("deleteOwnerGroup".equals(a)) {
services.deleteOwnerGroup(userId, user, module, objectId, groupId);
}
else if ("removeOwnerFromGroup".equals(a)) {
services.removeOwnerFromGroup(userId, user, module, objectId, groupId);
} // ************************* DS ADMIN ********************************
else if ("createUser".equals(a)) {
String userDN = request.getParameter("f");
String userName = request.getParameter("g");
services.createUser(user, userDN, userName);
}
else if ("updateUser".equals(a)) {
String login = request.getParameter("f");
String pass = request.getParameter("g");
//services.updateUser(sessionId, user, login, pass);
}
else if ("deleteUser".equals(a)) {
String login = request.getParameter("f");
services.deleteUser(user, login);
}
else if ("createAccount".equals(a)) {
String userDN = request.getParameter("f");
String owner = request.getParameter("g");
String userName = request.getParameter("h");
boolean rtr = services.createAccount(user, owner, userDN, userName);
if (rtr) {
html.append("Account successfull created.");
}
} // ************************** UPDATE *********************************
else if ("updateGroupName".equals(a)) {
String newValue = request.getParameter("c");
services.updateGroupName(userId, user, module, objectId, groupId, newValue);
} // ************************** SAVE **********************************
else if ("savePolicyOwner".equals(a)) {
services.savePolicyOwner(userId, user, module);
} // ************************** CANCEL **********************************
else if ("cancelOwnerPolicy".equals(a)) {
services.cancelOwnerPolicy(user, module);
} // ************************** LOAD POLICIES *************************
else if ("loadPolicyTree".equals(a)) {
services.loadPolicyTree(user, module);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, user.getOwnerID());
interfaceHelper.reload();
AccessPolicies policies = new AccessPolicies(userId, user.getOwnerID(), module);
switch (module) {
case adminModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesAdmin().get(0)));
break;
case queryModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesQuery().get(0)));
break;
case captureModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesCapture().get(0)));
break;
}
}
else {
throw new ServiceException("service method " + a + " not found!", ServiceErrorType.unknown);
}
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.Value.OK, "") + createXMLHTMLTag(html.toString())));
} catch (ServiceException se) {
log.info("", se);
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.Value.ERROR, se.getMessage())
+ createXMLHTMLTag(html.toString())));
} catch (Exception e) {
log.info("", e);
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.Value.ERROR, "INTERNAL ERROR: "
+ e.getMessage()) + createXMLHTMLTag(html.toString())));
}
} finally {
out.close();
}
}
public String createXMLEnvelop(String content) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n" + content + "</response>";
}
public String createXMLRespondeHeader(Response.Value code, String message) {
return "<result>\n<id>" + code.toString() + "</id>\n<desc>" + message + "</desc>\n</result>\n";
}
private String createXMLHTMLTag(String html) {
return "<htmlcontent>\n<![CDATA[" + html + "]]>\n</htmlcontent>";
}
public TreeNode createEmptyPolicies(User user, String name, Module module, String groupId) {
GroupPolicy gpq = new GroupPolicy(name, user.getOwnerID());
AccessPolicies accessPolicies = new AccessPolicies();
return accessPolicies.createGroupPolicy(gpq, module);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/Response.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
/**
*
*/
public class Response {
static public enum Value {
OK("1"),
ERROR("2");
private String str;
private Value(String str) {
this.str = str;
}
@Override
public String toString() {
return str;
}
}
private Value value;
private String desc;
public Response(Value value, String desc) {
this.value = value;
this.desc = desc;
}
/**
* @return the value
*/
public Value getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Value value) {
this.value = value;
}
/**
* @return the desc
*/
public String getDesc() {
return desc;
}
/**
* @param desc the desc to set
*/
public void setDesc(String desc) {
this.desc = desc;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/RootAccountAuth.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
import fr.unicaen.iota.dphi.auth.User;
import fr.unicaen.iota.mu.Utils;
import fr.unicaen.iota.dphi.utils.Constants;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserLookupOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class RootAccountAuth extends HttpServlet {
private static final Log LOG = LogFactory.getLog(RootAccountAuth.class);
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if ("login".equals(request.getParameter("action"))) {
String login = (request.getUserPrincipal() != null)? request.getUserPrincipal().getName() : null;
if (login == null || login.isEmpty()) {
request.setAttribute("message", "You are not authenticated.");
} else {
login = Utils.formatId(login);
try {
YPSilonClient ypsilonClient = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
UserLookupOut userLookupOut = ypsilonClient.userLookup(login);
if (userLookupOut.getUserList().isEmpty()) {
throw new ImplementationExceptionResponse("User not found");
}
User user = new User();
user.setUserID(login);
user.setOwnerID(userLookupOut.getUserList().get(0).getOwner());
request.getSession().setAttribute("user", user);
request.getSession().setAttribute("cert", login);
} catch (ImplementationExceptionResponse ex) {
request.setAttribute("message", ex.getMessage());
LOG.error("impl", ex);
}
}
request.getRequestDispatcher("index.jsp").forward(request, response);
} else if ("logout".equals(request.getParameter("action"))) {
String cert = (String) (request.getSession().getAttribute("cert"));
MapSessions.releaseSession(cert);
request.getSession().setAttribute("user", null);
request.getSession().setAttribute("cert", null);
response.sendRedirect("index.jsp");
}
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/ServiceErrorType.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
/**
*
*/
public enum ServiceErrorType {
unknown,
xacml,
ds;
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/ServiceException.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
/**
*
*/
public class ServiceException extends Exception {
private ServiceErrorType type;
public ServiceException(String message, ServiceErrorType type) {
super(message);
this.type = type;
}
/**
* @return the type
*/
public ServiceErrorType getType() {
return type;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/Services.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.auth.User;
import fr.unicaen.iota.dphi.utils.Constants;
import fr.unicaen.iota.dphi.utils.InterfaceHelper;
import fr.unicaen.iota.dphi.utils.MapSessions;
import fr.unicaen.iota.dphi.utils.PEPRequester;
import fr.unicaen.iota.dphi.xacml.ihm.Module;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserInfoOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class Services {
private static final Log log = LogFactory.getLog(Services.class.getName());
private void checkAccess(User user, Module module, String method) throws ServiceException {
if (PEPRequester.checkAccess(user, method) == Result.DECISION_DENY) {
throw new ServiceException(method + ": not allowed for user" + user.getUserID() + " in module " + module, ServiceErrorType.xacml);
}
}
public String createOwnerGroup(String userId, User user, Module module, String value)
throws ServiceException {
String method = module == Module.adminModule ? "createAdminOwnerGroup" : "createOwnerGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
GroupPolicy gpol = new GroupPolicy(value, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryGroupPolicy(owner, gpol);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureGroupPolicy(owner, gpol);
break;
case adminModule:
resp = interfaceHelper.APMSession.addAdminGroupPolicy(owner, gpol);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
return value;
}
public void deleteOwnerGroup(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "deleteAdminOwnerGroup" : "deleteOwnerGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.deleteQueryGroupPolicy(owner, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.deleteCaptureGroupPolicy(owner, objectId);
break;
case adminModule:
resp = interfaceHelper.APMSession.deleteAdminGroupPolicy(owner, objectId);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void addOwnerToGroup(String userId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "addAdminOwnerToGroup" : "addOwnerToGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryUserFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureUserFilter(owner, groupId, value);
break;
case adminModule:
resp = interfaceHelper.APMSession.addAdminUserFilter(owner, groupId, value);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void removeOwnerFromGroup(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "removeAdminOwnerFromGroup" : "removeOwnerFromGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryUserFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureUserFilter(owner, groupId, objectId);
break;
case adminModule:
resp = interfaceHelper.APMSession.removeAdminUserFilter(owner, groupId, objectId);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addBizStepRestriction(String userId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addBizStepRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryBizStepFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureBizStepFilter(owner, groupId, value);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addBizStepRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeBizStepRestriction(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeBizStepRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryBizStepFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureBizStepFilter(owner, groupId, objectId);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeBizStepRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addEPCRestriction(String userId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEpcFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEpcFilter(owner, groupId, value);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addEPCRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeEPCRestriction(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEPCRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEpcFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEpcFilter(owner, groupId, objectId);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeEPCRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addEventTypeRestriction(String userId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addEventTypeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEventTypeFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEventTypeFilter(owner, groupId, value);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addEventTypeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeEventTypeRestriction(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEventTypeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEventTypeFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEventTypeFilter(owner, groupId, objectId);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeEventTypeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addTimeRestriction(String userId, User user, Module module,
String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
checkAccess(user, module, "addTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
try {
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEventTimeFilter(owner,
groupId, convertStringToDate(valueMin, valueMax));
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEventTimeFilter(owner,
groupId, convertStringToDate(valueMin, valueMax));
break;
case adminModule:
break;
}
} catch (ParseException ex) {
throw new ServiceException("addTimeRestriction: parsing error: " + ex.getMessage(), ServiceErrorType.xacml);
}
if (!resp) {
throw new ServiceException("addTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeTimeRestriction(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
try {
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEventTimeFilter(owner, groupId, convertStringToDate((String) objectId));
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEventTimeFilter(owner, groupId, convertStringToDate((String) objectId));
break;
case adminModule:
break;
}
} catch (ParseException ex) {
throw new ServiceException("addTimeRestriction: parsing error: " + ex.getMessage(), ServiceErrorType.xacml);
}
if (!resp) {
throw new ServiceException("removeTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public String switchBizStepPolicy(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchBizStepPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionBizSteps(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getBizStepsFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionBizSteps(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getBizStepsFilterFunction().getValue();
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("switchBizStepPolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchEPCPolicy(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEPCPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionEpcs(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getEpcsFilterFunction().getValue();
break;
case captureModule:
break;
case adminModule:
resp = interfaceHelper.APMSession.switchCapturePermissionEpcs(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getEpcsFilterFunction().getValue();
break;
}
if (!resp) {
throw new ServiceException("switchEPCPolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchEventTypePolicy(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEventTypePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionEventTypes(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getEventTypesFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionEventTypes(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getEventTypesFilterFunction().getValue();
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("switchEventTypePolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchTimePolicy(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchTimePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionEventTimes(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getEventTimesFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionEventTimes(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getEventTimesFilterFunction().getValue();
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("switchTimePolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchUserPermissionPolicy(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "switchAdminUserPermissionPolicy" : "switchUserPermissionPolicy";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionUsers(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getUsersFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionUsers(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getUsersFilterFunction().getValue();
break;
case adminModule:
resp = interfaceHelper.APMSession.switchAdminPermissionUsers(owner, groupId);
value = (interfaceHelper.APMSession.getAdminPolicy(owner)).getGroupPolicy(groupId).getUsersFilterFunction().getValue();
break;
}
if (!resp) {
throw new ServiceException("switchUserPermissionPolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public void removeUserPermission(String userId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "removeAdminUserPermission" : "removeUserPermission";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryActionFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureActionFilter(owner, groupId, objectId);
break;
case adminModule:
resp = interfaceHelper.APMSession.removeAdminActionFilter(owner, groupId, objectId);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void addUserPermission(String userId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "addAdminUserPermission" : "addUserPermission";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryActionFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureActionFilter(owner, groupId, value);
break;
case adminModule:
resp = interfaceHelper.APMSession.addAdminActionFilter(owner, groupId, value);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void updateGroupName(String userId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "updateAdminGroupName" : "updateGroupName";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.updateQueryGroupName(owner, objectId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.updateCaptureGroupName(owner, objectId, value);
break;
case adminModule:
resp = interfaceHelper.APMSession.updateAdminGroupName(owner, objectId, value);
break;
default:
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void savePolicyOwner(String userId, User user, Module module) throws ServiceException {
String method = module == Module.adminModule ? "saveAdminPolicyOwner" : "savePolicyOwner";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.saveQueryPolicies(owner);
interfaceHelper.updateQueryAPM();
break;
case captureModule:
resp = interfaceHelper.APMSession.saveCapturePolicies(owner);
interfaceHelper.updateCaptureAPM();
break;
case adminModule:
resp = interfaceHelper.APMSession.saveAdminPolicies(owner);
interfaceHelper.updateAdminAPM();
break;
default:
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void createUser(User user, String userDN, String userName) throws ServiceException {
checkAccess(user, Module.adminModule, "userCreate");
try {
String owner = user.getOwnerID();
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
if (userName != null && !userName.isEmpty()) {
client.userCreate(userDN, owner, userName);
}
else {
client.userCreate(userDN, owner);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
}
public void deleteUser(User user, String userId) throws ServiceException {
checkAccess(user, Module.adminModule, "userDelete");
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
UserInfoOut userInfo = client.userInfo(userId);
if (userInfo.getUser() != null && userInfo.getUser().getOwner() != null
&& !userInfo.getUser().getOwner().isEmpty() && userInfo.getUser().getOwner().equals(user.getUserID())) {
client.userDelete(userId);
}
else {
throw new ServiceException("You can't delete this user.", ServiceErrorType.xacml);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
}
/*public void updateUser(String userId, User user, String login, String pass) throws ServiceException {
checkAccess(user, Module.adminModule, "userUpdate");
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
String owner = user.getOwnerID();
try {
client.userUpdate(userId, user.getId(), owner, login, pass, 30);
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
}*/
public void createRootOwnerPolicy(String userId, String ownerId) {
String gpName = "admin";
InterfaceHelper ih = new InterfaceHelper(ownerId);
OwnerPolicies ownerPolicies = new OwnerPolicies(ownerId, fr.unicaen.iota.xacml.policy.Module.administrationModule);
ih.APMSession.addAdminPolicy(ownerPolicies);
GroupPolicy gp = new GroupPolicy(gpName, ownerId);
ih.APMSession.addAdminGroupPolicy(ownerId, gp);
ih.APMSession.addAdminUserFilter(ownerId, gpName, userId);
for (Method m : MethodNamesAdmin.class.getMethods()) {
String n = m.getName();
ih.APMSession.addAdminActionFilter(ownerId, gpName, n);
}
ih.APMSession.saveAdminPolicies(ownerId);
ih.updateAPM();
log.debug(MapSessions.AdminAPMtoString());
}
public boolean createAccount(User user, String ownerId, String userDN, String userName) throws ServiceException {
checkAccess(user, Module.adminModule, "superadmin");
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
if (userName != null && !userName.isEmpty()) {
if (client.userInfo(userDN).getUser() == null) {
client.userCreate(userDN, ownerId, userName);
}
createRootOwnerPolicy(userName, ownerId);
}
else {
if (client.userInfo(userDN).getUser() == null) {
client.userCreate(userDN, ownerId);
}
createRootOwnerPolicy(userDN, ownerId);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
return true;
}
public void loadPolicyTree(User user, Module module) {
}
public void cancelOwnerPolicy(User user, Module module) {
}
private List<Date> convertStringToDate(String dateInString) throws ParseException {
List<Date> dates = new ArrayList<Date>();
String[] datesStringTab = dateInString.split(" -> ");
for (int i = 0; i < datesStringTab.length; i++) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
dates.add(formatter.parse(datesStringTab[i]));
}
return dates;
}
private List<Date> convertStringToDate(String dateMinInString, String dateMaxInString) throws ParseException {
List<Date> dates = new ArrayList<Date>();
String[] datesStringTab = {dateMinInString, dateMaxInString};
for (int i = 0; i < datesStringTab.length; i++) {
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
dates.add(formatter.parse(datesStringTab[i]));
}
return dates;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/dphi/xacml/servlet/XiServlet.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.servlet;
import com.sun.xacml.ParsingException;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.ResponseCtx;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.dphi.utils.MapSessions;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class XiServlet extends HttpServlet {
private static final Log log = LogFactory.getLog(XiServlet.class);
@Override
public void init() {
MapSessions.init();
}
/**
* Processes incoming XACML request and sends XACML response.
*
* @param req The HttpServletRequest.
* @param rsp The HttpServletResponse.
* @throws IOException If an error occurred while validating the request or
* writing the response.
*/
@Override
public void doPost(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException {
PrintWriter out = rsp.getWriter();
try {
rsp.setContentType("text/plain");
log.debug("Receiving XACML request...");
InputStream is = req.getInputStream();
String request = readXACMLRequest(is);
log.debug("create XACML request ...");
RequestCtx reqCtx = RequestCtx.getInstance(new ByteArrayInputStream(request.getBytes()));
log.debug("process policy");
String resp = String.valueOf(processRequest(reqCtx));
log.debug("process response");
out.println(resp);
rsp.setStatus(HttpServletResponse.SC_OK);
} catch (ParsingException ex) {
log.error("Error during parsing request.", ex);
rsp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
out.println(String.valueOf(Result.DECISION_DENY));
}
out.flush();
out.close();
}
private String readXACMLRequest(InputStream is) throws IOException {
char[] end = {'<', '/', 'R', 'e', 'q', 'u', 'e', 's', 't', '>'};
int endIndex = 0;
StringBuilder response = new StringBuilder();
int value = 0;
boolean active = true;
while (active) {
value = is.read();
if (value == -1) {
throw new IOException("End of Stream");
}
response.append((char) value);
if (value == end[endIndex]) {
endIndex++;
} else {
endIndex = 0;
}
if (endIndex == end.length) {
active = false;
}
}
return response.toString();
}
public int processRequest(RequestCtx request) {
try {
ResponseCtx result = MapSessions.APM.evaluate(request);
Iterator it = result.getResults().iterator();
while (it.hasNext()) {
Result res = (Result) it.next();
if (res != null) {
return res.getDecision();
}
}
} catch (Exception ex) {
log.error("error", ex);
return Result.DECISION_DENY;
}
return Result.DECISION_DENY;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/utils/Constants.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2011-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.utils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public final class Constants {
private Constants() {
}
private static Log log = LogFactory.getLog(Constants.class);
public static final String YPSILON_ADDRESS;
public static final String PKS_FILENAME;
public static final String PKS_PASSWORD;
public static final String TRUST_PKS_FILENAME;
public static final String TRUST_PKS_PASSWORD;
static {
Properties properties = new Properties();
InputStream is = Constants.class.getClassLoader().getResourceAsStream("application.properties");
log.info("Chargement des propriétés de l'application");
try {
properties.load(is);
} catch (IOException ex) {
log.fatal(null, ex);
}
YPSILON_ADDRESS = properties.getProperty("ypsilon-url");
PKS_FILENAME = properties.getProperty("pks-filename", "privatekeys.jks");
PKS_PASSWORD = properties.getProperty("pks-password", "changeit");
TRUST_PKS_FILENAME = properties.getProperty("trust-pks-filename", "publickeys.jks");
TRUST_PKS_PASSWORD = properties.getProperty("trust-pks-password", "changeit");
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/utils/HTMLUtilities.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.utils;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import fr.unicaen.iota.xacml.pep.MethodNamesCapture;
import fr.unicaen.iota.xacml.pep.MethodNamesQuery;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public final class HTMLUtilities {
private static final String[] SERVICES = {"ds", "ided_ds", "epcis", "ided_epcis", "html", "ws", "xmlrpc"};
private static final String[] TYPES = {"object", "aggregation", "quantity", "transaction"};
private HTMLUtilities() {
}
public static String createOwnerSelect() {
StringBuilder res = new StringBuilder();
res.append("<select class=\"ownerSelector\" id=\"groupOwnerName\">");
for (String ownerId : listAllOwners()) {
res.append("<option label=\"owner: ");
res.append(ownerId);
res.append("\" value=\"");
res.append(ownerId);
res.append("\">");
res.append(ownerId);
res.append("</option>");
}
res.append("</select>");
return res.toString();
}
public static String createMethodSelect(Module m) {
StringBuilder res = new StringBuilder();
switch (m) {
case adminModule:
res.append("<select class=\"methodSelector\" id=\"methodNameAdmin\">");
for (Method method1 : MethodNamesAdmin.class.getMethods()) {
res.append("<option label=\"method: ");
res.append(method1.getName());
res.append("\" value=\"");
res.append(method1.getName());
res.append("\">");
res.append(method1.getName());
res.append("</option>");
}
break;
case captureModule:
res.append("<select class=\"methodSelector\" id=\"methodNameCapture\">");
for (Method method2 : MethodNamesCapture.class.getMethods()) {
res.append("<option label=\"method: ");
res.append(method2.getName());
res.append("\" value=\"");
res.append(method2.getName());
res.append("\">");
res.append(method2.getName());
res.append("</option>");
}
break;
case queryModule:
res.append("<select class=\"methodSelector\" id=\"methodNameQuery\">");
for (Method method3 : MethodNamesQuery.class.getMethods()) {
res.append("<option label=\"method: ");
res.append(method3.getName());
res.append("\" value=\"");
res.append(method3.getName());
res.append("\">");
res.append(method3.getName());
res.append("</option>");
}
break;
}
res.append("</select>");
return res.toString();
}
public static String createSelectServiceType(String serviceType, String idSuffix) {
StringBuilder res = new StringBuilder();
res.append("<select id=\"serviceType");
res.append(idSuffix);
res.append("\" >");
for (String s : SERVICES) {
res.append("<option ");
res.append(serviceType.equals(s) ? "selected" : "");
res.append(" value=\"");
res.append(s);
res.append("\">");
res.append(s);
res.append("</option>");
}
res.append("</select>");
return res.toString();
}
public static String createSelectEventTypeFilter() {
StringBuilder res = new StringBuilder();
res.append("<select id=\"eventTypeFilterName\" >");
for (String s : TYPES) {
res.append("<option value=\"");
res.append(s);
res.append("\">");
res.append(s);
res.append("</option>");
}
res.append("</select>");
return res.toString();
}
private static Iterable<String> listAllOwners() {
// TODO: TODOTODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
List<String> ownerIdList = new ArrayList<String>();
ownerIdList.add("owner1");
ownerIdList.add("owner2");
ownerIdList.add("owner3");
ownerIdList.add("owner4");
ownerIdList.add("owner5");
return ownerIdList;
}
private static Iterable<String> listAllMethods() {
// TODO: TODOTODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
List<String> methodList = new ArrayList<String>();
methodList.add("m1");
methodList.add("m2");
methodList.add("m3");
methodList.add("m4");
methodList.add("m5");
return methodList;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/utils/InterfaceHelper.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.utils;
import fr.unicaen.iota.xacml.AccessPolicyManagerSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class InterfaceHelper {
private static final Log log = LogFactory.getLog(InterfaceHelper.class);
// TODO @SLS public field!
public AccessPolicyManagerSession APMSession;
public InterfaceHelper(String owner) {
log.info("InterfaceHelper instanciated");
APMSession = MapSessions.APM.getInstance(owner);
}
public void updateAPM() {
MapSessions.APM.updateAPMSession(APMSession);
}
public void updateQueryAPM() {
MapSessions.APM.updateAPMQuerySession(APMSession);
}
public void updateCaptureAPM() {
MapSessions.APM.updateAPMCaptureSession(APMSession);
}
public void updateAdminAPM() {
MapSessions.APM.updateAPMAdminSession(APMSession);
}
public void reload() {
log.info("RELAOD DSPDP");
APMSession.initDSPDP(APMSession.getOwner());
APMSession.initFinderModule();
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/utils/MapSessions.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.utils;
import fr.unicaen.iota.xacml.AccessPolicyManager;
import fr.unicaen.iota.xacml.finder.MyPolicyCollection;
import fr.unicaen.iota.xacml.finder.MyPolicyFinderModule;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public final class MapSessions {
private MapSessions() {
}
private final static Log log = LogFactory.getLog(MapSessions.class);
// TODO: SLS public hence not procected by synchronized
public final static AccessPolicyManager APM = new AccessPolicyManager();
private final static Map<String, InterfaceHelper> APMSessions = new HashMap<String, InterfaceHelper>();
public static synchronized String AdminAPMtoString() {
StringBuilder res = new StringBuilder();
for (Object o : APM.getDspdp().getPolicyFinder().getModules()) {
if (o instanceof MyPolicyFinderModule) {
MyPolicyFinderModule mod = (MyPolicyFinderModule) o;
MyPolicyCollection col = mod.getPolicies();
Map<String, OwnerPolicies> map = col.getAdminPolicies();
for (String key : map.keySet()) {
res.append(key);
res.append(" \n");
OwnerPolicies ownerPolicies = map.get(key);
//TODO: SLS and?
}
}
}
return res.toString();
}
public static synchronized InterfaceHelper getAPMSession(String sessionId, String ownerId) {
if (APMSessions.containsKey(sessionId)) {
return APMSessions.get(sessionId);
} else {
InterfaceHelper IH = new InterfaceHelper(ownerId);
APMSessions.put(sessionId, IH);
return IH;
}
}
public static synchronized void releaseSession(String sessionId) {
APMSessions.remove(sessionId);
}
public static synchronized void init() {
APM.init();
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/utils/PEPRequester.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.utils;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.auth.User;
import fr.unicaen.iota.xacml.pep.DSPEP;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public final class PEPRequester {
private static final Log log = LogFactory.getLog(PEPRequester.class);
private PEPRequester() {
}
private static Object runMethod(Object obj, Object[] args, String methodName) {
try {
Class<?>[] paramTypes = null;
if (args != null) {
paramTypes = new Class<?>[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
} catch (IllegalAccessException ex) {
log.fatal(null, ex);
} catch (IllegalArgumentException ex) {
log.fatal(null, ex);
} catch (InvocationTargetException ex) {
log.fatal(null, ex);
} catch (NoSuchMethodException ex) {
log.fatal(null, ex);
} catch (SecurityException ex) {
log.fatal(null, ex);
}
return Result.DECISION_DENY;
}
public static int checkAccess(User user, String methodName) {
String userS = user.getUserID();
String owner = user.getOwnerID();
ArrayList<String> args = new ArrayList<String>();
args.add(userS);
args.add(owner);
DSPEP dspep = new DSPEP();
return (Integer) runMethod(dspep, args.toArray(), methodName);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/utils/SessionLoader.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.utils;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserInfoOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import fr.unicaen.iota.ypsilon.client.soap.SecurityExceptionResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public final class SessionLoader {
private SessionLoader() {
}
private static final Log LOG = LogFactory.getLog(SessionLoader.class);
public static synchronized String loadSession(String sessionId, YPSilonClient ypsilonClient, String userId, HttpSession session) {
try {
UserInfoOut uInfo = ypsilonClient.userInfo(sessionId, userId);
session.setAttribute("uInfo", uInfo);
session.setAttribute("session-id", sessionId);
return "";
} catch (ImplementationExceptionResponse ex) {
LOG.error("An error occurred", ex);
return "?message=" + ex.getMessage();
} catch (SecurityExceptionResponse ex) {
LOG.error("A security error occurred", ex);
return "?message=" + ex.getMessage();
}
}
public static void clearSession(HttpSession session) {
session.setAttribute("session-id", null);
session.setAttribute("uInfo", null);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/Mode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm;
/**
*
*/
public enum Mode {
Assert_Mode,
Create_Mode;
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/Module.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm;
/**
*
*/
public enum Module {
queryModule,
captureModule,
adminModule
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/NodeType.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm;
/**
*
*/
public enum NodeType {
policiesNode,
policyNode,
bizStepFilterNode,
epcFilterNode,
eventTypeFilterNode,
eventTimeFilterNode,
methodFilterNode,
bizStepFilterGroupNode,
epcFilterGroupNode,
eventTypeFilterGroupNode,
eventTimeFilterGroupNode,
methodFilterGroupNode,
rulesNode,
userNode,
usersNode;
public boolean isFilter() {
return this == bizStepFilterNode
|| this == epcFilterNode
|| this == eventTypeFilterNode
|| this == eventTimeFilterNode
|| this == methodFilterNode;
}
public boolean isFilterGroup() {
return this == bizStepFilterGroupNode
|| this == epcFilterGroupNode
|| this == eventTypeFilterGroupNode
|| this == eventTimeFilterGroupNode
|| this == methodFilterGroupNode;
}
public boolean isExpandable() {
return this == bizStepFilterGroupNode
|| this == epcFilterGroupNode
|| this == eventTypeFilterGroupNode
|| this == eventTimeFilterGroupNode
|| this == policyNode
|| this == policiesNode
|| this == rulesNode
|| this == usersNode
|| this == methodFilterGroupNode;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/TreeFactory.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm;
/**
*
*/
public class TreeFactory {
private Mode mode;
public TreeFactory(Mode mode) {
this.mode = mode;
}
public String createTree(TreeNode treeNode) {
StringBuilder result = new StringBuilder();
String button = treeNode.getNodeType() == NodeType.policyNode && this.mode == Mode.Create_Mode
? "<a href=\"#\" onclick=\"expand(this);\" class=\"icon_tree expanderButton2\"></a>"
: "<a href=\"#\" onclick=\"expand(this);\" class=\"icon_tree expanderButton\"></a>";
String img = treeNode.getNodeType() == NodeType.userNode ? "user"
: (treeNode.getNodeType().isFilter() ? "filter" : "");
String desc = createTitleDescription(treeNode);
String icon = "<div class=\"icon_tree icon_tree_" + img + "\">&nbsp;</div>";
if (treeNode.getNodeType() == NodeType.policiesNode) {
result.append("<div class=\"rootzone\" id=\"root");
result.append(treeNode.getModule());
result.append("\">\n");
}
result.append("<div class=\"TreeNodeBlock\"><div class=\"TreeNodeTitle ");
result.append(treeNode.getNodeType());
result.append("\">");
result.append(treeNode.getNodeType().isExpandable() ? button : icon);
result.append("<a href=\"#\" class=\"TreeNodeTitleInnerHtml\" onclick=\"selectBoxNode(this);\"><span class=\"TreeNodeTitleInnerHtmlDesc\">");
result.append(desc);
result.append("</span><span class=\"TreeNodeTitleInnerHtmlValue\">");
result.append(treeNode.getLabel());
result.append("</span></a>");
result.append(createCommand(treeNode));
result.append("</div>\n");
if (!treeNode.getChildren().isEmpty()) {
result.append("<div class=\"TreeNodeContent\" ");
result.append((treeNode.getNodeType() == NodeType.policyNode && this.mode == Mode.Create_Mode) ? "style=\"display:none\" " : "");
result.append(">\n");
for (TreeNode node : treeNode.getChildren()) {
result.append(createTree(node));
}
result.append("</div>\n");
} else if (treeNode.getNodeType().isFilterGroup()
|| treeNode.getNodeType() == NodeType.usersNode
|| treeNode.getNodeType() == NodeType.policiesNode) {
result.append("<div class=\"TreeNodeContent\">\n</div>\n");
}
result.append("</div>\n");
if (treeNode.getNodeType() == NodeType.policiesNode) {
result.append("</div>\n");
}
return result.toString();
}
private String createCommand(TreeNode treeNode) {
String command_start = "<div class=\"nodeCommand\">";
String command_end = "</div>";
String switchPolicy = "<a class=\"switch\" href=\"#\" onclick=\"processSwitchPolicy('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + treeNode.getObjectID() + "',this,'" + treeNode.getModule() + "');\"></a>";
String create = "<a class=\"add\" href=\"#\" onclick=\"processRequestCreate('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + treeNode.getObjectID() + "',this,'" + treeNode.getModule() + "');\"></a>";
String remove = "<a class=\"remove\" href=\"#\" onclick=\"processRequestRemove('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + escapeRegExp(treeNode.getObjectID()) + "',this,'" + treeNode.getModule() + "');\"></a>";
String update = "<a class=\"update\" href=\"#\" onclick=\"processRequestUpdate('" + treeNode.getNodeType() + "','"
+ treeNode.getGroupID() + "','" + treeNode.getObjectID() + "',this,'" + treeNode.getModule() + "');\"></a>";
if (treeNode.getNodeType().isFilter()) {
return command_start + remove + command_end;
}
if (treeNode.getNodeType().isFilterGroup()) {
if (treeNode.getNodeType() == NodeType.methodFilterGroupNode) {
return command_start + create + command_end;
} else {
return command_start + switchPolicy + create + command_end;
}
}
switch (treeNode.getNodeType()) {
case rulesNode:
return command_start + command_end;
case usersNode:
return command_start + switchPolicy + create + command_end;
case userNode:
return command_start + remove + command_end;
case policyNode:
return command_start + update + remove + command_end;
case policiesNode:
return command_start + create + command_end;
default:
break;
}
return command_start + remove + create + update + command_end;
}
private String createTitleDescription(TreeNode treeNode) {
switch (treeNode.getNodeType()) {
case usersNode:
return "users / default policy: ";
case policyNode:
return "Group name: ";
case bizStepFilterGroupNode:
return "BizStep Filters / default policy: ";
case epcFilterGroupNode:
return "EPC Filters / default policy: ";
case eventTypeFilterGroupNode:
return "Event Class Filters / default policy: ";
case eventTimeFilterGroupNode:
return "Event Time Filters / default policy: ";
case rulesNode:
return "Restricted filters";
case policiesNode:
return "Group list";
case methodFilterGroupNode:
return "Method filters";
case methodFilterNode:
return "method: ";
case userNode:
return "user id: ";
case bizStepFilterNode:
return "bizStep filter: ";
case eventTimeFilterNode:
return "period filter: ";
case eventTypeFilterNode:
return "Event class filter: ";
case epcFilterNode:
return "EPC filter: ";
default:
return "";
}
}
private String escapeRegExp(String objectID) {
if (objectID == null) {
return "null";
}
return objectID.replaceAll("\\\\", "\\\\\\\\");
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/TreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm;
import java.util.List;
/**
*
*/
public interface TreeNode {
public String getLabel();
public NodeType getNodeType();
public List<TreeNode> getChildren();
public String getObjectID();
public Module getModule();
public String getGroupID();
public void addChild(TreeNode child);
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/AccessPolicies.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.utils.InterfaceHelper;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
*
*/
public class AccessPolicies {
private List<TreeNode> policiesQuery = new ArrayList<TreeNode>();
private List<TreeNode> policiesAdmin = new ArrayList<TreeNode>();
private List<TreeNode> policiesCapture = new ArrayList<TreeNode>();
public AccessPolicies() {
}
public AccessPolicies(String sessionId, String owner) {
this.createQueryPolicies(sessionId, owner);
this.createCapturePolicies(sessionId, owner);
this.createAdminPolicies(sessionId, owner);
}
public AccessPolicies(String sessionId, String owner, Module module) {
switch (module) {
case adminModule:
this.createAdminPolicies(sessionId, owner);
break;
case queryModule:
this.createQueryPolicies(sessionId, owner);
break;
case captureModule:
this.createCapturePolicies(sessionId, owner);
break;
}
}
private synchronized void createQueryPolicies(String sessionId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(sessionId, owner).APMSession.getQueryPolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.queryModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
if (ogp instanceof GroupPolicy) {
GroupPolicy gp = (GroupPolicy) ogp;
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), Module.queryModule);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), Module.queryModule);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), Module.queryModule);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
Node filters = new Node("", NodeType.rulesNode, null, Module.queryModule, "id_group_query_1"); // NATIVE
BizStepRuleTreeNode bizStepRuleTreeNode = new BizStepRuleTreeNode(gp.getBizStepsFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getBizSteps()) {
String value = (String) ob;
BizStepTreeNode treeNode = new BizStepTreeNode(value, value, gp.getId().toString(), Module.queryModule);
bizStepRuleTreeNode.addChild(treeNode);
}
filters.addChild(bizStepRuleTreeNode);
EventTypeRuleTreeNode eventTypeRuleTreeNode = new EventTypeRuleTreeNode(gp.getEventTypesFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getEventTypes()) {
String value = (String) ob;
EventTypeTreeNode treeNode = new EventTypeTreeNode(value, value, gp.getId().toString(), Module.queryModule);
eventTypeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTypeRuleTreeNode);
EpcsRuleTreeNode epcRuleTreeNode = new EpcsRuleTreeNode(gp.getEpcsFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getEpcs()) {
String value = (String) ob;
EpcTreeNode treeNode = new EpcTreeNode(value, value, gp.getId().toString(), Module.queryModule);
epcRuleTreeNode.addChild(treeNode);
}
filters.addChild(epcRuleTreeNode);
EventTimeRuleTreeNode eventTimeRuleTreeNode = new EventTimeRuleTreeNode(gp.getEventTimesFilterFunction(), gp.getId().toString(), Module.queryModule);
for (Object ob : gp.getEventTimes()) {
List value = (List) ob;
EventTimeTreeNode treeNode = new EventTimeTreeNode((Date) value.get(0), (Date) value.get(1), gp.getId().toString(), Module.queryModule);
eventTimeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTimeRuleTreeNode);
gptn.addChild(filters);
policies.addChild(gptn);
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(sessionId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.queryModule);
ih.APMSession.addQueryPolicy(ownerPolicies);
ih.APMSession.saveQueryPolicies(owner);
ih.updateAPM();
}
getPoliciesQuery().add(policies);
}
private synchronized void createCapturePolicies(String sessionId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(sessionId, owner).APMSession.getCapturePolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.captureModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
if (ogp instanceof GroupPolicy) {
GroupPolicy gp = (GroupPolicy) ogp;
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), Module.captureModule);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), Module.captureModule);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), Module.captureModule);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
Node filters = new Node("", NodeType.rulesNode, null, Module.captureModule, "id_group_capture_1"); // NATIVE
BizStepRuleTreeNode bizStepRuleTreeNode = new BizStepRuleTreeNode(gp.getBizStepsFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getBizSteps()) {
String value = (String) ob;
BizStepTreeNode treeNode = new BizStepTreeNode(value, value, gp.getId().toString(), Module.captureModule);
bizStepRuleTreeNode.addChild(treeNode);
}
filters.addChild(bizStepRuleTreeNode);
EventTypeRuleTreeNode eventTypeRuleTreeNode = new EventTypeRuleTreeNode(gp.getEventTypesFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getEventTypes()) {
String value = (String) ob;
EventTypeTreeNode treeNode = new EventTypeTreeNode(value, value, gp.getId().toString(), Module.captureModule);
eventTypeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTypeRuleTreeNode);
EpcsRuleTreeNode epcRuleTreeNode = new EpcsRuleTreeNode(gp.getEpcsFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getEpcs()) {
String value = (String) ob;
EpcTreeNode treeNode = new EpcTreeNode(value, value, gp.getId().toString(), Module.captureModule);
epcRuleTreeNode.addChild(treeNode);
}
filters.addChild(epcRuleTreeNode);
EventTimeRuleTreeNode eventTimeRuleTreeNode = new EventTimeRuleTreeNode(gp.getEventTimesFilterFunction(), gp.getId().toString(), Module.captureModule);
for (Object ob : gp.getEventTimes()) {
List value = (List) ob;
EventTimeTreeNode treeNode = new EventTimeTreeNode((Date) value.get(0), (Date) value.get(1), gp.getId().toString(), Module.captureModule);
eventTimeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTimeRuleTreeNode);
gptn.addChild(filters);
policies.addChild(gptn);
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(sessionId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.captureModule);
ih.APMSession.addCapturePolicy(ownerPolicies);
ih.APMSession.saveCapturePolicies(owner);
ih.updateAPM();
}
getPoliciesCapture().add(policies);
}
private synchronized void createAdminPolicies(String sessionId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(sessionId, owner).APMSession.getAdminPolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.adminModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
if (ogp instanceof GroupPolicy) {
GroupPolicy gp = (GroupPolicy) ogp;
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), Module.adminModule);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), Module.adminModule);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), Module.adminModule);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), Module.adminModule);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), Module.adminModule);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
policies.addChild(gptn);
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(sessionId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.administrationModule);
ih.APMSession.addAdminPolicy(ownerPolicies);
ih.APMSession.saveAdminPolicies(owner);
ih.updateAPM();
}
getPoliciesAdmin().add(policies);
}
public synchronized TreeNode createGroupPolicy(GroupPolicy gp, Module module) {
GroupPolicyTreeNode gptn = new GroupPolicyTreeNode(gp, gp.getId().toString(), module);
UserGroupRuleTreeNode groupRoot = new UserGroupRuleTreeNode(gp.getUsersFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getUsers()) {
String value = (String) ob;
UserTreeNode userTreeNode = new UserTreeNode(value, value, gp.getId().toString(), module);
groupRoot.addChild(userTreeNode);
}
gptn.addChild(groupRoot);
ActionTargetTreeNode actionTargetTreeNode = new ActionTargetTreeNode(gp.getId().toString(), module);
for (Object ob : gp.getActions()) {
String value = (String) ob;
ActionTreeNode actionTreeNode = new ActionTreeNode(value, value, gp.getId().toString(), module);
actionTargetTreeNode.addChild(actionTreeNode);
}
gptn.addChild(actionTargetTreeNode);
if (!module.equals(Module.adminModule)) {
Node filters = new Node("", NodeType.rulesNode, null, module, "id_group_query_1"); // NATIVE
BizStepRuleTreeNode bizStepRuleTreeNode = new BizStepRuleTreeNode(gp.getBizStepsFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getBizSteps()) {
String value = (String) ob;
BizStepTreeNode treeNode = new BizStepTreeNode(value, value, gp.getId().toString(), module);
bizStepRuleTreeNode.addChild(treeNode);
}
filters.addChild(bizStepRuleTreeNode);
EventTypeRuleTreeNode eventTypeRuleTreeNode = new EventTypeRuleTreeNode(gp.getEventTypesFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getEventTypes()) {
String value = (String) ob;
EventTypeTreeNode treeNode = new EventTypeTreeNode(value, value, gp.getId().toString(), module);
eventTypeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTypeRuleTreeNode);
EpcsRuleTreeNode epcRuleTreeNode = new EpcsRuleTreeNode(gp.getEpcsFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getEpcs()) {
String value = (String) ob;
EpcTreeNode treeNode = new EpcTreeNode(value, value, gp.getId().toString(), module);
epcRuleTreeNode.addChild(treeNode);
}
filters.addChild(epcRuleTreeNode);
EventTimeRuleTreeNode eventTimeRuleTreeNode = new EventTimeRuleTreeNode(gp.getEventTimesFilterFunction(), gp.getId().toString(), module);
for (Object ob : gp.getEventTimes()) {
List value = (List) ob;
EventTimeTreeNode treeNode = new EventTimeTreeNode((Date) value.get(0), (Date) value.get(1), gp.getId().toString(), module);
eventTimeRuleTreeNode.addChild(treeNode);
}
filters.addChild(eventTimeRuleTreeNode);
gptn.addChild(filters);
}
return gptn;
}
/**
* @return the policiesQuery
*/
public synchronized List<TreeNode> getPoliciesQuery() {
return policiesQuery;
}
/**
* @param policiesQuery the policiesQuery to set
*/
public synchronized void setPoliciesQuery(List<TreeNode> policiesQuery) {
this.policiesQuery = policiesQuery;
}
/**
* @return the policiesAdmin
*/
public synchronized List<TreeNode> getPoliciesAdmin() {
return policiesAdmin;
}
/**
* @param policiesAdmin the policiesAdmin to set
*/
public synchronized void setPoliciesAdmin(List<TreeNode> policiesAdmin) {
this.policiesAdmin = policiesAdmin;
}
/**
* @return the policiesCapture
*/
public synchronized List<TreeNode> getPoliciesCapture() {
return policiesCapture;
}
/**
* @param policiesCapture the policiesCapture to set
*/
public synchronized void setPoliciesCapture(List<TreeNode> policiesCapture) {
this.policiesCapture = policiesCapture;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/ActionTargetTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class ActionTargetTreeNode implements TreeNode {
private List<TreeNode> children;
private String id;
private Module module;
private String groupID;
public ActionTargetTreeNode(String gID, Module m) {
children = new ArrayList<TreeNode>();
this.id = "Actions";
this.module = m;
this.groupID = gID;
}
@Override
public String getLabel() {
return "";
}
@Override
public NodeType getNodeType() {
return NodeType.methodFilterGroupNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/ActionTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class ActionTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public ActionTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.methodFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/BizStepRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCBizStepRule;
/**
*
*/
public class BizStepRuleTreeNode extends RuleTreeNode {
public BizStepRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCBizStepRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/BizStepTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class BizStepTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public BizStepTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.bizStepFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/EpcTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class EpcTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public EpcTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.epcFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/EpcsRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCEPCsRule;
/**
*
*/
public class EpcsRuleTreeNode extends RuleTreeNode {
public EpcsRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCEPCsRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/EventTimeRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCEventTimeRule;
/**
*
*/
public class EventTimeRuleTreeNode extends RuleTreeNode {
public EventTimeRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCEventTimeRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/EventTimeTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
*
*/
public class EventTimeTreeNode implements TreeNode {
private Date minDate;
private Date maxDate;
private List<TreeNode> children;
private String groupID;
private Module module;
private String id;
public Date getMaxDate() {
return maxDate;
}
public void setMaxDate(Date maxDate) {
this.maxDate = maxDate;
}
public Date getMinDate() {
return minDate;
}
public void setMinDate(Date minDate) {
this.minDate = minDate;
}
public EventTimeTreeNode(Date minD, Date maxD, String gID, Module m) {
maxDate = maxD;
minDate = minD;
this.id = getLabel();
this.groupID = gID;
this.module = m;
this.children = new ArrayList<TreeNode>();
}
@Override
public String getLabel() {
Calendar cal = Calendar.getInstance();
cal.setTime(minDate);
StringBuilder res = new StringBuilder();
int m = cal.get(Calendar.MONTH);
if (m < 10) {
res.append("0");
}
res.append(m);
res.append("/");
int d = cal.get(Calendar.DAY_OF_MONTH);
if (d < 10) {
res.append("0");
}
res.append(d);
res.append("/");
res.append(cal.get(Calendar.YEAR));
res.append(" -> ");
cal.setTime(maxDate);
m = cal.get(Calendar.MONTH);
if (m < 10) {
res.append("0");
}
res.append(m);
res.append("/");
d = cal.get(Calendar.DAY_OF_MONTH);
if (d < 10) {
res.append("0");
}
res.append(d);
res.append("/");
res.append(cal.get(Calendar.YEAR));
return res.toString();
}
@Override
public NodeType getNodeType() {
return NodeType.eventTimeFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
this.children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/EventTypeRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCEventTypeRule;
/**
*
*/
public class EventTypeRuleTreeNode extends RuleTreeNode {
public EventTypeRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCEventTypeRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/EventTypeTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class EventTypeTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public EventTypeTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.eventTypeFilterNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/GroupPolicyTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class GroupPolicyTreeNode implements TreeNode {
private GroupPolicy groupPolicy;
private List nodeChildren;
private String groupID;
private Module module;
public GroupPolicy getGroupPolicy() {
return groupPolicy;
}
public GroupPolicyTreeNode(GroupPolicy gp, String groupID, Module module) {
this.groupPolicy = gp;
this.groupID = groupID;
this.module = module;
this.nodeChildren = new ArrayList();
}
@Override
public String getLabel() {
return groupPolicy.getName();
}
@Override
public NodeType getNodeType() {
return NodeType.policyNode;
}
@Override
public List<TreeNode> getChildren() {
return nodeChildren;
}
@Override
public String getObjectID() {
return groupID;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
nodeChildren.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/Node.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class Node implements TreeNode {
private String value;
private NodeType nodeType;
private List<TreeNode> children;
private String objectID;
private Module module;
private String groupID;
public Node(String value, NodeType type, String id, Module module, String groupID) {
this.value = value;
this.nodeType = type;
this.children = new ArrayList<TreeNode>();
this.objectID = id;
this.module = module;
this.groupID = groupID;
}
@Override
public void addChild(TreeNode node) {
children.add(node);
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return nodeType;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return objectID;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/Policies.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class Policies {
public List<TreeNode> policiesQuery = new ArrayList<TreeNode>();
public List<TreeNode> policiesAdmin = new ArrayList<TreeNode>();
public List<TreeNode> policiesCapture = new ArrayList<TreeNode>();
public Policies() {
createQueryPolicies();
createAdminPolicies();
createCapturePolicies();
}
private void createQueryPolicies() {
Node policy1 = new Node("group_query_1", NodeType.policyNode, null, Module.queryModule, "id_group_query_1");
Node users = new Node("Associated users:", NodeType.usersNode, null, Module.queryModule, "id_group_query_1"); // NATIVE
users.addChild(new Node("user1", NodeType.userNode, null, Module.queryModule, "id_group_query_1"));
users.addChild(new Node("user2", NodeType.userNode, null, Module.queryModule, "id_group_query_1"));
users.addChild(new Node("user3", NodeType.userNode, null, Module.queryModule, "id_group_query_1"));
Node filters = new Node("Restricted filters", NodeType.rulesNode, null, Module.queryModule, "id_group_query_1"); // NATIVE
Node rule1 = new Node("ACCEPT", NodeType.bizStepFilterGroupNode, null, Module.queryModule, "id_group_query_1");
Node filter1 = new Node("blablabla", NodeType.bizStepFilterNode, null, Module.queryModule, "id_group_query_1");
Node filter2 = new Node("bliblibli", NodeType.bizStepFilterNode, null, Module.queryModule, "id_group_query_1");
Node filter3 = new Node("blobloblo", NodeType.bizStepFilterNode, null, Module.queryModule, "id_group_query_1");
rule1.addChild(filter1);
rule1.addChild(filter2);
rule1.addChild(filter3);
Node rule2 = new Node("DROP", NodeType.epcFilterGroupNode, null, Module.queryModule, "id_group_query_1");
Node filter21 = new Node("clacclac", NodeType.epcFilterNode, null, Module.queryModule, "id_group_query_1");
Node filter22 = new Node("clicclic", NodeType.epcFilterNode, null, Module.queryModule, "id_group_query_1");
rule2.addChild(filter21);
rule2.addChild(filter22);
Node rule3 = new Node("DROP", NodeType.eventTypeFilterGroupNode, null, Module.queryModule, "id_group_query_1");
Node rule4 = new Node("DROP", NodeType.eventTimeFilterGroupNode, null, Module.queryModule, "id_group_query_1");
filters.addChild(rule1);
filters.addChild(rule2);
filters.addChild(rule3);
filters.addChild(rule4);
policy1.addChild(users);
policy1.addChild(filters);
Node policy2 = new Node("group_query_2", NodeType.policyNode, null, Module.queryModule, "id_group_query_2");
Node users2 = new Node("Associated users:", NodeType.usersNode, null, Module.queryModule, "id_group_query_2");
users2.addChild(new Node("userx", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("usery", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("userz", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("useru", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("userv", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
users2.addChild(new Node("userw", NodeType.userNode, null, Module.queryModule, "id_group_query_2"));
policy2.addChild(users2);
Node policies = new Node("Groups", NodeType.policiesNode, null, Module.queryModule, null); // NATIVE
policies.addChild(policy1);
policies.addChild(policy2);
policiesQuery.add(policies);
}
private void createAdminPolicies() {
Node policy1 = new Node("group_admin_1", NodeType.policyNode, null, Module.adminModule, "id_group_admin_1");
Node users = new Node("Associated users", NodeType.usersNode, null, Module.adminModule, "id_group_admin_1");
users.addChild(new Node("user1", NodeType.userNode, null, Module.adminModule, "id_group_admin_1"));
users.addChild(new Node("user3", NodeType.userNode, null, Module.adminModule, "id_group_admin_1"));
Node rule1 = new Node("ACCEPT", NodeType.methodFilterGroupNode, null, Module.adminModule, "id_group_admin_1");
Node filter1 = new Node("eventCreate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_1");
Node filter2 = new Node("filterCreate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_1");
rule1.addChild(filter1);
rule1.addChild(filter2);
policy1.addChild(users);
policy1.addChild(rule1);
Node policy2 = new Node("group_admin_2", NodeType.policyNode, null, Module.adminModule, "id_group_admin_2");
Node users2 = new Node("Associated users", NodeType.usersNode, null, Module.adminModule, "id_group_admin_2");
users2.addChild(new Node("userx", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("userz", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("useru", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("userv", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
users2.addChild(new Node("userw", NodeType.userNode, null, Module.adminModule, "id_group_admin_2"));
Node rule2 = new Node("DROP", NodeType.methodFilterGroupNode, null, Module.adminModule, "id_group_admin_2");
Node filter21 = new Node("groupCreate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_2");
Node filter22 = new Node("groupUpdate", NodeType.methodFilterNode, null, Module.adminModule, "id_group_admin_2");
rule2.addChild(filter21);
rule2.addChild(filter22);
policy2.addChild(rule2);
policy2.addChild(users2);
Node policies = new Node("Groups", NodeType.policiesNode, null, Module.adminModule, null);
policies.addChild(policy1);
policies.addChild(policy2);
policiesAdmin.add(policies);
}
private void createCapturePolicies() {
Node policies = new Node("Groups", NodeType.policiesNode, null, Module.captureModule, null);
policiesCapture.add(policies);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/RuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import fr.unicaen.iota.xacml.policy.*;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class RuleTreeNode implements TreeNode {
private OneOrGlobalFunction function;
protected String id;
private List<TreeNode> children;
private Module module;
private String groupID;
public String getId() {
return id;
}
public OneOrGlobalFunction getFunction() {
return function;
}
public RuleTreeNode(OneOrGlobalFunction f, String groupID, Module m) {
this.function = f;
this.groupID = groupID;
this.module = m;
this.children = new ArrayList<TreeNode>();
}
@Override
public String getLabel() {
if (function.getFunctionName().equals(OneOrGlobalFunction.NAME_GLOBAL_PERMIT)) {
return "ACCEPT";
} else if (function.getFunctionName().equals(OneOrGlobalFunction.NAME_GLOBAL_DENY)) {
return "DENY";
}
return "";
}
@Override
public NodeType getNodeType() {
if (SCBizStepRule.RULEFILTER.equals(id)) {
return NodeType.bizStepFilterGroupNode;
} else if (SCEventTypeRule.RULEFILTER.equals(id)) {
return NodeType.eventTypeFilterGroupNode;
} else if (SCEPCsRule.RULEFILTER.equals(id)) {
return NodeType.epcFilterGroupNode;
} else if (SCEventTimeRule.RULEFILTER.equals(id)) {
return NodeType.eventTimeFilterGroupNode;
} else if (SCgroupRule.RULEFILTER.equals(id)) {
return NodeType.usersNode;
}
return null;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
this.children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/UserGroupRuleTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.cond.OneOrGlobalFunction;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.policy.SCgroupRule;
/**
*
*/
public class UserGroupRuleTreeNode extends RuleTreeNode {
public UserGroupRuleTreeNode(OneOrGlobalFunction f, String gID, Module m) {
super(f, gID, m);
id = SCgroupRule.RULEFILTER;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/factory/UserTreeNode.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.factory;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.ihm.NodeType;
import fr.unicaen.iota.xacml.ihm.TreeNode;
import java.util.ArrayList;
import java.util.List;
/**
*
*/
public class UserTreeNode implements TreeNode {
private String value;
private String id;
private String groupID;
private Module module;
private List<TreeNode> children;
public UserTreeNode(String v, String id, String gID, Module module) {
value = v;
this.id = id;
this.groupID = gID;
this.module = module;
this.children = new ArrayList<TreeNode>();
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
@Override
public String getLabel() {
return value;
}
@Override
public NodeType getNodeType() {
return NodeType.userNode;
}
@Override
public List<TreeNode> getChildren() {
return children;
}
@Override
public String getObjectID() {
return id;
}
@Override
public Module getModule() {
return module;
}
@Override
public String getGroupID() {
return groupID;
}
@Override
public void addChild(TreeNode child) {
children.add(child);
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/AccessResponse.form
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JDialogFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="2"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="17" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="38" max="-2" attributes="0"/>
<Component id="responseLabel" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="responseLabel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="responseLabel">
<Properties>
<Property name="text" type="java.lang.String" value="Response"/>
<Property name="horizontalTextPosition" type="int" value="0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="Access Response"/>
</Properties>
</Component>
</SubComponents>
</Form>
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/AccessResponse.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
/**
*
*/
public class AccessResponse extends javax.swing.JDialog {
/**
* Creates new form AccessResponse
*/
public AccessResponse(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
responseLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
responseLabel.setText("Response");
responseLabel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jLabel2.setText("Access Response");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(17, 17, 17)
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(38, 38, 38)
.addComponent(responseLabel)))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(responseLabel)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
AccessResponse dialog = new AccessResponse(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel responseLabel;
// End of variables declaration//GEN-END:variables
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/AccessResponseDialog.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
/**
*
*/
public class AccessResponseDialog extends javax.swing.JDialog {
/**
* Creates new form AccessResponse
*/
public AccessResponseDialog(java.awt.Frame parent, boolean modal) {
super(parent, modal);
initComponents();
}
public void setResponse(String response) {
responseLabel.setText(response);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
responseLabel = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
responseLabel.setText("Response");
jLabel2.setText("Access Response");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGap(17, 17, 17).addComponent(jLabel2)).addGroup(layout.createSequentialGroup().addGap(38, 38, 38).addComponent(responseLabel))).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel2).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(responseLabel).addContainerGap(29, Short.MAX_VALUE)));
pack();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
AccessResponseDialog dialog = new AccessResponseDialog(new javax.swing.JFrame(), true);
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel responseLabel;
// End of variables declaration
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/AdminModuleClient.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.utils.InterfaceHelper;
import fr.unicaen.iota.xacml.pep.DSPEP;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class AdminModuleClient extends javax.swing.JFrame {
private static final Log log = LogFactory.getLog(AdminModuleClient.class);
private String ownerName;
/**
* Creates new form CaptureModule
*/
public AdminModuleClient(String ownerName) {
this.ownerName = ownerName;
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Admin Module");
jLabel2.setText("User: ");
jLabel3.setText("Owner: ");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
InterfaceHelper IH = new InterfaceHelper(ownerName);
IH.reload();
sendButtonActionPerformed(evt);
}
});
ArrayList actions = new ArrayList();
for (Method m : MethodNamesAdmin.class.getMethods()) {
actions.add(m.getName());
}
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(actions.toArray()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel3)).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel2)).addGroup(layout.createSequentialGroup().addContainerGap().addComponent(jLabel8))).addGap(20, 20, 20).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE).addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 231, Short.MAX_VALUE).addComponent(actionComboBox, 0, 231, Short.MAX_VALUE).addComponent(jLabel1))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(273, Short.MAX_VALUE).addComponent(sendButton))).addContainerGap()));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(12, 12, 12).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel2)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(sendButton).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack();
}
private Object runMethod(Object obj, Object[] args, String methodName) throws Exception {
Class[] paramTypes = null;
if (args != null) {
paramTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
}
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
String action = (String) actionComboBox.getSelectedItem();
ArrayList args = new ArrayList();
args.add(userField.getText());
args.add(ownerField.getText());
try {
DSPEP dspep = new DSPEP();
int response = (Integer) runMethod(dspep, args.toArray(), action);
String res = (response == Result.DECISION_PERMIT)? "ACCEPT": "DENY";
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse(res);
dialog.setVisible(true);
} catch (InvocationTargetException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (NullPointerException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (Exception ex) {
log.fatal(null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String owner = "anonymous";
new AdminModuleClient(owner).setVisible(true);
}
});
}
private javax.swing.JComboBox actionComboBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/CaptureModule.form
<?xml version="1.0" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JFrameFormInfo">
<Properties>
<Property name="defaultCloseOperation" type="int" value="3"/>
</Properties>
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
<SyntheticProperty name="generateCenter" type="boolean" value="false"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jLabel3" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="20" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="userField" alignment="0" pref="239" max="32767" attributes="0"/>
<Component id="ownerField" alignment="0" pref="239" max="32767" attributes="0"/>
<Component id="actionComboBox" alignment="0" pref="239" max="32767" attributes="0"/>
<Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="261" max="32767" attributes="0"/>
<Component id="sendButton" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="12" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="userField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="ownerField" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="actionComboBox" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel8" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="sendButton" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel1">
<Properties>
<Property name="text" type="java.lang.String" value="Capture Module"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<Properties>
<Property name="text" type="java.lang.String" value="User: "/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Owner:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel8">
<Properties>
<Property name="text" type="java.lang.String" value="Action: "/>
</Properties>
</Component>
<Component class="javax.swing.JButton" name="sendButton">
<Properties>
<Property name="text" type="java.lang.String" value="Send"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="sendButtonActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JComboBox" name="actionComboBox">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="userField">
</Component>
<Component class="javax.swing.JTextField" name="ownerField">
</Component>
</SubComponents>
</Form>
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/CaptureModule.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
/**
*
*/
public class CaptureModule extends javax.swing.JFrame {
/**
* Creates new form CaptureModule
*/
public CaptureModule() {
initComponents();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Capture Module");
jLabel2.setText("User: ");
jLabel3.setText("Owner:");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
sendButtonActionPerformed(evt);
}
});
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel8))
.addGap(20, 20, 20)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
.addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 239, Short.MAX_VALUE)
.addComponent(actionComboBox, 0, 239, Short.MAX_VALUE)
.addComponent(jLabel1)))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 261, Short.MAX_VALUE)
.addComponent(sendButton)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel1)
.addGap(12, 12, 12)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel8))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(sendButton)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
}//GEN-LAST:event_sendButtonActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new CaptureModule().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox actionComboBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
// End of variables declaration//GEN-END:variables
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/CaptureModuleClient.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.utils.InterfaceHelper;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.xacml.pep.DSPEP;
import fr.unicaen.iota.xacml.pep.MethodNamesCapture;
import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class CaptureModuleClient extends javax.swing.JFrame {
private static final Log log = LogFactory.getLog(CaptureModuleClient.class);
private String ownerName;
public CaptureModuleClient(String ownerName) {
this.ownerName = ownerName;
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
epcField = new javax.swing.JTextField();
eventTypeField = new javax.swing.JTextField();
bizStepField = new javax.swing.JTextField();
eventTimeDayBox = new javax.swing.JComboBox();
eventTimeMonthBox = new javax.swing.JComboBox();
eventTimeYearBox = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Capture Module");
jLabel2.setText("User: ");
jLabel3.setText("Owner: ");
jLabel4.setText("EPC: ");
jLabel5.setText("EventType: ");
jLabel6.setText("BizStep: ");
jLabel7.setText("EventTime: ");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
InterfaceHelper IH = new InterfaceHelper(ownerName);
IH.reload();
sendButtonActionPerformed(evt);
}
});
ArrayList actions = new ArrayList();
for (Method m : MethodNamesCapture.class.getMethods()) {
actions.add(m.getName());
}
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(actions.toArray()));
String[] days = new String[31];
for (int i = 1; i <= 31; i++) {
days[i - 1] = "" + i;
}
eventTimeDayBox.setModel(new javax.swing.DefaultComboBoxModel(days));
String[] months = new String[12];
for (int i = 1; i <= 12; i++) {
months[i - 1] = "" + i;
}
eventTimeMonthBox.setModel(new javax.swing.DefaultComboBoxModel(months));
ArrayList years = new ArrayList();
for (int i = 1970; i <= 2020; i++) {
years.add("" + i);
}
eventTimeYearBox.setModel(new javax.swing.DefaultComboBoxModel(years.toArray()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(jLabel3).addComponent(jLabel8).addComponent(jLabel4).addComponent(jLabel5).addComponent(jLabel6).addComponent(jLabel7)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeMonthBox, 0, 51, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)).addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(actionComboBox, 0, 212, Short.MAX_VALUE).addComponent(epcField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(eventTypeField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(bizStepField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(jLabel1))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(254, Short.MAX_VALUE).addComponent(sendButton))).addContainerGap()));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(12, 12, 12).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(epcField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel4)).addGap(7, 7, 7).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(eventTypeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel5)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(bizStepField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel6)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7).addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeMonthBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(sendButton).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack();
}
private Date convertStringToDate(String day, String month, String year) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
return cal.getTime();
}
private Object runMethod(Object obj, Object[] args, String methodName) throws Exception {
Class[] paramTypes = null;
if (args != null) {
paramTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
}
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
Date eventTime = convertStringToDate((String) eventTimeDayBox.getSelectedItem(), (String) eventTimeMonthBox.getSelectedItem(), (String) eventTimeYearBox.getSelectedItem());
String action = (String) actionComboBox.getSelectedItem();
ArrayList args = new ArrayList();
args.add(MapSessions.APM);
args.add(userField.getText());
args.add(ownerField.getText());
if (!"hello".equals(action)) {
XACMLDSEvent xacmldse = new XACMLDSEvent(ownerField.getText(), bizStepField.getText(), epcField.getText(), eventTypeField.getText(), eventTime);
args.add(xacmldse);
}
try {
DSPEP dspep = new DSPEP();
int response = (Integer) runMethod(dspep, args.toArray(), action);
String res = (response == Result.DECISION_PERMIT)? "ACCEPT": "DENY";
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse(res);
dialog.setVisible(true);
} catch (InvocationTargetException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (NullPointerException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (Exception ex) {
log.fatal(null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String owner = "ownerDeTest";
new CaptureModuleClient(owner).setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox actionComboBox;
private javax.swing.JTextField bizStepField;
private javax.swing.JTextField eventTypeField;
private javax.swing.JTextField epcField;
private javax.swing.JComboBox eventTimeDayBox;
private javax.swing.JComboBox eventTimeMonthBox;
private javax.swing.JComboBox eventTimeYearBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
// End of variables declaration
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/QueryModuleClient.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.utils.InterfaceHelper;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.xacml.pep.DSPEP;
import fr.unicaen.iota.xacml.pep.MethodNamesQuery;
import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class QueryModuleClient extends javax.swing.JFrame {
private static final Log log = LogFactory.getLog(QueryModuleClient.class);
private String ownerName;
public QueryModuleClient(String ownerName) {
this.ownerName = ownerName;
initComponents();
this.setLocationRelativeTo(null);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel();
jLabel7 = new javax.swing.JLabel();
jLabel8 = new javax.swing.JLabel();
sendButton = new javax.swing.JButton();
actionComboBox = new javax.swing.JComboBox();
userField = new javax.swing.JTextField();
ownerField = new javax.swing.JTextField();
epcField = new javax.swing.JTextField();
eventTypeField = new javax.swing.JTextField();
bizStepField = new javax.swing.JTextField();
eventTimeDayBox = new javax.swing.JComboBox();
eventTimeMonthBox = new javax.swing.JComboBox();
eventTimeYearBox = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jLabel1.setText("Query Module");
jLabel2.setText("Owner: ");
jLabel3.setText("Owner Partner: ");
jLabel4.setText("EPC: ");
jLabel5.setText("EventType: ");
jLabel6.setText("BizStep: ");
jLabel7.setText("EventTime: ");
jLabel8.setText("Action: ");
sendButton.setText("Send");
sendButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
InterfaceHelper IH = new InterfaceHelper(ownerName);
IH.reload();
sendButtonActionPerformed(evt);
}
});
ArrayList actions = new ArrayList();
for (Method m : MethodNamesQuery.class.getMethods()) {
actions.add(m.getName());
}
actionComboBox.setModel(new javax.swing.DefaultComboBoxModel(actions.toArray()));
String[] days = new String[31];
for (int i = 1; i <= 31; i++) {
days[i - 1] = "" + i;
}
eventTimeDayBox.setModel(new javax.swing.DefaultComboBoxModel(days));
String[] months = new String[12];
for (int i = 1; i <= 12; i++) {
months[i - 1] = "" + i;
}
eventTimeMonthBox.setModel(new javax.swing.DefaultComboBoxModel(months));
ArrayList years = new ArrayList();
for (int i = 1970; i <= 2020; i++) {
years.add("" + i);
}
eventTimeYearBox.setModel(new javax.swing.DefaultComboBoxModel(years.toArray()));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addComponent(jLabel2).addComponent(jLabel3).addComponent(jLabel8).addComponent(jLabel4).addComponent(jLabel5).addComponent(jLabel6).addComponent(jLabel7)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeMonthBox, 0, 51, Short.MAX_VALUE).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 98, javax.swing.GroupLayout.PREFERRED_SIZE)).addComponent(userField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(ownerField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(actionComboBox, 0, 212, Short.MAX_VALUE).addComponent(epcField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(eventTypeField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(bizStepField, javax.swing.GroupLayout.DEFAULT_SIZE, 212, Short.MAX_VALUE).addComponent(jLabel1))).addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup().addContainerGap(254, Short.MAX_VALUE).addComponent(sendButton))).addContainerGap()));
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(jLabel1).addGap(12, 12, 12).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel2).addComponent(userField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(ownerField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel3)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(actionComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel8)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(epcField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel4)).addGap(7, 7, 7).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(eventTypeField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel5)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(bizStepField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(jLabel6)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE).addComponent(jLabel7).addComponent(eventTimeDayBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeYearBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE).addComponent(eventTimeMonthBox, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)).addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED).addComponent(sendButton).addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
pack();
}
private Date convertStringToDate(String day, String month, String year) {
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(year), Integer.parseInt(month), Integer.parseInt(day));
return cal.getTime();
}
private Object runMethod(Object obj, Object[] args, String methodName) throws Exception {
Class[] paramTypes = null;
if (args != null) {
paramTypes = new Class[args.length];
for (int i = 0; i < args.length; ++i) {
paramTypes[i] = args[i].getClass();
}
}
Method m = obj.getClass().getMethod(methodName, paramTypes);
return m.invoke(obj, args);
}
private void sendButtonActionPerformed(java.awt.event.ActionEvent evt) {
Date eventTime = convertStringToDate((String) eventTimeDayBox.getSelectedItem(), (String) eventTimeMonthBox.getSelectedItem(), (String) eventTimeYearBox.getSelectedItem());
String action = (String) actionComboBox.getSelectedItem();
ArrayList args = new ArrayList();
args.add(MapSessions.APM);
args.add(userField.getText());
args.add(ownerField.getText());
if (!"hello".equals(action)) {
XACMLDSEvent xacmldse = new XACMLDSEvent(ownerField.getText(), bizStepField.getText(), epcField.getText(), eventTypeField.getText(), eventTime);
args.add(xacmldse);
}
try {
DSPEP dspep = new DSPEP();
int response = (Integer) runMethod(dspep, args.toArray(), action);
String res = (response == Result.DECISION_PERMIT)? "ACCEPT": "DENY";
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse(res);
dialog.setVisible(true);
} catch (InvocationTargetException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (NullPointerException ex) {
AccessResponseDialog dialog = new AccessResponseDialog(this, true);
dialog.setLocationRelativeTo(this);
dialog.setResponse("DENY");
dialog.setVisible(true);
} catch (Exception ex) {
log.fatal(null, ex);
}
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
String owner = "anonymous";
new QueryModuleClient(owner).setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JComboBox actionComboBox;
private javax.swing.JTextField bizStepField;
private javax.swing.JTextField eventTypeField;
private javax.swing.JTextField epcField;
private javax.swing.JComboBox eventTimeDayBox;
private javax.swing.JComboBox eventTimeMonthBox;
private javax.swing.JComboBox eventTimeYearBox;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JLabel jLabel8;
private javax.swing.JTextField ownerField;
private javax.swing.JButton sendButton;
private javax.swing.JTextField userField;
// End of variables declaration
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/ihm/test/TestPEP.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
//import fr.unicaen.iota.utils.InterfaceHelper;
//import fr.unicaen.iota.xacml.pep.DSPEP;
//import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
//import fr.unicaen.iota.xacml.pep.XACMLResponse;
/**
*
*/
public class TestPEP {
public static void main(String[] args) {
// DSPEP dspep = InterfaceHelper.APM.getDspep();
// XACMLResponse res = dspep.hello(InterfaceHelper.APM, "owner2", "OwnerDeTest");
// System.out.println(res.toString());
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/pep/DSPEP.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.pep;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.ResponseCtx;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.xacml.policy.Module;
import fr.unicaen.iota.xacml.request.EventRequest;
import java.util.Iterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class DSPEP implements MethodNamesAdmin {
private static final Log log = LogFactory.getLog(DSPEP.class);
//####################################################
//################## Authentication ##################
//####################################################
@Override
public int hello(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "hello", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userLookup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userLookup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userCreate(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userCreate", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userInfo(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userInfo", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userUpdate(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userUpdate", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int userDelete(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "userDelete", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int ownerUpdate(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "ownerUpdate", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int ownerDelete(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "ownerDelete", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
//####################################################
//############## Admin Module Section ################
//####################################################
public int superadmin(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "superadmin", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
public int allAdminMethods(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "allAdminMethods", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
public int allQueryMethods(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "allQueryMethods", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
public int allCaptureMethods(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "allCaptureMethods", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int createAdminOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "createAdminOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int deleteAdminOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "deleteAdminOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addAdminOwnerToGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addAdminOwnerToGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeAdminOwnerFromGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeAdminOwnerFromGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchAdminUserPermissionPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchAdminUserPermissionPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeAdminUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeAdminUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addAdminUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addAdminUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int updateAdminGroupName(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "updateAdminGroupName", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int saveAdminPolicyOwner(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "saveAdminPolicyOwner", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
//####################################################
//################# Modules Section ##################
//####################################################
@Override
public int createOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "createOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int deleteOwnerGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "deleteOwnerGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addOwnerToGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addOwnerToGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeOwnerFromGroup(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeOwnerFromGroup", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addBizStepRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addBizStepRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeBizStepRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeBizStepRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addEPCRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addEPCRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeEPCRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeEPCRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addEventTypeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addEventTypeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeEventTypeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeEventTypeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addTimeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addTimeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeTimeRestriction(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeTimeRestriction", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchBizStepPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchBizStepPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchEPCPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchEPCPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchEventTypePolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchEventTypePolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchTimePolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchTimePolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int switchUserPermissionPolicy(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "switchUserPermissionPolicy", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int removeUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "removeUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int addUserPermission(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "addUserPermission", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int updateGroupName(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "updateGroupName", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
@Override
public int savePolicyOwner(String user, String owner) {
EventRequest eventRequest = new EventRequest(user, "savePolicyOwner", owner, Module.administrationModule.getValue());
RequestCtx request = eventRequest.createRequest();
ResponseCtx result = MapSessions.APM.evaluate(request);
return processResult(result);
}
private int processResult(ResponseCtx result) {
Iterator it = result.getResults().iterator();
while (it.hasNext()) {
Result res = (Result) it.next();
if (res != null) {
return res.getDecision();
}
}
return Result.DECISION_DENY;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/AccessControlPolicy.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
import fr.unicaen.iota.auth.User;
import fr.unicaen.iota.utils.InterfaceHelper;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.xacml.ihm.*;
import fr.unicaen.iota.xacml.ihm.factory.AccessPolicies;
import fr.unicaen.iota.xacml.ihm.factory.Node;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.ypsilon.client.model.UserInfoOut;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class AccessControlPolicy extends HttpServlet {
private Services services = new Services();
private static final Log log = LogFactory.getLog(AccessControlPolicy.class);
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/xml;charset=UTF-8");
PrintWriter out = response.getWriter();
StringBuilder html = new StringBuilder();
try {
// ************************** CREATE *********************************
try {
if (request.getSession().getAttribute("session-id") == null) {
throw new ServiceException("Session expired you have to reconnect!", ServiceErrorType.ds);
}
UserInfoOut userInfo = (UserInfoOut) request.getSession().getAttribute("uInfo");
if (userInfo == null) {
throw new ServiceException("User not well connected !", ServiceErrorType.ds);
}
User user = new User(userInfo.getUserID(), userInfo.getOwnerID());
Module module = (request.getParameter("d") != null)? Module.valueOf(request.getParameter("d")) : null;
String objectId = request.getParameter("b");
String groupId = request.getParameter("e");
String sessionId = (String) request.getSession().getAttribute("session-id");
synchronized (services) {
String a = request.getParameter("a");
// ************************** CREATE *********************************
if ("createOwnerGroup".equals(a)) {
String newValue = request.getParameter("c");
String resp = services.createOwnerGroup(sessionId, user, module, newValue);
TreeNode node = createEmptyPolicies(user, newValue, module, resp);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addOwnerToGroup".equals(a)) {
String newValue = request.getParameter("c");
services.addOwnerToGroup(sessionId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.userNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addBizStepRestriction".equals(a)) {
String newValue = request.getParameter("c");
services.addBizStepRestriction(sessionId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.bizStepFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addEPCRestriction".equals(a)) {
String newValue = request.getParameter("c");
services.addEPCRestriction(sessionId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.epcFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addEventTypeRestriction".equals(a)) {
String newValue = request.getParameter("c");
services.addEventTypeRestriction(sessionId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.eventTypeFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addTimeRestriction".equals(a)) {
String d1 = request.getParameter("d1");
String d2 = request.getParameter("d2");
services.addTimeRestriction(sessionId, user, module, objectId, groupId, d1, d2);
TreeNode node = new Node(d1 + " -> " + d2, NodeType.eventTimeFilterNode, d1 + " -> " + d2, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addUserPermission".equals(a)) {
String newValue = request.getParameter("c");
services.addUserPermission(sessionId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.methodFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} // ************************** SWITCH *********************************
else if ("switchBizStepPolicy".equals(a)) {
html.append(services.switchBizStepPolicy(sessionId, user, module, objectId, groupId));
} else if ("switchEPCPolicy".equals(a)) {
html.append(services.switchEPCPolicy(sessionId, user, module, objectId, groupId));
} else if ("switchEventTypePolicy".equals(a)) {
html.append(services.switchEventTypePolicy(sessionId, user, module, objectId, groupId));
} else if ("switchTimePolicy".equals(a)) {
html.append(services.switchTimePolicy(sessionId, user, module, objectId, groupId));
} else if ("switchPermissionPolicy".equals(a)) {
html.append(services.switchUserPermissionPolicy(sessionId, user, module, objectId, groupId));
} // ************************** REMOVE *********************************
else if ("removeBizStepRestriction".equals(a)) {
services.removeBizStepRestriction(sessionId, user, module, objectId, groupId);
} else if ("removeEPCRestriction".equals(a)) {
services.removeEPCRestriction(sessionId, user, module, objectId, groupId);
} else if ("removeEventTypeRestriction".equals(a)) {
services.removeEventTypeRestriction(sessionId, user, module, objectId, groupId);
} else if ("removeTimeRestriction".equals(a)) {
services.removeTimeRestriction(sessionId, user, module, objectId, groupId);
} else if ("removeUserPermission".equals(a)) {
services.removeUserPermission(sessionId, user, module, objectId, groupId);
} else if ("deleteOwnerGroup".equals(a)) {
services.deleteOwnerGroup(sessionId, user, module, objectId, groupId);
} else if ("removeOwnerFromGroup".equals(a)) {
services.removeOwnerFromGroup(sessionId, user, module, objectId, groupId);
} // ************************* DS ADMIN ********************************
else if ("createUser".equals(a)) {
String userDN = request.getParameter("f");
String userName = request.getParameter("g");
services.createUser(sessionId, user, userDN, userName);
} else if ("updateUser".equals(a)) {
String login = request.getParameter("f");
String pass = request.getParameter("g");
//services.updateUser(sessionId, user, login, pass);
} else if ("deleteUser".equals(a)) {
String login = request.getParameter("f");
services.deleteUser(sessionId, user, login);
} else if ("createAccount".equals(a)) {
String userDN = request.getParameter("f");
String owner = request.getParameter("g");
String userName = request.getParameter("h");
boolean rtr = services.createAccount(sessionId, user, owner, userDN, userName);
if (rtr) {
html.append("Account successfull created.");
}
} // ************************** UPDATE *********************************
else if ("updateGroupName".equals(a)) {
String newValue = request.getParameter("c");
services.updateGroupName(sessionId, user, module, objectId, groupId, newValue);
} // ************************** SAVE **********************************
else if ("savePolicyOwner".equals(a)) {
services.savePolicyOwner(sessionId, user, module);
} // ************************** CANCEL **********************************
else if ("cancelOwnerPolicy".equals(a)) {
services.cancelOwnerPolicy(user, module);
} // ************************** LOAD POLICIES *************************
else if ("loadPolicyTree".equals(a)) {
services.loadPolicyTree(user, module);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, user.getOwnerID());
interfaceHelper.reload();
AccessPolicies policies = new AccessPolicies(sessionId, user.getOwnerID(), module);
switch (module) {
case adminModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesAdmin().get(0)));
break;
case queryModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesQuery().get(0)));
break;
case captureModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesCapture().get(0)));
break;
}
} else {
throw new ServiceException("service method " + a + " not found!", ServiceErrorType.unknown);
}
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.Value.OK, "") + createXMLHTMLTag(html.toString())));
}
} catch (ServiceException se) {
log.info("", se);
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.Value.ERROR, se.getMessage()) + createXMLHTMLTag(html.toString())));
return;
} catch (Exception e) {
log.info("", e);
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.Value.ERROR, "INTERNAL ERROR: "
+ e.getMessage()) + createXMLHTMLTag(html.toString())));
return;
}
} finally {
out.close();
}
}
public String createXMLEnvelop(String content) {
return "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<response>\n" + content + "</response>";
}
public String createXMLRespondeHeader(Response.Value code, String message) {
return "<result>\n<id>" + code.toString() + "</id>\n<desc>" + message + "</desc>\n</result>\n";
}
private String createXMLHTMLTag(String html) {
return "<htmlcontent>\n<![CDATA[" + html + "]]>\n</htmlcontent>";
}
public TreeNode createEmptyPolicies(User user, String name, Module module, String groupId) {
GroupPolicy gpq = new GroupPolicy(name, user.getOwnerID());
AccessPolicies accessPolicies = new AccessPolicies();
return accessPolicies.createGroupPolicy(gpq, module);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/Response.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
/**
*
*/
public class Response {
static public enum Value {
OK("1"),
ERROR("2");
private String str;
private Value(String str) {
this.str = str;
}
@Override
public String toString() {
return str;
}
}
private Value value;
private String desc;
public Response(Value value, String desc) {
this.value = value;
this.desc = desc;
}
/**
* @return the value
*/
public Value getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(Value value) {
this.value = value;
}
/**
* @return the desc
*/
public String getDesc() {
return desc;
}
/**
* @param desc the desc to set
*/
public void setDesc(String desc) {
this.desc = desc;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/RootAccountAuth.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
import fr.unicaen.iota.mu.Utils;
import fr.unicaen.iota.utils.Constants;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.utils.SessionLoader;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserLoginOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import fr.unicaen.iota.ypsilon.client.soap.SecurityExceptionResponse;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class RootAccountAuth extends HttpServlet {
private static final Log LOG = LogFactory.getLog(RootAccountAuth.class);
/**
* Processes requests for both HTTP
* <code>GET</code> and
* <code>POST</code> methods.
*
* @param request servlet request
* @param response servlet response
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String message = "";
if ("login".equals(request.getParameter("action"))) {
String login = (request.getUserPrincipal() != null)? request.getUserPrincipal().getName() : null;
if (login == null || login.isEmpty()) {
message = "?message=You are not authenticated.";
} else {
login = Utils.formatId(login);
UserLoginOut userLoginOut;
try {
YPSilonClient ypsilonClient = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
userLoginOut = ypsilonClient.userCertLogin(login);
request.setAttribute("session-id", userLoginOut.getSid());
message = SessionLoader.loadSession(userLoginOut.getSid(), ypsilonClient, login, request.getSession());
} catch (ImplementationExceptionResponse ex) {
message = "?message=" + ex.getMessage();
LOG.error("impl", ex);
} catch (SecurityExceptionResponse ex) {
message = "?message=" + ex.getMessage();
LOG.error("secur", ex);
}
}
} else if ("logout".equals(request.getParameter("action"))) {
String sessionId = (String) (request.getSession().getAttribute("session-id"));
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
client.userLogout(sessionId);
SessionLoader.clearSession(request.getSession());
MapSessions.releaseSession(sessionId);
} catch (ImplementationExceptionResponse ex) {
message = "?message=" + ex.getMessage();
} catch (SecurityExceptionResponse ex) {
message = "?message=" + ex.getMessage();
}
request.getSession().setAttribute("session-id", null);
MapSessions.releaseSession(sessionId);
}
//getServletContext().getRequestDispatcher("/test").forward(request, response);
response.sendRedirect(getServletContext().getContextPath() + "/index.jsp" + message);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP
* <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Handles the HTTP
* <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}
/**
* Returns a short description of the servlet.
*/
public String getServletInfo() {
return "Short description";
}// </editor-fold>
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/ServiceErrorType.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
/**
*
*/
public enum ServiceErrorType {
unknown,
xacml,
ds;
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/ServiceException.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
/**
*
*/
public class ServiceException extends Exception {
private ServiceErrorType type;
public ServiceException(String message, ServiceErrorType type) {
super(message);
this.type = type;
}
/**
* @return the type
*/
public ServiceErrorType getType() {
return type;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/Services.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2013 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.auth.User;
import fr.unicaen.iota.utils.Constants;
import fr.unicaen.iota.utils.InterfaceHelper;
import fr.unicaen.iota.utils.MapSessions;
import fr.unicaen.iota.utils.PEPRequester;
import fr.unicaen.iota.xacml.ihm.Module;
import fr.unicaen.iota.xacml.pep.MethodNamesAdmin;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import fr.unicaen.iota.ypsilon.client.soap.SecurityExceptionResponse;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
*
*/
public class Services {
private static final Log log = LogFactory.getLog(Services.class.getName());
private void checkAccess(User user, Module module, String method) throws ServiceException {
if (PEPRequester.checkAccess(user, method) == Result.DECISION_DENY) {
throw new ServiceException(method + ": not allowed for user" + user.getUserID() + " in module " + module, ServiceErrorType.xacml);
}
}
public String createOwnerGroup(String sessionId, User user, Module module, String value)
throws ServiceException {
String method = module == Module.adminModule ? "createAdminOwnerGroup" : "createOwnerGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
GroupPolicy gpol = new GroupPolicy(value, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryGroupPolicy(owner, gpol);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureGroupPolicy(owner, gpol);
break;
case adminModule:
resp = interfaceHelper.APMSession.addAdminGroupPolicy(owner, gpol);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
return value;
}
public void deleteOwnerGroup(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "deleteAdminOwnerGroup" : "deleteOwnerGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.deleteQueryGroupPolicy(owner, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.deleteCaptureGroupPolicy(owner, objectId);
break;
case adminModule:
resp = interfaceHelper.APMSession.deleteAdminGroupPolicy(owner, objectId);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void addOwnerToGroup(String sessionId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "addAdminOwnerToGroup" : "addOwnerToGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryUserFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureUserFilter(owner, groupId, value);
break;
case adminModule:
resp = interfaceHelper.APMSession.addAdminUserFilter(owner, groupId, value);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void removeOwnerFromGroup(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "removeAdminOwnerFromGroup" : "removeOwnerFromGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryUserFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureUserFilter(owner, groupId, objectId);
break;
case adminModule:
resp = interfaceHelper.APMSession.removeAdminUserFilter(owner, groupId, objectId);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addBizStepRestriction(String sessionId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addBizStepRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryBizStepFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureBizStepFilter(owner, groupId, value);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addBizStepRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeBizStepRestriction(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeBizStepRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryBizStepFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureBizStepFilter(owner, groupId, objectId);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeBizStepRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addEPCRestriction(String sessionId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEpcFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEpcFilter(owner, groupId, value);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addEPCRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeEPCRestriction(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEPCRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEpcFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEpcFilter(owner, groupId, objectId);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeEPCRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addEventTypeRestriction(String sessionId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addEventTypeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEventTypeFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEventTypeFilter(owner, groupId, value);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addEventTypeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeEventTypeRestriction(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEventTypeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEventTypeFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEventTypeFilter(owner, groupId, objectId);
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeEventTypeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addTimeRestriction(String sessionId, User user, Module module,
String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
checkAccess(user, module, "addTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEventTimeFilter(owner,
groupId, convertStringToDate(valueMin, valueMax));
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEventTimeFilter(owner,
groupId, convertStringToDate(valueMin, valueMax));
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("addTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeTimeRestriction(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEventTimeFilter(owner, groupId, convertStringToDate((String) objectId));
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEventTimeFilter(owner, groupId, convertStringToDate((String) objectId));
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("removeTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public String switchBizStepPolicy(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchBizStepPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionBizSteps(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getBizStepsFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionBizSteps(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getBizStepsFilterFunction().getValue();
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("switchBizStepPolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchEPCPolicy(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEPCPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionEpcs(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getEpcsFilterFunction().getValue();
break;
case captureModule:
break;
case adminModule:
resp = interfaceHelper.APMSession.switchCapturePermissionEpcs(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getEpcsFilterFunction().getValue();
break;
}
if (!resp) {
throw new ServiceException("switchEPCPolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchEventTypePolicy(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEventTypePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionEventTypes(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getEventTypesFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionEventTypes(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getEventTypesFilterFunction().getValue();
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("switchEventTypePolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchTimePolicy(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchTimePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionEventTimes(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getEventTimesFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionEventTimes(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getEventTimesFilterFunction().getValue();
break;
case adminModule:
break;
}
if (!resp) {
throw new ServiceException("switchTimePolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public String switchUserPermissionPolicy(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "switchAdminUserPermissionPolicy" : "switchUserPermissionPolicy";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
String value = "";
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.switchQueryPermissionUsers(owner, groupId);
value = (interfaceHelper.APMSession.getQueryPolicy(owner)).getGroupPolicy(groupId).getUsersFilterFunction().getValue();
break;
case captureModule:
resp = interfaceHelper.APMSession.switchCapturePermissionUsers(owner, groupId);
value = (interfaceHelper.APMSession.getCapturePolicy(owner)).getGroupPolicy(groupId).getUsersFilterFunction().getValue();
break;
case adminModule:
resp = interfaceHelper.APMSession.switchAdminPermissionUsers(owner, groupId);
value = (interfaceHelper.APMSession.getAdminPolicy(owner)).getGroupPolicy(groupId).getUsersFilterFunction().getValue();
break;
}
if (!resp) {
throw new ServiceException("switchUserPermissionPolicy: internal error in module: " + module, ServiceErrorType.xacml);
}
return value;
}
public void removeUserPermission(String sessionId, User user, Module module,
String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "removeAdminUserPermission" : "removeUserPermission";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryActionFilter(owner, groupId, objectId);
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureActionFilter(owner, groupId, objectId);
break;
case adminModule:
resp = interfaceHelper.APMSession.removeAdminActionFilter(owner, groupId, objectId);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void addUserPermission(String sessionId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "addAdminUserPermission" : "addUserPermission";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryActionFilter(owner, groupId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureActionFilter(owner, groupId, value);
break;
case adminModule:
resp = interfaceHelper.APMSession.addAdminActionFilter(owner, groupId, value);
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void updateGroupName(String sessionId, User user, Module module,
String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "updateAdminGroupName" : "updateGroupName";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.updateQueryGroupName(owner, objectId, value);
break;
case captureModule:
resp = interfaceHelper.APMSession.updateCaptureGroupName(owner, objectId, value);
break;
case adminModule:
resp = interfaceHelper.APMSession.updateAdminGroupName(owner, objectId, value);
break;
default:
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void savePolicyOwner(String sessionId, User user, Module module) throws ServiceException {
String method = module == Module.adminModule ? "saveAdminPolicyOwner" : "savePolicyOwner";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.saveQueryPolicies(owner);
interfaceHelper.updateQueryAPM();
break;
case captureModule:
resp = interfaceHelper.APMSession.saveCapturePolicies(owner);
interfaceHelper.updateCaptureAPM();
break;
case adminModule:
resp = interfaceHelper.APMSession.saveAdminPolicies(owner);
interfaceHelper.updateAdminAPM();
break;
default:
break;
}
if (!resp) {
throw new ServiceException(method + ": internal error in module " + module, ServiceErrorType.xacml);
}
}
public void createUser(String sessionId, User user, String userDN, String userName) throws ServiceException {
checkAccess(user, Module.adminModule, "userCreate");
try {
String owner = user.getOwnerID();
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
if (userName != null && !userName.isEmpty()) {
client.userCreate(sessionId, userDN, owner, userName, 30);
}
else {
client.userCreate(sessionId, userDN, owner, 30);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
}
public void deleteUser(String sessionId, User user, String login) throws ServiceException {
checkAccess(user, Module.adminModule, "userDelete");
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
client.userDelete(sessionId, login);
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
}
/*public void updateUser(String sessionId, User user, String login, String pass) throws ServiceException {
checkAccess(user, Module.adminModule, "userUpdate");
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
String owner = user.getOwnerID();
try {
client.userUpdate(sessionId, user.getId(), owner, login, pass, 30);
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
}*/
public void createRootOwnerPolicy(String sessionId, String userId, String ownerId) {
String gpName = "admin";
InterfaceHelper ih = new InterfaceHelper(ownerId);
OwnerPolicies ownerPolicies = new OwnerPolicies(ownerId, fr.unicaen.iota.xacml.policy.Module.administrationModule);
ih.APMSession.addAdminPolicy(ownerPolicies);
GroupPolicy gp = new GroupPolicy(gpName, ownerId);
ih.APMSession.addAdminGroupPolicy(ownerId, gp);
ih.APMSession.addAdminUserFilter(ownerId, gpName, userId);
for (Method m : MethodNamesAdmin.class.getMethods()) {
String n = m.getName();
ih.APMSession.addAdminActionFilter(ownerId, gpName, n);
}
ih.APMSession.saveAdminPolicies(ownerId);
ih.updateAPM();
log.debug(MapSessions.AdminAPMtoString());
}
public boolean createAccount(String sessionId, User user, String ownerId, String userDN, String userName) throws ServiceException {
checkAccess(user, Module.adminModule, "superadmin");
try {
String userId = (userName != null && !userName.isEmpty())? userName : userDN;
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
boolean found = false;
try {
client.userInfo(sessionId, userId);
found = true;
} catch (ImplementationExceptionResponse ex) {
log.trace(null, ex);
} catch (SecurityExceptionResponse ex) {
log.trace(null, ex);
}
if (found) {
throw new ServiceException("User exists", ServiceErrorType.unknown);
}
if (userName != null && !userName.isEmpty()) {
client.userCreate(sessionId, userDN, ownerId, userName, 30);
createRootOwnerPolicy(sessionId, userName, ownerId);
}
else {
client.userCreate(sessionId, userDN, ownerId, 30);
createRootOwnerPolicy(sessionId, userDN, ownerId);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.unknown);
}
return true;
}
public void loadPolicyTree(User user, Module module) {
}
public void cancelOwnerPolicy(User user, Module module) {
}
private List<Date> convertStringToDate(String dateInString) {
List<Date> dates = new ArrayList<Date>();
String[] datesStringTab = dateInString.split(" -> ");
for (int i = 0; i < datesStringTab.length; i++) {
String[] dateValue = datesStringTab[i].split("/");
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(dateValue[2]), Integer.parseInt(dateValue[0]), Integer.parseInt(dateValue[1]), 0, 0, 0);
long time = cal.getTimeInMillis() - cal.get(Calendar.MILLISECOND);
Date date = new Date(time);
dates.add(date);
}
return dates;
}
private List<Date> convertStringToDate(String dateMinInString, String dateMaxInString) {
List<Date> dates = new ArrayList<Date>();
String[] datesStringTab = {dateMinInString, dateMaxInString};
for (int i = 0; i < datesStringTab.length; i++) {
String[] dateValue = datesStringTab[i].split("/");
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(dateValue[2]), Integer.parseInt(dateValue[0]), Integer.parseInt(dateValue[1]), 0, 0, 0);
long time = cal.getTimeInMillis() - cal.get(Calendar.MILLISECOND);
Date date = new Date(time);
dates.add(date);
}
return dates;
}
}
DSeTa/DiscoveryPHI/src/main/java/fr/unicaen/iota/xacml/servlet/XiServlet.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.servlet;
import com.sun.xacml.ParsingException;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.ResponseCtx;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.utils.MapSessions;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Iterator;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class XiServlet extends HttpServlet {
private static final Log log = LogFactory.getLog(XiServlet.class);
@Override
public void init() {
MapSessions.init();
}
/**
* Processes incoming XACML request and sends XACML response.
*
* @param req The HttpServletRequest.
* @param rsp The HttpServletResponse.
* @throws IOException If an error occurred while validating the request or
* writing the response.
*/
@Override
public void doPost(final HttpServletRequest req, final HttpServletResponse rsp) throws IOException {
PrintWriter out = rsp.getWriter();
try {
rsp.setContentType("text/plain");
log.debug("Receiving XACML request...");
InputStream is = req.getInputStream();
String request = readXACMLRequest(is);
log.debug("create XACML request ...");
RequestCtx reqCtx = RequestCtx.getInstance(new ByteArrayInputStream(request.getBytes()));
log.debug("process policy");
String resp = String.valueOf(processRequest(reqCtx));
log.debug("process response");
out.println(resp);
rsp.setStatus(HttpServletResponse.SC_OK);
} catch (ParsingException ex) {
log.error("Error during parsing request.", ex);
rsp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
out.println(String.valueOf(Result.DECISION_DENY));
}
out.flush();
out.close();
}
private String readXACMLRequest(InputStream is) throws IOException {
char[] end = {'<', '/', 'R', 'e', 'q', 'u', 'e', 's', 't', '>'};
int endIndex = 0;
StringBuilder response = new StringBuilder();
int value = 0;
boolean active = true;
while (active) {
value = is.read();
if (value == -1) {
throw new IOException("End of Stream");
}
response.append((char) value);
if (value == end[endIndex]) {
endIndex++;
} else {
endIndex = 0;
}
if (endIndex == end.length) {
active = false;
}
}
return response.toString();
}
public int processRequest(RequestCtx request) {
try {
ResponseCtx result = MapSessions.APM.evaluate(request);
Iterator it = result.getResults().iterator();
while (it.hasNext()) {
Result res = (Result) it.next();
if (res != null) {
return res.getDecision();
}
}
} catch (Exception ex) {
log.error("error", ex);
return Result.DECISION_DENY;
}
return Result.DECISION_DENY;
}
}
DSeTa/DiscoveryPHI/src/main/webapp/Login.jsp
<body>
<h2>DS Access Control Center</h2>
<%
if (request.getParameter("message") != null) {
if (request.getAttribute("message") != null) {
String message = (String) request.getAttribute("message");
message = message.replaceAll("<", "&#60;");
message = message.replaceAll(">", "&#62;");
%>
<div style="color:red;text-align:center;font-weight:bold;"><%=request.getParameter("message")%></div>
<div style="color:red;text-align:center;font-weight:bold;"><%= message %></div>
<%
}
%>
DSeTa/DiscoveryPHI/src/main/webapp/WEB-INF/web.xml
<servlet>
<servlet-name>AccessControlPolicy</servlet-name>
<servlet-class>fr.unicaen.iota.xacml.servlet.AccessControlPolicy</servlet-class>
<servlet-class>fr.unicaen.iota.dphi.xacml.servlet.AccessControlPolicy</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AccessControlPolicy</servlet-name>
......
<servlet>
<servlet-name>RootAccountAuth</servlet-name>
<servlet-class>fr.unicaen.iota.xacml.servlet.RootAccountAuth</servlet-class>
<servlet-class>fr.unicaen.iota.dphi.xacml.servlet.RootAccountAuth</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>RootAccountAuth</servlet-name>
......
<servlet>
<servlet-name>XACMLInterface</servlet-name>
<servlet-class>fr.unicaen.iota.xacml.servlet.XiServlet</servlet-class>
<servlet-class>fr.unicaen.iota.dphi.xacml.servlet.XiServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
......
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
......
<security-constraint>
<web-resource-collection>
<web-resource-name>DPHiSecure</web-resource-name>
<url-pattern>/RootAccountAuth</url-pattern>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
DSeTa/DiscoveryPHI/src/main/webapp/dialogs.jsp
<%@page import="fr.unicaen.iota.ypsilon.client.model.UserInfoOut"%>
<%@page import="fr.unicaen.iota.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.utils.HTMLUtilities"%>
<%
String ownerId = ((UserInfoOut) session.getAttribute("uInfo")).getOwnerID();
%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.dphi.utils.HTMLUtilities"%>
<div id="createUser" title="Create User" class="modalDialog">
<div class="dialog_message">Enter user informations :</div>
......
<div id="updateOwner" title="Update Owner Informations" class="modalDialog">
<div class="dialog_message">Enter the new owner informations :</div>
<div class="dialog_options">Owner Id : <input disabled id="ownerID" type="text" value="<%=ownerId%>" /></div>
<div class="dialog_options">Owner Id : <input disabled id="ownerID" type="text" value="" /></div>
</div>
<div id="TimeDialog" title="Event Time Filter" class="modalDialog">
DSeTa/DiscoveryPHI/src/main/webapp/index.jsp
<%@page import="fr.unicaen.iota.ypsilon.client.model.UserInfoOut"%>
<%@page import="fr.unicaen.iota.utils.Constants"%>
<%@page import="fr.unicaen.iota.ypsilon.client.YPSilonClient"%>
<%@page import="fr.unicaen.iota.utils.SessionLoader"%>
<%@page import="com.sun.xacml.ctx.Result"%>
<%@page import="fr.unicaen.iota.utils.PEPRequester"%>
<%@page import="fr.unicaen.iota.dphi.utils.PEPRequester"%>
<%
String sessionId = (String) session.getAttribute("session-id");
String sid = (String) request.getParameter("sid");
String uid = (String) request.getParameter("uid");
if (sid != null) {
YPSilonClient ypsilonClient = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
String message = SessionLoader.loadSession(sid, ypsilonClient, uid, session);
if (!message.isEmpty()) {
request.setAttribute("message", message);
%>
<jsp:include page="Login.jsp" />
<%
return;
}
} else if (sessionId == null) {
String cert = (session.getAttribute("cert") != null)? (String) session.getAttribute("cert") : null;
if (cert == null) {
%>
<jsp:include page="Login.jsp" />
<%
return;
}
%>
<!-- SLS: c’est-il pas un peu crade ? -->
<%@page import="fr.unicaen.iota.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.utils.HTMLUtilities"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.dphi.utils.HTMLUtilities"%>
<%@page import="java.util.Date"%>
<%@page import="fr.unicaen.iota.auth.User"%>
<%@page import="fr.unicaen.iota.dphi.auth.User"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
......
<div class="treeTitle">&nbsp;</div>
<jsp:include page="dialogs.jsp" />
<%
UserInfoOut uInfo = (UserInfoOut) session.getAttribute("uInfo");
User u = new User(uInfo.getUserID(), uInfo.getOwnerID());
if (PEPRequester.checkAccess(u, "superadmin") != Result.DECISION_PERMIT) {
User user = (User) session.getAttribute("user");
if (PEPRequester.checkAccess(user, "superadmin") != Result.DECISION_PERMIT) {
%>
<jsp:include page="policyList.jsp" />
<%
} else {
}
else {
%>
<jsp:include page="rootMenu.jsp" />
<%
return;
}
String userId = ((UserInfoOut) session.getAttribute("uInfo")).getUserID();
String ownerId = ((UserInfoOut) session.getAttribute("uInfo")).getOwnerID();
String userId = user.getUserID();
String ownerId = user.getOwnerID();
%>
<div class="account">
<div class="logout"><a href="RootAccountAuth?action=logout">[ logout ]</a></div>
DSeTa/DiscoveryPHI/src/main/webapp/policyList.jsp
<%@page import="fr.unicaen.iota.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.xacml.ihm.factory.AccessPolicies"%>
<%@page import="fr.unicaen.iota.auth.User"%>
<%@page import="fr.unicaen.iota.xacml.ihm.Mode"%>
<%@page import="fr.unicaen.iota.xacml.ihm.TreeFactory"%>
<%@page import="fr.unicaen.iota.xacml.ihm.factory.Policies"%>
<%@page import="fr.unicaen.iota.xacml.ihm.NodeType"%>
<%@page import="fr.unicaen.iota.xacml.ihm.factory.Node"%>
<%@page import="fr.unicaen.iota.xacml.ihm.TreeNode"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.factory.AccessPolicies"%>
<%@page import="fr.unicaen.iota.dphi.auth.User"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.Mode"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.TreeFactory"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.factory.Policies"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.NodeType"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.factory.Node"%>
<%@page import="fr.unicaen.iota.dphi.xacml.ihm.TreeNode"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<script language="javascript">
DSeTa/DiscoveryPHI/src/main/webapp/rootMenu.jsp
<%@page import="fr.unicaen.iota.ypsilon.client.model.UserInfoOut"%>
<%@page import="fr.unicaen.iota.utils.HTMLUtilities"%>
<%@page import="fr.unicaen.iota.dphi.auth.User"%>
<div class="rootMenu">
<div class="rootMenuItem"><a href="#" onclick="processAccountCreate()" >Create Account</a></div>
<div class="rootMenuItem"><a href="#" onclick="processUpdateRootUser()" >Update root Account</a></div>
......
<div id="updateRootUser" title="Update User" class="modalDialog">
<div class="dialog_message">Enter user informations :</div>
<div class="dialog_options">Login : <input disabled id="userLogin2" type="text" value="<%=((UserInfoOut) session.getAttribute("uInfo")).getOwnerID()%>" /></div>
<div class="dialog_options">Login : <input disabled id="userLogin2" type="text" value="<%=((User) session.getAttribute("user")).getOwnerID()%>" /></div>
</div>
DSeTa/DiscoveryPHI/src/test/java/fr/unicaen/iota/dphi/xacml/ihm/test/DSPEP_TEST.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.dphi.xacml.ihm.test;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
import fr.unicaen.iota.xacml.request.EventRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class is used to manage the DS access control policy
*/
public class DSPEP_TEST {
private static String url;
private static final Log log = LogFactory.getLog(DSPEP_TEST.class);
public static void main(String[] args) {
url = args[0];
XACMLDSEvent dSEvent = new XACMLDSEvent("epcistest", "bizstep", "urn:epc:id:sgtin:1.3.325", "object", new Date());
int result = eventLookup("epcistest", dSEvent, "Query");
log.trace(result);
}
/**
* process access control policy for the Hello method.
* @param userId connected user
* @param ownerId corresponding ownerId
* @param module Query, Capture or Admin
* @return
*/
public static int hello(String userId, String ownerId, String module) {
log.trace("process hello policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "hello", ownerId, module);
return processXACMLRequest(eventRequest);
}
/**
* process access control policy for the eventLookup method for each retrieved event retriefed.
* @param userId connected user
* @param dsEvent the event
* @param module Query, Capture or Admin
* @return
*/
public static int eventLookup(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process eventLookup policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventLookup", dsEvent, module);
return processXACMLRequest(eventRequest);
}
/**
* process access control policy for the eventInfo method.
* @param userId connected user
* @param dsEvent
* @param module
* @return
*/
public static int eventInfo(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process eventInfo policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventInfo", dsEvent, module);
return processXACMLRequest(eventRequest);
}
public static int eventCreate(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process eventCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventCreate", dsEvent, module);
return processXACMLRequest(eventRequest);
}
public static int multipleEventCreate(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process multipleEventCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventLookup", dsEvent, module);
return processXACMLRequest(eventRequest);
}
public static int userLookup(String userId, String owner, String module) {
log.trace("process userLookup policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userLookup", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userCreate(String userId, String owner, String module) {
log.trace("process userCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userCreate", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userInfo(String userId, String owner, String module) {
log.trace("process userInfo policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userInfo", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userUpdate(String userId, String owner, String module) {
log.trace("process userUpdate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userUpdate", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userDelete(String userId, String owner, String module) {
log.trace("process userDelete policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userDelete", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerUpdate(String userId, String owner, String module) {
log.trace("process ownerUpdate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerUpdate", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerLookup(String userId, String owner, String module) {
log.trace("process ownerLookup policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerLookup", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerDelete(String userId, String owner, String module) {
log.trace("process ownerDelete policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerDelete", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerCreate(String userId, String owner, String module) {
log.trace("process ownerCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerCreate", owner, module);
return processXACMLRequest(eventRequest);
}
private static int processXACMLRequest(EventRequest eventRequest) {
int response = Result.DECISION_DENY;
try {
String respInString = sendXACMLRequest(eventRequest.createRequest());
response = Integer.parseInt(respInString);
} catch (Exception ex) {
log.error("", ex);
}
return response;
}
private static String sendXACMLRequest(RequestCtx xacmlReq) throws IOException {
HttpURLConnection httpConnection = getConnection("text/plain");
log.debug("Sending XACML request...");
xacmlReq.encode(httpConnection.getOutputStream());
log.debug("Getting XACML response...");
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpServletResponse.SC_OK) {
BufferedReader br = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
return sb.toString();
} else {
log.error("XACML module servlet response: " + responseCode);
return "DENY";
}
}
private static HttpURLConnection getConnection(final String contentType) throws IOException {
URL serviceUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
connection.setRequestProperty("content-type", contentType);
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
return connection;
}
}
DSeTa/DiscoveryPHI/src/test/java/fr/unicaen/iota/xacml/ihm/test/DSPEP_TEST.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2008-2012 Université de Caen Basse-Normandie, GREYC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.xacml.ihm.test;
import com.sun.xacml.ctx.RequestCtx;
import com.sun.xacml.ctx.Result;
import fr.unicaen.iota.xacml.pep.XACMLDSEvent;
import fr.unicaen.iota.xacml.request.EventRequest;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* This class is used to manage the DS access control policy
*/
public class DSPEP_TEST {
private static String url;
private static final Log log = LogFactory.getLog(DSPEP_TEST.class);
public static void main(String[] args) {
url = args[0];
XACMLDSEvent dSEvent = new XACMLDSEvent("epcistest", "bizstep", "urn:epc:id:sgtin:1.3.325", "object", new Date());
int result = eventLookup("epcistest", dSEvent, "Query");
log.trace(result);
}
/**
* process access control policy for the Hello method.
* @param userId connected user
* @param ownerId corresponding ownerId
* @param module Query, Capture or Admin
* @return
*/
public static int hello(String userId, String ownerId, String module) {
log.trace("process hello policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "hello", ownerId, module);
return processXACMLRequest(eventRequest);
}
/**
* process access control policy for the eventLookup method for each retrieved event retriefed.
* @param userId connected user
* @param dsEvent the event
* @param module Query, Capture or Admin
* @return
*/
public static int eventLookup(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process eventLookup policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventLookup", dsEvent, module);
return processXACMLRequest(eventRequest);
}
/**
* process access control policy for the eventInfo method.
* @param userId connected user
* @param dsEvent
* @param module
* @return
*/
public static int eventInfo(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process eventInfo policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventInfo", dsEvent, module);
return processXACMLRequest(eventRequest);
}
public static int eventCreate(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process eventCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventCreate", dsEvent, module);
return processXACMLRequest(eventRequest);
}
public static int multipleEventCreate(String userId, XACMLDSEvent dsEvent, String module) {
log.trace("process multipleEventCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "eventLookup", dsEvent, module);
return processXACMLRequest(eventRequest);
}
public static int userLookup(String userId, String owner, String module) {
log.trace("process userLookup policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userLookup", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userCreate(String userId, String owner, String module) {
log.trace("process userCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userCreate", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userInfo(String userId, String owner, String module) {
log.trace("process userInfo policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userInfo", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userUpdate(String userId, String owner, String module) {
log.trace("process userUpdate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userUpdate", owner, module);
return processXACMLRequest(eventRequest);
}
public static int userDelete(String userId, String owner, String module) {
log.trace("process userDelete policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "userDelete", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerUpdate(String userId, String owner, String module) {
log.trace("process ownerUpdate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerUpdate", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerLookup(String userId, String owner, String module) {
log.trace("process ownerLookup policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerLookup", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerDelete(String userId, String owner, String module) {
log.trace("process ownerDelete policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerDelete", owner, module);
return processXACMLRequest(eventRequest);
}
public static int ownerCreate(String userId, String owner, String module) {
log.trace("process ownerCreate policy for user : " + userId);
EventRequest eventRequest = new EventRequest(userId, "ownerCreate", owner, module);
return processXACMLRequest(eventRequest);
}
private static int processXACMLRequest(EventRequest eventRequest) {
int response = Result.DECISION_DENY;
try {
String respInString = sendXACMLRequest(eventRequest.createRequest());
response = Integer.parseInt(respInString);
} catch (Exception ex) {
log.error("", ex);
}
return response;
}
private static String sendXACMLRequest(RequestCtx xacmlReq) throws IOException {
HttpURLConnection httpConnection = getConnection("text/plain");
log.debug("Sending XACML request...");
xacmlReq.encode(httpConnection.getOutputStream());
log.debug("Getting XACML response...");
int responseCode = httpConnection.getResponseCode();
if (responseCode == HttpServletResponse.SC_OK) {
BufferedReader br = new BufferedReader(new InputStreamReader(httpConnection.getInputStream()));
StringBuilder sb = new StringBuilder();
String line;
while ((line = br.readLine()) != null) {
sb.append(line);
}
br.close();
return sb.toString();
} else {
log.error("XACML module servlet response: " + responseCode);
return "DENY";
}
}
private static HttpURLConnection getConnection(final String contentType) throws IOException {
URL serviceUrl = new URL(url);
HttpURLConnection connection = (HttpURLConnection) serviceUrl.openConnection();
connection.setRequestProperty("content-type", contentType);
connection.setRequestMethod("POST");
connection.setDoInput(true);
connection.setDoOutput(true);
return connection;
}
}
DSeTa/LibXACML-DS/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>libxacml-ds</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>LibXACML-DS</name>
ETa/ETa-Callback/ETa-Callback-Filter/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>eta-callback-filter</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>ETa-Callback-Filter</name>
......
</plugins>
</build>
<!--
<repositories>
<repository>
<id>fosstrak</id>
......
<url>http://oss.sonatype.org/content/repositories/public</url>
</repository>
</repositories>
-->
</project>
ETa/ETa-Callback/ETa-Callback-Receiver/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>eta-callback-receiver</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>ETa-Callback-Receiver</name>
ETa/ETa-Callback/ETa-Callback-Sender/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>eta-callback-sender</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>ETa-Callback-Sender</name>
ETa/ETa-Capture-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>eta-capture-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>ETa-Capture-Client</name>
ETa/ETa-Capture-Test/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>eta-capture-test</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>ETa-Capture-Test</name>
......
</build>
<!--
<repositories>
<repository>
<id>fosstrak</id>
......
<url>https://oss.sonatype.org/content/repositories/public</url>
</repository>
</repositories>
-->
</project>
ETa/ETa-Query-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>eta-query-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>ETa-Query-Client</name>
ETa/ETa/eta_schema.sql
-- MySQL dump 10.13 Distrib 5.1.63, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: gateway_db
-- ------------------------------------------------------
-- Server version 5.1.63-0+squeeze1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `subscription`
--
DROP TABLE IF EXISTS `subscription`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subscription` (
`subscriptionid` varchar(255) NOT NULL,
`user` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
PRIMARY KEY (`subscriptionid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `subscription`
--
LOCK TABLES `subscription` WRITE;
/*!40000 ALTER TABLE `subscription` DISABLE KEYS */;
/*!40000 ALTER TABLE `subscription` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2012-08-31 15:24:51
ETa/ETa/pom.xml
<artifactId>eta</artifactId>
<packaging>war</packaging>
<name>ETa Server</name>
<version>2.0</version>
<version>2.1</version>
<properties>
<epcis-version>0.5.0</epcis-version>
......
</build>
<!--
<repositories>
<repository>
<id>fosstrak</id>
......
<url>https://oss.sonatype.org/content/repositories/public</url>
</repository>
</repositories>
-->
</project>
ETa/ETa/src/main/java/fr/unicaen/iota/eta/query/QueryOperationsModule.java
String msg = "Paramters 'maxEventCount' and 'eventCountLimit' are mutually exclusive";
throw queryParameterException(msg, null);
}
if (paramOrderByIsPresent && eventCountLimit > -1) {
if (!paramOrderByIsPresent && eventCountLimit > -1) {
String msg = "'eventCountLimit' may only be used when 'orderBy' is specified";
throw queryParameterException(msg, null);
}
ETa/EpcisPHI/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>epcis-phi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>EpcisPHI</name>
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/utils/MapSessions.java
}
public static HashMap<String, InterfaceHelper> APMSessions = new HashMap<String, InterfaceHelper>();
public static synchronized InterfaceHelper getAPMSession(String sessionId, String ownerId) {
if (APMSessions.containsKey(sessionId)) {
return APMSessions.get(sessionId);
public static synchronized InterfaceHelper getAPMSession(String userId, String ownerId) {
if (APMSessions.containsKey(userId)) {
return APMSessions.get(userId);
} else {
InterfaceHelper IH = new InterfaceHelper(ownerId);
APMSessions.put(sessionId, IH);
APMSessions.put(userId, IH);
return IH;
}
}
public static synchronized void releaseSession(String sessionId) {
APMSessions.remove(sessionId);
public static synchronized void releaseSession(String userId) {
APMSessions.remove(userId);
}
public static synchronized void init() {
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/utils/SessionLoader.java
/*
* This program is a part of the IoTa project.
*
* Copyright © 2011-2013 Université de Caen Basse-Normandie, GREYC
* Copyright © 2011 Orange Labs
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* <http://www.gnu.org/licenses/>
*
* See AUTHORS for a list of contributors.
*/
package fr.unicaen.iota.epcisphi.utils;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserInfoOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import fr.unicaen.iota.ypsilon.client.soap.SecurityExceptionResponse;
import javax.servlet.http.HttpSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class SessionLoader {
private SessionLoader() {
}
private static final Log LOG = LogFactory.getLog(SessionLoader.class);
public static synchronized String loadSession(String sessionId, String userId, HttpSession session) throws SecurityExceptionResponse {
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME, Constants.PKS_PASSWORD,
Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
UserInfoOut uInfo = client.userInfo(sessionId, userId);
session.setAttribute("uInfo", uInfo);
session.setAttribute("session-id", sessionId);
return "";
} catch (ImplementationExceptionResponse ex) {
LOG.error("An error occurred", ex);
return "?message=" + ex.getMessage();
} catch (SecurityExceptionResponse ex) {
LOG.error("A security error occurred", ex);
return "?message=" + ex.getMessage();
}
}
public static void clearSession(HttpSession session) {
session.setAttribute("session-id", null);
session.setAttribute("uInfo", null);
// TODO session.setAttribute("pInfo", null);
}
}
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/xacml/ihm/factory/AccessPolicies.java
public AccessPolicies() {
}
public AccessPolicies(String sessionId, String owner) {
this.createQueryPolicies(sessionId, owner);
this.createCapturePolicies(sessionId, owner);
this.createAdminPolicies(sessionId, owner);
public AccessPolicies(String userId, String owner) {
this.createQueryPolicies(userId, owner);
this.createCapturePolicies(userId, owner);
this.createAdminPolicies(userId, owner);
}
public AccessPolicies(String sessionId, String owner, Module module) {
public AccessPolicies(String userId, String owner, Module module) {
switch (module) {
case adminModule:
this.createAdminPolicies(sessionId, owner);
this.createAdminPolicies(userId, owner);
break;
case queryModule:
this.createQueryPolicies(sessionId, owner);
this.createQueryPolicies(userId, owner);
break;
case captureModule:
this.createCapturePolicies(sessionId, owner);
this.createCapturePolicies(userId, owner);
break;
}
}
private synchronized void createQueryPolicies(String sessionId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(sessionId, owner).APMSession.getQueryPolicy(owner);
private synchronized void createQueryPolicies(String userId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(userId, owner).APMSession.getQueryPolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.queryModule, null);
if (ownerPolicies != null) {
for (Object ogp : ownerPolicies.getPolicies()) {
......
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper ih = MapSessions.getAPMSession(userId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.queryModule);
ih.APMSession.addQueryPolicy(ownerPolicies);
ih.APMSession.saveQueryPolicies(owner);
......
getPoliciesQuery().add(policies);
}
private synchronized void createCapturePolicies(String sessionId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(sessionId, owner).APMSession.getCapturePolicy(owner);
private synchronized void createCapturePolicies(String userId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(userId, owner).APMSession.getCapturePolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.captureModule, null);
if (ownerPolicies != null) {
......
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper ih = MapSessions.getAPMSession(userId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.captureModule);
ih.APMSession.addCapturePolicy(ownerPolicies);
// createCapturePolicies(sessionId, owner);
......
getPoliciesCapture().add(policies);
}
private synchronized void createAdminPolicies(String sessionId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(sessionId, owner).APMSession.getAdminPolicy(owner);
private synchronized void createAdminPolicies(String userId, String owner) {
OwnerPolicies ownerPolicies = MapSessions.getAPMSession(userId, owner).APMSession.getAdminPolicy(owner);
Node policies = new Node("", NodeType.policiesNode, null, Module.adminModule, null);
if (ownerPolicies != null) {
......
}
}
} else {
InterfaceHelper ih = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper ih = MapSessions.getAPMSession(userId, owner);
ownerPolicies = new OwnerPolicies(owner, fr.unicaen.iota.xacml.policy.Module.administrationModule);
ih.APMSession.addAdminPolicy(ownerPolicies);
ih.APMSession.saveAdminPolicies(owner);
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/xacml/ihm/factory/EventTimeTreeNode.java
@Override
public String getLabel() {
Calendar cal = Calendar.getInstance();
cal.setTime(minDate);
StringBuilder res = new StringBuilder();
int m = cal.get(Calendar.MONTH);
if (m < 10) {
res.append("0");
}
res.append(m);
res.append("/");
int d = cal.get(Calendar.DAY_OF_MONTH);
if (d < 10) {
res.append("0");
}
res.append(d);
res.append("/");
res.append(cal.get(Calendar.YEAR));
res.append(" -> ");
cal.setTime(maxDate);
m = cal.get(Calendar.MONTH);
if (m < 10) {
res.append("0");
}
res.append(m);
res.append("/");
d = cal.get(Calendar.DAY_OF_MONTH);
if (d < 10) {
res.append("0");
}
res.append(d);
res.append("/");
res.append(cal.get(Calendar.YEAR));
return res.toString();
Calendar calMin = Calendar.getInstance();
calMin.setTime(minDate);
Calendar calMax = Calendar.getInstance();
calMax.setTime(maxDate);
return String.format("%1$tm/%1$td/%1$tY -> %2$tm/%2$td/%2$tY", calMin, calMax);
}
@Override
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/xacml/ihm/factory/RecordTimeTreeNode.java
@Override
public String getLabel() {
Calendar cal = Calendar.getInstance();
cal.setTime(minDate);
StringBuilder res = new StringBuilder();
int m = cal.get(Calendar.MONTH);
if (m < 10) {
res.append("0");
}
res.append(m);
res.append("/");
int d = cal.get(Calendar.DAY_OF_MONTH);
if (d < 10) {
res.append("0");
}
res.append(d);
res.append("/");
res.append(cal.get(Calendar.YEAR));
res.append(" -> ");
cal.setTime(maxDate);
m = cal.get(Calendar.MONTH);
if (m < 10) {
res.append("0");
}
res.append(m);
res.append("/");
d = cal.get(Calendar.DAY_OF_MONTH);
if (d < 10) {
res.append("0");
}
res.append(d);
res.append("/");
res.append(cal.get(Calendar.YEAR));
return res.toString();
Calendar calMin = Calendar.getInstance();
calMin.setTime(minDate);
Calendar calMax = Calendar.getInstance();
calMax.setTime(maxDate);
return String.format("%1$tm/%1$td/%1$tY -> %2$tm/%2$td/%2$tY", calMin, calMax);
}
@Override
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/xacml/servlet/AccessControlPolicy.java
import fr.unicaen.iota.epcisphi.xacml.ihm.*;
import fr.unicaen.iota.epcisphi.xacml.ihm.factory.AccessPolicies;
import fr.unicaen.iota.epcisphi.xacml.ihm.factory.Node;
import fr.unicaen.iota.mu.Utils;
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.ypsilon.client.model.UserInfoOut;
import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.ServletException;
......
// ************************** CREATE *********************************
try {
if (request.getSession().getAttribute("session-id") == null) {
if (request.getSession().getAttribute("user") == null || request.getSession().getAttribute("cert") == null) {
throw new ServiceException("Session expired you have to reconnect !", ServiceErrorType.epcis);
}
UserInfoOut userInfo = (UserInfoOut) request.getSession().getAttribute("uInfo");
if (userInfo == null) {
throw new ServiceException("User not well connected !", ServiceErrorType.epcis);
String dn = (request.getUserPrincipal() != null) ? request.getUserPrincipal().getName() : null;
if (request.getSession().getAttribute("cert") != null) {
String cert = (String) request.getSession().getAttribute("cert");
if (!cert.equals(Utils.formatId(dn))) {
throw new ServiceException("Don't change your certificate!", ServiceErrorType.Unknown);
}
}
User user = new User(userInfo.getUserID(), userInfo.getOwnerID());
User user = (User) request.getSession().getAttribute("user");
Module module = (request.getParameter("d") != null)? Module.valueOf(request.getParameter("d")) : null;
String objectId = request.getParameter("b");
String groupId = request.getParameter("e");
String methodName = request.getParameter("a");
String sessionId = (String) request.getSession().getAttribute("session-id");
String userId = user.getUserID();
// ************************** CREATE *********************************
if ("createOwnerGroup".equals(methodName)) {
String newValue = request.getParameter("c");
String resp = services.createOwnerGroup(sessionId, user, module, newValue);
String resp = services.createOwnerGroup(userId, user, module, newValue);
TreeNode node = createEmptyPolicies(user, newValue, module, resp);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addOwnerToGroup".equals(methodName)) {
String newValue = request.getParameter("c");
services.addOwnerToGroup(sessionId, user, module, objectId, groupId, newValue);
services.addOwnerToGroup(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.userNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addBizStepRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addBizStepRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addBizStepRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.bizStepFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addEpcRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addEpcRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addEpcRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.epcFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addEventTimeRestriction".equals(methodName)) {
String d1 = request.getParameter("d1");
String d2 = request.getParameter("d2");
services.addEventTimeRestriction(sessionId, user, module, objectId, groupId, d1, d2);
services.addEventTimeRestriction(userId, user, module, objectId, groupId, d1, d2);
TreeNode node = new Node(d1 + " -> " + d2, NodeType.eventTimeFilterNode, d1 + " -> " + d2, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addRecordTimeRestriction".equals(methodName)) {
String d1 = request.getParameter("d1");
String d2 = request.getParameter("d2");
services.addRecordTimeRestriction(sessionId, user, module, objectId, groupId, d1, d2);
services.addRecordTimeRestriction(userId, user, module, objectId, groupId, d1, d2);
TreeNode node = new Node(d1 + " -> " + d2, NodeType.recordTimeFilterNode, d1 + " -> " + d2, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addOperationRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addOperationRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addOperationRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.operationFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addEventTypeRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addEventTypeRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addEventTypeRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.eventTypeFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addParentIdRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addParentIdRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addParentIdRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.parentIdFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addChildEpcRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addChildEpcRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addChildEpcRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.childEpcFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addQuantityRestriction".equals(methodName)) {
String d1 = request.getParameter("d1");
String d2 = request.getParameter("d2");
services.addQuantityRestriction(sessionId, user, module, objectId, groupId, d1, d2);
services.addQuantityRestriction(userId, user, module, objectId, groupId, d1, d2);
TreeNode node = new Node(d1 + " -> " + d2, NodeType.quantityFilterNode, d1 + " -> " + d2, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addReadPointRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addReadPointRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addReadPointRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.readPointFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addBizLocRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addBizLocRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addBizLocRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.bizLocFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addDispositionRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addDispositionRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addDispositionRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.dispositionFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addMasterDataIdRestriction".equals(methodName)) {
String newValue = request.getParameter("c");
services.addMasterDataIdRestriction(sessionId, user, module, objectId, groupId, newValue);
services.addMasterDataIdRestriction(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.masterDataIdFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} else if ("addUserPermission".equals(methodName)) {
String newValue = request.getParameter("c");
services.addUserPermission(sessionId, user, module, objectId, groupId, newValue);
services.addUserPermission(userId, user, module, objectId, groupId, newValue);
TreeNode node = new Node(newValue, NodeType.methodFilterNode, newValue, module, groupId);
html.append(new TreeFactory(Mode.Assert_Mode).createTree(node));
} // ************************** SWITCH *********************************
else if ("switchBizStepPolicy".equals(methodName)) {
html.append(services.switchBizStepPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchBizStepPolicy(userId, user, module, objectId, groupId));
} else if ("switchEpcPolicy".equals(request.getParameter("a"))) {
html.append(services.switchEpcPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchEpcPolicy(userId, user, module, objectId, groupId));
} else if ("switchEventTimePolicy".equals(methodName)) {
html.append(services.switchEventTimePolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchEventTimePolicy(userId, user, module, objectId, groupId));
} else if ("switchRecordTimePolicy".equals(methodName)) {
html.append(services.switchRecordTimePolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchRecordTimePolicy(userId, user, module, objectId, groupId));
} else if ("switchOperationPolicy".equals(methodName)) {
html.append(services.switchOperationPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchOperationPolicy(userId, user, module, objectId, groupId));
} else if ("switchEventTypePolicy".equals(methodName)) {
html.append(services.switchEventTypePolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchEventTypePolicy(userId, user, module, objectId, groupId));
} else if ("switchParentIdPolicy".equals(methodName)) {
html.append(services.switchParentIdPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchParentIdPolicy(userId, user, module, objectId, groupId));
} else if ("switchChildEpcPolicy".equals(methodName)) {
html.append(services.switchChildEpcPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchChildEpcPolicy(userId, user, module, objectId, groupId));
} else if ("switchQuantityPolicy".equals(methodName)) {
html.append(services.switchQuantityPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchQuantityPolicy(userId, user, module, objectId, groupId));
} else if ("switchReadPointPolicy".equals(methodName)) {
html.append(services.switchReadPointPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchReadPointPolicy(userId, user, module, objectId, groupId));
} else if ("switchBizLocPolicy".equals(methodName)) {
html.append(services.switchBizLocPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchBizLocPolicy(userId, user, module, objectId, groupId));
} else if ("switchDispositionPolicy".equals(methodName)) {
html.append(services.switchDispositionPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchDispositionPolicy(userId, user, module, objectId, groupId));
} else if ("switchMasterDataIdPolicy".equals(methodName)) {
html.append(services.switchMasterDataIdPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchMasterDataIdPolicy(userId, user, module, objectId, groupId));
} else if ("switchPermissionPolicy".equals(methodName)) {
html.append(services.switchUserPermissionPolicy(sessionId, user, module, objectId, groupId));
html.append(services.switchUserPermissionPolicy(userId, user, module, objectId, groupId));
} // ************************** REMOVE *********************************
else if ("removeBizStepRestriction".equals(methodName)) {
services.removeBizStepRestriction(sessionId, user, module, objectId, groupId);
services.removeBizStepRestriction(userId, user, module, objectId, groupId);
} else if ("removeEpcRestriction".equals(methodName)) {
services.removeEpcRestriction(sessionId, user, module, objectId, groupId);
services.removeEpcRestriction(userId, user, module, objectId, groupId);
} else if ("removeEventTimeRestriction".equals(methodName)) {
services.removeEventTimeRestriction(sessionId, user, module, objectId, groupId);
services.removeEventTimeRestriction(userId, user, module, objectId, groupId);
} else if ("removeRecordTimeRestriction".equals(methodName)) {
services.removeRecordTimeRestriction(sessionId, user, module, objectId, groupId);
services.removeRecordTimeRestriction(userId, user, module, objectId, groupId);
} else if ("removeOperationRestriction".equals(methodName)) {
services.removeOperationRestriction(sessionId, user, module, objectId, groupId);
services.removeOperationRestriction(userId, user, module, objectId, groupId);
} else if ("removeEventTypeRestriction".equals(methodName)) {
services.removeEventTypeRestriction(sessionId, user, module, objectId, groupId);
services.removeEventTypeRestriction(userId, user, module, objectId, groupId);
} else if ("removeParentIdRestriction".equals(methodName)) {
services.removeParentIdRestriction(sessionId, user, module, objectId, groupId);
services.removeParentIdRestriction(userId, user, module, objectId, groupId);
} else if ("removeChildEpcRestriction".equals(methodName)) {
services.removeChildEpcRestriction(sessionId, user, module, objectId, groupId);
services.removeChildEpcRestriction(userId, user, module, objectId, groupId);
} else if ("removeQuantityRestriction".equals(methodName)) {
services.removeQuantityRestriction(sessionId, user, module, objectId, groupId);
services.removeQuantityRestriction(userId, user, module, objectId, groupId);
} else if ("removeReadPointRestriction".equals(methodName)) {
services.removeReadPointRestriction(sessionId, user, module, objectId, groupId);
services.removeReadPointRestriction(userId, user, module, objectId, groupId);
} else if ("removeBizLocRestriction".equals(methodName)) {
services.removeBizLocRestriction(sessionId, user, module, objectId, groupId);
services.removeBizLocRestriction(userId, user, module, objectId, groupId);
} else if ("removeDispositionRestriction".equals(methodName)) {
services.removeDispositionRestriction(sessionId, user, module, objectId, groupId);
services.removeDispositionRestriction(userId, user, module, objectId, groupId);
} else if ("removeMasterDataIdRestriction".equals(methodName)) {
services.removeMasterDataIdRestriction(sessionId, user, module, objectId, groupId);
services.removeMasterDataIdRestriction(userId, user, module, objectId, groupId);
} else if ("removeUserPermission".equals(methodName)) {
services.removeUserPermission(sessionId, user, module, objectId, groupId);
services.removeUserPermission(userId, user, module, objectId, groupId);
} else if ("deleteOwnerGroup".equals(methodName)) {
services.deleteOwnerGroup(sessionId, user, module, objectId, groupId);
services.deleteOwnerGroup(userId, user, module, objectId, groupId);
} else if ("removeOwnerFromGroup".equals(methodName)) {
services.removeOwnerFromGroup(sessionId, user, module, objectId, groupId);
services.removeOwnerFromGroup(userId, user, module, objectId, groupId);
} // ************************* EPCIS ADMIN ********************************
else if ("updateOwner".equals(methodName)) {
String ownerID = request.getParameter("f");
......
} else if ("createUser".equals(methodName)) {
String login = request.getParameter("f");
String userName = request.getParameter("g");
services.createUser(sessionId, user, login, userName);
services.createUser(user, login, userName);
} else if ("updateUser".equals(methodName)) {
String login = request.getParameter("f");
//TODO services.updateUser(sessionId, user, login, pass);
} else if ("deleteUser".equals(methodName)) {
String login = request.getParameter("f");
services.deleteUser(sessionId, user, login);
services.deleteUser(user, login);
} else if ("createAccount".equals(methodName)) {
String userDN = request.getParameter("f");
String ownerId = request.getParameter("g");
String userName = request.getParameter("h");
boolean rtr = services.createAccount(sessionId, user, ownerId, userDN, userName);
boolean rtr = services.createAccount(user, ownerId, userDN, userName);
if (rtr) {
html.append("Account successfull created.");
}
} // ************************** UPDATE *********************************
else if ("updateGroupName".equals(methodName)) {
String newValue = request.getParameter("c");
services.updateGroupName(sessionId, user, module, objectId, groupId, newValue);
services.updateGroupName(userId, user, module, objectId, groupId, newValue);
} // ************************** SAVE **********************************
else if ("savePolicyOwner".equals(methodName)) {
services.savePolicyOwner(sessionId, user, module);
services.savePolicyOwner(userId, user, module);
} // ************************** CANCEL **********************************
else if ("cancelOwnerPolicy".equals(methodName)) {
......
} // ************************** LOAD POLICIES *************************
else if ("loadPolicyTree".equals(methodName)) {
services.loadPolicyTree(user, module);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, user.getOwnerID());
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, user.getOwnerID());
interfaceHelper.reload();
AccessPolicies policies = new AccessPolicies(sessionId, user.getOwnerID(), module);
AccessPolicies policies = new AccessPolicies(userId, user.getOwnerID(), module);
switch (module) {
case adminModule:
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesAdmin().get(0)));
......
html.append(new TreeFactory(Mode.Create_Mode).createTree(policies.getPoliciesCapture().get(0)));
break;
}
} else {
}
else {
throw new ServiceException("service method " + methodName + " not found !", ServiceErrorType.Unknown);
}
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.RESPONSE_OK, "") + createXMLHTMLTag(html.toString())));
} catch (ServiceException se) {
log.info("", se);
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.RESPONSE_ERROR, se.getMessage()) + createXMLHTMLTag(html.toString())));
return;
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.RESPONSE_ERROR, se.getMessage())
+ createXMLHTMLTag(html.toString())));
} catch (Exception e) {
log.info("", e);
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.RESPONSE_ERROR, "INTERNAL ERROR: " + e.getMessage()) + createXMLHTMLTag(html.toString())));
return;
out.print(createXMLEnvelop(createXMLRespondeHeader(Response.RESPONSE_ERROR, "INTERNAL ERROR: "
+ e.getMessage()) + createXMLHTMLTag(html.toString())));
}
} finally {
out.close();
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/xacml/servlet/RootAccountAuth.java
import fr.unicaen.iota.epcisphi.utils.Constants;
import fr.unicaen.iota.epcisphi.utils.MapSessions;
import fr.unicaen.iota.epcisphi.utils.SessionLoader;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.epcisphi.utils.User;
import fr.unicaen.iota.mu.Utils;
import fr.unicaen.iota.ypsilon.client.model.UserLoginOut;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserLookupOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import fr.unicaen.iota.ypsilon.client.soap.SecurityExceptionResponse;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
......
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String message = "";
if ("login".equals(request.getParameter("action"))) {
String login = (request.getUserPrincipal() != null)? request.getUserPrincipal().getName() : null;
if (login == null || login.isEmpty()) {
message = "?message=You are not authenticated.";
request.setAttribute("message", "You are not authenticated.");
} else {
login = Utils.formatId(login);
UserLoginOut userLoginOut;
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
YPSilonClient ypsilonClient = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
userLoginOut = client.userCertLogin(login);
request.setAttribute("session-id", userLoginOut.getSid());
message = SessionLoader.loadSession(userLoginOut.getSid(), login, request.getSession());
UserLookupOut userLookupOut = ypsilonClient.userLookup(login);
if (userLookupOut.getUserList().isEmpty()) {
throw new ImplementationExceptionResponse("User not found");
}
User user = new User();
user.setUserID(login);
user.setOwnerID(userLookupOut.getUserList().get(0).getOwner());
request.getSession().setAttribute("user", user);
request.getSession().setAttribute("cert", login);
} catch (ImplementationExceptionResponse ex) {
message = "?message=" + ex.getMessage();
request.setAttribute("message", ex.getMessage());
LOG.error("impl", ex);
} catch (SecurityExceptionResponse ex) {
message = "?message=" + ex.getMessage();
LOG.error("secur", ex);
}
}
request.getRequestDispatcher("index.jsp").forward(request, response);
} else if ("logout".equals(request.getParameter("action"))) {
String sessionId = (String) (request.getSession().getAttribute("session-id"));
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
client.userLogout(sessionId);
SessionLoader.clearSession(request.getSession());
MapSessions.releaseSession(sessionId);
} catch (ImplementationExceptionResponse ex) {
message = "?message=" + ex.getMessage();
} catch (SecurityExceptionResponse ex) {
message = "?message=" + ex.getMessage();
}
request.getSession().setAttribute("session-id", null);
MapSessions.releaseSession(sessionId);
String cert = (String) (request.getSession().getAttribute("cert"));
MapSessions.releaseSession(cert);
request.getSession().setAttribute("user", null);
request.getSession().setAttribute("cert", null);
response.sendRedirect("index.jsp");
}
response.sendRedirect(getServletContext().getContextPath() + "/index.jsp" + message);
}
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
ETa/EpcisPHI/src/main/java/fr/unicaen/iota/epcisphi/xacml/servlet/Services.java
import fr.unicaen.iota.xacml.policy.GroupPolicy;
import fr.unicaen.iota.xacml.policy.OwnerPolicies;
import fr.unicaen.iota.ypsilon.client.YPSilonClient;
import fr.unicaen.iota.ypsilon.client.model.UserInfoOut;
import fr.unicaen.iota.ypsilon.client.soap.ImplementationExceptionResponse;
import fr.unicaen.iota.ypsilon.client.soap.SecurityExceptionResponse;
import java.lang.reflect.Method;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import org.apache.commons.logging.Log;
......
}
}
public String createOwnerGroup(String sessionId, User user, Module module, String value) throws ServiceException {
public String createOwnerGroup(String userId, User user, Module module, String value) throws ServiceException {
String method = module == Module.adminModule ? "createAdminOwnerGroup" : "createOwnerGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
return value;
}
public void deleteOwnerGroup(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void deleteOwnerGroup(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "deleteAdminOwnerGroup" : "deleteOwnerGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addOwnerToGroup(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addOwnerToGroup(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "addAdminOwnerToGroup" : "addOwnerToGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeOwnerFromGroup(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeOwnerFromGroup(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "removeAdminOwnerFromGroup" : "removeOwnerFromGroup";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addBizStepRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addBizStepRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addBizStepRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeBizStepRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeBizStepRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeBizStepRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addEpcRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addEpcRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addEpcRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeEpcRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeEpcRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEpcRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addEventTimeRestriction(String sessionId, User user, Module module, String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
public void addEventTimeRestriction(String userId, User user, Module module, String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
checkAccess(user, module, "addEventTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEventTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEventTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case adminModule:
break;
try {
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryEventTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureEventTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case adminModule:
break;
}
} catch (ParseException ex) {
throw new ServiceException("addRecordTimeRestriction: parsing error: " + ex.getMessage(), ServiceErrorType.xacml);
}
if (!resp) {
throw new ServiceException("addEventTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeEventTimeRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeEventTimeRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEventTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEventTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEventTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case adminModule:
break;
try {
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryEventTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureEventTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case adminModule:
break;
}
} catch (ParseException ex) {
throw new ServiceException("addRecordTimeRestriction: parsing error: " + ex.getMessage(), ServiceErrorType.xacml);
}
if (!resp) {
throw new ServiceException("removeEventTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addRecordTimeRestriction(String sessionId, User user, Module module, String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
public void addRecordTimeRestriction(String userId, User user, Module module, String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
checkAccess(user, module, "addRecordTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryRecordTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureRecordTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case adminModule:
break;
try {
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.addQueryRecordTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case captureModule:
resp = interfaceHelper.APMSession.addCaptureRecordTimeFilter(owner, groupId, convertStringToDate(valueMin, valueMax));
break;
case adminModule:
break;
}
} catch (ParseException ex) {
throw new ServiceException("addRecordTimeRestriction: parsing error: " + ex.getMessage(), ServiceErrorType.xacml);
}
if (!resp) {
throw new ServiceException("addRecordTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void removeRecordTimeRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeRecordTimeRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeRecordTimeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryRecordTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureRecordTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case adminModule:
break;
try {
switch (module) {
case queryModule:
resp = interfaceHelper.APMSession.removeQueryRecordTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case captureModule:
resp = interfaceHelper.APMSession.removeCaptureRecordTimeFilter(owner, groupId, convertStringToDate(objectId));
break;
case adminModule:
break;
}
} catch (ParseException ex) {
throw new ServiceException("addRecordTimeRestriction: parsing error: " + ex.getMessage(), ServiceErrorType.xacml);
}
if (!resp) {
throw new ServiceException("removeRecordTimeRestriction: internal error in module: " + module, ServiceErrorType.xacml);
}
}
public void addOperationRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addOperationRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addOperationRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeOperationRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeOperationRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeOperationRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addEventTypeRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addEventTypeRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addEventTypeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeEventTypeRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeEventTypeRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeEventTypeRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addParentIdRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addParentIdRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addParentIdRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeParentIdRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeParentIdRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeParentIdRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addChildEpcRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addChildEpcRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addChildEpcRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeChildEpcRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeChildEpcRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeChildEpcRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addQuantityRestriction(String sessionId, User user, Module module, String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
public void addQuantityRestriction(String userId, User user, Module module, String objectId, String groupId, String valueMin, String valueMax) throws ServiceException {
checkAccess(user, module, "addQuantityRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
List quantities = new ArrayList();
quantities.add(Long.valueOf(valueMin));
......
}
}
public void removeQuantityRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeQuantityRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeQuantityRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addReadPointRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addReadPointRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addReadPointRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeReadPointRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeReadPointRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeReadPointRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addBizLocRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addBizLocRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addBizLocRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeBizLocRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeBizLocRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeBizLocRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addDispositionRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addDispositionRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addDispositionRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeDispositionRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeDispositionRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeDispositionRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addMasterDataIdRestriction(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addMasterDataIdRestriction(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
checkAccess(user, module, "addMasterDataIdRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void removeMasterDataIdRestriction(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeMasterDataIdRestriction(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "removeMasterDataIdRestriction");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public String switchBizStepPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchBizStepPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchBizStepPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchEpcPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchEpcPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEpcPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchEventTimePolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchEventTimePolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEventTimePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchRecordTimePolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchRecordTimePolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchRecordTimePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchOperationPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchOperationPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchOperationPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchEventTypePolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchEventTypePolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchEventTypePolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchParentIdPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchParentIdPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchParentIdPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchChildEpcPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchChildEpcPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchChildEpcPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchQuantityPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchQuantityPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchQuantityPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchReadPointPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchReadPointPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchReadPointPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchBizLocPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchBizLocPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchBizLocPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchDispositionPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchDispositionPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchDispositionPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchMasterDataIdPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchMasterDataIdPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
checkAccess(user, module, "switchMasterDataIdPolicy");
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public String switchUserPermissionPolicy(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public String switchUserPermissionPolicy(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "switchAdminUserPermissionPolicy" : "switchUserPermissionPolicy";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
String value = "";
switch (module) {
......
return value;
}
public void removeUserPermission(String sessionId, User user, Module module, String objectId, String groupId) throws ServiceException {
public void removeUserPermission(String userId, User user, Module module, String objectId, String groupId) throws ServiceException {
String method = module == Module.adminModule ? "removeAdminUserPermission" : "removeUserPermission";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void addUserPermission(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void addUserPermission(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "addAdminUserPermission" : "addUserPermission";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void updateGroupName(String sessionId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
public void updateGroupName(String userId, User user, Module module, String objectId, String groupId, String value) throws ServiceException {
String method = module == Module.adminModule ? "updateAdminGroupName" : "updateGroupName";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void savePolicyOwner(String sessionId, User user, Module module) throws ServiceException {
public void savePolicyOwner(String userId, User user, Module module) throws ServiceException {
String method = module == Module.adminModule ? "saveAdminPolicyOwner" : "savePolicyOwner";
checkAccess(user, module, method);
String owner = user.getOwnerID();
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(sessionId, owner);
InterfaceHelper interfaceHelper = MapSessions.getAPMSession(userId, owner);
boolean resp = false;
switch (module) {
case queryModule:
......
}
}
public void createUser(String sessionId, User user, String login, String userName) throws ServiceException {
public void createUser(User user, String userDN, String userName) throws ServiceException {
checkAccess(user, Module.adminModule, "userCreate");
try {
String owner = user.getOwnerID();
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
if (userName != null && !userName.isEmpty()) {
client.userCreate(sessionId, login, owner, userName, 30);
client.userCreate(userDN, owner, userName);
}
else {
client.userCreate(sessionId, login, owner, 30);
client.userCreate(userDN, owner);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.Unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.Unknown);
}
}
public void deleteUser(String sessionId, User user, String login) throws ServiceException {
public void deleteUser(User user, String userId) throws ServiceException {
checkAccess(user, Module.adminModule, "userDelete");
try {
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
client.userDelete(sessionId, login);
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
UserInfoOut userInfo = client.userInfo(userId);
if (userInfo.getUser() != null && userInfo.getUser().getOwner() != null
&& !userInfo.getUser().getOwner().isEmpty() && userInfo.getUser().getOwner().equals(user.getUserID())) {
client.userDelete(userId);
}
else {
throw new ServiceException("You can't delete this user.", ServiceErrorType.xacml);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.Unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.Unknown);
}
}
......
* ServiceErrorType.Unknown); } catch (EnancedProtocolException ex) { throw
* new ServiceException(ex.getMessage(), ServiceErrorType.Unknown); } }
*/
public void createRootOwnerPolicy(String sessionId, String userId, String ownerId) {
public void createRootOwnerPolicy(String userId, String ownerId) {
String gpName = "admin";
InterfaceHelper ih = new InterfaceHelper(ownerId);
OwnerPolicies ownerPolicies = new OwnerPolicies(ownerId, fr.unicaen.iota.xacml.policy.Module.administrationModule);
......
log.debug(MapSessions.AdminAPMtoString());
}
public boolean createAccount(String sessionId, User user, String ownerId, String userDN, String userName) throws ServiceException {
public boolean createAccount(User user, String ownerId, String userDN, String userName) throws ServiceException {
checkAccess(user, Module.adminModule, "superadmin");
try {
String userId = (userName != null && !userName.isEmpty())? userName : userDN;
YPSilonClient client = new YPSilonClient(Constants.YPSILON_ADDRESS, Constants.PKS_FILENAME,
Constants.PKS_PASSWORD, Constants.TRUST_PKS_FILENAME, Constants.TRUST_PKS_PASSWORD);
boolean found = false;
try {
client.userInfo(sessionId, userId);
found = true;
} catch (ImplementationExceptionResponse ex) {
log.trace(null, ex);
} catch (SecurityExceptionResponse ex) {
log.trace(null, ex);
}
if (found) {
throw new ServiceException("User exists", ServiceErrorType.Unknown);
}
if (userName != null && !userName.isEmpty()) {
client.userCreate(sessionId, userDN, ownerId, userName, 30);
createRootOwnerPolicy(sessionId, userName, ownerId);
if (client.userInfo(userDN).getUser() == null) {
client.userCreate(userDN, ownerId, userName);
}
createRootOwnerPolicy(userName, ownerId);
}
else {
client.userCreate(sessionId, userDN, ownerId, 30);
createRootOwnerPolicy(sessionId, userDN, ownerId);
if (client.userInfo(userDN).getUser() == null) {
client.userCreate(userDN, ownerId);
}
createRootOwnerPolicy(userDN, ownerId);
}
} catch (ImplementationExceptionResponse ex) {
log.error("Internal error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.Unknown);
} catch (SecurityExceptionResponse ex) {
log.error("Security error", ex);
throw new ServiceException(ex.getMessage(), ServiceErrorType.Unknown);
}
return true;
}
......
public void cancelOwnerPolicy(User user, Module module) {
}
private List convertStringToDate(String dateInString) {
private List<Date> convertStringToDate(String dateInString) throws ParseException {
List dates = new ArrayList();
String[] datesStringTab = dateInString.split(" -> ");
for (int i = 0; i < datesStringTab.length; i++) {
String[] dateValue = datesStringTab[i].split("/");
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(dateValue[2]), Integer.parseInt(dateValue[0]) - 1, Integer.parseInt(dateValue[1]), 0, 0, 0);
long time = cal.getTimeInMillis() - cal.get(Calendar.MILLISECOND);
Date date = new Date(time);
dates.add(date);
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
dates.add(formatter.parse(datesStringTab[i]));
}
return dates;
}
private List convertStringToDate(String dateMinInString, String dateMaxInString) {
private List<Date> convertStringToDate(String dateMinInString, String dateMaxInString) throws ParseException {
List dates = new ArrayList();
String[] datesStringTab = {dateMinInString, dateMaxInString};
for (int i = 0; i < datesStringTab.length; i++) {
String[] dateValue = datesStringTab[i].split("/");
Calendar cal = Calendar.getInstance();
cal.set(Integer.parseInt(dateValue[2]), Integer.parseInt(dateValue[0]) - 1, Integer.parseInt(dateValue[1]), 0, 0, 0);
long time = cal.getTimeInMillis() - cal.get(Calendar.MILLISECOND);
Date date = new Date(time);
dates.add(date);
SimpleDateFormat formatter = new SimpleDateFormat("MM/dd/yyyy");
dates.add(formatter.parse(datesStringTab[i]));
}
return dates;
}
ETa/EpcisPHI/src/main/webapp/Login.jsp
<body>
<h2>EPCIS ACCESS CONTROL CENTER</h2>
<%
if (request.getParameter("message") != null) {
if (request.getAttribute("message") != null) {
String message = (String) request.getAttribute("message");
message = message.replaceAll("<", "&#60;");
message = message.replaceAll(">", "&#62;");
%>
<div style="color:red;text-align:center;font-weight:bold;"><%=request.getParameter("message")%></div>
<div style="color:red;text-align:center;font-weight:bold;"><%= message %></div>
<%
}
%>
ETa/EpcisPHI/src/main/webapp/WEB-INF/web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>EpcisPHiSecure</web-resource-name>
<url-pattern>/RootAccountAuth</url-pattern>
<url-pattern>/*</url-pattern>
<http-method>GET</http-method>
<http-method>POST</http-method>
</web-resource-collection>
ETa/EpcisPHI/src/main/webapp/dialogs.jsp
<%@page import="fr.unicaen.iota.ypsilon.client.model.UserInfoOut"%>
<%@page import="fr.unicaen.iota.epcisphi.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.epcisphi.utils.HTMLUtilities"%>
<%
String ownerId = ((UserInfoOut) session.getAttribute("uInfo")).getOwnerID();
%>
<div id="createUser" title="Create User" class="modalDialog">
<div class="dialog_message">Enter user informations :</div>
<div class="dialog_options">User's certificate DN used to connect: <input id="userLogin" type="text" value="" /></div>
......
<div id="updateOwner" title="Update Owner Informations" class="modalDialog">
<div class="dialog_message">Enter the new Owner informations :</div>
<div class="dialog_options">Owner Id : <input disabled id="ownerID" type="text" value="<%=ownerId%>" /></div>
<div class="dialog_options">Owner Id : <input disabled id="ownerID" type="text" /></div>
</div>
<div id="GroupDialog" title="Group Name" class="modalDialog">
......
<div id="usersDialog" title="Add User" class="modalDialog">
<div class="dialog_message">Choose a new user you want to associate in this group :</div>
<div class="dialog_options">User : <input type="text" value="" id="groupPartnerName" /></div>
<div class="dialog_options">User : <input type="text" value="" id="groupOwnerName" /></div>
</div>
<div id="userAdminPermissionDialog" title="Add user permissions" class="modalDialog">
ETa/EpcisPHI/src/main/webapp/index.jsp
<%@page import="fr.unicaen.iota.epcisphi.utils.SessionLoader"%>
<%@page import="com.sun.xacml.ctx.Result"%>
<%@page import="fr.unicaen.iota.epcisphi.utils.PEPRequester"%>
<%@page import="fr.unicaen.iota.ypsilon.client.model.UserInfoOut"%>
<%
String sessionId = (String) session.getAttribute("session-id");
String sid = (String) request.getParameter("sid");
String uid = (String) request.getParameter("uid");
if (sid != null) {
String message = SessionLoader.loadSession(sid, uid, session);
if (!message.equals("")) {
request.setAttribute("message", message);
String cert = (session.getAttribute("cert") != null)? (String) session.getAttribute("cert") : null;
if (cert == null) {
%>
<jsp:include page="Login.jsp" />
<%
return;
}
} else if (sessionId == null) {
%>
<jsp:include page="Login.jsp" />
<%
return;
}
return;
}
%>
<%@page import="fr.unicaen.iota.epcisphi.xacml.ihm.Module"%>
<%@page import="fr.unicaen.iota.epcisphi.utils.HTMLUtilities"%>
<%@page import="java.util.Date"%>
......
<div class="treeTitle">&nbsp;</div>
<jsp:include page="dialogs.jsp" />
<%
UserInfoOut uInfo = (UserInfoOut) session.getAttribute("uInfo");
User u = new User(uInfo.getUserID(), uInfo.getOwnerID());
if (PEPRequester.checkAccess(u, "superadmin") != Result.DECISION_PERMIT) {
User user = (User) session.getAttribute("user");
if (PEPRequester.checkAccess(user, "superadmin") != Result.DECISION_PERMIT) {
%>
<jsp:include page="policyList.jsp" />
<% } else {
<%
}
else {
%>
<jsp:include page="rootMenu.jsp" />
<%
return;
}
String userId = ((UserInfoOut) session.getAttribute("uInfo")).getUserID();
String ownerId = ((UserInfoOut) session.getAttribute("uInfo")).getOwnerID();
return;
}
String userId = user.getUserID();
String ownerId = user.getOwnerID();
%>
<div class="account">
<div class="logout"><a href="RootAccountAuth?action=logout">[ logout ]</a></div>
ETa/EpcisPHI/src/main/webapp/rootMenu.jsp
<%@page import="fr.unicaen.iota.epcisphi.utils.HTMLUtilities"%>
<%@page import="fr.unicaen.iota.ypsilon.client.model.UserInfoOut"%>
<%@page import="fr.unicaen.iota.epcisphi.utils.User"%>
<div class="rootMenu">
<div class="rootMenuItem"><a href="#" onclick="processAccountCreate()" >Create Account</a></div>
<div class="rootMenuItem"><a href="#" onclick="processUpdateRootUser()" >Update root Account</a></div>
......
<div id="updateRootUser" title="Update User" class="modalDialog">
<div class="dialog_message">Enter user informations :</div>
<div class="dialog_options">Login : <input disabled id="userLogin2" type="text" value="<%=((UserInfoOut) session.getAttribute("uInfo")).getOwnerID()%>" /></div>
<div class="dialog_options">Login : <input disabled id="userLogin2" type="text" value="<%=((User) session.getAttribute("user")).getOwnerID()%>" /></div>
</div>
ETa/EpcisPHI/src/main/webapp/script/requestDispatcher.js
var date1s = date1.split('/');
var date2s = date2.split('/');
var day1 = parseInt(date1s[1]);
// Javascript begins month to 0
var month1 = parseInt(date1s[0]) - 1;
var year1 = parseInt(date1s[2]);
var dateobj1 = new Date(year1, month1, day1);
var day2 = parseInt(date2s[1]);
// Javascript begins month to 0
var month2 = parseInt(date2s[0]) - 1;
var year2 = parseInt(date2s[2]);
var dateobj2 = new Date(year2, month2, day2);
ETa/LibXACML-EPCIS/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>libxacml-epcis</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>LibXACML-EPCIS</name>
EpcILoN/epcilon-schema.sql
create table EventToPublish (
id integer auto_increment,
epc varchar(255) not null,
eventType varchar(40) not null,
bizStep varchar(255) not null,
eventTime timestamp not null,
lastUpdate timestamp not null,
owner varchar(255),
primary key (id)
);
EpcILoN/epcilon_schema.sql
create table EventToPublish (
id integer auto_increment,
epc varchar(255) not null,
eventType varchar(40) not null,
bizStep varchar(255) not null,
eventTime timestamp not null,
lastUpdate timestamp not null,
owner varchar(255),
primary key (id)
);
EpcILoN/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>epcilon</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>EpcILoN</name>
......
</goals>
<configuration>
<componentProperties>
<outputfilename>epcilon-schema.sql</outputfilename>
<outputfilename>epcilon_schema.sql</outputfilename>
<configurationfile>src/main/resources/hibernate.cfg.xml</configurationfile>
<drop>false</drop>
<create>true</create>
......
</plugins>
</build>
<!--
<repositories>
<repository>
<id>fosstrak</id>
......
<url>https://oss.sonatype.org/content/repositories/public</url>
</repository>
</repositories>
-->
</project>
EpcILoN/src/main/resources/sql/epcilon_schema.sql
BEGIN;
SET storage_engine=INNODB;
-- ---------------------------------------------
-- Aggregation Events
-- ---------------------------------------------
DROP TABLE IF EXISTS EventToPublish;
CREATE TABLE `EventToPublish` (
`id` bigint PRIMARY KEY auto_increment,
`eventTime` timestamp NOT NULL,
`epc` varchar(1023) DEFAULT NULL,
`bizStep` varchar(1023) DEFAULT NULL,
`eventType` varchar(1023) DEFAULT NULL,
`eventClass` varchar(1023) DEFAULT NULL,
`lastUpdate` timestamp NOT NULL
);
COMMIT;
GaMMa/src/scripts/gamma.js
}
function addPoint(layer, loc, ids) {
var ll = loc.split(",");
var p = new OpenLayers.Geometry.Point(parseInt(ll[0], 10), parseInt(ll[1], 10));
var p = newPoint(loc);
p.transform(pEPSG4326, pEPSG900913);
var feature = new OpenLayers.Feature.Vector(p);
feature.attributes.id = ids;
......
var points = [];
var bounds = null;
for (var k = 0; k < locationsAndIds.length; ++k) {
var ll = locationsAndIds[k].loc.split(",");
var lon = parseInt(ll[0], 10);
var lat = parseInt(ll[1], 10);
var p = new OpenLayers.Geometry.Point(lon, lat);
var p = newPoint(locationsAndIds[k].loc);
if (bounds == null)
bounds = new OpenLayers.Bounds(p.x, p.y, p.x, p.y);
else
......
select.unselectAll();
select.select(feature);
}
function newPoint(loc) {
var ll = loc.split(",");
var lat = parseInt(ll[0], 10);
var lon = parseInt(ll[1], 10);
return new OpenLayers.Geometry.Point(lon, lat);
}
IoTa-DiscoveryWS/IoTa-DiscoveryWS-Client/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>discovery-client</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>IoTa-DiscoveryWS-Client</name>
IoTa-DiscoveryWS/IoTa-DiscoveryWS/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>discovery-server</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>IoTa-DiscoveryWS</name>
IoTa-Installer/lib/ypsilon.py
installer.WebAppInstaller.__init__(self, "YPSilon web application", "ypsilon", [
("Enter the YPSilon web application name", "ypsilon", "name", {}),
("Enter the archive file pathname", "ypsilon", "repo", {"type": "file"}),
("Enter the URL to the XACML module (EXi or DXi)", "ypsilon", "xacml_url", {})
], [
("application",
{ "xacml-url": ("ypsilon", "xacml_url"),
"pks-filename": ("cert", "keystore"),
"pks-password": ("cert", "password"),
"trust-pks-filename": ("cert", "truststore"),
"trust-pks-password": ("cert", "trustpassword"),
"ldap-url": ("ldap", "url"),
{ "ldap-url": ("ldap", "url"),
"ldap-basedn": ("ldap", "base_dn"),
"ldap-user": ("ldap", "login"),
"ldap-password": ("ldap", "password"),
IoTa-Installer/resources/epcilon_schema.sql
../../EpcILoN/src/main/resources/sql/epcilon_schema.sql
../../EpcILoN/epcilon_schema.sql
IoTa-Installer/resources/eta_schema.sql
-- MySQL dump 10.13 Distrib 5.1.63, for debian-linux-gnu (x86_64)
--
-- Host: localhost Database: gateway_db
-- ------------------------------------------------------
-- Server version 5.1.63-0+squeeze1
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `subscription`
--
DROP TABLE IF EXISTS `subscription`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!40101 SET character_set_client = utf8 */;
CREATE TABLE `subscription` (
`subscriptionid` varchar(255) NOT NULL,
`user` varchar(255) DEFAULT NULL,
`address` varchar(255) DEFAULT NULL,
PRIMARY KEY (`subscriptionid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `subscription`
--
LOCK TABLES `subscription` WRITE;
/*!40000 ALTER TABLE `subscription` DISABLE KEYS */;
/*!40000 ALTER TABLE `subscription` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2012-08-31 15:24:51
IoTa-Installer/resources/eta_schema.sql
../../ETa/ETa/eta_schema.sql
IoTa-Installer/update-version.sh
jar_install = true
[tomcat]
repo = resources/apache-tomcat-7.0.41.tar.gz
repo = resources/apache-tomcat-7.0.42.tar.gz
name = apache-tomcat
directory = /srv/
catalina_home = /srv/apache-tomcat/
LaMBDa/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>lambda</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>LaMBDa</name>
Mu/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>mu</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>Mu</name>
MuPHI/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>muphi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>MuPHI</name>
Nu/Nu-PI/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>nu-pi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>Nu-PI</name>
Nu/Nu/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>nu</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>Nu</name>
OMeGa/OMeGa/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>omega</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>war</packaging>
<name>OMeGa</name>
OMeGa/OmICron/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>omicron</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>OmICron</name>
PSi/pom.xml
<groupId>fr.unicaen.iota</groupId>
<artifactId>psi</artifactId>
<version>2.0</version>
<version>2.1</version>
<packaging>jar</packaging>
<name>PSi</name>
......
</plugins>
</build>
<!--
<repositories>
<repository>
<id>fosstrak</id>
......
<url>https://oss.sonatype.org/content/repositories/public</url>
</repository>
</repositories>
-->
</project>
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff