Arbeitsstand Anfang Februar
git-svn-id: https://brutex.net/svn/xservices/trunk@113 e7e49efb-446e-492e-b9ec-fcafc1997a86tag-20130205r
parent
8b3c74e44b
commit
71980e0cb2
|
@ -1,104 +1,78 @@
|
|||
package net.brutex.xservices.util;
|
||||
/* */ package net.brutex.xservices.util;
|
||||
/* */
|
||||
/* */ import java.io.PrintStream;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.BinaryMessageEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.CVSListener;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.FileAddedEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.FileInfoEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.FileRemovedEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.FileToRemoveEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.FileUpdatedEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.MessageEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.ModuleExpansionEvent;
|
||||
/* */ import org.netbeans.lib.cvsclient.event.TerminationEvent;
|
||||
/* */
|
||||
/* */ public abstract class BasicCVSListener
|
||||
/* */ implements CVSListener
|
||||
/* */ {
|
||||
/* 24 */ private final StringBuffer taggedLine = new StringBuffer();
|
||||
/* */
|
||||
/* 26 */ private final boolean showEvents = true;
|
||||
/* */
|
||||
/* */ public void messageSent(MessageEvent e)
|
||||
/* */ {
|
||||
/* 36 */ String line = e.getMessage();
|
||||
/* 37 */ PrintStream stream = e.isError() ? System.err :
|
||||
/* 38 */ System.out;
|
||||
/* */
|
||||
/* 40 */ if (e.isTagged())
|
||||
/* */ {
|
||||
/* 42 */ String str1 = MessageEvent.parseTaggedMessage(this.taggedLine, line);
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void commandTerminated(TerminationEvent arg0)
|
||||
/* */ {
|
||||
/* 59 */ System.out.println("commandTerminated");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void fileAdded(FileAddedEvent arg0)
|
||||
/* */ {
|
||||
/* 65 */ System.out.println("fileAdded");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void fileInfoGenerated(FileInfoEvent arg0)
|
||||
/* */ {
|
||||
/* 71 */ System.out.println("fileInfoGenerated");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void fileRemoved(FileRemovedEvent arg0)
|
||||
/* */ {
|
||||
/* 76 */ System.out.println("fileRemoved");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void fileToRemove(FileToRemoveEvent arg0)
|
||||
/* */ {
|
||||
/* 82 */ System.out.println("fileToRemove");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void fileUpdated(FileUpdatedEvent arg0)
|
||||
/* */ {
|
||||
/* 88 */ System.out.println("fileUpdated");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void messageSent(BinaryMessageEvent arg0)
|
||||
/* */ {
|
||||
/* 94 */ System.out.println("messageSent_Binary");
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public void moduleExpanded(ModuleExpansionEvent arg0)
|
||||
/* */ {
|
||||
/* 100 */ System.out.println("ModuleExpansionEvent");
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
import java.io.PrintStream;
|
||||
|
||||
import org.netbeans.lib.cvsclient.command.FileInfoContainer;
|
||||
import org.netbeans.lib.cvsclient.command.log.LogInformation;
|
||||
import org.netbeans.lib.cvsclient.event.BinaryMessageEvent;
|
||||
import org.netbeans.lib.cvsclient.event.CVSAdapter;
|
||||
import org.netbeans.lib.cvsclient.event.CVSListener;
|
||||
import org.netbeans.lib.cvsclient.event.FileAddedEvent;
|
||||
import org.netbeans.lib.cvsclient.event.FileInfoEvent;
|
||||
import org.netbeans.lib.cvsclient.event.FileRemovedEvent;
|
||||
import org.netbeans.lib.cvsclient.event.FileToRemoveEvent;
|
||||
import org.netbeans.lib.cvsclient.event.FileUpdatedEvent;
|
||||
import org.netbeans.lib.cvsclient.event.MessageEvent;
|
||||
import org.netbeans.lib.cvsclient.event.ModuleExpansionEvent;
|
||||
import org.netbeans.lib.cvsclient.event.TerminationEvent;
|
||||
|
||||
public abstract class BasicCVSListener implements CVSListener
|
||||
{
|
||||
/**
|
||||
* Stores a tagged line
|
||||
/* Location: C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
|
||||
* Qualified Name: net.brutex.xservices.util.BasicCVSListener
|
||||
* JD-Core Version: 0.6.2
|
||||
*/
|
||||
private final StringBuffer taggedLine = new StringBuffer();
|
||||
|
||||
/**
|
||||
* Called when the server wants to send a message to be displayed to
|
||||
* the user. The message is only for information purposes and clients
|
||||
* can choose to ignore these messages if they wish.
|
||||
* @param e the event
|
||||
*/
|
||||
public void messageSent(MessageEvent e)
|
||||
{
|
||||
String line = e.getMessage();
|
||||
PrintStream stream = e.isError() ? System.err
|
||||
: System.out;
|
||||
|
||||
if (e.isTagged())
|
||||
{
|
||||
String message = e.parseTaggedMessage(taggedLine, line);
|
||||
// if we get back a non-null line, we have something
|
||||
// to output. Otherwise, there is more to come and we
|
||||
// should do nothing yet.
|
||||
if (message != null)
|
||||
{
|
||||
//stream.println("Message: " + message);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//stream.println("Message: " + line);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commandTerminated(TerminationEvent arg0) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileAdded(FileAddedEvent arg0) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileInfoGenerated(FileInfoEvent arg0) {
|
||||
FileInfoContainer info = arg0.getInfoContainer();
|
||||
LogInformation info2 = (LogInformation) info;
|
||||
System.out.println(info2.getRepositoryFilename());
|
||||
System.out.println(info2.getDescription());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileRemoved(FileRemovedEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileToRemove(FileToRemoveEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fileUpdated(FileUpdatedEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void messageSent(BinaryMessageEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void moduleExpanded(ModuleExpansionEvent arg0) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if( conn!= null && conn.isValid(5)) {
|
||||
if( conn!= null ) { // Todo: && conn.conn.isValid(5)) {
|
||||
logger.debug("Checking tables on pre-exisiting database connection.");
|
||||
checkTables();
|
||||
return conn;
|
||||
|
@ -154,7 +154,7 @@ public class BrutexHSQLQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
|
||||
private synchronized boolean isConnected(boolean fail) throws SQLException {
|
||||
if(conn!=null && conn.isValid(5)) {
|
||||
if(conn!=null ) { // Todo: && conn.conn.isValid(5)) {) {
|
||||
return true;
|
||||
} else {
|
||||
String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes
|
||||
|
|
|
@ -46,7 +46,7 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
|
||||
|
||||
public Connection getConnection() throws SQLException {
|
||||
if( conn!= null && conn.isValid(5)) {
|
||||
if( conn!= null) { // Todo: && conn.conn.isValid(5)) {) {
|
||||
logger.debug("Checking tables on pre-exisiting database connection.");
|
||||
checkTables();
|
||||
return conn;
|
||||
|
@ -154,7 +154,7 @@ public class BrutexQuartzConnectionProvider implements ConnectionProvider {
|
|||
}
|
||||
|
||||
private synchronized boolean isConnected(boolean fail) throws SQLException {
|
||||
if(conn!=null && conn.isValid(5)) {
|
||||
if(conn!=null ) { // Todo: && conn.conn.isValid(5)) {) {
|
||||
return true;
|
||||
} else {
|
||||
String t = this.getClass().getClassLoader().getResource("/").toString().substring(6); // WEB-INF/classes
|
||||
|
|
|
@ -1,94 +1,94 @@
|
|||
/*
|
||||
* Copyright 2012 Brian Rosenberger (Brutex Network)
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
/* */ package net.brutex.xservices.util;
|
||||
/* */
|
||||
/* */ import java.io.File;
|
||||
/* */ import net.brutex.xservices.types.scm.ItemType;
|
||||
/* */ import net.brutex.xservices.ws.rs.CVSInfoImpl;
|
||||
/* */ import org.apache.commons.configuration.Configuration;
|
||||
/* */ import org.apache.commons.configuration.ConfigurationException;
|
||||
/* */ import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
/* */ import org.apache.log4j.Logger;
|
||||
/* */ import org.netbeans.lib.cvsclient.Client;
|
||||
/* */ import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
|
||||
/* */ import org.netbeans.lib.cvsclient.command.CommandAbortedException;
|
||||
/* */ import org.netbeans.lib.cvsclient.command.GlobalOptions;
|
||||
/* */ import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
||||
/* */ import org.netbeans.lib.cvsclient.connection.PServerConnection;
|
||||
/* */
|
||||
/* */ public class CVSClient
|
||||
/* */ {
|
||||
/* */ private final File configfile;
|
||||
/* */ private final PServerConnection connection;
|
||||
/* */ private final CVSRoot root;
|
||||
/* */ private final GlobalOptions globalOptions;
|
||||
/* 41 */ final Logger logger = Logger.getLogger(CVSInfoImpl.class);
|
||||
/* */ public final Client client;
|
||||
/* */
|
||||
/* */ public Client getClient()
|
||||
/* */ {
|
||||
/* 49 */ return this.client;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public CVSClient(File config) throws CommandAbortedException, AuthenticationException, ConfigurationException {
|
||||
/* 53 */ System.setProperty("cvsClientLog", "c:/temp/cvs.log");
|
||||
/* 54 */ if ((config == null) || (!config.exists()) || (config.isDirectory())) {
|
||||
/* 55 */ throw new ConfigurationException("Config file not found");
|
||||
/* */ }
|
||||
/* 57 */ this.configfile = config;
|
||||
/* 58 */ Configuration configuration = new PropertiesConfiguration(this.configfile);
|
||||
/* */
|
||||
/* 60 */ String cvsroot = configuration.getString("CVSROOT");
|
||||
/* 61 */ String workdir = configuration.getString("WORKDIR");
|
||||
/* 62 */ String password = configuration.getString("PASSWORD");
|
||||
/* */
|
||||
/* 64 */ this.root = new CVSRoot(cvsroot);
|
||||
/* 65 */ this.globalOptions = new GlobalOptions();
|
||||
/* 66 */ this.globalOptions.setCVSRoot(cvsroot);
|
||||
/* */
|
||||
/* 68 */ this.connection = new PServerConnection();
|
||||
/* 69 */ this.connection.setUserName(this.root.user);
|
||||
/* 70 */ if (password != null)
|
||||
/* 71 */ this.connection.setEncodedPassword(CvsPassword.encode(password));
|
||||
/* */ else {
|
||||
/* 73 */ this.connection.setEncodedPassword(password);
|
||||
/* */ }
|
||||
/* */
|
||||
/* 76 */ this.connection.setHostName(this.root.host);
|
||||
/* 77 */ this.connection.setRepository(this.root.repository);
|
||||
/* */ try {
|
||||
/* 79 */ this.connection.open();
|
||||
/* */ } catch (AuthenticationException ex) {
|
||||
/* 81 */ this.logger.error(ex.getMessage());
|
||||
/* */ }
|
||||
/* */
|
||||
/* 84 */ this.client = new Client(this.connection, new StandardAdminHandler());
|
||||
/* 85 */ this.client.setLocalPath(workdir);
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public File getConfigFile()
|
||||
/* */ {
|
||||
/* 91 */ return this.configfile;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public GlobalOptions getGlobalOptions() {
|
||||
/* 95 */ return this.globalOptions;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public PServerConnection getConnection()
|
||||
/* */ {
|
||||
/* 101 */ return this.connection;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public CVSRoot getRoot()
|
||||
/* */ {
|
||||
/* 107 */ return this.root;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public static String generateID(ItemType item) {
|
||||
/* 111 */ return "::[" + item.getRemotename() + "]";
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
/* Location: C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
|
||||
* Qualified Name: net.brutex.xservices.util.CVSClient
|
||||
* JD-Core Version: 0.6.2
|
||||
*/
|
||||
|
||||
package net.brutex.xservices.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
|
||||
import org.apache.commons.configuration.Configuration;
|
||||
import org.apache.commons.configuration.ConfigurationException;
|
||||
import org.apache.commons.configuration.PropertiesConfiguration;
|
||||
import org.netbeans.lib.cvsclient.Client;
|
||||
import org.netbeans.lib.cvsclient.admin.StandardAdminHandler;
|
||||
import org.netbeans.lib.cvsclient.command.CommandAbortedException;
|
||||
import org.netbeans.lib.cvsclient.command.GlobalOptions;
|
||||
import org.netbeans.lib.cvsclient.connection.AuthenticationException;
|
||||
import org.netbeans.lib.cvsclient.connection.PServerConnection;
|
||||
|
||||
public class CVSClient {
|
||||
private final File configfile;
|
||||
private final PServerConnection connection;
|
||||
private final CVSRoot root;
|
||||
private final GlobalOptions globalOptions;
|
||||
|
||||
public final Client client;
|
||||
|
||||
public CVSClient(File config) throws CommandAbortedException, AuthenticationException, ConfigurationException {
|
||||
|
||||
if (config == null || !config.exists() || config.isDirectory())
|
||||
throw new ConfigurationException("Config file not found");
|
||||
|
||||
this.configfile = config;
|
||||
Configuration configuration = new PropertiesConfiguration(configfile);
|
||||
|
||||
String cvsroot = configuration.getString("CVSROOT");
|
||||
String workdir = configuration.getString("WORKDIR");
|
||||
String password = configuration.getString("PASSWORD");
|
||||
|
||||
this.root = new CVSRoot(cvsroot);
|
||||
this.globalOptions = new GlobalOptions();
|
||||
globalOptions.setCVSRoot(cvsroot);
|
||||
|
||||
this.connection = new PServerConnection();
|
||||
connection.setUserName(root.user);
|
||||
if (password != null) {
|
||||
connection.setEncodedPassword(CvsPassword.encode(password));
|
||||
} else {
|
||||
connection.setEncodedPassword(password);
|
||||
}
|
||||
|
||||
connection.setHostName(root.host);
|
||||
connection.setRepository(root.repository);
|
||||
connection.open();
|
||||
|
||||
this.client = new Client(connection, new StandardAdminHandler());
|
||||
client.setLocalPath(workdir);
|
||||
}
|
||||
/**
|
||||
* @return
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
return this.configfile;
|
||||
}
|
||||
|
||||
public GlobalOptions getGlobalOptions() {
|
||||
return this.globalOptions;
|
||||
}
|
||||
/**
|
||||
* @return the connection
|
||||
*/
|
||||
public PServerConnection getConnection() {
|
||||
return connection;
|
||||
}
|
||||
/**
|
||||
* @return the root
|
||||
*/
|
||||
public CVSRoot getRoot() {
|
||||
return root;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,67 +1,82 @@
|
|||
package net.brutex.xservices.util;
|
||||
/* */ package net.brutex.xservices.util;
|
||||
/* */
|
||||
/* */ import java.io.BufferedReader;
|
||||
/* */ import java.io.File;
|
||||
/* */ import java.io.FileReader;
|
||||
/* */ import java.io.IOException;
|
||||
/* */ import java.io.PrintStream;
|
||||
/* */
|
||||
/* */ public class CVSRoot
|
||||
/* */ {
|
||||
/* */ public String connectionType;
|
||||
/* */ public String user;
|
||||
/* */ public String host;
|
||||
/* */ public String repository;
|
||||
/* */
|
||||
/* */ public CVSRoot(String root)
|
||||
/* */ throws IllegalArgumentException
|
||||
/* */ {
|
||||
/* 19 */ if (!root.startsWith(":")) {
|
||||
/* 20 */ throw new IllegalArgumentException();
|
||||
/* */ }
|
||||
/* 22 */ int oldColonPosition = 0;
|
||||
/* 23 */ int colonPosition = root.indexOf(':', 1);
|
||||
/* 24 */ if (colonPosition == -1)
|
||||
/* 25 */ throw new IllegalArgumentException();
|
||||
/* 26 */ this.connectionType = root.substring(oldColonPosition + 1, colonPosition);
|
||||
/* 27 */ oldColonPosition = colonPosition;
|
||||
/* 28 */ colonPosition = root.indexOf('@', colonPosition + 1);
|
||||
/* 29 */ if (colonPosition == -1)
|
||||
/* 30 */ throw new IllegalArgumentException();
|
||||
/* 31 */ this.user = root.substring(oldColonPosition + 1, colonPosition);
|
||||
/* 32 */ oldColonPosition = colonPosition;
|
||||
/* 33 */ colonPosition = root.indexOf(':', colonPosition + 1);
|
||||
/* 34 */ if (colonPosition == -1)
|
||||
/* 35 */ throw new IllegalArgumentException();
|
||||
/* 36 */ this.host = root.substring(oldColonPosition + 1, colonPosition);
|
||||
/* 37 */ this.repository = root.substring(colonPosition + 1);
|
||||
/* 38 */ if ((this.connectionType == null) || (this.user == null) || (this.host == null) ||
|
||||
/* 39 */ (this.repository == null))
|
||||
/* 40 */ throw new IllegalArgumentException();
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public String getCVSRoot(File directory) {
|
||||
/* 44 */ String root = null;
|
||||
/* 45 */ BufferedReader r = null;
|
||||
/* */ try {
|
||||
/* 47 */ File rootFile = new File(directory, "CVS/Root");
|
||||
/* 48 */ if (rootFile.exists()) {
|
||||
/* 49 */ r = new BufferedReader(new FileReader(rootFile));
|
||||
/* 50 */ root = r.readLine();
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */ catch (IOException localIOException1)
|
||||
/* */ {
|
||||
/* */ try {
|
||||
/* 56 */ if (r != null)
|
||||
/* 57 */ r.close();
|
||||
/* */ } catch (IOException e) {
|
||||
/* 59 */ System.err.println("Warning: could not close CVS/Root file!");
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */ finally
|
||||
/* */ {
|
||||
/* */ try
|
||||
/* */ {
|
||||
/* 56 */ if (r != null)
|
||||
/* 57 */ r.close();
|
||||
/* */ } catch (IOException e) {
|
||||
/* 59 */ System.err.println("Warning: could not close CVS/Root file!");
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* 62 */ if (root == null) {
|
||||
/* 63 */ root = System.getProperty("cvs.root");
|
||||
/* */ }
|
||||
/* 65 */ return root;
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A struct containing the various bits of information in a CVS root string,
|
||||
* allowing easy retrieval of individual items of information
|
||||
/* Location: C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
|
||||
* Qualified Name: net.brutex.xservices.util.CVSRoot
|
||||
* JD-Core Version: 0.6.2
|
||||
*/
|
||||
public class CVSRoot {
|
||||
public String connectionType;
|
||||
public String user;
|
||||
public String host;
|
||||
public String repository;
|
||||
|
||||
public CVSRoot(String root) throws IllegalArgumentException {
|
||||
if (!root.startsWith(":"))
|
||||
throw new IllegalArgumentException();
|
||||
|
||||
int oldColonPosition = 0;
|
||||
int colonPosition = root.indexOf(':', 1);
|
||||
if (colonPosition == -1)
|
||||
throw new IllegalArgumentException();
|
||||
connectionType = root.substring(oldColonPosition + 1, colonPosition);
|
||||
oldColonPosition = colonPosition;
|
||||
colonPosition = root.indexOf('@', colonPosition + 1);
|
||||
if (colonPosition == -1)
|
||||
throw new IllegalArgumentException();
|
||||
user = root.substring(oldColonPosition + 1, colonPosition);
|
||||
oldColonPosition = colonPosition;
|
||||
colonPosition = root.indexOf(':', colonPosition + 1);
|
||||
if (colonPosition == -1)
|
||||
throw new IllegalArgumentException();
|
||||
host = root.substring(oldColonPosition + 1, colonPosition);
|
||||
repository = root.substring(colonPosition + 1);
|
||||
if (connectionType == null || user == null || host == null
|
||||
|| repository == null)
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
public String getCVSRoot(File directory) {
|
||||
String root = null;
|
||||
BufferedReader r = null;
|
||||
try {
|
||||
File rootFile = new File(directory, "CVS/Root");
|
||||
if (rootFile.exists()) {
|
||||
r = new BufferedReader(new FileReader(rootFile));
|
||||
root = r.readLine();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
// ignore
|
||||
} finally {
|
||||
try {
|
||||
if (r != null)
|
||||
r.close();
|
||||
} catch (IOException e) {
|
||||
System.err.println("Warning: could not close CVS/Root file!");
|
||||
}
|
||||
}
|
||||
if (root == null) {
|
||||
root = System.getProperty("cvs.root");
|
||||
}
|
||||
return root;
|
||||
}
|
||||
}
|
|
@ -1,125 +1,69 @@
|
|||
/*
|
||||
* Copyright 2012 Brian Rosenberger (Brutex Network)
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
/* */ package net.brutex.xservices.util;
|
||||
/* */
|
||||
/* */ import java.io.PrintStream;
|
||||
/* */
|
||||
/* */ public class CvsPassword
|
||||
/* */ {
|
||||
/* 46 */ private static final char[] LOOKUP_TABLE = {
|
||||
/* 47 */ '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', '\000', 'r', 'x', '5',
|
||||
/* 48 */ 'O', '\000', 'm', 'H', 'l', 'F', '@', 'L', 'C', 't', 'J', 'D', 'W', 'o', '4', 'K',
|
||||
/* 49 */ 'w', '1', '"', 'R', 'Q', '_', 'A', 'p', 'V', 'v', 'n', 'z', 'i', ')', '9',
|
||||
/* 50 */ 'S', '+', '.', 'f', '(', 'Y', '&', 'g', '-', '2', '*', '{', '[', '#', '}', '7',
|
||||
/* 51 */ '6', 'B', '|', '~', ';', '/', '\\', 'G', 's', 'N', 'X', 'k', 'j', '8',
|
||||
/* 52 */ '\000', 'y', 'u', 'h', 'e', 'd', 'E', 'I', 'c', '?', '^', ']', '\'', '%', '=', '0',
|
||||
/* 53 */ ':', 'q', ' ', 'Z', ',', 'b', '<', '3', '!', 'a', '>', 'M', 'T', 'P', 'U' };
|
||||
/* */
|
||||
/* */ public static String encode(String clearText)
|
||||
/* */ {
|
||||
/* 68 */ char[] encoded = new char[clearText.length() + 1];
|
||||
/* 69 */ encoded[0] = 'A';
|
||||
/* */
|
||||
/* 72 */ int counter = 1;
|
||||
/* 73 */ for (char c : clearText.toCharArray())
|
||||
/* */ {
|
||||
/* 75 */ if ((c == '`') || (c == '$') || (c < ' '))
|
||||
/* */ {
|
||||
/* 77 */ throw new IllegalArgumentException(
|
||||
/* 78 */ "Illegal character was found in clear password.");
|
||||
/* */ }
|
||||
/* */
|
||||
/* 81 */ encoded[(counter++)] = LOOKUP_TABLE[c];
|
||||
/* */ }
|
||||
/* */
|
||||
/* 84 */ return String.valueOf(encoded);
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public static String decode(String encodedPassword)
|
||||
/* */ {
|
||||
/* 98 */ String rtn = null;
|
||||
/* */
|
||||
/* 100 */ if ((encodedPassword != null) && (encodedPassword.length() > 0))
|
||||
/* */ {
|
||||
/* 102 */ if (encodedPassword.startsWith("A"))
|
||||
/* */ {
|
||||
/* 104 */ rtn = encode(encodedPassword.substring(1)).substring(1);
|
||||
/* */ }
|
||||
/* */ else
|
||||
/* */ {
|
||||
/* 108 */ rtn = encode(encodedPassword).substring(1);
|
||||
/* */ }
|
||||
/* */ }
|
||||
/* */
|
||||
/* 112 */ return rtn;
|
||||
/* */ }
|
||||
/* */
|
||||
/* */ public static void main(String[] sArgs)
|
||||
/* */ {
|
||||
/* 117 */ String TEST_WORD = "i07w91";
|
||||
/* 118 */ String encoded = encode("i07w91");
|
||||
/* 119 */ System.out.println("Encoded: <" + encoded + ">");
|
||||
/* 120 */ String decoded = decode(encoded);
|
||||
/* 121 */ System.out.println("Decoded: <" + decoded + ">");
|
||||
/* 122 */ System.out.println(decoded.equals("i07w91") ? "Test Passed" : "Test Failed");
|
||||
/* */ }
|
||||
/* */ }
|
||||
|
||||
/* Location: C:\Users\brosenberger\Documents\My Box Files\XBridgeNG-download\XServices-20130131 - Kopie\WEB-INF\classes\net.zip
|
||||
* Qualified Name: net.brutex.xservices.util.CvsPassword
|
||||
* JD-Core Version: 0.6.2
|
||||
*/
|
||||
|
||||
package net.brutex.xservices.util;
|
||||
/*
|
||||
* Copyright 2010 Andrew Kroh
|
||||
*
|
||||
* 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.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A simple class for encoding and decoding passwords for CVS pserver protocol.
|
||||
* Can be used to recover forgotten passwords.
|
||||
*
|
||||
* <p>
|
||||
* Adapted from: http://blog.zmeeagain.com/2005/01/recover-cvs-pserver-passwords.html
|
||||
*/
|
||||
public class CvsPassword
|
||||
{
|
||||
private static final char[] LOOKUP_TABLE =
|
||||
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 120, 53,
|
||||
79, 0, 109, 72, 108, 70, 64, 76, 67, 116, 74, 68, 87, 111, 52, 75,
|
||||
119, 49, 34, 82, 81, 95, 65, 112, 86, 118, 110, 122, 105, 41, 57,
|
||||
83, 43, 46, 102, 40, 89, 38, 103, 45, 50, 42, 123, 91, 35, 125, 55,
|
||||
54, 66, 124, 126, 59, 47, 92, 71, 115, 78, 88, 107, 106, 56, 0,
|
||||
121, 117, 104, 101, 100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
|
||||
58, 113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85};
|
||||
|
||||
/**
|
||||
* Encodes a CVS password to be used in .cvspass file. Throws an exception
|
||||
* if clearText is null, if a character is found outside the 0 - 126 range, or
|
||||
* if within the range, one of the non-allowed characters.
|
||||
*
|
||||
* @param clearText
|
||||
* the password in clear to be encoded
|
||||
*
|
||||
* @return the encoded cvs password
|
||||
*/
|
||||
public static String encode(String clearText)
|
||||
{
|
||||
// First character of encoded version is A:
|
||||
char[] encoded = new char[clearText.length() + 1];
|
||||
encoded[0] = 'A';
|
||||
|
||||
// Skip the first character:
|
||||
int counter = 1;
|
||||
for (char c : clearText.toCharArray())
|
||||
{
|
||||
if (c == '`' || c == '$' || c < 32)
|
||||
{
|
||||
throw new IllegalArgumentException(
|
||||
"Illegal character was found in clear password.");
|
||||
}
|
||||
|
||||
encoded[counter++] = LOOKUP_TABLE[c];
|
||||
}
|
||||
|
||||
return String.valueOf(encoded);
|
||||
}
|
||||
|
||||
/**
|
||||
* Recovers an encoded via pserver protocol CVS password.
|
||||
*
|
||||
* @param encodedPassword
|
||||
* the encoded password to be decoded
|
||||
*
|
||||
* @return the decoded password or null if the input was
|
||||
* null or empty
|
||||
*/
|
||||
public static String decode(String encodedPassword)
|
||||
{
|
||||
String rtn = null;
|
||||
|
||||
if (encodedPassword != null && encodedPassword.length() > 0)
|
||||
{
|
||||
if (encodedPassword.startsWith("A"))
|
||||
{
|
||||
rtn = encode(encodedPassword.substring(1)).substring(1);
|
||||
}
|
||||
else
|
||||
{
|
||||
rtn = encode(encodedPassword).substring(1);
|
||||
}
|
||||
}
|
||||
|
||||
return rtn;
|
||||
}
|
||||
|
||||
public static void main(String[] sArgs)
|
||||
{
|
||||
final String TEST_WORD = "i07w91";
|
||||
String encoded = CvsPassword.encode(TEST_WORD);
|
||||
System.out.println("Encoded: <" + encoded + ">");
|
||||
String decoded = CvsPassword.decode(encoded);
|
||||
System.out.println("Decoded: <" + decoded + ">");
|
||||
System.out.println(decoded.equals(TEST_WORD) ? "Test Passed" : "Test Failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,8 +48,6 @@ public class XServicesDocumentation {
|
|||
"as inline base64 encoded block. Keep in mind that unless you are using MTOM, a lot of " +
|
||||
"java heap memory is used.";
|
||||
|
||||
public static final String SERVICE_OPERATION_ENCODEFILE = "Encodes a file.";
|
||||
|
||||
public static final String SERVICE_OPERATION_UPLOADFILE = "Send a file from client to web service server using either " +
|
||||
"MTOM attachment or base64 inline attachment.";
|
||||
|
||||
|
|
Loading…
Reference in New Issue