001: /**
002: * LibreSource
003: * Copyright (C) 2004-2008 Artenum SARL / INRIA
004: * http://www.libresource.org - contact@artenum.com
005: *
006: * This file is part of the LibreSource software,
007: * which can be used and distributed under license conditions.
008: * The license conditions are provided in the LICENSE.TXT file
009: * at the root path of the packaging that enclose this file.
010: * More information can be found at
011: * - http://dev.libresource.org/home/license
012: *
013: * Initial authors :
014: *
015: * Guillaume Bort / INRIA
016: * Francois Charoy / Universite Nancy 2
017: * Julien Forest / Artenum
018: * Claude Godart / Universite Henry Poincare
019: * Florent Jouille / INRIA
020: * Sebastien Jourdain / INRIA / Artenum
021: * Yves Lerumeur / Artenum
022: * Pascal Molli / Universite Henry Poincare
023: * Gerald Oster / INRIA
024: * Mariarosa Penzi / Artenum
025: * Gerard Sookahet / Artenum
026: * Raphael Tani / INRIA
027: *
028: * Contributors :
029: *
030: * Stephane Bagnier / Artenum
031: * Amadou Dia / Artenum-IUP Blois
032: * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
033: */package org.libresource.so6.core.exec;
034:
035: import org.libresource.so6.core.WsConnection;
036: import org.libresource.so6.core.client.ClientI;
037: import org.libresource.so6.core.engine.util.CryptUtil;
038:
039: import java.lang.reflect.Method;
040:
041: import java.util.Properties;
042:
043: /**
044: * @author smack
045: */
046: public class UpdateWsConnection {
047: private String clientName;
048: private String wscPath;
049: private Properties props;
050:
051: public UpdateWsConnection(String wscPath, String clientName) {
052: this (clientName, wscPath, null);
053: }
054:
055: public UpdateWsConnection(String clientName, String wscPath,
056: Properties props) {
057: this .wscPath = wscPath;
058: this .clientName = clientName;
059:
060: if (props == null) {
061: this .props = System.getProperties();
062: } else {
063: this .props = props;
064: }
065: }
066:
067: public void execute() throws Exception {
068: WsConnection wsc = new WsConnection(wscPath);
069: Method m = Class.forName(clientName).getMethod(
070: "getInternalPropertyList", new Class[] {});
071: String[] ops = (String[]) m.invoke(null, new Object[] {});
072: wsc.setProperty(WsConnection.SYNC_CLIENT_NAME, clientName);
073:
074: for (int i = 0; i < ops.length; i++) {
075: String value = System.getProperties().getProperty(ops[i]);
076:
077: if (value != null) {
078: if (ops[i].equals(ClientI.SO6_PASSWORD)) {
079: wsc.setProperty(ops[i], value); //CryptUtil.encode(value));
080: } else {
081: wsc.setProperty(ops[i], value);
082: }
083: }
084: }
085: }
086:
087: public static void main(String[] args) throws Exception {
088: if (args.length != 2) {
089: System.err.println("Usage: wscPath clientName");
090: System.err
091: .println(" (1) wscPath: path of the so6.properties");
092: System.err
093: .println(" (2) clientName: class name of the client");
094: System.err
095: .println(" (3) set all the required props in the JVM");
096: } else {
097: new UpdateWsConnection(args[0], args[1]).execute();
098: }
099: }
100: }
|