Commit d530453d by Tuukka Kivilahti

Merge branch 'dep-bump' into 'master'

Bump dependency versions

See merge request !390
2 parents 98baa0d0 442b9981
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
<!-- Primefaces dependency --> <!-- Primefaces dependency -->
<groupId>commons-fileupload</groupId> <groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId> <artifactId>commons-fileupload</artifactId>
<version>1.3.2</version> <version>1.3.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.primefaces.extensions</groupId> <groupId>org.primefaces.extensions</groupId>
...@@ -38,11 +38,6 @@ ...@@ -38,11 +38,6 @@
<version>2.1</version> <version>2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.sshd</groupId>
<artifactId>sshd-core</artifactId>
<version>0.14.0</version>
</dependency>
<dependency>
<!-- Java melody dependency --> <!-- Java melody dependency -->
<groupId>org.jrobin</groupId> <groupId>org.jrobin</groupId>
<artifactId>jrobin</artifactId> <artifactId>jrobin</artifactId>
...@@ -61,7 +56,7 @@ ...@@ -61,7 +56,7 @@
<dependency> <dependency>
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
<version>4.5.3</version> <version>4.5.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.testng</groupId> <groupId>org.testng</groupId>
...@@ -112,7 +107,7 @@ ...@@ -112,7 +107,7 @@
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
<version>3.5</version> <version>3.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>javax.json</groupId> <groupId>javax.json</groupId>
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId> <artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions> <executions>
<execution> <execution>
<id>attach-sources</id> <id>attach-sources</id>
......
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.servlet;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.nio.charset.Charset;
import java.util.HashMap;
import org.apache.sshd.server.Command;
import org.apache.sshd.server.Environment;
import org.apache.sshd.server.ExitCallback;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
import fi.codecrew.moya.cmdline.ICommandlineCommand;
public class BortalCommand implements Command, Runnable {
private static Logger logger = LoggerFactory.getLogger(BortalCommand.class);
private OutputStreamWriter errstream;
private ExitCallback exitCallback;
private InputStreamReader instream;
private OutputStreamWriter outstream;
private BortalLocalContextHolder contextHolder;
private Charset UTF8 = Charset.forName("UTF-8");
private HashMap<String, ICommandlineCommand> commandMap = new HashMap<String, ICommandlineCommand>();
public BortalCommand(BortalLocalContextHolder context) {
contextHolder = context;
}
public BortalCommand addCommandlineCommand(String name, ICommandlineCommand c) {
this.commandMap.put(name, c);
return this;
}
@Override
public void setInputStream(InputStream in) {
instream = new InputStreamReader(in, UTF8);
}
@Override
public void setOutputStream(OutputStream out) {
outstream = new OutputStreamWriter(out, UTF8);
}
@Override
public void setErrorStream(OutputStream err) {
errstream = new OutputStreamWriter(err, UTF8);
}
@Override
public void setExitCallback(ExitCallback callback) {
exitCallback = callback;
}
@Override
public void start(Environment env) throws IOException {
logger.info("Starting something...");
new Thread(this).start();
}
@Override
public void destroy() {
logger.info("destroying ssh command");
}
@Override
public void run() {
BortalLocalContextHolder.copy(contextHolder);
try {
logger.info("Created new bortalCommane");
outstream.write("Hello you...");
StringBuilder cmdBuilder = new StringBuilder();
// prime 0 return value
int returnValue = 0;
while (true) {
if (!instream.ready()) {
Thread.sleep(100);
} else {
char inchar = (char) instream.read();
if (inchar == '\n' || inchar == '\r')
{
outstream.write("\r\n");
outstream.flush();
returnValue = parseCommand(cmdBuilder.toString());
//outstream.write("[" + returnValue + "] " + BortalLocalContextHolder.getInstance().getLoginContext().getSubject().getPrincipals().iterator().next().getName() + " # ");
outstream.flush();
cmdBuilder = new StringBuilder();
}
else {
outstream.write(inchar);
outstream.flush();
cmdBuilder.append(inchar);
}
}
}
} catch (InterruptedException e) {
logger.warn("Running command interrupted", e);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
exitCallback.onExit(3);
}
private int parseCommand(String args) {
String[] argv = null;
if(args != null) {
if(args.length() == 0) return 0;
argv = args.split(" ");
}
if(argv != null && argv.length > 0) {
logger.info("received command {}", argv[0]);
ICommandlineCommand cmd;
if((cmd = this.commandMap.get(argv[0])) != null) {
return cmd.execute(argv,this.instream, this.outstream, this.errstream);
} else {
try {
this.errstream.write("unknown command\r\n");
this.errstream.flush();
} catch(IOException ioe) {}
return -1;
}
} else {
return 0;
}
}
}
/*
* Copyright Codecrew Ry
*
* All rights reserved.
*
* This license applies to any software containing a notice placed by the
* copyright holder. Such software is herein referred to as the Software.
* This license covers modification, distribution and use of the Software.
*
* Any distribution and use in source and binary forms, with or without
* modification is not permitted without explicit written permission from the
* copyright owner.
*
* A non-exclusive royalty-free right is granted to the copyright owner of the
* Software to use, modify and distribute all modifications to the Software in
* future versions of the Software.
*
*/
package fi.codecrew.moya.servlet;
import java.io.IOException;
import java.security.Principal;
import java.util.HashSet;
import javax.resource.spi.security.PasswordCredential;
import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.callback.CallbackHandler;
import javax.security.auth.callback.NameCallback;
import javax.security.auth.callback.PasswordCallback;
import javax.security.auth.callback.UnsupportedCallbackException;
import javax.security.auth.login.LoginContext;
import org.apache.sshd.server.PasswordAuthenticator;
import org.apache.sshd.server.session.ServerSession;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import fi.codecrew.moya.clientutils.BortalLocalContextHolder;
// Deprecated: TODO: Pitäisi käydä ajatuksella läpi!
@Deprecated()
public class BortalPasswordAuthenticator implements PasswordAuthenticator {
private static final Logger logger = LoggerFactory.getLogger(BortalPasswordAuthenticator.class);
private BortalLocalContextHolder context;
public BortalPasswordAuthenticator(BortalLocalContextHolder instance) {
super();
context = instance;
}
@Override
public boolean authenticate(String username, String password, ServerSession session) {
BortalLocalContextHolder.copy(context);
return authenticate(username, password);
}
public boolean authenticate(final String username, final String password) {
try {
PasswordCredential pwdcred = new PasswordCredential(username, password.toCharArray());
HashSet<PasswordCredential> privcred = new HashSet<PasswordCredential>();
privcred.add(pwdcred);
Subject subject = new Subject(false, new HashSet<Principal>(), new HashSet<Object>(), privcred);
LoginContext loginContext = new LoginContext("bortalRealm", subject, new CallbackHandler() {
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
Callback cb = callbacks[i];
logger.info("Handling callback. {}", cb);
if (cb instanceof NameCallback) {
logger.info("Handling name callback");
((NameCallback) callbacks[i]).setName(username);
} else if (cb instanceof PasswordCallback) {
logger.info("Handling password callback");
((PasswordCallback) cb).setPassword(password.toCharArray());
} else {
throw new UnsupportedCallbackException(cb);
}
}
}
});
loginContext.login();
// loginContext.logout();
return true;
} catch (Exception e) {
logger.error("Authentication failed with error", e);
return false;
}
}
}
...@@ -31,10 +31,10 @@ ...@@ -31,10 +31,10 @@
<swagger.version>1.5.13</swagger.version> <swagger.version>1.5.13</swagger.version>
<slf4j.version>1.7.25</slf4j.version> <slf4j.version>1.7.25</slf4j.version>
<logback.version>1.2.3</logback.version> <logback.version>1.2.3</logback.version>
<testng.version>6.11</testng.version> <testng.version>6.14.2</testng.version>
<findbugs.version>3.0.1</findbugs.version> <findbugs.version>3.0.1</findbugs.version>
<findbugs-maven.version>3.0.5</findbugs-maven.version> <findbugs-maven.version>3.0.5</findbugs-maven.version>
<javamelody.version>1.65.0</javamelody.version> <javamelody.version>1.70.0</javamelody.version>
<primefaces.version>6.0</primefaces.version> <primefaces.version>6.0</primefaces.version>
<primefaces.themeversion>1.0.10</primefaces.themeversion> <primefaces.themeversion>1.0.10</primefaces.themeversion>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!