1 11 package org.eclipse.update.internal.jarprocessor; 12 13 import java.io.File ; 14 import java.io.IOException ; 15 import java.util.Iterator ; 16 import java.util.List ; 17 import java.util.Properties ; 18 import java.util.Set ; 19 20 public class SignCommandStep extends CommandStep { 21 private Set exclusions = null; 22 23 public SignCommandStep(Properties options, String command) { 24 super(options, command, ".jar", false); exclusions = Utils.getSignExclusions(options); 26 } 27 28 public SignCommandStep(Properties options, String command, boolean verbose) { 29 super(options, command, ".jar", verbose); exclusions = Utils.getSignExclusions(options); 31 } 32 33 36 public String recursionEffect(String entryName) { 37 if (entryName.endsWith(extension) && !exclusions.contains(entryName)) 38 return entryName; 39 return null; 40 } 41 42 45 public File preProcess(File input, File workingDirectory, List containers) { 46 return null; 47 } 48 49 52 public File postProcess(File input, File workingDirectory, List containers) { 53 if (command != null && input != null && shouldSign(input, containers)) { 54 try { 55 String [] cmd = new String [] {command, input.getCanonicalPath()}; 56 int result = execute(cmd, verbose); 57 if (result == 0) { 58 return input; 59 } else if (verbose) { 60 System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); } 62 } catch (IOException e) { 63 if (verbose) { 64 e.printStackTrace(); 65 } 66 } 67 } 68 return null; 69 } 70 71 public boolean shouldSign(File input, List containers) { 72 Properties inf = null; 73 74 for (Iterator iterator = containers.iterator(); iterator.hasNext();) { 77 inf = (Properties ) iterator.next(); 78 if (inf.containsKey(Utils.MARK_EXCLUDE_CHILDREN_SIGN)){ 79 if(Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_CHILDREN_SIGN)).booleanValue()) { 80 if (verbose) 81 System.out.println(input.getName() + "is excluded from signing by its containers."); return false; 83 } 84 break; 85 } 86 } 87 88 inf = Utils.getEclipseInf(input, verbose); 90 if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_SIGN) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_SIGN)).booleanValue()) { 91 if (verbose) 92 System.out.println("Excluding " + input.getName() + " from signing."); return false; 94 } 95 return true; 96 } 97 98 public String getStepName() { 99 return "Sign"; } 101 } 102 | Popular Tags |