Revision 938
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Fri Sep 22 23:01:42 CEST 2017 |
|
2 |
buildNumber=110 |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<assembly> |
|
2 |
<id>gvsig-plugin-package</id> |
|
3 |
<formats> |
|
4 |
<format>zip</format> |
|
5 |
</formats> |
|
6 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
7 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
8 |
<files> |
|
9 |
<file> |
|
10 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
11 |
<outputDirectory>lib</outputDirectory> |
|
12 |
</file> |
|
13 |
<file> |
|
14 |
<source>target/package.info</source> |
|
15 |
</file> |
|
16 |
</files> |
|
17 |
|
|
18 |
<fileSets> |
|
19 |
<fileSet> |
|
20 |
<directory>src/main/resources-plugin</directory> |
|
21 |
<outputDirectory>.</outputDirectory> |
|
22 |
</fileSet> |
|
23 |
<fileSet> |
|
24 |
<directory>target/abeille</directory> |
|
25 |
<outputDirectory>.</outputDirectory> |
|
26 |
</fileSet> |
|
27 |
</fileSets> |
|
28 |
|
|
29 |
<dependencySets> |
|
30 |
|
|
31 |
<dependencySet> |
|
32 |
<useProjectArtifact>false</useProjectArtifact> |
|
33 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
34 |
<outputDirectory>lib</outputDirectory> |
|
35 |
<includes> |
|
36 |
<!-- |
|
37 |
Plugin libraries |
|
38 |
--> |
|
39 |
<include>org.ini4j:ini4j</include> |
|
40 |
<include>net.sourceforge.thinlet:thinlet</include> |
|
41 |
<include>org.gvsig:org.gvsig.scripting.thing</include> |
|
42 |
<include>org.gvsig:org.gvsig.scripting.lib.api</include> |
|
43 |
<include>org.gvsig:org.gvsig.scripting.swing.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.scripting.lib.impl</include> |
|
45 |
<include>org.gvsig:org.gvsig.scripting.swing.impl</include> |
|
46 |
<include>org.apache.tika:tika-core</include> |
|
47 |
|
|
48 |
<!-- |
|
49 |
Utility libraries |
|
50 |
--> |
|
51 |
<!-- JOpenDocument --> |
|
52 |
<include>org.jopendocument:jOpenDocument</include> |
|
53 |
|
|
54 |
<!-- CSSBox webbrowser --> |
|
55 |
<include>net.sf.cssbox:cssbox</include> |
|
56 |
<include>net.sf.cssbox:swingbox</include> |
|
57 |
<include>net.sf.cssbox:jstyleparser</include> |
|
58 |
<include>net.sourceforge.nekohtml:nekohtml</include> |
|
59 |
<include>org.antlr:antlr-runtime</include> |
|
60 |
|
|
61 |
<!-- |
|
62 |
Script engines libraries |
|
63 |
--> |
|
64 |
|
|
65 |
<include>org.codehaus.groovy:groovy-all</include> |
|
66 |
|
|
67 |
<include>org.renjin:renjin-script-engine:jar:jar-with-dependencies</include> |
|
68 |
|
|
69 |
<include>org.python:${jython.artifactId}</include> |
|
70 |
<include>com.github.tbekolay.jnumeric:jnumeric</include> |
|
71 |
|
|
72 |
<!-- |
|
73 |
JRuby doesn't work by default on gvSIG, maybe the problems are |
|
74 |
related to the PluginClassLoader or to the way JRuby sets its |
|
75 |
internal classpath, so maybe setting the system property |
|
76 |
"org.jruby.embed.class.path" may solve the problem. |
|
77 |
See: |
|
78 |
http://kenai.com/projects/jruby/pages/RedBridge#Class_Path_%28Load_Path%29 |
|
79 |
<include>org.jruby:jruby</include> |
|
80 |
--> |
|
81 |
|
|
82 |
<!-- |
|
83 |
Scala doesn't work. When try to run a scala script show the message: |
|
84 |
Failed to initialize compiler: object scala in compiler mirror not found. |
|
85 |
** Note that as of 2.8 scala does not assume use of the java classpath. |
|
86 |
** For the old behavior pass -usejavacp to scala, or if using a Settings |
|
87 |
** object programmatically, settings.usejavacp.value = true. |
|
88 |
--> |
|
89 |
|
|
90 |
<include>org.scala-lang:scala-dist</include> |
|
91 |
<include>org.scala-lang:scala-compiler</include> |
|
92 |
<include>org.scala-lang:scala-library</include> |
|
93 |
<include>org.scala-lang:scala-reflect</include> |
|
94 |
<include>org.scala-lang:scalap</include> |
|
95 |
|
|
96 |
<include>jline:jline</include> |
|
97 |
|
|
98 |
|
|
99 |
</includes> |
|
100 |
</dependencySet> |
|
101 |
|
|
102 |
|
|
103 |
</dependencySets> |
|
104 |
|
|
105 |
</assembly> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptLaunchExtension.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import java.util.ArrayList; |
|
5 |
import java.util.Arrays; |
|
6 |
import java.util.List; |
|
7 |
import javax.swing.JOptionPane; |
|
8 |
import org.gvsig.andami.PluginsLocator; |
|
9 |
import org.gvsig.andami.PluginsManager; |
|
10 |
import org.gvsig.andami.plugins.Extension; |
|
11 |
import org.gvsig.app.ApplicationLocator; |
|
12 |
import org.gvsig.app.ApplicationManager; |
|
13 |
import org.gvsig.scripting.ScriptingLocator; |
|
14 |
import org.gvsig.scripting.ScriptingManager; |
|
15 |
import org.gvsig.scripting.ScriptingScript; |
|
16 |
import org.slf4j.Logger; |
|
17 |
import org.slf4j.LoggerFactory; |
|
18 |
|
|
19 |
public class ScriptLaunchExtension extends Extension { |
|
20 |
|
|
21 |
private static final Logger logger = LoggerFactory.getLogger(ScriptLaunchExtension.class); |
|
22 |
|
|
23 |
@Override |
|
24 |
public void initialize() { |
|
25 |
} |
|
26 |
|
|
27 |
@Override |
|
28 |
public boolean isEnabled() { |
|
29 |
return true; |
|
30 |
} |
|
31 |
|
|
32 |
@Override |
|
33 |
public boolean isVisible() { |
|
34 |
return true; |
|
35 |
} |
|
36 |
|
|
37 |
@Override |
|
38 |
public boolean canQueryByAction() { |
|
39 |
return true; |
|
40 |
} |
|
41 |
|
|
42 |
@Override |
|
43 |
public void execute(String action) { |
|
44 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
45 |
ScriptingScript script = getScript(action); |
|
46 |
if( script == null ) { |
|
47 |
application.messageDialog( |
|
48 |
"Can't locate script '"+action+"'", |
|
49 |
"Warning", |
|
50 |
JOptionPane.WARNING_MESSAGE |
|
51 |
); |
|
52 |
return; |
|
53 |
} |
|
54 |
try { |
|
55 |
script.runAsTask(null); |
|
56 |
} catch (Throwable th) { |
|
57 |
logger.warn("Can't execute '" + action + "' script.", th); |
|
58 |
} |
|
59 |
} |
|
60 |
|
|
61 |
@Override |
|
62 |
public void execute(String action, Object[] args) { |
|
63 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
64 |
ScriptingScript script = getScript(action); |
|
65 |
if( script == null ) { |
|
66 |
application.messageDialog( |
|
67 |
"Can't locate script '"+action+"'", |
|
68 |
"Warning", |
|
69 |
JOptionPane.WARNING_MESSAGE |
|
70 |
); |
|
71 |
return; |
|
72 |
} |
|
73 |
try { |
|
74 |
script.runAsTask(args); |
|
75 |
} catch (Throwable th) { |
|
76 |
logger.warn("Can't execute '" + action + "' script.", th); |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
@Override |
|
81 |
public boolean isVisible(String action) { |
|
82 |
ScriptingScript script = getScript(action); |
|
83 |
try { |
|
84 |
Boolean value = (Boolean) script.invokeFunction("isVisible", null); |
|
85 |
return value; |
|
86 |
} catch (Throwable th) { |
|
87 |
logger.warn("Can't execute isVisible in '" + action + "' script.", th); |
|
88 |
} |
|
89 |
return false; |
|
90 |
} |
|
91 |
|
|
92 |
@Override |
|
93 |
public boolean isEnabled(String action) { |
|
94 |
ScriptingScript script = getScript(action); |
|
95 |
try { |
|
96 |
Boolean value = (Boolean) script.invokeFunction("isEnabled", null); |
|
97 |
return value; |
|
98 |
} catch (Throwable th) { |
|
99 |
logger.warn("Can't execute isEnabled in '" + action + "' script.", th); |
|
100 |
} |
|
101 |
return false; |
|
102 |
} |
|
103 |
|
|
104 |
private ScriptingScript getScript(String scriptpathname) { |
|
105 |
final ScriptingManager manager = ScriptingLocator.getManager(); |
|
106 |
final PluginsManager pluginManager = PluginsLocator.getManager(); |
|
107 |
|
|
108 |
File scriptfile; |
|
109 |
ScriptingScript script; |
|
110 |
|
|
111 |
String s = manager.getRootUserFolder().getAbsolutePath().replace("\\", "/"); |
|
112 |
scriptfile = new File(s+"/"+scriptpathname); |
|
113 |
if (scriptfile.exists()) { |
|
114 |
script = (ScriptingScript) manager.getScript(scriptfile); |
|
115 |
return script; |
|
116 |
} |
|
117 |
|
|
118 |
final List<File> pluginsFolders = new ArrayList<>(); |
|
119 |
for (File f : pluginManager.getPluginsFolders()) { |
|
120 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
121 |
} |
|
122 |
|
|
123 |
for (File pluginFolder : pluginsFolders) { |
|
124 |
s = pluginFolder.getAbsolutePath().replace("\\", "/"); |
|
125 |
scriptfile = new File(s+"/scripting/scripts/"+scriptpathname); |
|
126 |
if (scriptfile.exists()) { |
|
127 |
script = (ScriptingScript) manager.getScript(scriptfile); |
|
128 |
return script; |
|
129 |
} |
|
130 |
} |
|
131 |
return (ScriptingScript) manager.getScript(scriptpathname); |
|
132 |
} |
|
133 |
|
|
134 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.scripting.app.extension; |
|
23 |
|
|
24 |
import java.io.File; |
|
25 |
import java.io.IOException; |
|
26 |
import java.io.InputStream; |
|
27 |
import java.nio.file.FileVisitOption; |
|
28 |
import static java.nio.file.FileVisitOption.FOLLOW_LINKS; |
|
29 |
import java.nio.file.FileVisitResult; |
|
30 |
import java.nio.file.Files; |
|
31 |
import java.nio.file.Path; |
|
32 |
import java.nio.file.Paths; |
|
33 |
import java.nio.file.SimpleFileVisitor; |
|
34 |
import java.nio.file.attribute.BasicFileAttributes; |
|
35 |
import java.text.MessageFormat; |
|
36 |
import java.util.ArrayList; |
|
37 |
import java.util.Arrays; |
|
38 |
import java.util.Collections; |
|
39 |
import java.util.Comparator; |
|
40 |
import java.util.EnumSet; |
|
41 |
import java.util.List; |
|
42 |
|
|
43 |
import javax.swing.JOptionPane; |
|
44 |
import javax.swing.SwingUtilities; |
|
45 |
import org.apache.commons.io.FileUtils; |
|
46 |
import org.apache.commons.io.IOUtils; |
|
47 |
import org.apache.commons.lang3.StringUtils; |
|
48 |
|
|
49 |
import org.gvsig.andami.IconThemeHelper; |
|
50 |
import org.gvsig.andami.PluginServices; |
|
51 |
import org.gvsig.andami.PluginsLocator; |
|
52 |
import org.gvsig.andami.PluginsManager; |
|
53 |
import org.gvsig.andami.plugins.Extension; |
|
54 |
import org.gvsig.app.ApplicationLocator; |
|
55 |
import org.gvsig.app.ApplicationManager; |
|
56 |
import org.gvsig.scripting.ScriptingBaseScript; |
|
57 |
import org.gvsig.scripting.ScriptingFolder; |
|
58 |
import org.gvsig.scripting.ScriptingLocator; |
|
59 |
import org.gvsig.scripting.ScriptingManager; |
|
60 |
import org.gvsig.scripting.ScriptingScript; |
|
61 |
import org.gvsig.scripting.ScriptingUnit; |
|
62 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
|
63 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
|
64 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
|
65 |
import static org.gvsig.scripting.swing.api.ScriptingUIManager.SCRIPT_COMPOSER_AUTORUN; |
|
66 |
import org.gvsig.tools.dynobject.DynObject; |
|
67 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
68 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
69 |
import org.gvsig.tools.swing.impl.windowmanager.DefaultWindowManager; |
|
70 |
import org.slf4j.Logger; |
|
71 |
import org.slf4j.LoggerFactory; |
|
72 |
import org.gvsig.tools.ToolsLocator; |
|
73 |
import org.gvsig.tools.exception.BaseException; |
|
74 |
import org.gvsig.tools.i18n.I18nManager; |
|
75 |
import org.gvsig.tools.script.Script; |
|
76 |
import org.gvsig.tools.task.SimpleTaskStatus; |
|
77 |
import org.gvsig.tools.util.Invocable; |
|
78 |
import org.gvsig.tools.visitor.VisitCanceledException; |
|
79 |
import org.gvsig.tools.visitor.Visitor; |
|
80 |
|
|
81 |
public class ScriptingExtension extends Extension { |
|
82 |
|
|
83 |
private static final Logger logger = LoggerFactory.getLogger(ScriptingExtension.class); |
|
84 |
|
|
85 |
private PluginServices plugin = null; |
|
86 |
|
|
87 |
/* |
|
88 |
* la funcion log y las constantes estan pensadas para usarlas desde los scripts. |
|
89 |
*/ |
|
90 |
public static final int INFO = 0; |
|
91 |
public static final int TRACE = 1; |
|
92 |
public static final int WARN = 2; |
|
93 |
public static final int ERROR = 3; |
|
94 |
private static boolean composer_initialized = false; |
|
95 |
|
|
96 |
public static void log(String message) { |
|
97 |
log(INFO, message, null); |
|
98 |
} |
|
99 |
|
|
100 |
public static void log(int level, String message) { |
|
101 |
log(level, message, null); |
|
102 |
} |
|
103 |
|
|
104 |
public static void log(int level, String message, Throwable th) { |
|
105 |
switch( level ) { |
|
106 |
case TRACE: |
|
107 |
logger.trace(message, th); |
|
108 |
break; |
|
109 |
case ERROR: |
|
110 |
logger.error(message, th); |
|
111 |
break; |
|
112 |
case WARN: |
|
113 |
logger.warn(message, th); |
|
114 |
break; |
|
115 |
default: |
|
116 |
case INFO: |
|
117 |
logger.info(message, th); |
|
118 |
break; |
|
119 |
} |
|
120 |
} |
|
121 |
|
|
122 |
@Override |
|
123 |
public PluginServices getPlugin() { |
|
124 |
if( this.plugin == null ) { |
|
125 |
this.plugin = PluginsLocator.getManager().getPlugin(ScriptingExtension.class); |
|
126 |
} |
|
127 |
return this.plugin; |
|
128 |
} |
|
129 |
|
|
130 |
@Override |
|
131 |
public void execute(String actionCommand) { |
|
132 |
this.execute(actionCommand, null); |
|
133 |
} |
|
134 |
|
|
135 |
@Override |
|
136 |
public void execute(String command, Object[] args) { |
|
137 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
138 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
|
139 |
|
|
140 |
if( "tools-scripting-launcher".equalsIgnoreCase(command) ) { |
|
141 |
winmanager.showWindow(uimanager.createLauncher().asJComponent(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL); |
|
142 |
|
|
143 |
} else if( "tools-scripting-composer".equalsIgnoreCase(command) ) { |
|
144 |
if( composer_initialized ) { |
|
145 |
showScriptingComposer(); |
|
146 |
} else { |
|
147 |
Thread th = new Thread(new StartupAndShowScriptingComposer(), "StartupAndShowScriptingComposer"); |
|
148 |
th.start(); |
|
149 |
} |
|
150 |
|
|
151 |
} else { |
|
152 |
ScriptingBaseScript script = uimanager.getManager().getScript(command); |
|
153 |
if( script != null ) { |
|
154 |
script.run(args); |
|
155 |
} else { |
|
156 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
157 |
application.messageDialog("Can't locate script '" + command + "'.", "ScriptLaunch", JOptionPane.OK_OPTION); |
|
158 |
} |
|
159 |
} |
|
160 |
} |
|
161 |
|
|
162 |
private void showScriptingComposer() { |
|
163 |
ScriptingUIManager uimanager = ScriptingSwingLocator.getUIManager(); |
|
164 |
WindowManager winmanager = ToolsSwingLocator.getWindowManager(); |
|
165 |
|
|
166 |
DynObject preferences = getPlugin().getPluginProperties(); |
|
167 |
Boolean composerUseHisWindowManager = (Boolean) preferences.getDynValue("ComposerUseHisWindowManager"); |
|
168 |
ScriptingUIManager uiManager = ScriptingSwingLocator.getUIManager(); |
|
169 |
if( composerUseHisWindowManager ) { |
|
170 |
winmanager = new DefaultWindowManager(); |
|
171 |
uiManager.setWindowManager(winmanager); |
|
172 |
} |
|
173 |
JScriptingComposer composer = uimanager.createComposer(); |
|
174 |
uiManager.showWindow( |
|
175 |
composer.asJComponent(), |
|
176 |
uimanager.getTranslation("Scripting_Composer") |
|
177 |
); |
|
178 |
} |
|
179 |
|
|
180 |
private class StartupAndShowScriptingComposer implements Runnable { |
|
181 |
|
|
182 |
@Override |
|
183 |
public void run() { |
|
184 |
SimpleTaskStatus status = ToolsLocator.getTaskStatusManager().createDefaultSimpleTaskStatus("Script composer startup"); |
|
185 |
status.setIndeterminate(); |
|
186 |
status.setAutoremove(true); |
|
187 |
status.add(); |
|
188 |
final ApplicationManager application = ApplicationLocator.getManager(); |
|
189 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
190 |
try { |
|
191 |
logger.info("Searching autorun scripts..."); |
|
192 |
application.message( |
|
193 |
i18nManager.getTranslation("_Searching_autorun_scripts_Xhorizontal_ellipsisX"), |
|
194 |
JOptionPane.INFORMATION_MESSAGE |
|
195 |
); |
|
196 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
197 |
final List<ScriptingScript> autoruns = new ArrayList<>(); |
|
198 |
|
|
199 |
Visitor visitor = new Visitor() { |
|
200 |
|
|
201 |
@Override |
|
202 |
public void visit(Object o) throws VisitCanceledException, BaseException { |
|
203 |
ScriptingUnit unit = (ScriptingUnit) o; |
|
204 |
if( unit instanceof ScriptingScript && SCRIPT_COMPOSER_AUTORUN.equalsIgnoreCase(unit.getId()) ) { |
|
205 |
ScriptingScript autorun = (ScriptingScript) unit; |
|
206 |
if( autorun.isEnabled() ) { |
|
207 |
autoruns.add(autorun); |
|
208 |
} else { |
|
209 |
logger.info("Skip scautorun script '" + autorun.getFile().getAbsolutePath() + "'."); |
|
210 |
} |
|
211 |
} |
|
212 |
} |
|
213 |
}; |
|
214 |
manager.getSystemFolder().accept(visitor); |
|
215 |
manager.getUserFolder().accept(visitor); |
|
216 |
if( !autoruns.isEmpty() ) { |
|
217 |
status.setRangeOfValues(0, autoruns.size()); |
|
218 |
int n=0; |
|
219 |
for (ScriptingScript autorun : autoruns) { |
|
220 |
status.setCurValue(n++); |
|
221 |
try { |
|
222 |
logger.info("running autorun script '" + autorun.getFile().getAbsolutePath() + "."); |
|
223 |
application.message( |
|
224 |
i18nManager.getTranslation( |
|
225 |
"_Running_autorun_script_from_XnameX", |
|
226 |
new String[]{ |
|
227 |
autorun.getFile().getParentFile().getName()} |
|
228 |
), |
|
229 |
JOptionPane.INFORMATION_MESSAGE |
|
230 |
); |
|
231 |
} catch (Exception ex) { |
|
232 |
// Ignore it |
|
233 |
} |
|
234 |
try { |
|
235 |
autorun.run(); |
|
236 |
} catch (Exception ex) { |
|
237 |
logger.warn("Can't execute autorun from '" + autorun.getFile().getAbsolutePath() + "'.", ex); |
|
238 |
} |
|
239 |
} |
|
240 |
} |
|
241 |
} catch(Throwable th) { |
|
242 |
|
|
243 |
} finally { |
|
244 |
logger.info("Running autorun scripts terminated."); |
|
245 |
application.message("", JOptionPane.INFORMATION_MESSAGE); |
|
246 |
status.terminate(); |
|
247 |
composer_initialized = true; |
|
248 |
} |
|
249 |
|
|
250 |
SwingUtilities.invokeLater(new Runnable() { |
|
251 |
@Override |
|
252 |
public void run() { |
|
253 |
showScriptingComposer(); |
|
254 |
} |
|
255 |
}); |
|
256 |
} |
|
257 |
} |
|
258 |
|
|
259 |
@Override |
|
260 |
public void initialize() { |
|
261 |
IconThemeHelper.registerIcon("action", "tools-scripting-launcher", this); |
|
262 |
IconThemeHelper.registerIcon("action", "tools-scripting-composer", this); |
|
263 |
IconThemeHelper.registerIcon("action", "tools-scripting-console-jython", this); |
|
264 |
|
|
265 |
initPaths(); |
|
266 |
Thread th = new Thread(new Runnable() { |
|
267 |
@Override |
|
268 |
public void run() { |
|
269 |
preloadPythonEngine(); |
|
270 |
} |
|
271 |
}, "ScriptEnginesInitializer"); |
|
272 |
th.start(); |
|
273 |
try { |
|
274 |
th.join(3000); // force change to other thread |
|
275 |
} catch (InterruptedException ex) { |
|
276 |
// Ignore. |
|
277 |
} |
|
278 |
} |
|
279 |
|
|
280 |
private void preloadPythonEngine() { |
|
281 |
ScriptingManager manager = (ScriptingManager) ScriptingLocator.getManager(); |
|
282 |
synchronized (manager) { |
|
283 |
String respath = "/scripting/langs/python/preload.py"; |
|
284 |
InputStream res = this.getClass().getResourceAsStream(respath); |
|
285 |
if( res != null ) { |
|
286 |
logger.info("Scan for script engines"); |
|
287 |
List<String> lines; |
|
288 |
try { |
|
289 |
lines = IOUtils.readLines(res); |
|
290 |
String code = StringUtils.join(lines, "\n"); |
|
291 |
logger.info("Preload python script engine"); |
|
292 |
Script script = manager.createScript( |
|
293 |
"preload", |
|
294 |
code, |
|
295 |
ScriptingManager.PYTHON_LANGUAGE_NAME |
|
296 |
); |
|
297 |
logger.info("Preload python modules"); |
|
298 |
script.invokeFunction("main", null); |
|
299 |
|
|
300 |
} catch (Exception ex) { |
|
301 |
logger.warn("Can't run preload script for python.", ex); |
|
302 |
} |
|
303 |
logger.info("Preload of script engines finished"); |
|
304 |
} |
|
305 |
} |
|
306 |
} |
|
307 |
|
|
308 |
private void addLinkToPreviousVersion(ScriptingManager manager) { |
|
309 |
|
|
310 |
String contents = "[Unit]\n" |
|
311 |
+ "type = Folder\n" |
|
312 |
+ "name = Previous version\n" |
|
313 |
+ "description =\n" |
|
314 |
+ "createdBy =\n" |
|
315 |
+ "version =\n" |
|
316 |
+ "\n" |
|
317 |
+ "[Folder]\n" |
|
318 |
+ "path = ../../org.gvsig.scripting.app.extension/scripts\n\n\n"; |
|
319 |
File previousVersion = new File(manager.getUserFolder().getFile(), "previous_version.inf"); |
|
320 |
if( !previousVersion.exists() ) { |
|
321 |
try { |
|
322 |
FileUtils.writeStringToFile(previousVersion, contents); |
|
323 |
} catch (IOException ex) { |
|
324 |
logger.warn("Can't create ScriptingFolder file in '" + previousVersion.getAbsolutePath() + "'.", ex); |
|
325 |
} |
|
326 |
} |
|
327 |
} |
|
328 |
|
|
329 |
private void initPaths() { |
|
330 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
331 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
332 |
|
|
333 |
File home = this.getPlugin().getPluginHomeFolder(); |
|
334 |
manager.setHomeFolder(home); |
|
335 |
|
|
336 |
this.addLinkToPreviousVersion(manager); |
|
337 |
|
|
338 |
List<File> pluginsFolders = new ArrayList<>(); |
|
339 |
for( File f : pluginManager.getPluginsFolders() ) { |
|
340 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
341 |
} |
|
342 |
|
|
343 |
for( File pluginFolder : pluginsFolders ) { |
|
344 |
File scriptsFolder = new File(pluginFolder, "scripting/scripts"); |
|
345 |
if( scriptsFolder.exists() ) { |
|
346 |
manager.registerSystemFolder(pluginFolder.getName(), scriptsFolder); |
|
347 |
} |
|
348 |
File libFolder = new File(pluginFolder, "scripting/lib"); |
|
349 |
if( libFolder.exists() ) { |
|
350 |
manager.addLibFolder(libFolder); |
|
351 |
} |
|
352 |
} |
|
353 |
manager.setPackagesFolder(pluginManager.getInstallFolder()); |
|
354 |
|
|
355 |
File localAddonRepositoryFolder = new File(manager.getRootUserFolder(), "addons"); |
|
356 |
if( !localAddonRepositoryFolder.exists() ) { |
|
357 |
try { |
|
358 |
FileUtils.forceMkdir(localAddonRepositoryFolder); |
|
359 |
} catch (IOException ex) { |
|
360 |
logger.info("Can't create addons folder in '" + localAddonRepositoryFolder.getAbsolutePath() + "'.", ex); |
|
361 |
} |
|
362 |
} |
|
363 |
File initAddonFile = new File(localAddonRepositoryFolder, "__init__.py"); |
|
364 |
if( !initAddonFile.exists() ) { |
|
365 |
try { |
|
366 |
FileUtils.touch(initAddonFile); |
|
367 |
} catch (IOException ex) { |
|
368 |
logger.info("Can't create addons __init__ file in '" + localAddonRepositoryFolder.getAbsolutePath() + "'.", ex); |
|
369 |
} |
|
370 |
} |
|
371 |
} |
|
372 |
|
|
373 |
@Override |
|
374 |
public void postInitialize() { |
|
375 |
super.postInitialize(); |
|
376 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
377 |
pluginManager.addStartupTask( |
|
378 |
"ExecuteAutorunScripts", |
|
379 |
new ExecuteAutorunScriptsOnStartup(), |
|
380 |
true, |
|
381 |
600 |
|
382 |
); |
|
383 |
|
|
384 |
Invocable initializer = new ScriptsInstallerInitializer(); |
|
385 |
initializer.call(this.getPlugin().getPluginName()); |
|
386 |
} |
|
387 |
|
|
388 |
@Override |
|
389 |
public boolean isEnabled() { |
|
390 |
return true; |
|
391 |
} |
|
392 |
|
|
393 |
@Override |
|
394 |
public boolean isVisible() { |
|
395 |
return true; |
|
396 |
} |
|
397 |
|
|
398 |
private static class ExecuteAutorunScriptsOnStartup implements Runnable { |
|
399 |
|
|
400 |
@Override |
|
401 |
public void run() { |
|
402 |
Thread th = new Thread(new ExecuteAutorunScripts()); |
|
403 |
th.start(); |
|
404 |
} |
|
405 |
} |
|
406 |
|
|
407 |
private static class ExecuteAutorunScripts implements Runnable { |
|
408 |
|
|
409 |
@Override |
|
410 |
public void run() { |
|
411 |
final ScriptingManager manager = ScriptingLocator.getManager(); |
|
412 |
manager.loadEngines(); |
|
413 |
|
|
414 |
final PluginsManager pluginManager = PluginsLocator.getManager(); |
|
415 |
final ApplicationManager application = ApplicationLocator.getManager(); |
|
416 |
final I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
417 |
|
|
418 |
final List<ScriptingBaseScript> autoruns = new ArrayList<>(); |
|
419 |
|
|
420 |
try { |
|
421 |
List<File> pluginsFolders = new ArrayList<>(); |
|
422 |
for( File f : pluginManager.getPluginsFolders() ) { |
|
423 |
pluginsFolders.addAll(Arrays.asList(f.listFiles())); |
|
424 |
} |
|
425 |
|
|
426 |
application.message( |
|
427 |
i18nManager.getTranslation("_Searching_autorun_scripts_Xhorizontal_ellipsisX"), |
|
428 |
JOptionPane.INFORMATION_MESSAGE |
|
429 |
); |
|
430 |
for( File pluginFolder : pluginsFolders ) { |
|
431 |
File autorun_file = new File(pluginFolder, "scripting/scripts/autorun.inf"); |
|
432 |
if( autorun_file.exists() ) { |
|
433 |
ScriptingBaseScript autorun = manager.getScript(autorun_file); |
|
434 |
if( autorun.isEnabled() ) { |
|
435 |
autoruns.add(autorun); |
|
436 |
} else { |
|
437 |
logger.info("Skip autorun script '" + autorun_file.getAbsolutePath() + "'."); |
|
438 |
} |
|
439 |
} |
|
440 |
} |
|
441 |
|
|
442 |
SimpleFileVisitor<Path> visitor = new SimpleFileVisitor<Path>() { |
|
443 |
@Override |
|
444 |
public FileVisitResult visitFile(Path path, BasicFileAttributes bfa) throws IOException { |
|
445 |
File file = path.toFile(); |
|
446 |
if( "autorun.inf".equalsIgnoreCase(file.getName()) ) { |
|
447 |
if( file.exists() ) { |
|
448 |
ScriptingBaseScript autorun = manager.getScript(file); |
|
449 |
if( autorun.isEnabled() ) { |
|
450 |
autoruns.add(autorun); |
|
451 |
} else { |
|
452 |
logger.info("Skip autorun script '" + file.getAbsolutePath() + "'."); |
|
453 |
} |
|
454 |
} |
|
455 |
} |
|
456 |
return FileVisitResult.CONTINUE; |
|
457 |
} |
|
458 |
}; |
|
459 |
try { |
|
460 |
EnumSet<FileVisitOption> opts = EnumSet.of(FOLLOW_LINKS); |
|
461 |
Files.walkFileTree(Paths.get(manager.getRootUserFolder().toURI()), opts, Integer.MAX_VALUE, visitor); |
|
462 |
List<ScriptingFolder> folders = manager.getAlternativeUserFolders(); |
|
463 |
for( ScriptingFolder folder : folders ) { |
|
464 |
Files.walkFileTree(Paths.get(folder.getFile().toURI()), opts, Integer.MAX_VALUE, visitor); |
|
465 |
} |
|
466 |
} catch (Exception ex) { |
|
467 |
logger.warn("Can't execute autoruns in home.", ex); |
|
468 |
} |
|
469 |
|
|
470 |
Collections.sort(autoruns, new Comparator<ScriptingBaseScript>() { |
|
471 |
|
|
472 |
@Override |
|
473 |
public int compare(ScriptingBaseScript o1, ScriptingBaseScript o2) { |
|
474 |
return getScriptOrderKey(o2).compareToIgnoreCase(getScriptOrderKey(o1)); |
|
475 |
} |
|
476 |
}); |
|
477 |
|
|
478 |
for( ScriptingBaseScript autorun : autoruns ) { |
|
479 |
try { |
|
480 |
logger.info("running autorun script '" + autorun.getFile().getAbsolutePath() + "' (" + getScriptOrderKey(autorun) + ", " + autorun.getIsolationGroup() + ")."); |
|
481 |
application.message( |
|
482 |
i18nManager.getTranslation( |
|
483 |
"_Running_autorun_script_from_XnameX", |
|
484 |
new String[]{ |
|
485 |
autorun.getFile().getParentFile().getName()} |
|
486 |
), |
|
487 |
JOptionPane.INFORMATION_MESSAGE |
|
488 |
); |
|
489 |
} catch (Exception ex) { |
|
490 |
// Ignore it |
|
491 |
} |
|
492 |
try { |
|
493 |
autorun.run(); |
|
494 |
} catch (Exception ex) { |
|
495 |
logger.warn("Can't execute autorun from '" + autorun.getFile().getAbsolutePath() + "'.", ex); |
|
496 |
} |
|
497 |
} |
|
498 |
|
|
499 |
} finally { |
|
500 |
logger.info("Running autorun scripts terminated."); |
|
501 |
application.message("", JOptionPane.INFORMATION_MESSAGE); |
|
502 |
} |
|
503 |
} |
|
504 |
|
|
505 |
private String getScriptOrderKey(ScriptingBaseScript o) { |
|
506 |
int groupOrder = 500; |
|
507 |
String groupName = "default"; |
|
508 |
int scriptOrder = 500; |
|
509 |
String s = o.getProperty("autorun.group.order"); |
|
510 |
if( s != null ) { |
|
511 |
try { |
|
512 |
groupOrder = Integer.parseInt(s); |
|
513 |
} catch (Exception ex) { |
|
514 |
// Do nothing. |
|
515 |
} |
|
516 |
} |
|
517 |
s = o.getProperty("autorun.group.name"); |
|
518 |
if( s != null ) { |
|
519 |
groupName = s; |
|
520 |
} |
|
521 |
s = o.getProperty("autorun.order"); |
|
522 |
if( s != null ) { |
|
523 |
try { |
|
524 |
scriptOrder = Integer.parseInt(s); |
|
525 |
} catch (Exception ex) { |
|
526 |
// Do nothing. |
|
527 |
} |
|
528 |
} |
|
529 |
String key = MessageFormat.format( |
|
530 |
"{0,number,000000}.{1}.{2,number,000000}", |
|
531 |
groupOrder, |
|
532 |
groupName, |
|
533 |
scriptOrder |
|
534 |
); |
|
535 |
return key; |
|
536 |
} |
|
537 |
} |
|
538 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptsInstallerInitializer.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension; |
|
2 |
|
|
3 |
import java.io.File; |
|
4 |
import org.apache.commons.io.FileUtils; |
|
5 |
import org.gvsig.andami.PluginsLocator; |
|
6 |
import org.gvsig.andami.PluginsManager; |
|
7 |
import org.gvsig.installer.lib.api.InstallerLocator; |
|
8 |
import org.gvsig.installer.lib.api.InstallerManager; |
|
9 |
import org.gvsig.installer.lib.spi.InstallerProviderLocator; |
|
10 |
import org.gvsig.scripting.ScriptingLocator; |
|
11 |
import org.gvsig.scripting.ScriptingManager; |
|
12 |
import org.gvsig.tools.service.spi.ProviderFactory; |
|
13 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
14 |
import org.gvsig.tools.util.Invocable; |
|
15 |
import org.slf4j.Logger; |
|
16 |
import org.slf4j.LoggerFactory; |
|
17 |
|
|
18 |
public class ScriptsInstallerInitializer implements Invocable { |
|
19 |
|
|
20 |
private static final Logger LOG = LoggerFactory.getLogger(ScriptsInstallerInitializer.class); |
|
21 |
|
|
22 |
@Override |
|
23 |
public Object call(Object... args) { |
|
24 |
try { |
|
25 |
String pluginName = (String) args[0]; |
|
26 |
|
|
27 |
ProviderManager providerManager = InstallerProviderLocator.getProviderManager(); |
|
28 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
|
29 |
ScriptingManager manager = ScriptingLocator.getManager(); |
|
30 |
InstallerManager installerManager = InstallerLocator.getInstallerManager(); |
|
31 |
|
|
32 |
File home = FileUtils.getFile(pluginManager.getApplicationHomeFolder(),"plugins",pluginName); |
|
33 |
|
|
34 |
manager.setHomeFolder(home); |
|
35 |
manager.setPackagesFolder(pluginManager.getInstallFolder()); |
|
36 |
|
|
37 |
File localAddonRepositoryFolder = new File(manager.getRootUserFolder(), "addons"); |
|
38 |
|
|
39 |
ProviderFactory factory = manager.getInstallerFactory(); |
|
40 |
providerManager.addProviderFactory(factory); |
|
41 |
|
|
42 |
installerManager.setDefaultLocalAddonRepository( |
|
43 |
localAddonRepositoryFolder, |
|
44 |
factory.getName() |
|
45 |
); |
|
46 |
|
|
47 |
return true; |
|
48 |
|
|
49 |
} catch (Exception ex) { |
|
50 |
LOG.warn("Problems initializing scripts installer.",ex); |
|
51 |
return false; |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
} |
|
0 | 56 |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/InstallCert.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app; |
|
2 |
|
|
3 |
/* |
|
4 |
* Copyright 2006 Sun Microsystems, Inc. All Rights Reserved. |
|
5 |
* |
|
6 |
* Redistribution and use in source and binary forms, with or without |
|
7 |
* modification, are permitted provided that the following conditions |
|
8 |
* are met: |
|
9 |
* |
|
10 |
* - Redistributions of source code must retain the above copyright |
|
11 |
* notice, this list of conditions and the following disclaimer. |
|
12 |
* |
|
13 |
* - Redistributions in binary form must reproduce the above copyright |
|
14 |
* notice, this list of conditions and the following disclaimer in the |
|
15 |
* documentation and/or other materials provided with the distribution. |
|
16 |
* |
|
17 |
* - Neither the name of Sun Microsystems nor the names of its |
|
18 |
* contributors may be used to endorse or promote products derived |
|
19 |
* from this software without specific prior written permission. |
|
20 |
* |
|
21 |
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS |
|
22 |
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
23 |
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
24 |
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR |
|
25 |
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
|
26 |
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
|
28 |
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF |
|
29 |
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
30 |
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
|
31 |
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
32 |
*/ |
|
33 |
/** |
|
34 |
* Originally from: |
|
35 |
* http://blogs.sun.com/andreas/resource/InstallCert.java |
|
36 |
* Use: |
|
37 |
* java InstallCert hostname |
|
38 |
* Example: |
|
39 |
*% java InstallCert ecc.fedora.redhat.com |
|
40 |
*/ |
|
41 |
|
|
42 |
import java.io.BufferedReader; |
|
43 |
import java.io.File; |
|
44 |
import java.io.FileInputStream; |
|
45 |
import java.io.FileOutputStream; |
|
46 |
import java.io.InputStream; |
|
47 |
import java.io.InputStreamReader; |
|
48 |
import java.io.OutputStream; |
|
49 |
import java.security.KeyStore; |
|
50 |
import java.security.MessageDigest; |
|
51 |
import java.security.cert.CertificateException; |
|
52 |
import java.security.cert.X509Certificate; |
|
53 |
|
|
54 |
import javax.net.ssl.SSLContext; |
|
55 |
import javax.net.ssl.SSLException; |
|
56 |
import javax.net.ssl.SSLSocket; |
|
57 |
import javax.net.ssl.SSLSocketFactory; |
|
58 |
import javax.net.ssl.TrustManager; |
|
59 |
import javax.net.ssl.TrustManagerFactory; |
|
60 |
import javax.net.ssl.X509TrustManager; |
|
61 |
|
|
62 |
/** |
|
63 |
* Class used to add the server's certificate to the KeyStore |
|
64 |
* with your trusted certificates. |
|
65 |
* |
|
66 |
* NOTE: modified to install the certificate always into the main cacerts |
|
67 |
* keystore. |
|
68 |
*/ |
|
69 |
public class InstallCert { |
|
70 |
|
|
71 |
public static void install(String host, Integer port, String passphrase) throws Exception { |
|
72 |
if( passphrase==null ) { |
|
73 |
passphrase = "changeit"; |
|
74 |
} |
|
75 |
if( port == null || port <1) { |
|
76 |
port = 443; |
|
77 |
} |
|
78 |
main( |
|
79 |
new String[] { |
|
80 |
host +":"+port, |
|
81 |
passphrase |
|
82 |
} |
|
83 |
); |
|
84 |
} |
|
85 |
|
|
86 |
public static void main(String[] args) throws Exception { |
|
87 |
String host; |
|
88 |
int port; |
|
89 |
char[] passphrase; |
|
90 |
if ((args.length == 1) || (args.length == 2)) { |
|
91 |
String[] c = args[0].split(":"); |
|
92 |
host = c[0]; |
|
93 |
port = (c.length == 1) ? 443 : Integer.parseInt(c[1]); |
|
94 |
String p = (args.length == 1) ? "changeit" : args[1]; |
|
95 |
passphrase = p.toCharArray(); |
|
96 |
} else { |
|
97 |
System.out.println("Usage: java InstallCert [:port] [passphrase]"); |
|
98 |
return; |
|
99 |
} |
|
100 |
|
|
101 |
File file = null; |
|
102 |
// File file = new File("jssecacerts"); |
|
103 |
// if (file.isFile() == false) { |
|
104 |
char SEP = File.separatorChar; |
|
105 |
File dir = |
|
106 |
new File(System.getProperty("java.home") + SEP + "lib" + SEP |
|
107 |
+ "security"); |
|
108 |
// file = new File(dir, "jssecacerts"); |
|
109 |
// if (file.isFile() == false) { |
|
110 |
file = new File(dir, "cacerts"); |
|
111 |
|
|
112 |
if (!file.canWrite()) { |
|
113 |
System.err |
|
114 |
.println("Unable to write in the file " |
|
115 |
+ file |
|
116 |
+ ".\nRun InstallCert as an administrator or a user with " |
|
117 |
+ "privileges to write in the cacerts file"); |
|
118 |
|
|
119 |
System.exit(-1); |
|
120 |
} |
|
121 |
// } |
|
122 |
// } |
|
123 |
System.out.println("Loading KeyStore " + file + "..."); |
|
124 |
InputStream in = new FileInputStream(file); |
|
125 |
KeyStore ks = KeyStore.getInstance(KeyStore.getDefaultType()); |
|
126 |
ks.load(in, passphrase); |
|
127 |
in.close(); |
|
128 |
|
|
129 |
SSLContext context = SSLContext.getInstance("TLS"); |
|
130 |
TrustManagerFactory tmf = |
|
131 |
TrustManagerFactory.getInstance(TrustManagerFactory |
|
132 |
.getDefaultAlgorithm()); |
|
133 |
tmf.init(ks); |
|
134 |
X509TrustManager defaultTrustManager = |
|
135 |
(X509TrustManager) tmf.getTrustManagers()[0]; |
|
136 |
SavingTrustManager tm = new SavingTrustManager(defaultTrustManager); |
|
137 |
context.init(null, new TrustManager[] { tm }, null); |
|
138 |
SSLSocketFactory factory = context.getSocketFactory(); |
|
139 |
|
|
140 |
System.out |
|
141 |
.println("Opening connection to " + host + ":" + port + "..."); |
|
142 |
SSLSocket socket = (SSLSocket) factory.createSocket(host, port); |
|
143 |
socket.setSoTimeout(10000); |
|
144 |
try { |
|
145 |
System.out.println("Starting SSL handshake..."); |
|
146 |
socket.startHandshake(); |
|
147 |
socket.close(); |
|
148 |
System.out.println(); |
|
149 |
System.out.println("No errors, certificate is already trusted"); |
|
150 |
} catch (SSLException e) { |
|
151 |
System.out.println(); |
|
152 |
e.printStackTrace(System.out); |
|
153 |
} |
|
154 |
|
|
155 |
X509Certificate[] chain = tm.chain; |
|
156 |
if (chain == null) { |
|
157 |
System.out.println("Could not obtain server certificate chain"); |
|
158 |
return; |
|
159 |
} |
|
160 |
|
|
161 |
BufferedReader reader = |
|
162 |
new BufferedReader(new InputStreamReader(System.in)); |
|
163 |
|
|
164 |
System.out.println(); |
|
165 |
System.out.println("Server sent " + chain.length + " certificate(s):"); |
|
166 |
System.out.println(); |
|
167 |
MessageDigest sha1 = MessageDigest.getInstance("SHA1"); |
|
168 |
MessageDigest md5 = MessageDigest.getInstance("MD5"); |
|
169 |
for (int i = 0; i < chain.length; i++) { |
|
170 |
X509Certificate cert = chain[i]; |
|
171 |
System.out.println(" " + (i + 1) + " Subject " |
|
172 |
+ cert.getSubjectDN()); |
|
173 |
System.out.println(" Issuer " + cert.getIssuerDN()); |
|
174 |
sha1.update(cert.getEncoded()); |
|
175 |
System.out.println(" sha1 " + toHexString(sha1.digest())); |
|
176 |
md5.update(cert.getEncoded()); |
|
177 |
System.out.println(" md5 " + toHexString(md5.digest())); |
|
178 |
System.out.println(); |
|
179 |
} |
|
180 |
|
|
181 |
// int k=0; |
|
182 |
// System.out |
|
183 |
// .println("Enter certificate to add to trusted keystore or 'q' to quit: [1]"); |
|
184 |
// String line = reader.readLine().trim(); |
|
185 |
// try { |
|
186 |
// k = (line.length() == 0) ? 0 : Integer.parseInt(line) - 1; |
|
187 |
// } catch (NumberFormatException e) { |
|
188 |
// System.out.println("KeyStore not changed"); |
|
189 |
// return; |
|
190 |
// } |
|
191 |
|
|
192 |
for( int k=0; k<chain.length; k++ ) { |
|
193 |
X509Certificate cert = chain[k]; |
|
194 |
String alias = host + "-" + (k + 1); |
|
195 |
ks.setCertificateEntry(alias, cert); |
|
196 |
|
|
197 |
// OutputStream out = new FileOutputStream("jssecacerts"); |
|
198 |
OutputStream out = new FileOutputStream(file); |
|
199 |
ks.store(out, passphrase); |
|
200 |
out.close(); |
|
201 |
|
|
202 |
System.out.println(); |
|
203 |
System.out.println(cert); |
|
204 |
System.out.println(); |
|
205 |
System.out |
|
206 |
.println("Added certificate to keystore '" + |
|
207 |
file + "' using alias '" + alias + "'"); |
|
208 |
} |
|
209 |
} |
|
210 |
|
|
211 |
private static final char[] HEXDIGITS = "0123456789abcdef".toCharArray(); |
|
212 |
|
|
213 |
private static String toHexString(byte[] bytes) { |
|
214 |
StringBuilder sb = new StringBuilder(bytes.length * 3); |
|
215 |
for (int b : bytes) { |
|
216 |
b &= 0xff; |
|
217 |
sb.append(HEXDIGITS[b >> 4]); |
|
218 |
sb.append(HEXDIGITS[b & 15]); |
|
219 |
sb.append(' '); |
|
220 |
} |
|
221 |
return sb.toString(); |
|
222 |
} |
|
223 |
|
|
224 |
private static class SavingTrustManager implements X509TrustManager { |
|
225 |
|
|
226 |
private final X509TrustManager tm; |
|
227 |
private X509Certificate[] chain; |
|
228 |
|
|
229 |
SavingTrustManager(X509TrustManager tm) { |
|
230 |
this.tm = tm; |
|
231 |
} |
|
232 |
|
|
233 |
public X509Certificate[] getAcceptedIssuers() { |
|
234 |
throw new UnsupportedOperationException(); |
|
235 |
} |
|
236 |
|
|
237 |
public void checkClientTrusted(X509Certificate[] chain, String authType) |
|
238 |
throws CertificateException { |
|
239 |
throw new UnsupportedOperationException(); |
|
240 |
} |
|
241 |
|
|
242 |
public void checkServerTrusted(X509Certificate[] chain, String authType) |
|
243 |
throws CertificateException { |
|
244 |
this.chain = chain; |
|
245 |
tm.checkServerTrusted(chain, authType); |
|
246 |
} |
|
247 |
} |
|
248 |
} |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
1 |
<?xml version="1.0"?> |
|
2 |
<!-- |
|
3 |
Definitions of plugin persistence org.gvsig.scripting.app.mainplugin. |
|
4 |
--> |
|
5 |
<definitions> |
|
6 |
<version>1.0.0</version> |
|
7 |
<classes> |
|
8 |
<class name="org.gvsig.scripting.app.mainplugin"> |
|
9 |
<description>Persistence of scripting plugin</description> |
|
10 |
<fields> |
|
11 |
<field name="ComposerUseHisWindowManager" type="boolean" mandatory="true" defaultValue="true"> |
|
12 |
<description>When true the composer use his window manager instead of the gvSIG Window manager.</description> |
|
13 |
</field> |
|
14 |
</fields> |
|
15 |
</class> |
|
16 |
</classes> |
|
17 |
</definitions> |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
1 |
_Scripting=Scripting |
|
2 |
_Show_scripting_launcher=Abrir lanzador de scripts |
|
3 |
_Show_scripting_composer=Abrir editor de scripts |
|
4 |
_Show_scripting_jython_console=Abrir consola Jython |
|
5 |
|
|
6 |
User=Usuario |
|
7 |
System=Sistema |
|
8 |
|
|
9 |
Accept=Aceptar |
|
10 |
Cancel=Cancelar |
|
11 |
Apply=Aplicar |
|
12 |
|
|
13 |
Retrieving_data=Recibiendo datos... |
|
14 |
|
|
15 |
File=Fichero |
|
16 |
New=Nuevo |
|
17 |
Close_document=Cerrar documento |
|
18 |
Close_all_documents=Cerrar todos los documentos |
|
19 |
Run=Ejecutar |
|
20 |
Save=Guardar |
|
21 |
Close=Cerrar |
|
22 |
Close_current_tab=Cerrar pesta\u00f1a actual |
|
23 |
Open_edition_mode=Abrir modo edici\u00f3n |
|
24 |
Run_selected_script=Ejecutar script seleccionado |
|
25 |
Delete_selected_script=Borrar script seleccionado |
|
26 |
Refresh_directories=Actualizar carpetas |
|
27 |
Move_files=Mover ficheros |
|
28 |
Set_file_preferences=Editar preferencias de fichero |
|
29 |
|
|
30 |
|
|
31 |
Edit=Editar |
|
32 |
Cut=Cortar |
|
33 |
Copy=Copiar |
|
34 |
Paste=Pegar |
|
35 |
Select_all=Seleccionar todo |
|
36 |
|
|
37 |
Tools=Herramientas |
|
38 |
Launcher=Lanzador de scripts |
|
39 |
Scripting_Launcher=Lanzador de scripts |
|
40 |
Scripting_Composer=Editor de scripts |
|
41 |
Jython_Console=Consola Jython |
|
42 |
Import_JavaDoc=Importar JavaDoc |
|
43 |
JavaDoc=Ayuda de Java (JavaDoc) |
|
44 |
Remove_JavaDoc=Eliminar JavaDoc |
|
45 |
Help_contents=Contenido de la ayuda |
|
46 |
About_scripts_editor=Acerca del editor de scripts |
|
47 |
Get_help=Ayuda |
|
48 |
Help=Ayuda |
|
49 |
_Package_script=Empaquetar script... |
|
50 |
_Package_help=Empaquetar ayuda... |
|
51 |
|
|
52 |
Problems=Errores |
|
53 |
Console=Consola |
|
54 |
|
|
55 |
Description=Descripci\u00f3n |
|
56 |
Resource=Recurso |
|
57 |
Location=Ubicaci\u00f3n |
|
58 |
|
|
59 |
no_line=sin l\u00ednea |
|
60 |
Line=L\u00ednea |
|
61 |
|
|
62 |
Welcome_message=Bienvenido al entorno de scripting |
|
63 |
|
|
64 |
Error_opening_in_edition_mode_title=Error al abrir fichero |
|
65 |
Error_opening_in_edition_mode=No se pudo abrir el fichero en modo edici\u00f3n |
|
66 |
|
|
67 |
New_Script=Nuevo elemento |
|
68 |
New_Script_Description=Crea un nuevo script, di\u00e1logo, proyecto, directorio |
|
69 |
|
|
70 |
Deleting_JavaDocs_successfully_title=Operaci\u00f3n realizada con \u00e9xito |
|
71 |
Deleting_JavaDocs_successfully=Eliminaci\u00f3n de los JavaDocs exitosa |
|
72 |
|
|
73 |
Import_JavaDoc_title=Importar JavaDocs desde los directorios de sistema al ScriptingFramework JavaDoc |
|
74 |
Remove_JavaDoc_title=Eliminar JavaDocs del ScriptingFramework JavaDoc |
|
75 |
|
|
76 |
projects_modified_title=Proyectos sin guardar |
|
77 |
projects_modified=Algunos proyectos han sido modificados.\u00bfSalvar cambios? |
|
78 |
project_modified=ha sido modificado.\u00bfSalvar cambios? |
|
79 |
|
|
80 |
Delete_all_title=Borrar el documento |
|
81 |
Delete_all_message=Esta acci\u00f3n elimina el documento o el directorio con todo su contenido. \u00bf Desea continuar ? |
|
82 |
|
|
83 |
About_us_title=Informaci\u00f3n de todos los contribuidores al proyecto gvSIG |
|
84 |
|
|
85 |
Success=Operaci\u00f3n realizada con \u00e9xito |
|
86 |
Error=Error |
|
87 |
Error_renaming=Inesperado error renombrando el fichero |
|
88 |
Error_moving=Inesperado error moviendo el fichero |
|
89 |
Error_help=Selecciona una ayuda |
|
90 |
Rename_succesfully=Renombrado del fichero realizado con \u00e9xito |
|
91 |
Select_first=Debe seleccionar un fichero primero |
|
92 |
help_key=No hay ayuda para el texto |
|
93 |
|
|
94 |
|
|
95 |
script_filesystem=script en el \u00e1rbol de directorio |
|
96 |
Move=Mover |
|
97 |
move_desc=Cambia la ubicaci\u00f3n del fichero seleccionado |
|
98 |
Rename=Renombrar |
|
99 |
rename_desc=Cambia el nombre y otras propiedades del fichero seleccionado |
|
100 |
Moving_succesfully=Reubicaci\u00f3n del fichero realizado con \u00e9xito |
|
101 |
|
|
102 |
Dialog=Di\u00e1logo |
|
103 |
Code=C\u00f3digo |
|
104 |
Properties=Propiedades |
|
105 |
|
|
106 |
current_name=Nombre actual |
|
107 |
new_name=Nuevo name |
|
108 |
rename_name_title=Cambiar el nombre del fichero |
|
109 |
more_properties=M\u00e1s propiedades |
|
110 |
|
|
111 |
Javadoc_remove=Selecciona el JavaDoc a eliminar |
|
112 |
no_Javadoc_remove=No hay JavaDoc para eliminar |
|
113 |
|
|
114 |
Name=Nombre |
|
115 |
Version=Versi\u00f3n |
|
116 |
Created_by=Creado por |
|
117 |
Description=Descripci\u00f3n |
|
118 |
Type=Tipo |
|
119 |
Language=Lenguaje |
|
120 |
Author=Autor |
|
121 |
Move_from=Mover desde |
|
122 |
Move_to=Destino |
|
123 |
Browse=Abrir |
|
124 |
Import_from=Importar desde |
|
125 |
|
|
126 |
Name_blank=El nombre no puede estar en blanco |
|
127 |
Name_exists=Este nombre ya existe. Debe elegir otro |
|
128 |
Import_success=Los JavaDocs se han importado satisfactoriamente |
|
129 |
JavaDoc_Error=Selecciona JavaDoc a importar |
|
130 |
|
|
131 |
go_to_line_Xhorizontal_ellipsisX=Ir a la l\u00ednea\u2026 |
|
132 |
find_Xhorizontal_ellipsisX=Buscar\u2026 |
|
133 |
replace_Xhorizontal_ellipsisX=Reemplazar\u2026 |
|
134 |
_Searching_autorun_scripts_Xhorizontal_ellipsisX=Buscando scripts de autoarranque... |
|
135 |
_Running_autorun_script_from_XnameX=Ejecutando script de autoarranque desde "{0}" |
|
136 |
_The_script_XscriptnameX_is_modified=El script "{0}" ha sido modificado. |
|
137 |
_Save_changes_XquestionX=\u00bf Guardar cambios ? |
|
138 |
_Do_you_want_to_save_changes_XquestionX=\u00bf Desea guardar los cambios ? |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
1 |
_Scripting=Scripting |
|
2 |
_Show_scripting_launcher=Show scripting launcher |
|
3 |
_Show_scripting_composer=Show scripting composer |
|
4 |
_Show_scripting_jython_console=Show Jython console |
|
5 |
|
|
6 |
User=User |
|
7 |
System=System |
|
8 |
|
|
9 |
Accept=Accept |
|
10 |
Cancel=Cancel |
|
11 |
Apply=Apply |
|
12 |
|
|
13 |
Retrieving_data=Retrieving data... |
|
14 |
|
|
15 |
File=File |
|
16 |
New=New |
|
17 |
Close_document=Close document |
|
18 |
Close_all_documents=Cloase all documents |
|
19 |
Run=Run |
|
20 |
Save=Save |
|
21 |
Close=Close |
|
22 |
Close_current_tab=Close current tab |
|
23 |
Open_edition_mode=Open edition mode |
|
24 |
Run_selected_script=Run selected script |
|
25 |
Delete_selected_script=Delete selected script |
|
26 |
Refresh_directories=Refresh directories |
|
27 |
Move_files=Move files |
|
28 |
Set_file_preferences=Set file preferences |
|
29 |
_Running_autorun_script_from_XnameX=Running autorun script from {0} |
|
30 |
|
|
31 |
Edit=Edit |
|
32 |
Cut=Cut |
|
33 |
Copy=Copy |
|
34 |
Paste=Paste |
|
35 |
Select_all=Select all |
|
36 |
|
|
37 |
Tools=Tools |
|
38 |
Launcher=Scripting Launcher |
|
39 |
Scripting_Launcher=Scripting Launcher |
|
40 |
Scripting_Composer=Scripting Composer |
|
41 |
Jython_Console=Jython console |
|
42 |
Import_JavaDoc=Import JavaDoc |
|
43 |
JavaDoc=Java Help (JavaDoc) |
|
44 |
Remove_JavaDoc=Remove JavaDoc |
|
45 |
Help_contents=Help contents |
|
46 |
About_scripts_editor=About scripts editor |
|
47 |
Get_help=Help |
|
48 |
Help=Help |
|
49 |
_Package_script=Package script... |
|
50 |
_Package_help=Package help... |
|
51 |
|
|
52 |
Problems=Errors |
|
53 |
Console=Console |
|
54 |
|
|
55 |
Description=Description |
|
56 |
Resource=Resource |
|
57 |
Location=Location |
|
58 |
|
|
59 |
no_line=no line |
|
60 |
Line=Line |
|
61 |
|
|
62 |
Welcome_message=Welcome to the scripting framework |
|
63 |
|
|
64 |
Error_opening_in_edition_mode_title=Error opening file in edition mode |
|
65 |
Error_opening_in_edition_mode=The file can't be opened in edition mode |
|
66 |
|
|
67 |
New_Script=New element |
|
68 |
New_Script_Description=Create a new script, dialog, project, directory |
|
69 |
|
|
70 |
Deleting_JavaDocs_successfully_title=Operation successful |
|
71 |
Deleting_JavaDocs_successfully=Deleting JavaDocs successfully |
|
72 |
|
|
73 |
Import_JavaDoc_title=Import JavaDocs from filesystem to ScriptingFramework JavaDoc |
|
74 |
Remove_JavaDoc_title=Remove JavaDocs from ScriptingFramework JavaDoc |
|
75 |
|
|
76 |
projects_modified_title=Projects without saving |
|
77 |
projects_modified=Some projects have been modified. Save changes? |
|
78 |
project_modified=has been modified. Save changes? |
|
79 |
|
|
80 |
Delete_all_title=Delete document |
|
81 |
Delete_all_message=This action removes the document or directory with all its content. Do you wish to continue ? |
|
82 |
|
|
83 |
About_us_title=Information about all the gvSIG's contributors |
|
84 |
|
|
85 |
Success=Operation done successfully |
|
86 |
Error=Error |
|
87 |
Error_renaming=Unexpected error renaming the file |
|
88 |
Error_moving=Unexpected error moving the file |
|
89 |
Error_help=Select help |
|
90 |
Rename_succesfully=Renaming successfully |
|
91 |
Select_first=Select a file first |
|
92 |
help_key=There isn't any help to this text |
|
93 |
|
|
94 |
|
|
95 |
script_filesystem=script filesystem |
|
96 |
Move=Move |
|
97 |
move_desc=Change location of selected file |
|
98 |
Rename=Rename |
|
99 |
rename_desc=Change the name and more properties of the selected file |
|
100 |
Moving_succesfully=File moved succesfully |
|
101 |
|
|
102 |
Dialog=Dialog |
|
103 |
Code=Code |
|
104 |
Properties=Properties |
|
105 |
|
|
106 |
current_name=Current name |
|
107 |
new_name=New name |
|
108 |
rename_name_title=Change filename |
|
109 |
more_properties=more properties |
|
110 |
|
|
111 |
Javadoc_remove=Choose JavaDoc to delete |
|
112 |
no_Javadoc_remove=There's no JavaDoc to delete |
|
113 |
|
|
114 |
Name=Name |
|
115 |
Version=Version |
|
116 |
Created_by=Create by |
|
117 |
Description=Description |
|
118 |
Type=Type |
|
119 |
Language=Language |
|
120 |
Author=Author |
|
121 |
Move_from=Move from |
|
122 |
Move_to=Move to |
|
123 |
Browse=Browse |
|
124 |
Import_from=Import from |
|
125 |
|
|
126 |
Name_blank=Name can't be blank |
|
127 |
Name_exists=This name already exists. Choose another one |
|
128 |
Import_success=JavaDocs imported successfully |
|
129 |
JavaDoc_Error=Select JavaDoc to import |
|
130 |
|
|
131 |
|
|
132 |
go_to_line_Xhorizontal_ellipsisX=Go To Line\u2026 |
|
133 |
find_Xhorizontal_ellipsisX=Find\u2026 |
|
134 |
replace_Xhorizontal_ellipsisX=Replace\u2026 |
|
135 |
|
|
136 |
_Searching_autorun_scripts_Xhorizontal_ellipsisX=Searching autorun scripts... |
|
137 |
_Running_autorun_script_from_XnameX=Running autorun script from "{0}" |
|
138 |
_The_script_XscriptnameX_is_modified=The script "{0}" has been modified. |
|
139 |
_Save_changes_XquestionX=Save changes ? |
|
140 |
_Do_you_want_to_save_changes_XquestionX=Do you want to save changes ? |
org.gvsig.scripting/tags/org.gvsig.scripting-2.3.52/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/License_Chalkwork_icons.txt | ||
---|---|---|
1 |
---------------------------------------------- |
|
2 |
CHALKWORK BASIC |
|
3 |
by Dave Shea |
|
4 |
mezzoblue.com/icons/chalkwork/basic |
|
5 |
---------------------------------------------- |
|
6 |
CHALKWORK COMMERCE |
|
7 |
by Dave Shea |
|
8 |
mezzoblue.com/icons/chalkwork/commerce |
|
9 |
---------------------------------------------- |
|
10 |
CHALKWORK EDITING CONTROLS |
|
11 |
by Dave Shea |
|
12 |
mezzoblue.com/icons/chalkwork/editing-controls |
|
13 |
---------------------------------------------- |
|
14 |
CHALKWORK INFORMATION MANAGEMENT |
|
15 |
by Dave Shea |
|
16 |
mezzoblue.com/icons/chalkwork/information-management |
|
17 |
---------------------------------------------- |
|
18 |
CHALKWORK HTML (Free Version) |
|
19 |
by Dave Shea |
|
20 |
mezzoblue.com/icons/chalkwork/html |
|
21 |
---------------------------------------------- |
|
22 |
|
|
23 |
Thanks for your interest in the Chalkwork Family. Please consider subscribing to the Chalkwork news feed, which will announce new releases in the family as well as inform existing users of updates if any occur. |
|
24 |
|
|
25 |
http://mezzoblue.com/icons/chalkwork/news.xml |
|
26 |
|
|
27 |
- Dave Shea |
|
28 |
mezzoblue.com |
|
29 |
@mezzoblue on Twitter |
|
30 |
|
|
31 |
|
|
32 |
|
|
33 |
|
|
34 |
LICENSE AGREEMENT |
|
35 |
---------------------------------------------- |
|
36 |
By downloading this icon set, you agree to abide by the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License under which these icons are being made available for non-commercial use. |
|
37 |
|
|
38 |
Applicable Creative Commons License: http://creativecommons.org/licenses/by-nc-sa/3.0/ |
|
39 |
Attribution and additional license information: http://www.mezzoblue.com/icons/license/#license-cc |
|
40 |
|
|
41 |
By purchasing a Chalkwork Commercial License, you agree to abide by the Chalkwork Royalty-Free Stock Icon License Agreement under which these icons are being made available for commercial use. |
|
42 |
|
|
43 |
Chalkwork Commercial License: http://www.mezzoblue.com/icons/license/#license-cc |
|
44 |
|
|
45 |
This notice must be included any time these icons are redistributed. |
|
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
---------------------------------------------- |
|
51 |
ICON FOLDER INDEX |
|
52 |
---------------------------------------------- |
|
53 |
The icon files are broken down by file format. Due to some formats resulting in higher quality results, those are considered the preferred files and are located in the folder titled 'High Quality'. This package should contain the following folders in this hierarchy: |
|
54 |
|
|
55 |
High Quality |
|
56 |
ICNS (Mac) |
|
57 |
ICO (Windows) |
|
58 |
PNG |
|
59 |
TIF |
|
60 |
Lower Quality |
|
61 |
BMP |
|
62 |
GIF |
|
63 |
|
|
64 |
Within each of the second-level folders, you'll find 102 further folders, one for each icon and its variations. Depending on the file format, you may find multiple sizes within these folders along with any icon variations that may exist. Please note that ICO and ICNS files contain all applicable sizes within a single file, and that ICNS files do not support the 24x24 icon size. |
Also available in: Unified diff