perfsonar-dev - r2076 - trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security
Subject: perfsonar development work
List archive
r2076 - trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security
Chronological Thread
- From:
- To:
- Subject: r2076 - trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security
- Date: Wed, 14 Feb 2007 12:06:49 -0500
Author: uros
Date: 2007-02-14 12:06:48 -0500 (Wed, 14 Feb 2007)
New Revision: 2076
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
Log:
Special case of anonymization parameter (PATTERN_FILL) done. REGEXP and
general implementation still missing
Modified:
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
===================================================================
---
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
2007-02-14 15:57:46 UTC (rev 2075)
+++
trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security/Authorization.java
2007-02-14 17:06:48 UTC (rev 2076)
@@ -1195,6 +1195,16 @@
}
+ /**
+ * Value getter.
+ *
+ * @return value
+ */
+ public AnonymizationPatternType getValue() {
+
+ return value;
+
+ }
}
/**
@@ -1208,6 +1218,7 @@
// ---------------------------------- class fields
+ private Authorization parentCls = null;
private AnonymizationProtocolType protocolType = null;
private AnonymizationFieldType fieldType = null;
private AnonymizationFunctionType functionType = null;
@@ -1218,10 +1229,14 @@
/**
- * Default constructor
+ * Constructor with parentClass
+ *
+ * @param parentClass
*/
- public Anonymization() {
+ public Anonymization(Authorization parentCls) {
+ this.parentCls = parentCls;
+
}
/**
@@ -1325,6 +1340,84 @@
}
/**
+ * Function params setter.
+ * (Strings should be converted to AnonymizationParameter)
+ *
+ * @param params function params (String)
+ * @throws AuthorizationException in case of conversion error
+ */
+ public void setFunctionParams(List<String> functionParams)
+ throws AuthorizationException {
+
+ List<AnonymizationParameter> convParams =
+ new ArrayList<AnonymizationParameter>();
+
+ if (functionType == null) return;
+
+ try {
+ // Handle PATTERN_FILL function differently
+ // (second parameter depends on the value of the first one)
+ if (functionType == AnonymizationFunctionType.PATTERN_FILL) {
+
+ if (functionParams.size() != 2)
+ throw new Exception("Invalid number of parameters
for"
+ + " anonymization function '"
+ + functionType.getType() + "'");
+
+ AnonymizationParameterType paramTypes[] =
+ functionType.getParamTypes();
+ AnonymizationPatternTypeParameter param0 =
+
(AnonymizationPatternTypeParameter)paramTypes[0].getCls()
+ .getConstructor(parentCls.getClass(),
String.class)
+ .newInstance(parentCls, functionParams.get(0));
+ if (param0.getValue() == null)
+ throw new Exception("Unknown pattern type '"
+ + functionParams.get(0) + "'");
+
+ Class param1Cls = null;
+ switch (param0.getValue()) {
+
+ case INTEGER:
+ param1Cls =
AnonymizationParameterType.INTEGER.getCls();
+ break;
+
+ case STR:
+ param1Cls =
AnonymizationParameterType.STRING.getCls();
+ break;
+
+ }
+
+ AnonymizationParameter param1 =
+ (AnonymizationParameter)param1Cls
+ .getConstructor(parentCls.getClass(),
String.class)
+ .newInstance(parentCls, functionParams.get(1));
+
+ convParams.add(param0);
+ convParams.add(param1);
+
+ } else if (functionType == AnonymizationFunctionType.REGEXP)
{
+
+ //TODO
+
+ } else {
+
+ //TODO
+
+ }
+
+ this.functionParams =
+ convParams.toArray(new
AnonymizationParameter[convParams.size()]);
+ } catch (Exception ex) {
+
+ throw new AuthorizationException(
+ "Parameter conversion error",
+ ex);
+
+ }
+
+ }
+
+ /**
* Function params getter.
*
* @return function params
@@ -1348,7 +1441,7 @@
out.println("\t\tFunctionType: '" + functionType.getType() +
"'");
out.println("\t\tFunctionParams: [");
for (AnonymizationParameter p : functionParams)
- out.println("\t\t\t'" + p + "',");
+ out.println("\t\t\t'" + p.getValueAsObject() + "',");
out.println("\t\t]");
}
@@ -1552,19 +1645,13 @@
if (paramList != null && curAnon != null) {
- //TODO: Function should be doing this, because it is
- // repeated.
- // PATTERN_FILL should be an exception to the
rule,
- // because second parameter depends on first
one!
- /*
- curAnon.setFunctionParams(
- paramList.toArray(new String[paramList.size()]));
- */
+
+ curAnon.setFunctionParams(paramList);
anonsList.add(curAnon);
}
- curAnon = new Anonymization();
+ curAnon = new Anonymization(this);
paramList.clear();
AnonymizationProtocolType apt =
@@ -1611,11 +1698,7 @@
if (paramList != null && curAnon != null) {
- //TODO
- /*
- curAnon.setFunctionParams(
- paramList.toArray(new String[paramList.size()]));
- */
+ curAnon.setFunctionParams(paramList);
anonsList.add(curAnon);
}
- r2076 - trunk/perfsonar/src/org/perfsonar/service/measurementPoint/tracefileCaptureType/security, svnlog, 02/14/2007
Archive powered by MHonArc 2.6.16.