Commit 45e2be8a authored by Alina Habibulina's avatar Alina Habibulina

fix 4

parent 3342249e
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>synergy-api-proxy</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="WebContent"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="synergy-api-proxy">
<wb-resource deploy-path="/" source-path="/WebContent" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src"/>
<property name="context-root" value="synergy-api-proxy"/>
<property name="java-output-path" value="/synergy-api-proxy/build/classes"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<fixed facet="wst.jsdt.web"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.web" version="3.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Manifest-Version: 1.0
Class-Path:
......@@ -14,30 +14,30 @@ import java.sql.SQLException;
* Date: 04.10.2015
* Time: 12:49
*
* Пример класса для работы с СУБД
* работа с СУБД
* использует соединение, указанное в @{@link ConnectionPool}
*/
public class ClientManager {
public class UserManager {
private static final Logger LOGGER = LoggerFactory.getLogger(ClientManager.class);
private static final Logger LOGGER = LoggerFactory.getLogger(UserManager.class);
public static void log(Object logItem, String oldPass, String NewPass, String Login) {
Connection con = null;
public static String set_pass(String login, String new_pass) {
Connection con = null;
try {
con = ConnectionPool.getConnection();
PreparedStatement st = con.prepareStatement("INSERT INTO log(logged, clientid, hostname, extip, localip) VALUES (CURRENT_TIMESTAMP, ?, ?, ?, ?)");
// PreparedStatement st = con.prepareStatement("UPDATE users SET password= ");
st.setString(1, "clientId");
st.setString(2, "hostname");
st.setString(3, "extip");
st.setString(4, "localip");
st.execute();
PreparedStatement updatePassword = con.prepareStatement("UPDATE users SET password = MD5( ? ) WHERE login = ? ");
updatePassword.setString(1, new_pass);
updatePassword.setString(2, login);
updatePassword.executeUpdate();
return "{\"result\":\"success\", \"errorCode\":\"0\"}";
} catch (SQLException | NamingException e) {
LOGGER.error("", e);
return "{\"status\":\"something gone wrong\", \"error\":\"" + e + "\", \"errorCode\": \"500\"}";
} finally {
ConnectionPool.close(con);
}
}
}
......@@ -13,6 +13,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import kz.arta.ext.sap.util.ConnectionPool;
import kz.arta.ext.sap.db.UserManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -57,20 +59,6 @@ public class UnsecuredProxyService {
@Path("/set_password")
@Produces(MediaType.APPLICATION_JSON + "; charset=utf-8")
public String setPassword(@QueryParam("login") String login, @QueryParam("new_password") String new_pass){
Connection con = null;
try {
con = ConnectionPool.getConnection();
String update_passwordSQL = "UPDATE users SET password=MD5(\"" + new_pass + "\") WHERE login =\"" + login + "\";";
PreparedStatement UpdatePassword = con.prepareStatement(update_passwordSQL);
UpdatePassword.execute();
return "{\"result\":\"success\", \"errorCode\":\"0\"}";
} catch (SQLException | NamingException e) {
LOGGER.error("", e);
return "{\"status\":\"something gone wrong\", \"error\":\"" + e + "\", \"errorCode\": \"500\"}";
} finally {
ConnectionPool.close(con);
}
}
return UserManager.set_pass(login, new_pass);
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment