* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
protected static final String C_R = "\n";
protected File dir;
-
+
// This checks for multiple passes of Dir on the same objects. Run clear after done.
protected final static Map<String,Object> processed = new HashMap<>();
- private static final Map<String, Symm> symms = new HashMap<>();
-
+ private static final Map<String, Symm> symms = new HashMap<>();
+
/**
- * Note: Derived Classes should ALWAYS call "super.place(cert,arti)" first, and
+ * Note: Derived Classes should ALWAYS call "super.place(cert,arti)" first, and
* then "placeProperties(arti)" just after they implement
*/
@Override
public final boolean place(Trans trans, CertInfo certInfo, Artifact arti, String machine) throws CadiException {
validate(arti);
-
+
try {
PropHolder cred = PropHolder.get(arti,"cred.props");
throw new CadiException("Could not create " + dir);
}
}
-
+
// Obtain Issuers
boolean first = true;
StringBuilder issuers = new StringBuilder();
cred.addEnc("Challenge", certInfo.getChallenge());
}
-
+
_place(trans, certInfo,arti);
-
+
processed.put("dir",dir);
} catch (Exception e) {
return true;
}
- /**
+ /**
* Derived Classes implement this instead, so Dir can process first, and write any Properties last
* @param cert
* @param arti
protected abstract boolean _place(Trans trans, CertInfo certInfo, Artifact arti) throws CadiException;
public static void write(File f, Chmod c, String ... data) throws IOException {
- System.out.println("Writing file " + f.getCanonicalPath());
+ System.out.println("Writing file " + f.getCanonicalPath());
f.setWritable(true,true);
-
+
FileOutputStream fos = new FileOutputStream(f);
PrintStream ps = new PrintStream(fos);
try {
}
public static void write(File f, Chmod c, byte[] bytes) throws IOException {
- System.out.println("Writing file " + f.getCanonicalPath());
+ System.out.println("Writing file " + f.getCanonicalPath());
f.setWritable(true,true);
-
+
FileOutputStream fos = new FileOutputStream(f);
try {
fos.write(bytes);
c.chmod(f);
}
}
-
+
public static void write(File f, Chmod c, KeyStore ks, char[] pass ) throws IOException, CadiException {
- System.out.println("Writing file " + f.getCanonicalPath());
+ System.out.println("Writing file " + f.getCanonicalPath());
f.setWritable(true,true);
-
+
FileOutputStream fos = new FileOutputStream(f);
try {
ks.store(fos, pass);
// Get the Symm associated with specific File (there can be several active at once)
public synchronized static final Symm getSymm(File f) throws IOException {
- Symm symm = symms.get(f.getCanonicalPath());
- if(symm==null) {
+ Symm symm = symms.get(f.getCanonicalPath());
+ if(symm==null) {
if (!f.exists()) {
write(f,Chmod.to400,Symm.keygen());
// } else {
-// System.out.println("Encryptor using " + f.getCanonicalPath());
+// System.out.println("Encryptor using " + f.getCanonicalPath());
}
- symm = Symm.obtain(f);
+ symm = Symm.obtain(f);
symms.put(f.getCanonicalPath(),symm);
- }
- return symm;
+ }
+ return symm;
}
private void validate(Artifact a) throws CadiException {
}
sb.append("File Artifacts require an AAF Namespace");
}
-
+
if (sb.length()>0) {
throw new CadiException(sb.toString());
}