Changeset 3394 for branches/2.2/security/ExpressoCert/src/br
- Timestamp:
- 10/21/10 15:52:45 (14 years ago)
- Location:
- branches/2.2/security/ExpressoCert/src/br/gov/serpro
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2.2/security/ExpressoCert/src/br/gov/serpro/cert/DigitalCertificate.java
r3232 r3394 55 55 import br.gov.serpro.ui.DialogBuilder; 56 56 import br.gov.serpro.util.Base64Utils; 57 import com.sun.mail.util.BASE64DecoderStream;58 import java.io.InputStreamReader;59 57 import java.io.OutputStream; 60 58 import java.io.OutputStreamWriter; 61 import java.io.PipedInputStream;62 import java.io.PipedOutputStream;63 59 import java.security.AlgorithmParameters; 60 import java.util.regex.Matcher; 61 import java.util.regex.Pattern; 64 62 import javax.activation.CommandMap; 65 63 import javax.activation.MailcapCommandMap; 66 import javax.mail.BodyPart;67 64 import javax.mail.internet.ContentType; 68 65 import javax.mail.internet.MimeUtility; 69 66 import javax.mail.internet.PreencodedMimeBodyPart; 70 import org.bouncycastle.asn1.ASN1InputStream;71 import org.bouncycastle.asn1.DERObject;72 67 import org.bouncycastle.cms.CMSException; 73 68 import org.bouncycastle.cms.RecipientId; … … 623 618 } 624 619 620 // Corrige problemas com e-mails vindos do Outlook 621 // Corrige linhas que são terminadas por \n (\x0A) e deveriam ser terminadas por \r\n (\x0D\x0A) 622 Pattern p = Pattern.compile("(?<!\\r)\\n"); 623 Matcher matcher = p.matcher(retorno); 624 retorno = matcher.replaceAll(CRLF); 625 625 626 return retorno; 626 627 } else { -
branches/2.2/security/ExpressoCert/src/br/gov/serpro/setup/Setup.java
r3232 r3394 1 1 package br.gov.serpro.setup; 2 2 3 import java.applet.Applet; 3 4 import java.util.HashMap; … … 8 9 import java.util.ResourceBundle; 9 10 10 11 11 public class Setup { 12 12 13 /** 14 * 15 */ 16 private static final long serialVersionUID = -8164125429139606589L; 17 18 private Properties parameters; 19 private Properties preferences; 13 /** 14 * 15 */ 16 private static final long serialVersionUID = -8164125429139606589L; 17 private Properties parameters; 18 private Properties preferences; 20 19 private Map<String, ResourceBundle> langResources; 21 20 Locale currentLocale; 22 private Applet currentApplet; 23 21 private Applet currentApplet; 24 22 private static final String PREFERENCES_PATH; 25 23 private static final String EPASS_2000; … … 27 25 static { 28 26 29 //PrintStream ps = new PrintStream(System.out); 30 //System.getProperties().list(System.out); 31 32 if (System.getProperty("os.name").equalsIgnoreCase("linux")){ 33 EPASS_2000 = "/usr/lib/libepsng_p11.so"; 34 } 35 else { 36 EPASS_2000 = System.getenv("SystemRoot").replaceAll("\\\\", "/")+"/system32/ngp11v211.dll"; 37 //EPASS_2000 = System.getenv("ProgramFiles")+"\\Gemplus\\GemSafe Libraries\\BIN\\gclib.dll"; 38 } 27 if (System.getProperty("os.name").equalsIgnoreCase("linux")) { 28 EPASS_2000 = "/usr/lib/libepsng_p11.so"; 29 } else { 30 EPASS_2000 = System.getenv("SystemRoot").replaceAll("\\\\", "/") + "/system32/ngp11v211.dll"; 31 } 39 32 40 33 41 34 PREFERENCES_PATH = "TESTE"; 42 35 43 36 } 44 37 45 public Setup(Applet applet){38 public Setup(Applet applet) { 46 39 47 48 49 40 this.currentApplet = applet; 41 parameters = new Properties(); 42 //preferences = Do arquivo apontado por preferences_path 50 43 51 52 for (String[] parameter: getParameterInfo()){53 54 44 // Pega os parâmetros da applet 45 for (String[] parameter : getParameterInfo()) { 46 String parameterName = parameter[0]; 47 String parameterValue; 55 48 56 if (this.currentApplet.isActive()){ 57 parameterValue = this.currentApplet.getParameter(parameterName); 58 } 59 else { 60 parameterValue = null; 61 } 49 parameterValue = this.currentApplet.getParameter(parameterName); 62 50 63 //System.out.println("Parameter a ser adicionado - " + parameterName + "= " +parameterValue);51 System.out.println("parameter: "+parameterName+" value: "+parameterValue); 64 52 65 if (parameterValue != null && !parameterValue.equals("")){66 67 if (parameterName.equalsIgnoreCase("locale")) {53 if (parameterValue != null && !parameterValue.equals("")) { 54 parameters.setProperty(parameterName.toLowerCase(), parameterValue); 55 if (parameterName.equalsIgnoreCase("locale")) { 68 56 System.out.println("Locale recebido."); 69 57 } 70 } 71 else { 58 } else { 72 59 //Defaults 73 if (parameterName.equalsIgnoreCase("debug")) {60 if (parameterName.equalsIgnoreCase("debug")) { 74 61 parameters.setProperty(parameterName.toLowerCase(), "false"); 75 62 } 76 if (parameterName.equalsIgnoreCase("token")) {77 parameters.setProperty(parameterName.toLowerCase(), "Epass2000;" +EPASS_2000);63 if (parameterName.equalsIgnoreCase("token")) { 64 parameters.setProperty(parameterName.toLowerCase(), "Epass2000;" + EPASS_2000); 78 65 } 79 if (parameterName.equalsIgnoreCase("locale")) {66 if (parameterName.equalsIgnoreCase("locale")) { 80 67 System.out.println("Locale não recebido, definindo valor default."); 81 68 parameters.setProperty(parameterName.toLowerCase(), "pt_BR"); 82 69 } 83 70 } 84 71 } 85 72 86 //TODO: Pegaas preferências do arquivo de preferências se encontrado;73 //TODO: Pegar as preferências do arquivo de preferências se encontrado; 87 74 88 75 // Lang Resources … … 91 78 langResources.put("ExpressoCertMessages", ResourceBundle.getBundle("ExpressoCertMessages", currentLocale)); 92 79 93 80 } 94 81 95 public String[][] getParameterInfo(){82 public String[][] getParameterInfo() { 96 83 97 98 84 String[][] info = { 85 {"debug", "boolean", "Habilita mensagens de debug"}, 99 86 {"token", "string", "Lista de tokens suportados. Formato: nome1;caminho1,nome2;caminho2"}, 100 87 {"locale", "string", "Locale do sistema"} 101 88 }; 102 89 103 104 90 return info; 91 } 105 92 106 public String[][] getPreferencesInfo(){93 public String[][] getPreferencesInfo() { 107 94 108 109 110 95 String[][] info = { 96 {"preferedToken", "string", "Token preferencial do usuário. Formato: nome;caminho"} 97 }; 111 98 112 99 return info; 113 100 114 101 } 115 102 116 public String getParameter(String key){117 118 103 public String getParameter(String key) { 104 return parameters.getProperty(key); 105 } 119 106 120 public String getPreference(String key){121 122 107 public String getPreference(String key) { 108 return getPreference(key); 109 } 123 110 124 125 public void setPreference(String key, String value){111 //TODO: implementar PreferenceNotRegisteredException 112 public void setPreference(String key, String value) { 126 113 127 128 while (!exists){129 for (String[] preference: getPreferencesInfo()){130 if (key.equalsIgnoreCase(preference[1])){131 132 133 134 135 114 boolean exists = false; 115 while (!exists) { 116 for (String[] preference : getPreferencesInfo()) { 117 if (key.equalsIgnoreCase(preference[1])) { 118 exists = true; 119 preferences.setProperty(key, value); 120 } 121 } 122 } 136 123 137 if (!exists){124 if (!exists) { 138 125 // throws PreferenceNotRegisteredException(); 139 126 System.out.println("Preferência não existe!"); 140 141 127 } 128 } 142 129 143 Locale buildLocale(String localeCode) {130 Locale buildLocale(String localeCode) { 144 131 145 132 String[] localeItems = localeCode.split("_"); 146 133 Locale locale; 147 148 switch (localeItems.length){ 149 case 1: locale = new Locale(localeItems[0]); 150 break; 151 case 2: locale = new Locale(localeItems[0], localeItems[1]); 152 break; 153 case 3: locale = new Locale(localeItems[0], localeItems[1], localeItems[2]); 154 break; 155 default: locale = new Locale("pt", "BR"); 156 System.out.println("Locale code error, setting default locale: " + locale.toString()); 134 135 switch (localeItems.length) { 136 case 1: 137 locale = new Locale(localeItems[0]); 138 break; 139 case 2: 140 locale = new Locale(localeItems[0], localeItems[1]); 141 break; 142 case 3: 143 locale = new Locale(localeItems[0], localeItems[1], localeItems[2]); 144 break; 145 default: 146 locale = new Locale("pt", "BR"); 147 System.out.println("Locale code error, setting default locale: " + locale.toString()); 157 148 } 158 149 … … 160 151 } 161 152 162 public void addLanguageResource(String langResource) {163 System.out.println("registrando recu sro de linguagem " + langResource);153 public void addLanguageResource(String langResource) { 154 System.out.println("registrando recurso de linguagem " + langResource); 164 155 langResources.put(langResource, ResourceBundle.getBundle(langResource, currentLocale)); 165 156 } 166 157 167 public String getLang(String langResource, String message) {158 public String getLang(String langResource, String message) { 168 159 169 160 ResourceBundle resource = langResources.get(langResource); … … 172 163 try { 173 164 i18nText = resource.getString(message); 174 } 175 catch (MissingResourceException e){ 165 } catch (MissingResourceException e) { 176 166 e.printStackTrace(); 177 167 } … … 182 172 } 183 173 184 // TODO: Not Implemented Yet 185 public boolean savePreferences(){ 186 return false; 187 } 188 174 // TODO: Not Implemented Yet 175 public boolean savePreferences() { 176 return false; 177 } 189 178 }
Note: See TracChangeset
for help on using the changeset viewer.