perfsonar-dev - perfsonar: r2310 - in trunk/perfsonar: schema/example-instances/perfSONAR src/org/perfsonar/service/measurementPoint/tracefileCaptureType src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security
Subject: perfsonar development work
List archive
perfsonar: r2310 - in trunk/perfsonar: schema/example-instances/perfSONAR src/org/perfsonar/service/measurementPoint/tracefileCaptureType src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security
Chronological Thread
- From:
- To:
- Subject: perfsonar: r2310 - in trunk/perfsonar: schema/example-instances/perfSONAR src/org/perfsonar/service/measurementPoint/tracefileCaptureType src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security
- Date: Fri, 30 Mar 2007 07:17:52 -0400
Author: uros
Date: 2007-03-30 07:17:52 -0400 (Fri, 30 Mar 2007)
New Revision: 2310
Added:
trunk/perfsonar/schema/example-instances/perfSONAR/TCMPCaptureRequest-measurement-AA.xml
trunk/perfsonar/schema/example-instances/perfSONAR/TCMPCaptureRequest-measurement-noAA.xml
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementExecutor.java
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementRequest.java
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/SqlManager.java
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql/MySqlManager.java
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Credentials.java
Log:
Added support for (optional) authentication and role based authorization
(currently enforces: header filtering, payload filtering, sampling,
anonymization [complete support in mapi-jni should be added])
Added:
trunk/perfsonar/schema/example-instances/perfSONAR/TCMPCaptureRequest-measurement-AA.xml
Property changes on:
trunk/perfsonar/schema/example-instances/perfSONAR/TCMPCaptureRequest-measurement-AA.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Added:
trunk/perfsonar/schema/example-instances/perfSONAR/TCMPCaptureRequest-measurement-noAA.xml
Property changes on:
trunk/perfsonar/schema/example-instances/perfSONAR/TCMPCaptureRequest-measurement-noAA.xml
___________________________________________________________________
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementExecutor.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementExecutor.java
2007-03-28 14:31:57 UTC (rev 2309)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementExecutor.java
2007-03-30 11:17:52 UTC (rev 2310)
@@ -6,11 +6,18 @@
package org.perfsonar.service.measurementPoint.tracefileCaptureType;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.sql.Timestamp;
import java.util.Collection;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.EnumSet;
import java.util.Date;
+import java.util.Set;
import java.util.Vector;
import java.util.HashSet;
import java.util.StringTokenizer;
@@ -49,6 +56,7 @@
import org.ggf.ns.nmwg.topology.v2_0.Dst;
import org.ggf.ns.nmwg.time.v2_0.Start;
import org.ggf.ns.nmwg.time.v2_0.End;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.security.Authorization;
import si.arnes.jra1.perfsonar.jni.mapijni.MonitorRequest;
import si.arnes.jra1.perfsonar.jni.mapijni.MAPIMonitorRequest;
@@ -58,7 +66,12 @@
import org.perfsonar.service.commons.transport.FileTransportFactory;
import org.perfsonar.service.commons.transport.FileTransport;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.db.SqlManager;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.db.mysql.MySqlManager;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.security.Credentials;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.security.CredentialsException;
+
/**
* This class provides the capability to interact with
* MAPI to interact with DAG, NIC, COMBO9, ... cards.
@@ -92,6 +105,11 @@
private static HashSet<String> localHostsIPs = null;
private boolean runnedAlready = false;
+
+ private static SqlManager sqlManager =
+ new MySqlManager(
+ "127.0.0.1", "3306", "gn2_jra1_tcmp",
+ "tcmp", "odEldxcVyk0wq5zr");
// ---------------------------------- constructors
@@ -179,6 +197,79 @@
// Throw either SystemException on RequestException if validation
fails
TCMPTypeMeasurementRequest req = validateTCMPRequest(request);
+ // Add table entry(ies) for the given capture(s) to SQL db.
+ if (req.getCredentials() != null) {
+
+ Connection conn = null;
+ PreparedStatement pstmt = null;
+ ResultSet rst = null;
+ try {
+
+ conn = sqlManager.getConnection();
+
+ // Retrieve mapping for given username to it's id
+ pstmt = conn.prepareStatement("SELECT id FROM user WHERE
username=?");
+ pstmt.setString(1, req.getCredentials().getUsername());
+ rst = pstmt.executeQuery();
+ if (! rst.next())
+ throw new SystemException("error.common.sqldb_error",
+ "Unable to retrieve id for user '"
+ + req.getCredentials().getUsername() + "'");
+ int id = rst.getInt(1);
+
+ // Insert new tracefile entry for the first tracefile
+ rst.close();
+ rst = null;
+ pstmt.close();
+ pstmt = null;
+ pstmt = conn.prepareStatement(
+ "INSERT INTO tracefile
(url,name,user_id,capture_start,"
+ + "capture_stop,inserted) VALUES(?,?,?,?,?,NOW())");
+ int idx = 1;
+ pstmt.setString(idx++,
+ constructTracefileURL(req.getFirstFilenameDatum()));
+ pstmt.setString(idx++,
+ req.getFirstFilenameDatum());
+ pstmt.setInt(idx++, id);
+ pstmt.setTimestamp(idx++, new
Timestamp(req.getStartTimeParam().getTime()));
+ pstmt.setTimestamp(idx++, new
Timestamp(req.getEndTimeParam().getTime()));
+ pstmt.executeUpdate();
+
+ // If second tracefile should be generated, also insert
second
+ // tracefile entry also
+ if (req.getSecondEndPointHost() != null) {
+ rst.close();
+ rst = null;
+ idx = 1;
+ pstmt.setString(idx++,
+
constructTracefileURL(req.getSecondFilenameDatum()));
+ pstmt.setString(idx++,
+ req.getSecondEndPointHost());
+ pstmt.executeUpdate();
+ }
+
+ } catch (SQLException se) {
+
+ logger.fatal(type + ".makeMeasurement: Unable to add
tracefile"
+ + " entry to SQL db: " + se);
+ throw new SystemException("error.common.sqldb_error",
+ "Unable to add tracefile entry to SQL db: " + se);
+
+ } finally {
+
+ if (rst != null)
+ try { rst.close(); } catch (SQLException se) {}
+
+ if (pstmt != null)
+ try { pstmt.close(); } catch (SQLException se) {}
+
+ if (conn != null)
+ try { conn.close(); } catch (SQLException se) {}
+
+ }
+
+ }
+
// Create one or more Measurement executors
// (first or both interfaces)
// and pass them to the scheduler.
@@ -217,7 +308,7 @@
+ req.getStartTimeParam());
}
-
+
// Construct a generic OK response, with URL to resulted data,
// and timestamp when measurement is completed.
// Also add success.mp.tcmp metadata,data pair
@@ -241,22 +332,12 @@
org.ggf.ns.nmwg.tools.passivetracefile.v2_0.Datum datum =
(org.ggf.ns.nmwg.tools.passivetracefile.v2_0.Datum)ct
.getDatum(0);
- try {
- datum.setFilename("http://"
- + InetAddress.getLocalHost().getCanonicalHostName()
- + ":8080/axis/servlet/perfSONARFileServer?file="
- + datum.getFilename());
- } catch (UnknownHostException e) { }
+ datum.setFilename(constructTracefileURL(datum.getFileName()));
if (ct.getDatumLength() > 1) {
datum =
(org.ggf.ns.nmwg.tools.passivetracefile.v2_0.Datum)ct
.getDatum(1);
- try {
- datum.setFilename("http://"
- + InetAddress.getLocalHost().getCanonicalHostName()
- + ":8080/axis/servlet/perfSONARFileServer?file="
- + datum.getFilename());
- } catch (UnknownHostException e) { }
+
datum.setFilename(constructTracefileURL(datum.getFileName()));
}
response.addChild(d);
}
@@ -413,40 +494,171 @@
this.logger.info(type + ".runAction: Created flow to " + hostIf
+ "(tid=" + Thread.currentThread().getId() + ")");
+
+ // Apply function required by the role based enforcement policy
+ // defined by user credentials
+ if (this.request.getCredentials() != null &&
+ this.request.getCredentials().getAuthorization() != null) {
+
+ Authorization authorization =
+ this.request.getCredentials().getAuthorization();
+ // Apply BPF_FILTER functions required by credentials
+ if (authorization.getHeaderFilters() != null) {
+
+ for (String credFilter :
authorization.getHeaderFilters()) {
+
+ monReq.mapiApplyFunction(
+ "BPF_FILTER",
+ credFilter);
+ this.logger.info(type
+ + ".runAction: Credentials enforced
BPF_FILTER"
+ + " function ("
+ + credFilter
+ + ") applied to the flow on " + hostIf
+ + " (tid=" + Thread.currentThread().getId()
+ ")");
+
+ }
+
+ }
+
+ // Apply SAMPLE functions defined by user credentials
+ if (authorization.getSamplings() != null) {
+
+ for (Authorization.Sampling credSampling :
+ authorization.getSamplings()) {
+
+ monReq.mapiApplyFunction(
+ "SAMPLE",
+ credSampling.getThreshold(),
+ credSampling.getType().getMrNum());
+ this.logger.info(type
+ + ".runAction: Credentials enforced SAMPLE"
+ + " function ("
+ + credSampling.getThreshold() + ", "
+ + credSampling.getType() + " ["
+ + credSampling.getType().getMrNum() + "]"
+ + ") applied to the flow on " + hostIf
+ + " (tid=" + Thread.currentThread().getId()
+ ")");
+
+ }
+
+ }
+
+ // Apply STR_SEARCH functions defined by user credentials
+ if (authorization.getPayloadFilters() != null) {
+
+ for (String credFilter :
authorization.getPayloadFilters()) {
+
+ monReq.mapiApplyFunction(
+ "STR_SEARCH", credFilter, 0, 0);
+ this.logger.info(type
+ + ".runAction: Credentials enforced
STR_SEARCH"
+ + " function ("
+ + credFilter
+ + ") applied to the flow on " + hostIf
+ + " (tid=" + Thread.currentThread().getId()
+ + ")");
+
+ }
+
+ }
+
+ // Apply ANONYMIZE functions defined by user credentials
+ /*
+ if (authorization.getAnonymizations() != null) {
+
+ for (Authorization.Anonymization anon :
+ authorization.getAnonymizations()) {
+
+ Object[] anonParams = anon.toObjectArray();
+
+ monReq.mapiApplyFunction("ANONYMIZE", anonParams);
+ this.logger.info(type
+ + ".runAction: Credentials enforced
ANONYMIZE"
+ + " function ("
+ + anon
+ + ") applied to the flow on " + hostIf
+ + " (tid=" + Thread.currentThread().getId()
+ + ")");
+
+ }
+
+ }
+ */
+
+ }
+
// Apply BPF_FILTER function to the flow if requested
- if (this.request.getFlowHFilterParam() != null) {
+ if (this.request.getReqAuthorization().getHeaderFilters()[0] !=
null) {
- monReq.mapiApplyFunction("BPF_FILTER",
this.request.getFlowHFilterParam());
+ monReq.mapiApplyFunction(
+ "BPF_FILTER",
+
this.request.getReqAuthorization().getHeaderFilters()[0]);
this.logger.info(type + ".runAction: Applied BPF_FILTER
function ('"
- + this.request.getFlowHFilterParam() + "') to the flow
on " + hostIf
+ +
this.request.getReqAuthorization().getHeaderFilters()[0]
+ + "') to the flow on " + hostIf
+ " (tid=" + Thread.currentThread().getId() + ")");
}
// Apply SAMPLE function to the flow if requested
- if (this.request.getFlowSTypeParam() != null &&
- this.request.getFlowSThreParam() != null) {
+ Authorization.Sampling sampling =
+ this.request.getReqAuthorization().getSamplings()[0];
+ if (sampling != null) {
- monReq.mapiApplyFunction("SAMPLE",
this.request.getFlowSThreParam(),
- this.request.getFlowSTypeParam());
+ monReq.mapiApplyFunction(
+ "SAMPLE",
+ sampling.getThreshold(),
+ sampling.getType().getMrNum());
this.logger.info(type + ".runAction: Applied SAMPLE function
("
- + this.request.getFlowSThreParam() + ", "
- + this.request.getFlowSTypeParam() + ") to the flow on "
+ hostIf
+ + sampling.getThreshold() + ", "
+ + sampling.getType()
+ + " [" + sampling.getType().getMrNum() + "]"
+ + ") to the flow on " + hostIf
+ " (tid=" + Thread.currentThread().getId() + ")");
}
// Apply STR_SEARCH function to the flow if requested
- if (this.request.getFlowPFilterParam() != null) {
+ if (this.request.getReqAuthorization().getPayloadFilters()[0] !=
null) {
- monReq.mapiApplyFunction("STR_SEARCH",
this.request.getFlowPFilterParam(), 0, 0);
+ monReq.mapiApplyFunction(
+ "STR_SEARCH",
+
this.request.getReqAuthorization().getPayloadFilters()[0],
+ 0, 0);
this.logger.info(type + ".runAction: Applied STR_SEARCH
function ('"
- + this.request.getFlowPFilterParam() + "', 0, 0) to the
flow on " + hostIf
- + " (tid=" + Thread.currentThread().getId() + ")");
+ +
this.request.getReqAuthorization().getPayloadFilters()[0]
+ + "', 0, 0) to the flow on " + hostIf
+ + " (tid=" + Thread.currentThread().getId() + ")");
}
+
+ // Apply ANONYMIZE functions to the flow if requested
+ /*
+ if (this.request.getReqAuthorization().getAnonymizations() !=
null) {
+
+ for (Authorization.Anonymization anon :
+ this.request.getReqAuthorization().getAnonymizations()) {
+ Object[] anonParams = anon.toObjectArray();
+
+ //monReq.mapiApplyFunction("ANONYMIZE", anonParams);
+ monReq.mapiApplyFunction("ANONYMIZE",
MonitorRequest.ANON_PROTO_TCP,
+ MonitorRequest.ANON_BASE_FIELD_SRC_PORT,
MonitorRequest.ANON_FUNC_MAP);
+ this.logger.info(type
+ + ".runAction: Applied ANONYMIZE"
+ + " function ("
+ + anon
+ + ") to the flow on " + hostIf
+ + " (tid=" + Thread.currentThread().getId()
+ + ")");
+
+ }
+
+ }
+ */
+
// Apply TO_FILE function to the flow
// TODO: another configuration option specifying maximum limit
of packets
// that can be captured to one pcap file (disk space
safeguard)
@@ -510,8 +722,39 @@
// ---------------------------------- private methods
+
+
+ /**
+ * Construct URL to the tracefile based on the filename argument.
+ *
+ * @param filename tracefile
+ * @return URL to the tracefile
+ */
+ private String constructTracefileURL(String filename) {
+
+ String hostname = "127.0.0.1";
+ String serviceName = "axis";
+
+ try {
+ hostname = InetAddress.getLocalHost().getCanonicalHostName();
+ } catch (UnknownHostException e) { }
+
+ try {
+ String sn = configuration.getProperty("service.r.service_name");
+ if (sn != null) serviceName = sn;
+ } catch (Exception e) { }
+
+ return "http://"
+ + hostname
+ + ":8080/"
+ + serviceName
+ + "/servlet/perfSONARFileServer?file="
+ + filename;
+
+ }
+
/**
* Validate incomming TCMP request and return extracted
* request parameters as TCMPTypeMeasurementRequest.
@@ -807,7 +1050,63 @@
+ "found in request.");
}
+
+ // If auth.username and auth.password parameters are available,
+ // check credentials first!
+ Parameter authUsernameParam =
params.getParameterByName("auth.username");
+ Parameter authPasswordParam =
params.getParameterByName("auth.password");
+ if (authUsernameParam != null && authPasswordParam != null) {
+
+ String username = authUsernameParam.getParameterValue();
+ String password = authPasswordParam.getParameterValue();
+
+ // Retrieve credentials from db based on supplied username
+ // and password
+ Credentials creds = new Credentials(sqlManager);
+ try {
+ creds = creds.getFromDb(username, password);
+ } catch (Exception e) {
+ logger.fatal(
+ type + ".validateTCMPRequest: Credentials error:"
+ + e);
+ throw new RequestException(
+ "error.mp.tcmp.validator.credentials_error",
+ type + ".validateTCMPRequest: Credentials error: "
+ + e,
+ e);
+ }
+ req.setCredentials(creds);
+
+ logger.info(type + ".validateTCMPRequest: Successfully
authenticated"
+ + " user '" + creds.getUsername() + "' with role '"
+ + creds.getRole() + "'");
+
+ }
+
+ // Retrieve authorization parameters supplied by user
+ Authorization authorization = new Authorization();
+ // Convert params to Map, having name as key and
+ // parameterValue as value
+ Map<String, String> simpleParams =
+ new HashMap<String, String>();
+ for (String k : (Set<String>)params.getParameterMap().keySet())
+ simpleParams.put(k, ((Parameter)params.getParameterMap().get(k))
+ .getParameterValue());
+ try {
+ authorization.getFromParams(simpleParams);
+ } catch (Exception e) {
+ logger.fatal(
+ type + ".validateTCMPRequest: Authorization error:"
+ + e);
+ throw new RequestException(
+ "error.mp.tcmp.validator._error",
+ type + ".validateTCMPRequest: Credentials error: "
+ + e,
+ e);
+ }
+ req.setReqAuthorization(authorization);
+ /*
// Retrieve flow_h_filter parameter, allow even blank one
if (params.getParameterByName("flow_h_filter") != null)
req.setFlowHFilterParam(params.getParameterByName("flow_h_filter")
@@ -884,6 +1183,7 @@
if (params.getParameterByName("flow_p_filter") != null)
req.setFlowPFilterParam(params.getParameterByName("flow_p_filter")
.getParameterValue());
+ */
// Retrieve characteristics as positive Integer
// (optional value, currently not used)
@@ -1210,10 +1510,13 @@
// either firstFilenameDatum or secondFilenameDatum were set
req.setFirstFilePath(pcapDir.getAbsolutePath()
+ fileSeparator + req.getFirstFilenameDatum());
+
req.setFirstFileUrl(constructTracefileURL(req.getFirstFilenameDatum()));
if (req.getSecondFilenameDatum() != null) {
req.setSecondFilePath(pcapDir.getAbsolutePath()
+ fileSeparator + req.getSecondFilenameDatum());
+ req.setSecondFileUrl(constructTracefileURL(
+ req.getSecondFilenameDatum()));
}
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementRequest.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementRequest.java
2007-03-28 14:31:57 UTC (rev 2309)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/TCMPTypeMeasurementRequest.java
2007-03-30 11:17:52 UTC (rev 2310)
@@ -8,6 +8,8 @@
import java.util.EnumSet;
import java.util.Date;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.security.Authorization;
+import
org.perfsonar.service.measurementPoint.tracefileCaptureType.security.Credentials;
/**
@@ -82,7 +84,7 @@
/**
* flow_h_filter parameter
*/
- private String flowHFilterParam = null;
+ //private String flowHFilterParam = null;
/**
* flow_s_type parameter as defined in
@@ -90,17 +92,17 @@
* constants SAMPLE_MODE_*
*
*/
- private Integer flowSTypeParam = null;
+ //private Integer flowSTypeParam = null;
/**
* flow_s_thre parameter
*/
- private Integer flowSThreParam = null;
+ //private Integer flowSThreParam = null;
/**
* flow_p_filter parameter
*/
- private String flowPFilterParam = null;
+ //private String flowPFilterParam = null;
/**
* characteristics parameter
@@ -131,6 +133,11 @@
* Full path to the firstFilenameDatum
*/
private String firstFilePath = null;
+
+ /**
+ * URL for the firstFilenameDatum
+ */
+ private String firstFileUrl = null;
/**
* secondFilename datum
@@ -141,6 +148,21 @@
* Full path to the secondFilenameDatum
*/
private String secondFilePath = null;
+
+ /**
+ * URL for the secondFilenameDatum
+ */
+ private String secondFileUrl = null;
+
+ /**
+ * Credentials holder
+ */
+ private Credentials credentials = null;
+
+ /**
+ * Request authorization holder
+ */
+ private Authorization reqAuthorization = null;
// ---------------------------------- public methods
@@ -327,88 +349,104 @@
*
* @param flowHFilterParam
*/
+ /*
public void setFlowHFilterParam(String flowHFilterParam) {
this.flowHFilterParam = flowHFilterParam;
}
+ */
/**
* flowHFilterParam getter
*
* @return flowHFilterParam
*/
+ /*
public String getFlowHFilterParam() {
return this.flowHFilterParam;
}
+ */
/**
* flowSTypeParam setter
*
* @param flowSTypeParam
*/
+ /*
public void setFlowSTypeParam(Integer flowSTypeParam) {
this.flowSTypeParam = flowSTypeParam;
}
+ */
/**
* flowSTypeParam getter
*
* @return flowSTypeParam
*/
+ /*
public Integer getFlowSTypeParam() {
return this.flowSTypeParam;
}
+ */
/**
* flowSThreParam setter
*
* @param flowSThreParam
*/
+ /*
public void setFlowSThreParam(Integer flowSThreParam) {
this.flowSThreParam = flowSThreParam;
}
+ */
/**
* flowSThreParam getter
*
* @return flowSThreParam
*/
+ /*
public Integer getFlowSThreParam() {
return this.flowSThreParam;
}
+ */
/**
* flowPFilterParam setter
*
* @param flowPFilterParam
*/
+ /*
public void setFlowPFilterParam(String flowPFilterParam) {
this.flowPFilterParam = flowPFilterParam;
}
+ */
/**
* flowPFilterParam getter
*
* @return flowPFilterParam
*/
+ /*
public String getFlowPFilterParam() {
return this.flowPFilterParam;
}
+ */
/**
* characteristicsParam setter
@@ -565,6 +603,28 @@
}
/**
+ * firstFileUrl setter
+ *
+ * @param firstFileUrl
+ */
+ public void setFirstFileUrl(String firstFileUrl) {
+
+ this.firstFileUrl = firstFileUrl;
+
+ }
+
+ /**
+ * firstFileUrl getter
+ *
+ * @return firstFileUrl
+ */
+ public String getFirstFileUrl() {
+
+ return this.firstFileUrl;
+
+ }
+
+ /**
* secondFilePath setter
*
* @param secondFilePath
@@ -585,5 +645,71 @@
return this.secondFilePath;
}
+
+ /**
+ * secondFileUrl setter
+ *
+ * @param secondFileUrl
+ */
+ public void setSecondFileUrl(String secondFileUrl) {
+ this.secondFileUrl = secondFileUrl;
+
+ }
+
+ /**
+ * secondFileUrl getter
+ *
+ * @return secondFileUrl
+ */
+ public String getSecondFileUrl() {
+
+ return this.secondFileUrl;
+
+ }
+
+ /**
+ * credentials setter
+ *
+ * @param credentials
+ */
+ public void setCredentials(Credentials credentials) {
+
+ this.credentials = credentials;
+
+ }
+
+ /**
+ * credentials getter
+ *
+ * @return credentials
+ */
+ public Credentials getCredentials() {
+
+ return this.credentials;
+
+ }
+
+ /**
+ * reqAuthorization setter
+ *
+ * @param reqAuthorization
+ */
+ public void setReqAuthorization(Authorization reqAuthorization) {
+
+ this.reqAuthorization = reqAuthorization;
+
+ }
+
+ /**
+ * reqAuthorization getter
+ *
+ * @return reqAuthorization
+ */
+ public Authorization getReqAuthorization() {
+
+ return this.reqAuthorization;
+
+ }
+
}
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/SqlManager.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/SqlManager.java
2007-03-28 14:31:57 UTC (rev 2309)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/SqlManager.java
2007-03-30 11:17:52 UTC (rev 2310)
@@ -22,6 +22,21 @@
public abstract class SqlManager {
+ // ---------------------------------- class fields
+
+
+ // Host name holder
+ protected String hostname = null;
+ // Port holder
+ protected String port = null;
+ // DB name holder
+ protected String dbName = null;
+ // Username holder
+ protected String username = null;
+ // Password holder
+ protected String password = null;
+
+
// ---------------------------------- public methods
@@ -40,19 +55,12 @@
/**
* Construct new Connection by constructing url and calling
- * getConnection(url) using the supplied arguments.
+ * getConnection(url) using the predefined args.
*
- * @param hostname
- * @param port
- * @param dbname
- * @param username
- * @param password
* @return sql connection
* @throws SLQException when error occures during retrieval of connection
*/
- public abstract Connection getConnection(String hostname, String port,
- String dbname, String username, String password)
- throws SQLException;
+ public abstract Connection getConnection() throws SQLException;
// Playground (testing)
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql/MySqlManager.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql/MySqlManager.java
2007-03-28 14:31:57 UTC (rev 2309)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql/MySqlManager.java
2007-03-30 11:17:52 UTC (rev 2310)
@@ -31,6 +31,7 @@
// ---------------------------------- class fields
+
/**
* MySQL driver class.
*/
@@ -50,25 +51,43 @@
+ " (" + ex + ")");
}
}
+
+ // ---------------------------------- constructors
- // ---------------------------------- public methods
-
/**
- * Construct new Connection by constructing url and calling
- * getConnection(url) using the supplied arguments.
+ * Constructor with all the required parameters to build connection URL
*
* @param hostname
* @param port
* @param dbname
* @param username
* @param password
+ */
+ public MySqlManager(String hostname, String port,
+ String dbName, String username, String password) {
+
+ this.hostname = hostname;
+ this.port = port;
+ this.dbName = dbName;
+ this.username = username;
+ this.password = password;
+
+ }
+
+
+ // ---------------------------------- public methods
+
+
+ /**
+ * Construct new Connection by constructing url and calling
+ * getConnection(url) using the predefined args.
+ *
* @return sql connection
* @throws SLQException when error occures during retrieval of connection
*/
- public Connection getConnection(String hostname, String port,
- String dbname, String username, String password)
+ public Connection getConnection()
throws SQLException {
try {
@@ -79,7 +98,7 @@
} catch (UnsupportedEncodingException e) {}
String url =
- "jdbc:mysql://" + hostname + ":" + port + "/" + dbname
+ "jdbc:mysql://" + hostname + ":" + port + "/" + dbName
+ "?user=" + username
+ "&password=" + password
+ "&useUnicode=true&characterEncoding=UTF-8";
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
2007-03-28 14:31:57 UTC (rev 2309)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
2007-03-30 11:17:52 UTC (rev 2310)
@@ -15,8 +15,12 @@
import java.util.List;
import java.util.ArrayList;
import java.io.PrintStream;
+import java.util.Map;
+import java.util.StringTokenizer;
+import si.arnes.jra1.perfsonar.jni.mapijni.MonitorRequest;
+
/**
* This class provides access to user authorization parameters
* and methods for retrieving it from different sources.
@@ -88,17 +92,19 @@
*/
public enum SamplingType {
- DETERMINISTIC("deterministic"),
- PROBABILISTIC("probabilistic");
+ DETERMINISTIC("deterministic", MonitorRequest.SAMPLE_MODE_PERIODIC),
+ PROBABILISTIC("probabilistic",
MonitorRequest.SAMPLE_MODE_PROBABILISTIC);
/**
* Constructor with sampling type name argument.
*
* @param type sampling type name
+ * @param mrNum MonitorRequest SAMPLE_MODE type
*/
- private SamplingType(String type) {
+ private SamplingType(String type, int mrNum) {
this.type = type;
+ this.mrNum = mrNum;
}
@@ -114,6 +120,17 @@
}
/**
+ * Return MonitorRequest SAMPLE_MODE type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return sampling type identified by sampling type name.
*
* @return sampling type or null if not found
@@ -134,6 +151,7 @@
* Sampling type name holder.
*/
private final String type;
+ private final int mrNum;
}
/**
@@ -141,22 +159,24 @@
*/
public enum AnonymizationProtocolType {
- IP("ip"),
- TCP("tcp"),
- UDP("udp"),
- ICMP("icmp"),
- HTTP("http"),
- FTP("ftp");
+ IP("ip", MonitorRequest.ANON_PROTO_IP),
+ TCP("tcp", MonitorRequest.ANON_PROTO_TCP),
+ UDP("udp", MonitorRequest.ANON_PROTO_UDP),
+ ICMP("icmp", MonitorRequest.ANON_PROTO_ICMP),
+ HTTP("http", MonitorRequest.ANON_PROTO_HTTP),
+ FTP("ftp", MonitorRequest.ANON_PROTO_FTP);
/**
* Constructor with anonymization protocol type name.
*
* @param type anonymization protocol type name
+ * @param mrNum anonymization protocol type
*/
- private AnonymizationProtocolType(String type) {
+ private AnonymizationProtocolType(String type, int mrNum) {
this.type = type;
+ this.mrNum = mrNum;
}
@@ -172,6 +192,17 @@
}
/**
+ * Return MonitorRequest ANON_PROTO type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return anonymization protocol type identified by anon type name.
*
* @return anonymization protocol type or null if not found
@@ -190,6 +221,7 @@
}
private final String type;
+ private final int mrNum;
}
@@ -198,135 +230,167 @@
*/
public enum AnonymizationFieldType {
- PAYLOAD("payload"),
- CHECKSUM("checksum"),
- SRC_IP("srcIp"),
- DST_IP("dstIp"),
- TTL("ttl"),
- TOS("tos"),
- ID("id"),
- IP_VERSION("fieldVersion"),
- OPTIONS("options"),
- PACKET_LENGTH("packetLength"),
- IP_PROTO("ipProto"),
- IHL("ihl"),
- FRAGMENT_OFFSET("fragmentOffset"),
- SRC_PORT("srcPort"),
- DST_PORT("dstPort"),
- SEQUENCE_NUMBER("sequenceNumber"),
- OFFSET_AND_RESERVED("offsetAndReserved"),
- ACK_NUMBER("ackNumber"),
- FLAGS("flags"),
- URGENT_POINTER("urgentPointer"),
- WINDOW("window"),
- TCP_OPTIONS("tcpOptions"),
- UDP_DATAGRAM_LENGTH("udpDatagramLength"),
- TYPE("type"),
- CODE("code"),
- HTTP_VERSION("httpVersion"),
- METHOD("method"),
- URI("uri"),
- USER_AGENT("userAgent"),
- ACCEPT("accept"),
- ACCEPT_CHARSET("acceptCharset"),
- ACCEPT_ENCODING("acceptEncoding"),
- ACCEPT_LANGUAGE("acceptLanguage"),
- ACCEPT_RANGES("acceptRanges"),
- AGE("age"),
- ALLOW("allow"),
- AUTHORIZATION("authorization"),
- CACHE_CONTROL("chacheControl"),
- CONNECTION_TYPE("connectionType"),
- CONTENT_TYPE("contentType"),
- CONTENT_LENGTH("contentLength"),
- CONTENT_LOCATION("contentLocation"),
- CONTENT_MD5("contentMd5"),
- CONTENT_RANGE("contentRange"),
- COOKIE("cookie"),
- ETAG("etag"),
- EXPECT("expect"),
- EXPIRES("expires"),
- FROM("from"),
- HOST("host"),
- IF_MATCH("ifMatch"),
- IF_MODIFIED_SINCE("ifModifiedSince"),
- IF_NONE_MATCH("ifNoneMatch"),
- IF_RANGE("ifRange"),
- IF_UNMODIFIED_SINCE("ifUnmodifiedSince"),
- LAST_MODIFIED("lastModified"),
- MAX_FORWRDS("maxForwrds"),
- PRAGMA("pragma"),
- PROXY_AUTHENTICATE("proxyAuthenticate"),
- PROXY_AUTHORIZATION("proxyAuthorization"),
- RANGE("range"),
- REFERRER("referrer"),
- RETRY_AFTER("retryAfter"),
- SET_COOKIE("setCookie"),
- SERVER("server"),
- TE("te"),
- TRAILER("trailer"),
- TRANSFER_ENCODING("transferEncoding"),
- UPGRADE("upgrade"),
- VIA("via"),
- WARNING("warning"),
- WWW_AUTHENTICATE("wwwAuthenticate"),
- X_POWERED_BY("xPoweredBy"),
- RESPONSE_CODE("responseCode"),
- RESP_CODE_DESCR("respCodeDescr"),
- VARY("vary"),
- DATE("date"),
- CONTENT_ENCODING("contentEncoding"),
- KEEP_ALIVE("keepAlive"),
- LOCATION("location"),
- CONTENT_LANGUAGE("contentLanguage"),
- DERIVED_FROM("derivedForm"),
- ALLOWED("allowed"),
- MIME_VERSION("mimeVersion"),
- TITLE("title"),
- REFRESH("refresh"),
- HTTP_PAYLOAD("httpPayload"),
- USER("user"),
- PASS("pass"),
- ACCT("acct"),
- FTP_TYPE("ftpType"),
- STRU("stru"),
- MODE("mode"),
- CWD("cwd"),
- PWD("pwd"),
- CDUP("cdup"),
- PASV("pasv"),
- RETR("retr"),
- REST("rest"),
- PORT("port"),
- LIST("list"),
- NLST("nlst"),
- QUIT("quit"),
- SYST("syst"),
- STAT("stat"),
- HELP("help"),
- NOOP("noop"),
- STOR("stor"),
- APPE("appe"),
- STOU("stou"),
- ALLO("allo"),
- MKD("mkd"),
- RMD("rmd"),
- DELE("dele"),
- RNFR("rnfr"),
- RNTO("rnto"),
- SITE("site"),
- FTP_RESPONSE_CODE("ftpResponseCode"),
- FTP_RESPONSE_ARG("ftpResponseArg");
+ PAYLOAD("payload", MonitorRequest.ANON_BASE_FIELD_PAYLOAD),
+ CHECKSUM("checksum", MonitorRequest.ANON_BASE_FIELD_CHECKSUM),
+ SRC_IP("srcIp", MonitorRequest.ANON_BASE_FIELD_SRC_IP),
+ DST_IP("dstIp", MonitorRequest.ANON_BASE_FIELD_DST_IP),
+ TTL("ttl", MonitorRequest.ANON_BASE_FIELD_TTL),
+ TOS("tos", MonitorRequest.ANON_BASE_FIELD_TOS),
+ ID("id", MonitorRequest.ANON_BASE_FIELD_ID),
+ IP_VERSION("fieldVersion", MonitorRequest.ANON_BASE_FIELD_VERSION),
+ OPTIONS("options", MonitorRequest.ANON_BASE_FIELD_OPTIONS),
+ PACKET_LENGTH("packetLength",
+ MonitorRequest.ANON_BASE_FIELD_PACKET_LENGTH),
+ IP_PROTO("ipProto", MonitorRequest.ANON_BASE_FIELD_IP_PROTO),
+ IHL("ihl", MonitorRequest.ANON_BASE_FIELD_IHL),
+ FRAGMENT_OFFSET("fragmentOffset",
+ MonitorRequest.ANON_BASE_FIELD_FRAGMENT_OFFSET),
+ SRC_PORT("srcPort", MonitorRequest.ANON_BASE_FIELD_SRC_PORT),
+ DST_PORT("dstPort", MonitorRequest.ANON_BASE_FIELD_DST_PORT),
+ SEQUENCE_NUMBER("sequenceNumber",
+ MonitorRequest.ANON_BASE_FIELD_SEQUENCE_NUMBER),
+ OFFSET_AND_RESERVED("offsetAndReserved",
+ MonitorRequest.ANON_BASE_FIELD_OFFSET_AND_RESERVED),
+ ACK_NUMBER("ackNumber", MonitorRequest.ANON_BASE_FIELD_ACK_NUMBER),
+ FLAGS("flags", MonitorRequest.ANON_BASE_FIELD_FLAGS),
+ URGENT_POINTER("urgentPointer",
+ MonitorRequest.ANON_BASE_FIELD_URGENT_POINTER),
+ WINDOW("window", MonitorRequest.ANON_BASE_FIELD_WINDOW),
+ TCP_OPTIONS("tcpOptions",
MonitorRequest.ANON_BASE_FIELD_TCP_OPTIONS),
+ UDP_DATAGRAM_LENGTH("udpDatagramLength",
+ MonitorRequest.ANON_BASE_FIELD_UDP_DATAGRAM_LENGTH),
+ TYPE("type", MonitorRequest.ANON_BASE_FIELD_TYPE),
+ CODE("code", MonitorRequest.ANON_BASE_FIELD_CODE),
+ HTTP_VERSION("httpVersion",
MonitorRequest.ANON_HTTP_FIELD_HTTP_VERSION),
+ METHOD("method", MonitorRequest.ANON_HTTP_FIELD_METHOD),
+ URI("uri", MonitorRequest.ANON_HTTP_FIELD_URI),
+ USER_AGENT("userAgent", MonitorRequest.ANON_HTTP_FIELD_USER_AGENT),
+ ACCEPT("accept", MonitorRequest.ANON_HTTP_FIELD_ACCEPT),
+ ACCEPT_CHARSET("acceptCharset",
+ MonitorRequest.ANON_HTTP_FIELD_ACCEPT_CHARSET),
+ ACCEPT_ENCODING("acceptEncoding",
+ MonitorRequest.ANON_HTTP_FIELD_ACCEPT_ENCODING),
+ ACCEPT_LANGUAGE("acceptLanguage",
+ MonitorRequest.ANON_HTTP_FIELD_ACCEPT_LANGUAGE),
+ ACCEPT_RANGES("acceptRanges",
+ MonitorRequest.ANON_HTTP_FIELD_ACCEPT_RANGES),
+ AGE("age", MonitorRequest.ANON_HTTP_FIELD_AGE),
+ ALLOW("allow", MonitorRequest.ANON_HTTP_FIELD_ALLOW),
+ AUTHORIZATION("authorization",
+ MonitorRequest.ANON_HTTP_FIELD_AUTHORIZATION),
+ CACHE_CONTROL("chacheControl",
+ MonitorRequest.ANON_HTTP_FIELD_CACHE_CONTROL),
+ CONNECTION_TYPE("connectionType",
+ MonitorRequest.ANON_HTTP_FIELD_CONNECTION_TYPE),
+ CONTENT_TYPE("contentType",
MonitorRequest.ANON_HTTP_FIELD_CONTENT_TYPE),
+ CONTENT_LENGTH("contentLength",
+ MonitorRequest.ANON_HTTP_FIELD_CONTENT_LENGTH),
+ CONTENT_LOCATION("contentLocation",
+ MonitorRequest.ANON_HTTP_FIELD_CONTENT_LOCATION),
+ CONTENT_MD5("contentMd5",
MonitorRequest.ANON_HTTP_FIELD_CONTENT_MD5),
+ CONTENT_RANGE("contentRange",
+ MonitorRequest.ANON_HTTP_FIELD_CONTENT_RANGE),
+ COOKIE("cookie", MonitorRequest.ANON_HTTP_FIELD_COOKIE),
+ ETAG("etag", MonitorRequest.ANON_HTTP_FIELD_ETAG),
+ EXPECT("expect", MonitorRequest.ANON_HTTP_FIELD_EXPECT),
+ EXPIRES("expires", MonitorRequest.ANON_HTTP_FIELD_EXPIRES),
+ FROM("from", MonitorRequest.ANON_HTTP_FIELD_FROM),
+ HOST("host", MonitorRequest.ANON_HTTP_FIELD_HOST),
+ IF_MATCH("ifMatch", MonitorRequest.ANON_HTTP_FIELD_IF_MATCH),
+ IF_MODIFIED_SINCE("ifModifiedSince",
+ MonitorRequest.ANON_HTTP_FIELD_IF_MODIFIED_SINCE),
+ IF_NONE_MATCH("ifNoneMatch",
+ MonitorRequest.ANON_HTTP_FIELD_IF_NONE_MATCH),
+ IF_RANGE("ifRange", MonitorRequest.ANON_HTTP_FIELD_IF_RANGE),
+ IF_UNMODIFIED_SINCE("ifUnmodifiedSince",
+ MonitorRequest.ANON_HTTP_FIELD_IF_UNMODIFIED_SINCE),
+ LAST_MODIFIED("lastModified",
+ MonitorRequest.ANON_HTTP_FIELD_LAST_MODIFIED),
+ MAX_FORWRDS("maxForwrds",
MonitorRequest.ANON_HTTP_FIELD_MAX_FORWRDS),
+ PRAGMA("pragma", MonitorRequest.ANON_HTTP_FIELD_PRAGMA),
+ PROXY_AUTHENTICATE("proxyAuthenticate",
+ MonitorRequest.ANON_HTTP_FIELD_PROXY_AUTHENTICATE),
+ PROXY_AUTHORIZATION("proxyAuthorization",
+ MonitorRequest.ANON_HTTP_FIELD_AUTHORIZATION),
+ RANGE("range", MonitorRequest.ANON_HTTP_FIELD_RANGE),
+ REFERRER("referrer", MonitorRequest.ANON_HTTP_FIELD_REFERRER),
+ RETRY_AFTER("retryAfter",
MonitorRequest.ANON_HTTP_FIELD_RETRY_AFTER),
+ SET_COOKIE("setCookie", MonitorRequest.ANON_HTTP_FIELD_SET_COOKIE),
+ SERVER("server", MonitorRequest.ANON_HTTP_FIELD_SERVER),
+ TE("te", MonitorRequest.ANON_HTTP_FIELD_TE),
+ TRAILER("trailer", MonitorRequest.ANON_HTTP_FIELD_TRAILER),
+ TRANSFER_ENCODING("transferEncoding",
+ MonitorRequest.ANON_HTTP_FIELD_TRANSFER_ENCODING),
+ UPGRADE("upgrade", MonitorRequest.ANON_HTTP_FIELD_UPGRADE),
+ VIA("via", MonitorRequest.ANON_HTTP_FIELD_VIA),
+ WARNING("warning", MonitorRequest.ANON_HTTP_FIELD_WARNING),
+ WWW_AUTHENTICATE("wwwAuthenticate",
+ MonitorRequest.ANON_HTTP_FIELD_WWW_AUTHENTICATE),
+ X_POWERED_BY("xPoweredBy",
MonitorRequest.ANON_HTTP_FIELD_X_POWERED_BY),
+ RESPONSE_CODE("responseCode",
+ MonitorRequest.ANON_HTTP_FIELD_RESPONSE_CODE),
+ RESP_CODE_DESCR("respCodeDescr",
+ MonitorRequest.ANON_HTTP_FIELD_RESP_CODE_DESCR),
+ VARY("vary", MonitorRequest.ANON_HTTP_FIELD_VARY),
+ DATE("date", MonitorRequest.ANON_HTTP_FIELD_DATE),
+ CONTENT_ENCODING("contentEncoding",
+ MonitorRequest.ANON_HTTP_FIELD_CONTENT_ENCODING),
+ KEEP_ALIVE("keepAlive", MonitorRequest.ANON_HTTP_FIELD_KEEP_ALIVE),
+ LOCATION("location", MonitorRequest.ANON_HTTP_FIELD_LOCATION),
+ CONTENT_LANGUAGE("contentLanguage",
+ MonitorRequest.ANON_HTTP_FIELD_CONTENT_LANGUAGE),
+ DERIVED_FROM("derivedForm",
MonitorRequest.ANON_HTTP_FIELD_DERIVED_FROM),
+ ALLOWED("allowed", MonitorRequest.ANON_HTTP_FIELD_ALLOWED),
+ MIME_VERSION("mimeVersion",
MonitorRequest.ANON_HTTP_FIELD_MIME_VERSION),
+ TITLE("title", MonitorRequest.ANON_HTTP_FIELD_TITLE),
+ REFRESH("refresh", MonitorRequest.ANON_HTTP_FIELD_REFRESH),
+ HTTP_PAYLOAD("httpPayload",
MonitorRequest.ANON_HTTP_FIELD_HTTP_PAYLOAD),
+ USER("user", MonitorRequest.ANON_FTP_FIELD_USER),
+ PASS("pass", MonitorRequest.ANON_FTP_FIELD_PASS),
+ ACCT("acct", MonitorRequest.ANON_FTP_FIELD_ACCT),
+ FTP_TYPE("ftpType", MonitorRequest.ANON_FTP_FIELD_FTP_TYPE),
+ STRU("stru", MonitorRequest.ANON_FTP_FIELD_STRU),
+ MODE("mode", MonitorRequest.ANON_FTP_FIELD_MODE),
+ CWD("cwd", MonitorRequest.ANON_FTP_FIELD_CWD),
+ PWD("pwd", MonitorRequest.ANON_FTP_FIELD_PWD),
+ CDUP("cdup", MonitorRequest.ANON_FTP_FIELD_CDUP),
+ PASV("pasv", MonitorRequest.ANON_FTP_FIELD_PASV),
+ RETR("retr", MonitorRequest.ANON_FTP_FIELD_RETR),
+ REST("rest", MonitorRequest.ANON_FTP_FIELD_REST),
+ PORT("port", MonitorRequest.ANON_FTP_FIELD_PORT),
+ LIST("list", MonitorRequest.ANON_FTP_FIELD_LIST),
+ NLST("nlst", MonitorRequest.ANON_FTP_FIELD_NLST),
+ QUIT("quit", MonitorRequest.ANON_FTP_FIELD_QUIT),
+ SYST("syst", MonitorRequest.ANON_FTP_FIELD_SYST),
+ STAT("stat", MonitorRequest.ANON_FTP_FIELD_STAT),
+ HELP("help", MonitorRequest.ANON_FTP_FIELD_HELP),
+ NOOP("noop", MonitorRequest.ANON_FTP_FIELD_NOOP),
+ STOR("stor", MonitorRequest.ANON_FTP_FIELD_STOR),
+ APPE("appe", MonitorRequest.ANON_FTP_FIELD_APPE),
+ STOU("stou", MonitorRequest.ANON_FTP_FIELD_STOU),
+ ALLO("allo", MonitorRequest.ANON_FTP_FIELD_ALLO),
+ MKD("mkd", MonitorRequest.ANON_FTP_FIELD_MKD),
+ RMD("rmd", MonitorRequest.ANON_FTP_FIELD_RMD),
+ DELE("dele", MonitorRequest.ANON_FTP_FIELD_DELE),
+ RNFR("rnfr", MonitorRequest.ANON_FTP_FIELD_RNFR),
+ RNTO("rnto", MonitorRequest.ANON_FTP_FIELD_RNTO),
+ SITE("site", MonitorRequest.ANON_FTP_FIELD_SITE),
+ FTP_RESPONSE_CODE("ftpResponseCode",
+ MonitorRequest.ANON_FTP_FIELD_FTP_RESPONSE_CODE),
+ FTP_RESPONSE_ARG("ftpResponseArg",
+ MonitorRequest.ANON_FTP_FIELD_FTP_RESPONSE_ARG);
/**
* Constructor with anonymization field type name.
*
* @param type anonymization field type name
+ * @param mrNum anonymizatio field type
*/
- private AnonymizationFieldType(String type) {
+ private AnonymizationFieldType(String type, int mrNum) {
this.type = type;
+ this.mrNum = mrNum;
}
@@ -342,6 +406,17 @@
}
/**
+ * Return MonitorRequest ANON_FIELD type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return anonymization field type identified by anon type name.
*
* @return anonymization field type or null if not found
@@ -360,6 +435,7 @@
}
private final String type;
+ private final int mrNum;
}
@@ -368,17 +444,19 @@
*/
public enum AnonymizationPatternType {
- INTEGER("integer"),
- STR("string");
+ INTEGER("integer", MonitorRequest.ANON_PATTERN_INTEGER),
+ STR("string", MonitorRequest.ANON_PATTERN_STR);
/**
* Constructor with anonymization pattern type name.
*
* @param type anonymization pattern type name
+ * @param mrNum anonymizatio pattern type
*/
- private AnonymizationPatternType(String type) {
+ private AnonymizationPatternType(String type, int mrNum) {
this.type = type;
+ this.mrNum = mrNum;
}
@@ -394,6 +472,17 @@
}
/**
+ * Return MonitorRequest ANON_PATTERN type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return anonymization pattern type identified by anon type name.
*
* @return anonymization pattern type or null if not found
@@ -412,6 +501,7 @@
}
private final String type;
+ private final int mrNum;
}
/**
@@ -419,18 +509,20 @@
*/
public enum AnonymizationMapDistributionType {
- GAUSSIAN("gaussian"),
- UNIFORM("uniform");
+ GAUSSIAN("gaussian", MonitorRequest.ANON_MAP_DISTR_GAUSSIAN),
+ UNIFORM("uniform", MonitorRequest.ANON_MAP_DISTR_UNIFORM);
/**
* Constructor with anonymization map distribution type name.
*
* @param type anonymization type name
+ * @param mrNum anonymizatio map distribution type
*/
- private AnonymizationMapDistributionType(String type) {
+ private AnonymizationMapDistributionType(String type, int mrNum) {
this.type = type;
+ this.mrNum = mrNum;
}
@@ -446,6 +538,17 @@
}
/**
+ * Return MonitorRequest ANON_MAP_DISTRIBUTION type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return anonymization type identified by anon type name.
*
* @return anonymization map distribution type or null if not found
@@ -464,6 +567,7 @@
}
private final String type;
+ private final int mrNum;
}
@@ -514,42 +618,52 @@
*/
public enum AnonymizationFunctionType {
- UNCHANGED("unchanged", null),
- MAP("map", null),
+ UNCHANGED("unchanged", null, MonitorRequest.ANON_FUNC_UNCHANGED),
+ MAP("map", null, MonitorRequest.ANON_FUNC_MAP),
MAP_DISTRIBUTION("mapDistribution",
new AnonymizationParameterType[] {
AnonymizationParameterType.ANONYMIZATION_MAP_DISTRIBUTION_TYPE,
AnonymizationParameterType.INTEGER,
AnonymizationParameterType.INTEGER
- }),
+ },
+ MonitorRequest.ANON_FUNC_MAP_DISTRIBUTION),
STRIP("strip",
new AnonymizationParameterType[] {
AnonymizationParameterType.INTEGER
- }),
- RANDOM("random", null),
+ },
+ MonitorRequest.ANON_FUNC_STRIP),
+ RANDOM("random", null, MonitorRequest.ANON_FUNC_RANDOM),
HASHED("hashed",
new AnonymizationParameterType[] {
AnonymizationParameterType.ANONYMIZATION_HASH_FUNCTION_TYPE,
AnonymizationParameterType
.ANONYMIZATION_HASH_FUNCTION_PADDING_TYPE
- }),
+ },
+ MonitorRequest.ANON_FUNC_HASHED),
PATTERN_FILL("patternFill",
new AnonymizationParameterType[] {
AnonymizationParameterType.ANONYMIZATION_PATTERN_TYPE
- }),
- ZERO("zero", null),
+ },
+ MonitorRequest.ANON_FUNC_PATTERN_FILL),
+ ZERO("zero", null, MonitorRequest.ANON_FUNC_ZERO),
REPLACE("replace",
new AnonymizationParameterType[] {
AnonymizationParameterType.STRING
- }),
- PREFIX_PRESERVING("prefixPreserving", null),
- PREFIX_PRESERVING_MAP("prefixPreservingMap", null),
- CHECKSUM_ADJUST("checksumAdjust", null),
- FILENAME_RANDOM("filenameRandom", null),
+ },
+ MonitorRequest.ANON_FUNC_REPLACE),
+ PREFIX_PRESERVING("prefixPreserving", null,
+ MonitorRequest.ANON_FUNC_PREFIX_PRESERVING),
+ PREFIX_PRESERVING_MAP("prefixPreservingMap", null,
+ MonitorRequest.ANON_FUNC_PREFIX_PRESERVING_MAP),
+ CHECKSUM_ADJUST("checksumAdjust", null,
+ MonitorRequest.ANON_FUNC_CHECKSUM_ADJUST),
+ FILENAME_RANDOM("filenameRandom", null,
+ MonitorRequest.ANON_FUNC_FILENAME_RANDOM),
REGEXP("regexp",
new AnonymizationParameterType[] {
AnonymizationParameterType.STRING
- });
+ },
+ MonitorRequest.ANON_FUNC_REGEXP);
/**
@@ -557,12 +671,14 @@
*
* @param type anonymization function type name
* @parma paramTypes array of parameter types valid for this function
+ * @param mrNum anonymizatio function type
*/
private AnonymizationFunctionType(String type,
- AnonymizationParameterType paramTypes[]) {
+ AnonymizationParameterType paramTypes[], int mrNum) {
this.type = type;
this.paramTypes = paramTypes;
+ this.mrNum = mrNum;
}
@@ -578,6 +694,17 @@
}
/**
+ * Return MonitorRequest ANON_FUNC type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Get parameter types valid for this function.
*
* @return array of parameter types valid for this function
@@ -608,6 +735,7 @@
private final String type;
private final AnonymizationParameterType paramTypes[];
+ private final int mrNum;
}
@@ -616,23 +744,25 @@
*/
public enum AnonymizationHashFunctionType {
- SHA("sha"),
- MD5("md5"),
- CRC32("crc32"),
- SHA_2("sha2"),
- TRIPLEDES("trippleDes"),
- AES("aes"),
- DES("des");
+ SHA("sha", MonitorRequest.ANON_HASH_FUNC_SHA),
+ MD5("md5", MonitorRequest.ANON_HASH_FUNC_MD5),
+ CRC32("crc32", MonitorRequest.ANON_HASH_FUNC_CRC32),
+ SHA_2("sha2", MonitorRequest.ANON_HASH_FUNC_SHA_2),
+ TRIPLEDES("trippleDes", MonitorRequest.ANON_HASH_FUNC_TRIPLEDES),
+ AES("aes", MonitorRequest.ANON_HASH_FUNC_AES),
+ DES("des", MonitorRequest.ANON_HASH_FUNC_DES);
/**
* Constructor with anonymization hash function type name.
*
* @param type anonymization hash function type name
+ * @param mrNum anonymizatio hash function type
*/
- private AnonymizationHashFunctionType(String type) {
+ private AnonymizationHashFunctionType(String type, int mrNum) {
this.type = type;
+ this.mrNum = mrNum;
}
@@ -648,6 +778,17 @@
}
/**
+ * Return MonitorRequest ANON_HASH_FUNC type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return anonymization hash function type identified by anon type
name.
*
* @return anonymization hash function type or null if not found
@@ -666,6 +807,7 @@
}
private final String type;
+ private final int mrNum;
}
@@ -674,18 +816,20 @@
*/
public enum AnonymizationHashFunctionPaddingType {
- PAD_WITH_ZERO("padWithZero"),
- STRIP_REST("stripRest");
+ PAD_WITH_ZERO("padWithZero", MonitorRequest.ANON_HASH_PAD_WITH_ZERO),
+ STRIP_REST("stripRest", MonitorRequest.ANON_HASH_STRIP_REST);
/**
* Constructor with anonymization hash function padding type name.
*
* @param type anonymization hash function padding type name
+ * @param mrNum anonymizatio hash function type
*/
- private AnonymizationHashFunctionPaddingType(String type) {
+ private AnonymizationHashFunctionPaddingType(String type, int mrNum)
{
this.type = type;
+ this.mrNum = mrNum;
}
@@ -701,6 +845,17 @@
}
/**
+ * Return MonitorRequest ANON_HASH padding type
+ *
+ * @return mrNum
+ */
+ public int getMrNum() {
+
+ return mrNum;
+
+ }
+
+ /**
* Return anonymization hash function padding type
* identified by anon type name.
*
@@ -721,6 +876,7 @@
}
private final String type;
+ private final int mrNum;
}
@@ -818,7 +974,7 @@
*/
public void printOut(PrintStream out) {
- out.println("\t\t\tType: '" + type.getType() + "'");
+ out.println("\t\t\tType: '" + type + "'");
out.println("\t\t\tThreshold: " + threshold);
}
@@ -1256,6 +1412,7 @@
}
}
+
/**
* This class provides placeholder for anonymization authorization data
@@ -1300,12 +1457,14 @@
public Anonymization(AnonymizationProtocolType protocolType,
AnonymizationFieldType fieldType,
AnonymizationFunctionType functionType,
- AnonymizationParameter[] functionParams) {
+ AnonymizationParameter[] functionParams,
+ Authorization parentCls) {
this.protocolType = protocolType;
this.fieldType = fieldType;
this.functionType = functionType;
this.functionParams = functionParams;
+ this.parentCls = parentCls;
}
@@ -1481,10 +1640,32 @@
functionParams.add(0, saved);
- } else {
+ } else if (functionType.getParamTypes() != null) {
- //TODO
+ AnonymizationParameterType paramTypes[] =
+ functionType.getParamTypes();
+ if (functionParams.size() != paramTypes.length)
+ throw new Exception("Invalid number of parameters
for"
+ + " anonymization function '"
+ + functionType.getType()
+ + "' (expected " + paramTypes.length
+ + ", got " + functionParams.size() + ")");
+ int idx = 0;
+ for (String s : functionParams) {
+
+ AnonymizationParameter param =
+
(AnonymizationParameter)paramTypes[idx++].getCls()
+ .getConstructor(parentCls.getClass(),
String.class)
+ .newInstance(parentCls, s);
+ if (param.getValueAsObject() == null)
+ throw new Exception("Parameter #" + idx
+ + " contains invalid value '"
+ + s + "'");
+ convParams.add(param);
+
+ }
+
}
this.functionParams =
@@ -1518,9 +1699,9 @@
*/
public void printOut(PrintStream out) {
- out.println("\t\tProtocolType: '" + protocolType.getType() +
"'");
- out.println("\t\tFieldType: '" + fieldType.getType() + "'");
- out.println("\t\tFunctionType: '" + functionType.getType() +
"'");
+ out.println("\t\tProtocolType: '" + protocolType + "'");
+ out.println("\t\tFieldType: '" + fieldType + "'");
+ out.println("\t\tFunctionType: '" + functionType + "'");
out.println("\t\tFunctionParams: [");
for (AnonymizationParameter p : functionParams)
out.println("\t\t\t'" + p.getValueAsObject() + "',");
@@ -1528,6 +1709,69 @@
}
+ /**
+ * Convert this anonymization to Object array consisting of:
+ * - protocol type (Integer MonitorRequest.ANON_PROTO_*)
+ * - field type (Integer MonitorRequest.ANON_*_FIELD_*)
+ * - function type (Integer MonitorRequest.ANON_FUNC_*)
+ * - function parameters [0..n] (depends on a function, may
+ * be String or Integer)
+ *
+ * @return Object array representing this
+ * @throws Exception on any error encountered during conversion
+ */
+ public Object[] toObjectArray() throws Exception {
+
+ List<Object> ret = new ArrayList<Object>();
+
+ if (protocolType == null)
+ throw new Exception("Protocol type not defined");
+ ret.add(protocolType.getMrNum());
+
+ if (fieldType == null)
+ throw new Exception("Field type not defined");
+ ret.add(fieldType.getMrNum());
+
+ if (functionType == null)
+ throw new Exception("Function type not defined");
+ ret.add(functionType.getMrNum());
+
+ for (AnonymizationParameter param : functionParams)
+ ret.add(param.getValueAsObject());
+
+ return ret.toArray(new Object[ret.size()]);
+
+ }
+
+ /**
+ * Return comma separated String list of all parameters:
+ * - protocol type (Integer MonitorRequest.ANON_PROTO_*)
+ * - field type (Integer MonitorRequest.ANON_*_FIELD_*)
+ * - function type (Integer MonitorRequest.ANON_FUNC_*)
+ * - function parameters [0..n] (depends on a function, may
+ * be String or Integer)
+ *
+ * @return string of comma separated parameters
+ * @throws Exception on any error encountered during conversion
+ */
+ public String toString() {
+
+ Object[] params = null;
+ try {
+ params = toObjectArray();
+ } catch (Exception e) {
+ return e.toString();
+ }
+
+ StringBuilder sb = new StringBuilder();
+
+ for (Object o : params) sb.append(o).append(", ");
+ if (sb.length() > 1) sb.delete(sb.length() - 2, sb.length());
+
+ return sb.toString();
+ }
+
+
}
@@ -1552,6 +1796,13 @@
/**
+ * Empty constructor.
+ */
+ public Authorization() {
+
+ }
+
+ /**
* Set Connection.
*
* @param connection
@@ -1559,6 +1810,7 @@
public Authorization(Connection conn) {
this.conn = conn;
+
}
@@ -1608,6 +1860,8 @@
return anonymizations;
}
+
+
/**
* Retrieve authorization parameters for given role from Db conn.
@@ -1622,6 +1876,9 @@
PreparedStatement pstmt = null;
ResultSet rst = null;
+
+ if (conn == null)
+ throw new AuthorizationException("Connection object not set");
try {
@@ -1797,14 +2054,133 @@
}
}
- // Validate authorization information
- validate();
-
return this;
}
/**
+ * Retrieve authorization parameters from given params Map.
+ * Keys of type:
+ * anon
+ * anon.ip.srcIp.func
+ * anon.ip.srcIp.<func>.param<n>
+ *
+ * @param params
+ * @return this object with filled in authorization information
+ * @throws AuthorizationException in case of authorization error
+ */
+ public Authorization getFromParams(Map<String, String> params)
+ throws AuthorizationException {
+
+ // Retrieve header filter
+ headerFilters = new String[1];
+ headerFilters[0] = (String)params.get("flow_h_filter");
+
+ // Retrieve all the payload filters
+ payloadFilters = new String[1];
+ payloadFilters[0] = (String)params.get("flow_p_filter");
+
+ // Retrieve all the sampling params
+ samplings = new Sampling[1];
+ SamplingType sType =
+
SamplingType.getTypeByName((String)params.get("flow_s_type"));
+ if (sType != null) {
+ Integer sValue = null;
+ String sValueStr = null;
+ try {
+ sValueStr = (String)params.get("flow_s_type");
+ if (sValueStr == null) sValue = 0;
+ else sValue = Integer.valueOf(sValueStr);
+ } catch (Exception e) {
+ throw new AuthorizationException(
+ "Invalid sampling threshold value ("
+ + sValueStr + "): "
+ + e,
+ e);
+ }
+ if (sValue < 0) {
+ throw new AuthorizationException(
+ "Invalid sampling threshold value ("
+ + sValue
+ + "): negative");
+ }
+ samplings[0] = new Sampling(sType, sValue);
+ }
+
+ // Retrieve all anonymization params
+ String anonsStr = (String)params.get("anon");
+ List<Anonymization> anons = new ArrayList<Anonymization>();
+ if (anonsStr != null) {
+ // Retrieve list of required anonymizations (protocol.field)
+ StringTokenizer st = new StringTokenizer(anonsStr, ",");
+ String[] anonsStrs = new String[st.countTokens()];
+ for (int i = 0; i < anonsStrs.length && st.hasMoreTokens(); i++)
+ anonsStrs[i] = st.nextToken();
+
+ // Retrieve required data for each anonymization
+ for (String anon : anonsStrs) {
+ // Extract protocol and field information
+ st = new StringTokenizer(anon, ".");
+ if (st.countTokens() > 2)
+ throw new AuthorizationException(
+ "Invalid protocol.field pair (" + anon + ")");
+ String[] protoField = new String[st.countTokens()];
+ for (int i = 0; i < protoField.length && st.hasMoreTokens();
i++)
+ protoField[i] = st.nextToken();
+
+ Anonymization curAnon = new Anonymization(this);
+
+ curAnon.setProtocolType(
+
AnonymizationProtocolType.getTypeByName(protoField[0]));
+ if (curAnon.getProtocolType() == null)
+ throw new AuthorizationException("Unknown protocol ("
+ + protoField[0] + ") in protocol.field pair ("
+ + anon + ")");
+
+ curAnon.setFieldType(
+ AnonymizationFieldType.getTypeByName(protoField[1]));
+ if (curAnon.getFieldType() == null)
+ throw new AuthorizationException("Unknown field ("
+ + protoField[1] + ") in protocol.field pair ("
+ + anon + ")");
+
+ // Retrieve anonymization function for given protocol.field
pair
+ String funcStr = (String)params.get("anon." + anon +
".func");
+ if (funcStr == null)
+ throw new AuthorizationException("Missing function"
+ + " specification for protocol.field pair ("
+ + anon + ")");
+
+ curAnon.setFunctionType(
+ AnonymizationFunctionType.getTypeByName(funcStr));
+ if (curAnon.getFunctionType() == null)
+ throw new AuthorizationException("Unknown function type
("
+ + funcStr + ") for protocol.field pair ("
+ + anon + ")");
+
+ // Now retrieve all parameters for specified function type
+ // and put them to ArrayList to call setFunctionParams later
on
+ List<String> funcParms = new ArrayList<String>();
+ for (int i = 1;
+ i > 0 &&
+ params.get("anon." + anon + "." + funcStr + ".param" +
i) != null;
+ i++)
+ funcParms.add((String)params.get(
+ "anon." + anon + "." + funcStr + ".param" + i));
+ curAnon.setFunctionParams(funcParms);
+
+curAnon.printOut(System.out);
+ anons.add(curAnon);
+ }
+
+ anonymizations = anons.toArray(new Anonymization[anons.size()]);
+ }
+
+ return this;
+
+ }
+
+ /**
* Validate current authorization data.
*
* @throws AuthorizationException if there is any invalid authorization
@@ -1812,8 +2188,8 @@
*/
public void validate() throws AuthorizationException {
+ //TODO
-
}
/**
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Credentials.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Credentials.java
2007-03-28 14:31:57 UTC (rev 2309)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Credentials.java
2007-03-30 11:17:52 UTC (rev 2310)
@@ -35,11 +35,6 @@
* SqlManager holder and all the required connections params.
*/
private SqlManager sqlManager = null;
- private String sqlHost = null;
- private String sqlPort = null;
- private String sqlDbName = null;
- private String sqlUsername = null;
- private String sqlPassword = null;
/**
* All the credential information
@@ -50,7 +45,6 @@
private Authorization authorization = null;
-
// ---------------------------------- constructors
@@ -65,22 +59,10 @@
* Set SQL manager.
*
* @param sqlManager
- * @param sqlHost
- * @param sqlPort
- * @param sqlDbName
- * @param sqlUsername
- * @param sqlPassword
*/
- public Credentials(SqlManager sqlManager,
- String sqlHost, String sqlPort, String sqlDbName,
- String sqlUsername, String sqlPassword) {
+ public Credentials(SqlManager sqlManager) {
this.sqlManager = sqlManager;
- this.sqlHost = sqlHost;
- this.sqlPort = sqlPort;
- this.sqlDbName = sqlDbName;
- this.sqlUsername = sqlUsername;
- this.sqlPassword = sqlPassword;
}
@@ -154,8 +136,7 @@
try {
- conn = sqlManager.getConnection(sqlHost, sqlPort, sqlDbName,
- sqlUsername, sqlPassword);
+ conn = sqlManager.getConnection();
// Retrieve role for the given user,
// if the given (username, password) pair matches one in DB
@@ -226,10 +207,10 @@
String password = reader.readLine();
System.out.print("Checking credentials for username '" + username
+ "', password '" + password + "' ...");
- SqlManager sqlManager = new MySqlManager();
- Credentials creds = new Credentials(
- sqlManager, "127.0.0.1", "3306", "gn2_jra1_tcmp",
- "tcmp", "odEldxcVyk0wq5zr");
+ SqlManager sqlManager = new MySqlManager(
+ "127.0.0.1", "3306", "gn2_jra1_tcmp",
+ "tcmp", "odEldxcVyk0wq5zr");
+ Credentials creds = new Credentials(sqlManager);
Credentials userCreds = creds.getFromDb(username, password);
System.out.println("\nGot the following credentials:");
userCreds.printOut(System.out);
- perfsonar: r2310 - in trunk/perfsonar: schema/example-instances/perfSONAR src/org/perfsonar/service/measurementPoint/tracefileCaptureType src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db src/org/perfsonar/service/measurementPoint/tracefileCaptureType/db/mysql src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security, svnlog, 03/30/2007
Archive powered by MHonArc 2.6.16.