Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iCatLovers - 13513037 - M. Visat Sutarno #8

Open
wants to merge 85 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
c91a961
Initial Commit
azwaradli Nov 13, 2015
8881113
setting 3 servers and 3 ports
azwaradli Nov 14, 2015
1c52001
setting up 3 servers
Nov 15, 2015
50f4295
Create Answer Web Service
azwaradli Nov 16, 2015
81b1e30
setting 3 server
Nov 16, 2015
ad31f53
Merge remote-tracking branch 'origin/master'
Nov 16, 2015
7ec372d
setting up 3 server and 3 port
Nov 16, 2015
04292d7
fix AnswerWS
azwaradli Nov 16, 2015
eb8e7d3
Create database
Nov 16, 2015
fc46b2b
Merge branch 'master' of https://github.com/iCatLovers/IF3110-2015-T2
Nov 16, 2015
ebd03d4
Downgrade to Java 7
mvisat Nov 16, 2015
9653cd2
Add question model
mvisat Nov 16, 2015
da58a81
fixing db
Nov 16, 2015
34c9617
Merge branch 'master' of https://github.com/iCatLovers/IF3110-2015-T2
Nov 16, 2015
54abcab
update AnswerWS
azwaradli Nov 16, 2015
24e1996
Merge remote-tracking branch 'origin/master'
azwaradli Nov 16, 2015
f11fff7
Add question operation: addQuestion
mvisat Nov 16, 2015
4028e81
Add question operation: deleteQuestion
mvisat Nov 16, 2015
3f246a9
dump sql
Nov 16, 2015
ee9517c
Fix some configuration
mvisat Nov 16, 2015
a8f704e
add user model
Nov 16, 2015
5ae1847
adding register method
Nov 16, 2015
efeeba2
update db scheme
Nov 16, 2015
80e8883
add answer operation: vote answer
azwaradli Nov 16, 2015
6c84ce5
Merge branch 'master' of https://github.com/iCatLovers/IF3110-2015-T2
azwaradli Nov 16, 2015
c8919e3
Add main page servlet + jsp
mvisat Nov 17, 2015
542ff8b
create connection for IS
Nov 17, 2015
16b9d4f
Merge all web services to StackExchange web service
mvisat Nov 17, 2015
a4be5ba
Update database schema
mvisat Nov 17, 2015
0b4ef73
add getUser operation
Nov 17, 2015
593b1fd
add Login in Identity Service
azwaradli Nov 17, 2015
6a35bb3
fixing some configuration
Nov 17, 2015
e1273ed
Fix root servlet + page
mvisat Nov 17, 2015
abd8ff2
Fix index page and servlet
mvisat Nov 17, 2015
fe286bc
Add question servlet and page, some cleanups
mvisat Nov 17, 2015
71561da
Merge branch
Nov 17, 2015
a6c5eb8
Merge branch 'master' of https://github.com/iCatLovers/IF3110-2015-T2
Nov 17, 2015
babb15b
update scheme by adding token table
Nov 17, 2015
f299198
Add ask servlet and page
mvisat Nov 18, 2015
68fa1d7
Add login servlet and page
mvisat Nov 18, 2015
06c0eac
fixing identity service
azwaradli Nov 18, 2015
4177a0b
recreate Identity Service project
azwaradli Nov 18, 2015
5435eac
fixing AuthServlet.java
Nov 18, 2015
927a02c
Fix login and auth in identity service
mvisat Nov 18, 2015
182b060
rename IS servlet
azwaradli Nov 22, 2015
67026fd
resolve rename IS Servlet
azwaradli Nov 22, 2015
f4f6a23
Fix auth, ask servlet and page, addQuestion WS
mvisat Nov 22, 2015
08785ac
fixing login form
Nov 22, 2015
4d772a1
add register servlet
azwaradli Nov 22, 2015
be4592f
creating register form, fixing some styling and login servlet
Nov 22, 2015
d5deb4a
Add bootstrap and update style, fix some views
mvisat Nov 22, 2015
977e12b
Add servlet filter, add connector from webservice to identity service
mvisat Nov 22, 2015
1b863a2
Add required fonts to fix missing icon
mvisat Nov 22, 2015
ce96d7c
Update ask servlet and page: use ServletFilter to get current logged …
mvisat Nov 23, 2015
694af67
fix register servlet, fix style register.jsp & login.jsp
azwaradli Nov 23, 2015
b23b217
Add logout functionality
mvisat Nov 23, 2015
4ce07e2
fixing login servlet
Nov 23, 2015
22398e1
Merge branch
Nov 23, 2015
8d01e69
add Delete (Question) Servlet
azwaradli Nov 23, 2015
fbe475d
Post answer done
mvisat Nov 23, 2015
9b3f4a9
Sign in functionality done
Nov 23, 2015
88f3e8c
Minor fix index and question views
mvisat Nov 23, 2015
0503dfe
fix delete servlet
azwaradli Nov 23, 2015
2a50e3c
merge branch
Nov 23, 2015
6c220f8
delete servlet done
Nov 23, 2015
52470d3
create edit servlet
Nov 23, 2015
dfb4776
Vote system done. Update db schema and add javascript
mvisat Nov 24, 2015
d5b28f1
edit servlet done
Nov 24, 2015
0cc37b7
fix some configuration
Nov 24, 2015
18d279d
Bug fix in answer model (votes not included in constructor)
mvisat Nov 24, 2015
1c3f4c3
merge branch
Nov 24, 2015
364c4a8
Merge branch 'master' of https://github.com/iCatLovers/IF3110-2015-T2
Nov 24, 2015
b595974
Add missing vote pattern
mvisat Nov 24, 2015
436ccf4
add WS operation: search
azwaradli Nov 24, 2015
dc1616a
add Search Servlet & search.jsp, fix other file
azwaradli Nov 24, 2015
12f00e6
Fix bug in vote, tweak views
mvisat Nov 24, 2015
98807fd
fix search bug
azwaradli Nov 25, 2015
e575760
fix minor bug in edit servlet
Nov 25, 2015
c63d1a0
fix search aesthetique & xss in header
azwaradli Nov 25, 2015
59f13fb
Handles expired session, tweak some views
mvisat Nov 26, 2015
b48037e
Update search page
mvisat Nov 26, 2015
d6dae06
Separate services to different servers
mvisat Nov 27, 2015
35e9cad
update link in readme
azwaradli Nov 27, 2015
4cd1ed0
add comment table to db
Dec 5, 2015
64c8fd2
add angular js
Dec 5, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/StackExchange WS/nbproject/
/StackExchange Client/nbproject/
/Identity Service/nbproject/
/Identity Service/build/
/Identity Service/dist/
/StackExchange WS/build/
/StackExchange WS/dist/
/StackExchange Client/build/
/StackExchange Client/dist/
71 changes: 71 additions & 0 deletions Identity Service/build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="Identity_Service" default="default" basedir=".">
<description>Builds, tests, and runs the project Identity Service.</description>
<import file="nbproject/build-impl.xml"/>
<!--

There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:

-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying

Example of pluging an obfuscator after the compilation could look like

<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>

For list of available properties check the imported
nbproject/build-impl.xml file.


Other way how to customize the build is by overriding existing main targets.
The target of interest are:

init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation

Example of overriding the target for project execution could look like

<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>

Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.

-->
</project>
2 changes: 2 additions & 0 deletions Identity Service/src/conf/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

43 changes: 43 additions & 0 deletions Identity Service/src/java/connection/DB.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package connection;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
*
* @author Acer
*/
public class DB {
// JDBC driver name and database URL
static final String JDBC_DRIVER="com.mysql.jdbc.Driver";
static final String url="jdbc:mysql://localhost:3306/stackexchange?zeroDateTimeBehavior=convertToNull";

// Database credentials
static final String user = "root";
static final String password = "";

public static Connection connect() {
Connection con = null;
try {
// Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");

con = DriverManager.getConnection(url, user, password);

} catch (SQLException ex) {
System.out.println("asu " + ex.getMessage());
} catch (ClassNotFoundException ex) {
System.out.println("usa " + ex.getMessage());
}

return con;
}
}
126 changes: 126 additions & 0 deletions Identity Service/src/java/controller/ISAuthServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package controller;

import connection.DB;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.util.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.simple.JSONObject;

/**
*
* @author Acer
*/
@WebServlet(name = "AuthServlet", urlPatterns = {"/auth"})
public class ISAuthServlet extends HttpServlet {

private final Connection conn = DB.connect();
/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("application/json");
try (PrintWriter out = response.getWriter()) {
String token = request.getParameter("auth");
String query = "SELECT * FROM token WHERE access_token = ?";
JSONObject obj = new JSONObject();
if (token != null) try (PreparedStatement statement = conn.prepareStatement(query)) {
statement.setString(1, token);

ResultSet result = statement.executeQuery();
if(result.next()) {
Date current_date = new Date();
DateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
Date expire_date = format.parse(result.getString("expire_date"));
if (current_date.after(expire_date)) {
obj.put("status", -1);
query = "DELETE FROM token WHERE access_token = ?";
try (PreparedStatement deleteStatement = conn.prepareStatement(query)) {
deleteStatement.setString(1, token);
deleteStatement.executeUpdate();
}
}
else {
obj.put("status", 1);
obj.put("id", result.getInt("user_id"));
}
}
catch ( SQLException | ParseException ex ){
System.err.println(ex.getMessage());
}
}
else {
obj.put("status", 0);
}
}
out.println(obj);
}
catch(SQLException ex) {
System.err.println(ex.getMessage());
}
}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Short description";
}// </editor-fold>

}
Loading