1 package org.umu.cops.ospep;
3 import org.slf4j.Logger;
4 import org.slf4j.LoggerFactory;
5 import org.umu.cops.prpep.COPSPepReqStateMan;
6 import org.umu.cops.stack.*;
8 import java.net.Socket;
12 * State manager class for outsourcing requests, at the PEP side.
14 public class COPSPepOSReqStateMan extends COPSPepReqStateMan {
16 private final static Logger logger = LoggerFactory.getLogger(COPSPepOSReqStateMan.class);
19 * ClientSI data from signaling.
21 protected final Set<COPSClientSI> _clientSIs;
24 Object for performing policy data processing
26 protected final COPSPepOSDataProcess _thisProcess;
29 COPS message transceiver used to send COPS messages
31 protected transient COPSPepOSMsgSender _thisSender;
34 * Creates a state request manager
35 * @param clientType Client-type
36 * @param clientHandle Client's <tt>COPSHandle</tt>
38 public COPSPepOSReqStateMan(final short clientType, final COPSHandle clientHandle, final COPSPepOSDataProcess process,
39 final Collection<COPSClientSI> clientSIs) {
40 super(clientType, clientHandle, process);
41 this._thisProcess = process;
42 this._clientSIs = new HashSet<>(clientSIs);
46 protected void initRequestState(final Socket sock) throws COPSException {
47 // Inits an object for sending COPS messages to the PDP
48 _thisSender = new COPSPepOSMsgSender(_clientType, _handle, sock);
49 _sender = _thisSender;
52 _thisSender.sendRequest(_clientSIs);
55 _status = Status.ST_INIT;
59 * Processes the decision message
60 * @param dMsg Decision message from the PDP
61 * @throws COPSPepException
63 protected void processDecision(final COPSDecisionMsg dMsg) throws COPSException {
64 //** Applies decisions to the configuration
65 //_thisProcess.setDecisions(this, removeDecs, installDecs, errorDecs);
66 // second param changed to dMsg so that the data processor
67 // can check the 'solicited' flag
68 final boolean isFailReport = _thisProcess.setDecisions(this, dMsg);
69 _status = Status.ST_DECS;
72 logger.info("Sending FAIL Report");
73 _thisSender.sendFailReport(_thisProcess.getReportData(this));
75 logger.info("Sending SUCCESS Report");
76 _thisSender.sendSuccessReport(_thisProcess.getReportData(this));
78 _status = Status.ST_REPORT;
81 _sender.sendSyncComplete();
83 _status = Status.ST_SYNCALL;
88 protected void processSyncStateRequest(final COPSSyncStateMsg ssMsg) throws COPSException {
90 // If an object exists for retrieving the PEP features,
91 // use it for retrieving them.
94 _thisSender.sendRequest(_clientSIs);
96 _status = Status.ST_SYNC;
100 public void processAcctReport() throws COPSPepException {
101 final List<COPSClientSI> report;
102 if (_thisProcess != null) report = new ArrayList<>(_thisProcess.getAcctData(this));
103 else report = new ArrayList<>();
105 _thisSender.sendAcctReport(report);
107 _status = Status.ST_ACCT;