Вы находитесь на странице: 1из 98

CHAPTER 1

Introduction
1.1 Overview ShareManager- will be an application which will provide its users a FTP Server to upload and download files on a central repository.Users will be able to share files with other users as files will be on central repository and FTP Server will be created to support file sharing.A user friendly Graphical User Interface will be provided to easily upload and download files using FTP Server.Only registered / authorized users will be able to use this application for download & upload as per the rights available to them. Users will be able to rename and delete files uploaded by them.It will be developed using Java technologies. It Create a FTP Server to transfer

files.Provide interface to users for downloading & uploading files of specific FTP server.Provide support to users to share, rename and delete files on server.To maintain various users of the application & their access rights.Maintain history of all the activities (File Downloads and Uploads) of users, for future analysis.To provide a functionality to the administrator of the application for setting up the configuration of FTP server.

Figure 1.1 sharemanager

Business Functions

1. Login: To access this application, users would be required to login through a login screen. After authentication user would be able to access the application according to his/her privileges.

2. Users Maintenance: That allows adding or updating the details of all users who will access this application.

3. File Upload: To provide support to users, so that they could upload their files on central server using FTP Server and Client.

4. File Download: To provide support to users, so that they could download files from central server using FTP Client.

5. Report: Reports of users of the system, user activities, and files uploaded and downloaded by users.

Users

The users of this system will be the users of the organization using this ShareManager. Following are the type of users: a. Administrator: Administrator will be the super user of the system having all the privileges. Administrator will be responsible to add, delete and assign privileges to the other users of the system. Administrator will decide whether a user can download files or not.

b. Employee: Employee is the member of staff of the organization using this application. Employee will be having limited privileges as assigned by the administrator. Employees will be able to upload ,download,rename and delete files as per the privileges assigned.

Modules

Following modules are to be developed:

1. Login

2. Admin User Maintenance Privilege Maintenance

3. File Upload

4. File Download

5. Reports All Users details. User Activities Details. File upload and download details.

1.2 Feasibility study of project . Project The meaning of project is to give physical existence to the vibration idea and thought. Project is a great source to develop technical skills in technical students. During the programming of projects, students undergo different problems and experiences. A student gets charged to climb on the roof of practicals, step by step through the ladder of the theory, thus he gets adequate practical knowledge and knowledge of economics to go at the field. A very important aim of any project is that it should be feasible and economical. Actually the word PROJECT consists of seven alphabets, each of which has separate meanings : P for PLANNING: Planning is must to start a work or scheme.. If planning is good and impressive, half work is done. R for RELIABLE SOURCE: Practical and Theoretical material and an able guidance and assistance is achieved from different sources to promote the function of plan area. O for OVERALL EXPENCES: Overall expenses to provide final design to any project are also considerable. These expenses are analyzed for each concept and method of working on the computer. J for JOINT EFFORT: Joint Effort is crucial for programming. E for ECONOMIC TIME FEASIBILITY: Another important point is to check how much economic time feasible is the planned scheme. It is must to analyze estimate for completion of the project. C for CONSTRUCTION: After analyzing the program, complete project work is done to give logical existence of planned scheme. T for TESTING: Testing of project is done before submitting the project. After testing the gadget is OK for use.

System Development Strategy Rapid Prototyping Model:-

Fig:- 1.2 Rapid Prototyping Model

Rapid application development (RAD) is a software development methodology that uses minimal planning in favor of rapid prototyping. The "planning" of software developed using RAD is interleaved with writing the software itself. The lack of extensive preplanning generally allows software to be written much faster, and makes it easier to change requirements.

Rapid application development involves methods like iterative development and software prototyping. It is a merger of various structured techniques, especially data-driven Information Engineering, with prototyping techniques to accelerate software systems development.

In rapid application development, structured techniques and prototyping are especially used to define users' requirements and to design the final system. The development process starts with the development of preliminary data models and business process models using structured techniques. In the next stage, requirements are verified using prototyping, eventually to refine the data and process models. These stages are repeated iteratively; further development results in "a combined business requirements and technical design statement to be used for constructing new systems".

Feasibility Study: An important outcome of the proposed system is the determination that the System requested is feasible. There are three aspects in feasibility study.
1)

Technical Feasibility:

Technical feasibility requires the work done with the current equipment i.e. existing software, hardware etc. in our case we have required hardware and software tools.
2)

Economic Feasibility:

Economic Feasibility includes sufficient benefit in creating the system to make the cost acceptable. The system do not need much of infrastructure i.e. large amount of investing in infrastructure is do not needed. Project will be done with the available resources.
3)

Operational feasibility:

Operational feasibility shows the risk analysis, which involves following characteristics: a) Will the system work? b) Will the system be implemented?

CHAPTER-2

Requirement Specification And Analysis

Software Requirements

JDK 1.6 NetBeans 6.5.1

2 Jdbc Driver for MySQL Database Server mysql-connector-java-5.1.7-bin.jar

3 Database Server MySQL Database Server 5.0

4 Operating system Windows Vista / XP sp3/ Linux Fedora 11

Hardware Requirements 1 Intel P4 processor with minimum 2.0Ghz Speed 2. RAM: Minimum 512MB 3. Hard Disk: Minimum 20GB

Input Requirements

1. Login details. 2. Users details and their privileges. 3. FTP server connection details.

Output Requirements

1. An FTP Server to support file sharing 2. Files to be uploaded successfully. 3. Files to be downloaded successfully. 4. Listing of user activities. 5. Listing of user details. 6. Listing of files uploaded, downloaded and shared by users.

10

CHAPTER-3

Design
3.1 DFDS Graphical description of system data is as Data Flow diagrams. It dont supply detailed description of modules but graphically describe a systems data interact with the syst em. To construct data flow diagrams, we use arrows, circles, open end boxes and squares. An Arrow identifies data flow i.e. data in motion. An open ended box or temporary repository of data. A square defines system data. server a square (originator) or destination of or or represents data store

fig-3.1 DFD for server Login

11

fig-3.2 DFD for sharemanager server

fig-3.3 DFD for FTP Server

12

fig-3.4 DFD for Profile Maintenance

fig-3.5 DFD for user Maintenance

13

fig-3.6 DFD for Reports

14

Client

fig-3.7 DFD for client Login

15

fig-3.8 DFD for Profile Maintenance

fig-3.9 DFD for sharemanager client

16

fig-3.10 DFD for FTP Server

17

3.2 Data Model

Fig-3.2 Data model

18

CHAPTER-4

Implementation And Coding 4.1 Introduction of Language 1. Java Java is a platform independent, object-oriented, robust, secure and innovative programming language. It consist of Two Parts JVM (Java Virtual Machine), which is software component that is used to execute java programs. Java API (Application Programming Interface) that consist of inbuilt classes that are used in different programs.

2. Database Programming JDBC is Java Database Connectivity that is used for communication between database server and a java application. JDBC is a specification and API that is in programming database applications in java.

3. Windows Programming Swings: Swings in java is a rich set of components for building GUIs and adding interactivity to java applications. Swing includes all the components that you would expect from a modern GUI toolkit that is table controls, list controls, tree controls, buttons and labels. The basic architecture of swing is MVC. And are entirely made in java.

19

The Java Programming Language The Java programming language is a high-level language that can be characterized by all of the following characteristics Simple Object oriented Distributed Multithreaded Architecture neutral Portable High performance Robust

In the Java programming language, all source code is first written in plain text files ending with the .java extension. Those source files are then compiled into .class files by the javac compiler. A .class file does not contain code that is native to your processor; it instead contains bytecodes the machine language of the Java Virtual Machine1 (Java VM). The java launcher tool then runs your application with an instance of the Java Virtual Machine.

Fig-4.1 An overview of the software development process.

20

Because the Java VM is available on many different operating systems, the same .class files are capable of running on Microsoft Windows, the Solaris
TM

Operating System (Solaris

OS), Linux, or Mac OS. Some virtual machines, such as the Java HotSpot virtual machine, perform additional steps at runtime to give your application a performance boost. This include various tasks such as finding performance bottlenecks and recompiling (to native code) frequently used sections of code.

Through the Java VM, the same application is capable of running on multiple platforms.

21

Java is an object-oriented programming language with a built-in application programming interface (API) that can handle graphics and user interfaces and that can be used to create applications or applets. Because of its rich set of API's, similar to Macintosh and Windows, and its platform independence, Java can also be thought of as a platform in itself. Java also has standard libraries for doing mathematics. Much of the syntax of Java is the same as C and C++. One major difference is that Java does not have pointers. However, the biggest difference is that you must write object oriented code in Java. Procedural pieces of code can only be embedded in objects. In the following we assume that the reader has some familiarity with a programming language. In particular, some familiarity with the syntax of C/C++ is useful. In Java we distinguish between applications, which are programs that perform the same functions as those written in other programming languages, and applets, which are programs that can be embedded in a Web page and accessed over the Internet. Our initial focus will be on writing applications. When a program is compiled, a byte code is produced that can be read and executed by any platform that can run Java. Characteristics: Platform independent Java is a platform for application development. A platform is a loosely defined computer industry buzzword that typically means some combination of hardware and system software that will mostly run all the same software. Java byte code is exactly the same on every platform. Java programs that have been compiled into byte code still need an interpreter to execute them on any given platform. The interpreter reads the byte code and translates it into the native language of the host machine on the fly. Since the byte code is completely platform independent, only the interpreter and a few native libraries need to be ported to get Java to run on a new computer or operating system. All these pieces, the javac compiler, the java interpreter, the Java programming language, and more are collectively referred to as Java.
22

Object oriented In object-oriented programs data is represented by objects. Objects have two sections, fields (instance variables) and methods. Fields tell you what an object is. Methods tell you what an object does. These fields and methods are closely tied to the object's real world characteristics and behavior. When a program is run messages are passed back and forth between objects. When an object receives a message it responds accordingly as defined by its methods.

Robust Java implements a robust exception handling mechanism to deal with both expected and unexpected errors. The worst that an applet can do to a host system is bringing down the runtime environment. It cannot bring down the entire system. Most importantly Java applets can be executed in an environment that prohibits them from introducing viruses, deleting or modifying files, or otherwise destroying data and crashing the host computer. A Java enabled web browser checks the byte codes of an applet to verify that it doesn't do anything nasty before it will run the applet.

Multithreaded Java is inherently multi-threaded. A single Java program can have many different threads executing independently and continuously. Three Java applets on the same page can run together with each getting equal time from the CPU with very little extra effort on the part of the programmer.

High performance Java byte codes can be compiled on the fly to code that rivals C++ in speed using a "justin-time compiler." Several companies are also working on native-machine-architecture compilers for Java. These will produce executable code that does not require a separate interpreter, and that is indistinguishable in speed from C++.

23

Dynamic

Java programs carry with them substantial amounts of run-time type information that is used to verify and resolve accesses to objects at run-time. This makes it possible to dynamically link code in a safe and expedient manner. The java programming language is unusual than other programming languages it first compiles and then interprets the program

24

The Java Platform

A platform is the hardware or software environment in which a program runs. Most platforms can be described as a combination of the operating system and underlying hardware. The Java platform differs from most other platforms in that it's a software-only platform that runs on top of other hardware-based platforms.

The Java platform has two components:

The Java Virtual Machine (JVM) The Java Application Programming Interface (API)

Java Virtual Machine is the base for the Java platform and is ported onto various hardware-based platforms.

The API is a large collection of ready-made software components that provide many useful capabilities. It is grouped into libraries of related classes and interfaces; these libraries are known as packages.

1. The API and Java Virtual Machine insulate the program from the underlying hardware. Every full implementation of the Java platform gives you the following features: Development Tools: The development tools provide means for compiling, running, debugging, and documenting your applications. The main tools are the javac compiler, the java launcher, and the javadoc documentation tool.
25

Application Programming Interface (API): The API provides the core functionality of the Java programming language. It offers a wide array of useful classes ready for use in your own applications. It spans everything from basic objects, to networking and security, to XML generation and database access, etc.

Deployment Technologies: The JDK software provides standard mechanisms such as the Java Web Start software and Java Plug-In software for deploying your applications to end users.

User Interface Toolkits: The Swing and Java 2D toolkits make it possible to create sophisticated Graphical User Interfaces (GUIs).

Integration Libraries: Integration libraries such as the Java IDL, JDBC, JNDI, Java RMI, and Java Remote Method Invocation over Internet Inter-ORB Protocol Technology (Java RMI-IIOP Technology) enable database access and manipulation of remote objects.

Introduction to MYSQL MySQL, the most popular Open Source SQL database management system, is developed, distributed, and supported by Oracle Corporation. The MySQL (R) software delivers a very fast, multi-threaded, multi-user, and robust SQL (Structured Query Language) database server. MySQL Server is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software. The MySQL software is Dual Licensed. Users can choose to use the MySQL software as an Open Source/Free Software product under the terms of the GNU General Public License or can purchase a standard commercial license. The MySQL web site (http://www.mysql.com/) provides the latest information about the MySQL software.

26

MySQL is a relational database management system.

A database is a structured collection of data. It may be anything from a simple shopping list to a picture gallery or the vast amounts of information in a corporate network. To add, access, and process data stored in a computer database, you need a database management system such as MySQL Server. Since computers are very good at handling large amounts of data, database management systems play a central role in computing, as standalone utilities, or as parts of other applications. MySQL software is Open Source.

A relational database stores data in separate tables rather than putting all the data in one big storeroom. This adds speed and flexibility. The SQL part of MySQL stands for Structured Query Language. SQL is the most common standardized language used t o access databases and is defined by the ANSI/ISO SQL Standard. The SQL standard has been evolving since 1986 and several versions exist. The MySQL Database Server is very fast, reliable, and easy to use.

MySQL Server was originally developed to handle large databases much faster than existing solutions and has been successfully used in highly demanding production environments for several years. Although under constant development, MySQL Server today offers a rich and useful set of functions. Its connectivity, speed, and security make MySQL Server highly suited for accessing databases on the Internet MySQL Server works in client/server or embedded systems.

The MySQL Database Software is a client/server system that consists of a multi-threaded SQL server that supports different backends, several different client programs and libraries,

administrative tools, and a wide range of application programming interfaces (APIs)

27

4.2 Coding 1. Server LOGIN import sharemanagerserver.alpha.DBOperations; import sharemanagerserver.alpha.UsermasterBean; import sharemanagerserver.em/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package sharemanagerserver;

ail.SendSMTP;

public class LoginFrame extends javax.swing.JFrame {

/** Creates new form LoginFrame */ public LoginFrame() { initComponents(); setLocationRelativeTo(null); }

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked")

28

//

<editor-fold

defaultstate="collapsed"

desc="Generated

Code">//GEN-

BEGIN:initComponents private void initComponents() {

jPanel1 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); txtUsername = new javax.swing.JTextField(); txtPassword = new javax.swing.JPasswordField(); btnLogin = new javax.swing.JButton(); btnCancel = new javax.swing.JButton(); btnRetrievePassword = new javax.swing.JButton(); lblMessage = new javax.swing.JLabel();

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Login"));

jLabel1.setText("Username");

jLabel2.setText("Password");

txtPassword.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { txtPasswordActionPerformed(evt); } });

btnLogin.setText("Login"); btnLogin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {


29

btnLoginActionPerformed(evt); } });

btnCancel.setText("Cancel"); btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelActionPerformed(evt); } });

btnRetrievePassword.setText("Retrieve Password"); btnRetrievePassword.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnRetrievePasswordActionPerformed(evt); } });

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addComponent(btnLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

30

.addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnRetrievePassword, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(jPanel1Layout.createSequentialGroup() javax.swing.GroupLayout.DEFAULT_SIZE,

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPassword, 226, Short.MAX_VALUE) .addComponent(txtUsername, 226, Short.MAX_VALUE)))) .addContainerGap()) ); javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE,

jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, java.awt.Component[] {btnCancel, btnLogin});

new

jPanel1Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, java.awt.Component[] {jLabel1, jLabel2});

new

jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
31

.addGroup(jPanel1Layout.createSequentialGroup()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(18, 18, 18)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(btnLogin, javax.swing.GroupLayout.PREFERRED_SIZE, 21,

javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnCancel) .addComponent(btnRetrievePassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); 21,

jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, java.awt.Component[] {jLabel1, jLabel2});


32

new

jPanel1Layout.linkSize(javax.swing.SwingConstants.VERTICAL, java.awt.Component[] {btnCancel, btnLogin, btnRetrievePassword});

new

lblMessage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); lblMessage.setText(" ");

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(lblMessage, javax.swing.GroupLayout.Alignment.LEADING,

javax.swing.GroupLayout.DEFAULT_SIZE, 350, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addComponent(lblMessage) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

33

.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

pack(); }// </editor-fold>//GEN-END:initComponents

private

void

txtPasswordActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_txtPasswordActionPerformed // TODO add your handling code here: loginAction(); }//GEN-LAST:event_txtPasswordActionPerformed

private

void

btnLoginActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnLoginActionPerformed // TODO add your handling code here: loginAction(); }//GEN-LAST:event_btnLoginActionPerformed

private

void

btnCancelActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnCancelActionPerformed // TODO add your handling code here: System.exit(0); }//GEN-LAST:event_btnCancelActionPerformed

private void btnRetrievePasswordActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_btnRetrievePasswordActionPerformed // TODO add your handling code here: DBOperations objDB = new DBOperations(); String username = txtUsername.getText(); if (username.equalsIgnoreCase("")) {
34

lblMessage.setText("Enter username to retrieve password"); } else { UsermasterBean objBean = objDB.getUserDetailByUsername(username); if (objBean == null) { lblMessage.setText("Invalid username"); } else { String email = objDB.getEmailByUsername(username); if (!email.equalsIgnoreCase("failed")) {

String result = new SendSMTP().sendMail(email, "Your recovered password is : " + objBean.getPassword(), "Your recovered password is :");

if (result.equalsIgnoreCase("sent")) { lblMessage.setText("Your password has been sent to : " + email); } else { lblMessage.setText("Error in sending password to your emailid"); } } } } }//GEN-LAST:event_btnRetrievePasswordActionPerformed

void loginAction() { String username = txtUsername.getText(); String passowrd = new String(txtPassword.getPassword()); DBOperations objDB = new DBOperations(); UsermasterBean objBean = objDB.authenticateUser(username, passowrd); if (objBean == null) { lblMessage.setText("Invalid Username or Password");

} else {
35

System.out.println(""); if (objBean.getUserStatus().equalsIgnoreCase("inactive") ||

!(objBean.getUserType().equalsIgnoreCase("Administrator"))) { lblMessage.setText("Invalid Username or Password"); } else { int userActivityID = objDB.addUserActivity(objBean.getUserId()); new MainFrame(objBean, userActivityID); setVisible(false); } }

/** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() {

public void run() { new LoginFrame().setVisible(true); } }); }

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCancel; private javax.swing.JButton btnLogin; private javax.swing.JButton btnRetrievePassword; private javax.swing.JLabel jLabel1;
36

private javax.swing.JLabel jLabel2; private javax.swing.JPanel jPanel1; private javax.swing.JLabel lblMessage; private javax.swing.JPasswordField txtPassword; private javax.swing.JTextField txtUsername; // End of variables declaration//GEN-END:variables }

USER MAINTAINENCE /* * To change this template, choose Tools | Templates * and open the template in the editor. */

package sharemanagerserver;

import sharemanagerserver.alpha.DBOperations; import sharemanagerserver.alpha.UsermasterBean; import java.util.ArrayList; import javax.swing.JOptionPane;

/** * * @author admin */ public class UserAccountDetail extends javax.swing.JPanel {

int count = 0; ArrayList alstUser; DBOperations objDB = new DBOperations();


37

String AddUpdateFlag;

/** Creates new form UserAccountDetail */ public UserAccountDetail() { initComponents(); btnSave.setEnabled(false); disable(false); alstUser = objDB.getAllUserDetailList(); if (alstUser.size() > 0) { UsermasterBean objBean = (UsermasterBean) alstUser.get(count); showUserRecord(objBean); } setVisible(true); }

public UserAccountDetail(int count) { initComponents(); btnSave.setEnabled(false); disable(false); alstUser = objDB.getAllUserDetailList(); this.count = count; if (alstUser.size() > 0) { UsermasterBean objBean = (UsermasterBean) alstUser.get(count); showUserRecord(objBean); } setVisible(true); }

public UserAccountDetail(String operationType) { initComponents(); alstUser = objDB.getAllUserDetailList();


38

if (operationType.equals("add")) { AddUpdateFlag = "add"; disable(true); clear(); btnSave.setEnabled(true); btnAdd.setEnabled(false);

btnUpdate.setEnabled(false);

btnFirst.setEnabled(false); btnPrevious.setEnabled(false); btnNext.setEnabled(false); btnLast.setEnabled(false); btnUserPersonalDetail.setEnabled(false); int maxUserID = objDB.getMaxUserId(); txtUserID.setText(String.valueOf(maxUserID + 1)); }

setVisible(true); }

public void disable(boolean val) { txtUsername.setEditable(val); txtPassword.setEditable(val); ddlUserType.setEnabled(val); ddlSecurityQuestion.setEnabled(val);

ddlUserStatus.setEnabled(val); //txtSecurityQuestion.setEditable(val); txtSecurityAnswer.setEditable(val); chkUpload.setEnabled(val);


39

chkDownload.setEnabled(val); }

public void clear() { txtUsername.setText(""); txtPassword.setText(""); txtSecurityAnswer.setText(""); // txtSecurityQuestion.setText("");

public void showUserRecord(UsermasterBean objBean) {

txtUserID.setText(String.valueOf(objBean.getUserId())); txtUsername.setText(objBean.getUsername()); txtPassword.setText(objBean.getPassword()); ddlUserType.setSelectedItem(objBean.getUserType()); ddlUserStatus.setSelectedItem(objBean.getUserStatus());

ddlSecurityQuestion.setSelectedItem(objBean.getSecurityQuestion()); txtSecurityAnswer.setText(objBean.getSecurityAnswer()); chkUpload.setSelected(objBean.isCan_Upload()); chkDownload.setSelected(objBean.isCan_Download()); }

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked")
40

//

<editor-fold

defaultstate="collapsed"

desc="Generated

Code">//GEN-

BEGIN:initComponents private void initComponents() {

jLabel7 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); txtSecurityAnswer = new javax.swing.JTextField(); txtPassword = new javax.swing.JPasswordField(); txtUserID = new javax.swing.JTextField(); txtUsername = new javax.swing.JTextField(); ddlUserType = new javax.swing.JComboBox(); ddlUserStatus = new javax.swing.JComboBox(); jLabel8 = new javax.swing.JLabel(); btnAdd = new javax.swing.JButton(); btnFirst = new javax.swing.JButton(); btnUpdate = new javax.swing.JButton(); btnPrevious = new javax.swing.JButton(); btnNext = new javax.swing.JButton(); btnSave = new javax.swing.JButton(); btnCancel = new javax.swing.JButton(); btnLast = new javax.swing.JButton(); btnUserPersonalDetail = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); chkUpload = new javax.swing.JCheckBox(); chkDownload = new javax.swing.JCheckBox(); ddlSecurityQuestion = new javax.swing.JComboBox();
41

setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

jLabel7.setText("Security Answer");

jLabel4.setText("User Type");

jLabel6.setText("Security Question");

jLabel5.setText("User Status");

jLabel3.setText("Password");

jLabel2.setText("Username");

jLabel1.setText("User ID");

txtUserID.setEditable(false);

ddlUserType.setModel(new "Administrator", "Employee" }));

javax.swing.DefaultComboBoxModel(new

String[]

ddlUserType.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ddlUserTypeActionPerformed(evt); } });

ddlUserStatus.setModel(new "Active", "InActive" }));

javax.swing.DefaultComboBoxModel(new

String[]

jLabel8.setFont(new java.awt.Font("Courier New", 1, 18));


42

jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); jLabel8.setText("User Account Detail");

btnAdd.setText("Add"); btnAdd.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAddActionPerformed(evt); } });

btnFirst.setText("First"); btnFirst.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnFirstActionPerformed(evt); } });

btnUpdate.setText("Update"); btnUpdate.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnUpdateActionPerformed(evt); } });

btnPrevious.setText("Previous"); btnPrevious.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPreviousActionPerformed(evt); } });

43

btnNext.setText("Next"); btnNext.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnNextActionPerformed(evt); } });

btnSave.setText("Save"); btnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveActionPerformed(evt); } });

btnCancel.setText("Cancel"); btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelActionPerformed(evt); } });

btnLast.setText("Last"); btnLast.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLastActionPerformed(evt); } });

btnUserPersonalDetail.setText("Personal Detail"); btnUserPersonalDetail.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) {


44

btnUserPersonalDetailActionPerformed(evt); } });

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("User Privilege"));

chkUpload.setText("Upload"); chkUpload.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chkUploadActionPerformed(evt); } });

chkDownload.setText("Download");

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(chkUpload) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, Short.MAX_VALUE) .addComponent(chkDownload) .addGap(43, 43, 43)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup()
45

168,

.addContainerGap()

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(chkDownload) .addComponent(chkUpload)) .addContainerGap(17, Short.MAX_VALUE)) );

ddlSecurityQuestion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "What is your first mobile number? ", "What is your first school name?", "What is your hobby?", "Which is your favourite color?", "Which is your favourite sport?" }));

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addComponent(jLabel4) .addComponent(jLabel6) .addComponent(jLabel3) .addComponent(jLabel2) .addComponent(jLabel1) .addComponent(jLabel5))


46

.addGap(71, 71, 71)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(ddlSecurityQuestion, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) 0,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtPassword) .addGroup(layout.createSequentialGroup() .addComponent(txtUserID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) 60,

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnUserPersonalDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE) .addComponent(ddlUserType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtSecurityAnswer, javax.swing.GroupLayout.DEFAULT_SIZE, 233, Short.MAX_VALUE) .addComponent(ddlUserStatus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(jLabel8, javax.swing.GroupLayout.Alignment.TRAILING, 108, javax.swing.GroupLayout.DEFAULT_SIZE, 152,

javax.swing.GroupLayout.DEFAULT_SIZE, 441, Short.MAX_VALUE)) .addGap(34, 34, 34)) .addGroup(layout.createSequentialGroup()


47

.addGap(53, 53, 53)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(btnAdd, javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnFirst, javax.swing.GroupLayout.PREFERRED_SIZE, 75,

javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(btnUpdate, javax.swing.GroupLayout.DEFAULT_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnPrevious, javax.swing.GroupLayout.PREFERRED_SIZE, 89, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnNext, javax.swing.GroupLayout.Alignment.TRAILING, 75,

javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE,

75,

javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 75,

javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnLast, javax.swing.GroupLayout.PREFERRED_SIZE, 75,

javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(90, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup()


48

.addContainerGap() .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(66, Short.MAX_VALUE)) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(20, 20, 20) .addComponent(jLabel8) .addGap(32, 32, 32)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(txtUserID, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnUserPersonalDetail, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) 20,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(12, 12, 12)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
49

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel4) .addComponent(ddlUserType, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(ddlUserStatus, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel5)) .addGap(12, 12, 12)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(ddlSecurityQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(16, 16, 16) javax.swing.GroupLayout.DEFAULT_SIZE,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(txtSecurityAnswer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

50

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnFirst, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnPrevious, javax.swing.GroupLayout.PREFERRED_SIZE,

20, javax.swing.GroupLayout.PREFERRED_SIZE))

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnAdd, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE,

20, javax.swing.GroupLayout.PREFERRED_SIZE))) .addGroup(layout.createSequentialGroup() .addComponent(btnNext, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(btnLast, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)))


51

.addGap(20, 20, 20)) ); }// </editor-fold>//GEN-END:initComponents

private

void

ddlUserTypeActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_ddlUserTypeActionPerformed // TODO add your handling code here: }//GEN-LAST:event_ddlUserTypeActionPerformed

private

void

btnAddActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnAddActionPerformed // TODO add your handling code here: AddUpdateFlag = "add"; disable(true); clear(); btnSave.setEnabled(true); btnAdd.setEnabled(false);

btnUpdate.setEnabled(false);

btnFirst.setEnabled(false); btnPrevious.setEnabled(false); btnNext.setEnabled(false); btnLast.setEnabled(false); btnUserPersonalDetail.setEnabled(false); chkDownload.setSelected(false); chkUpload.setSelected(false); int maxUserID = objDB.getMaxUserId(); txtUserID.setText(String.valueOf(maxUserID + 1)); }//GEN-LAST:event_btnAddActionPerformed

52

private

void

btnFirstActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnFirstActionPerformed if (alstUser.size() > 0) { count = 0; UsermasterBean objBean = (UsermasterBean) alstUser.get(count); showUserRecord(objBean); } }//GEN-LAST:event_btnFirstActionPerformed

private

void

btnUpdateActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnUpdateActionPerformed // TODO add your handling code here: AddUpdateFlag = "update"; disable(true); btnSave.setEnabled(true); btnAdd.setEnabled(false); btnUpdate.setEnabled(false);

btnFirst.setEnabled(false); btnPrevious.setEnabled(false); btnNext.setEnabled(false); btnLast.setEnabled(false); btnUserPersonalDetail.setEnabled(false);

}//GEN-LAST:event_btnUpdateActionPerformed

private

void

btnPreviousActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnPreviousActionPerformed // TODO add your handling code here: if (count > 0) { count--;
53

UsermasterBean objBean = (UsermasterBean) alstUser.get(count); showUserRecord(objBean); } }//GEN-LAST:event_btnPreviousActionPerformed

private

void

btnNextActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnNextActionPerformed // TODO add your handling code here: if (count < alstUser.size() - 1) { count++; UsermasterBean objBean = (UsermasterBean) alstUser.get(count); showUserRecord(objBean);

} }//GEN-LAST:event_btnNextActionPerformed

private

void

btnSaveActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnSaveActionPerformed

String result = ""; int flag = 0; UsermasterBean objBean = new UsermasterBean(); objBean.setUserId(Integer.parseInt(txtUserID.getText())); objBean.setPassword(new String(txtPassword.getPassword())); objBean.setUserType(ddlUserType.getSelectedItem().toString()); objBean.setUserStatus(ddlUserStatus.getSelectedItem().toString()); objBean.setUsername(txtUsername.getText()); objBean.setSecurityQuestion(ddlSecurityQuestion.getSelectedItem().toString()); objBean.setSecurityAnswer(txtSecurityAnswer.getText()); objBean.setCan_Upload(chkUpload.isSelected()); objBean.setCan_Download(chkDownload.isSelected());
54

if (AddUpdateFlag.equals("add")) {

if (txtUserID.getText().equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else if (txtUsername.getText().equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else if (new String(txtPassword.getPassword()).equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else { "Password is missing", "ERROR", "Username is missing", "ERROR", "User ID is missing", "ERROR",

try { result = objDB.addUserAccountDetail(objBean); } catch (Exception e) { JOptionPane.showMessageDialog(this, "Record Cannot be Added", "ERROR", JOptionPane.ERROR_MESSAGE); } }

if (result.equals("added")) { flag = 1; alstUser = objDB.getAllUserDetailList(); count = alstUser.size() - 1; UsermasterBean objBean1 = (UsermasterBean) alstUser.get(count); showUserRecord(objBean1); JOptionPane.showMessageDialog(null, "Record has been successfully added", "Record Added", 1); } else if (result.equals("failed")) {
55

JOptionPane.showMessageDialog(null, "Record not Added", "ERROR", 2); } else if (result.equals("exists")) { JOptionPane.showMessageDialog(null, "User already exist", "ERROR", 2);

} } else if (AddUpdateFlag.equals("update")) {

if (txtUserID.getText().equals("")) {

JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE);

"User

ID

is

missing",

"ERROR",

} else if (txtUsername.getText().equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else if (new String(txtPassword.getPassword()).equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else { objBean.setFlag(true); result = objDB.updateUserAccountDetail(objBean); } "Password is missing", "ERROR", "Username is missing", "ERROR",

if (result.equals("updated")) { flag = 1; alstUser = objDB.getAllUserDetailList(); UsermasterBean objBean1 = (UsermasterBean) alstUser.get(count); showUserRecord(objBean1); JOptionPane.showMessageDialog(null, "Record has been successfully updated", "Record Updated", 1); } else if (result.equals("failed")) { JOptionPane.showMessageDialog(null, "Record not Added", "ERROR", 2);
56

} else if (result.equals("exists")) { JOptionPane.showMessageDialog(null, "User already exists", "ERROR", 2); }

if (flag == 1) { disable(false); btnSave.setEnabled(false); btnAdd.setEnabled(true); btnUpdate.setEnabled(true);

btnFirst.setEnabled(true); btnPrevious.setEnabled(true); btnNext.setEnabled(true); btnLast.setEnabled(true); btnUserPersonalDetail.setEnabled(true);

}//GEN-LAST:event_btnSaveActionPerformed

private

void

btnCancelActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnCancelActionPerformed // TODO add your handling code here: MainFrame.container.removeAll(); MainFrame.container.setVisible(false); }//GEN-LAST:event_btnCancelActionPerformed

private

void

btnLastActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnLastActionPerformed
57

// TODO add your handling code here: if (alstUser.size() > 0) { count = alstUser.size() - 1; UsermasterBean objBean = (UsermasterBean) alstUser.get(count); showUserRecord(objBean); } }//GEN-LAST:event_btnLastActionPerformed

private void btnUserPersonalDetailActionPerformed(java.awt.event.ActionEvent evt) {//GENFIRST:event_btnUserPersonalDetailActionPerformed // TODO add your handling code here: MainFrame.container.removeAll(); UserPersonalDetail objUserPersonalDetail = new UserPersonalDetail(count); objUserPersonalDetail.setBounds(250, 100, 460, 450); MainFrame.container.setVisible(false); MainFrame.container.add(objUserPersonalDetail); MainFrame.container.setVisible(true);

}//GEN-LAST:event_btnUserPersonalDetailActionPerformed

private

void

chkUploadActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_chkUploadActionPerformed // TODO add your handling code here: }//GEN-LAST:event_chkUploadActionPerformed

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnAdd; private javax.swing.JButton btnCancel; private javax.swing.JButton btnFirst; private javax.swing.JButton btnLast; private javax.swing.JButton btnNext;
58

private javax.swing.JButton btnPrevious; private javax.swing.JButton btnSave; private javax.swing.JButton btnUpdate; private javax.swing.JButton btnUserPersonalDetail; private javax.swing.JCheckBox chkDownload; private javax.swing.JCheckBox chkUpload; private javax.swing.JComboBox ddlSecurityQuestion; private javax.swing.JComboBox ddlUserStatus; private javax.swing.JComboBox ddlUserType; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JPanel jPanel1; private javax.swing.JPasswordField txtPassword; private javax.swing.JTextField txtSecurityAnswer; private javax.swing.JTextField txtUserID; private javax.swing.JTextField txtUsername; // End of variables declaration//GEN-END:variables }

FILE UPLOAD AND DOWNLOAD /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package sharemanagerserver.server;
59

import java.net.ServerSocket; import java.net.Socket; import sharemanagerserver.Authentication; import sharemanagerserver.MainFrame; import sharemanagerserver.alpha.DBOperations;

/** * * @author Administrator */ public class FTPServer extends Thread {

DBOperations db = new DBOperations(); int serverPort = 1; ServerSocket soc;

public FTPServer() { try { serverPort = db.getServerPort(); System.out.println("server port " + serverPort); soc = new ServerSocket(serverPort); System.out.println("FTP Server Started on Port Number " + serverPort); start(); if (!isAlive()) { MainFrame.serverFlag = 0; } } catch (Exception e) { MainFrame.serverFlag = 0; e.printStackTrace(); }
60

@Override public void run() { MainFrame.serverFlag = 1; while (true) {

try { sleep(2000); while (true) { sleep(2000); System.out.println("Waiting for Connection ..."); Socket s = soc.accept(); System.out.println("CSonnected ..."); Authentication.cancelFlag = 0; Authentication.flag = 0; while (true) { if (Authentication.cancelFlag == 1 || Authentication.flag == 1) { // s.close(); break;

} else { new Authentication(s); }

} if (Authentication.flag == 1) { new TransferFile(s); } }


61

} catch (Exception e) { MainFrame.serverFlag = 0; System.out.println("Tested " + e); } }

} }

/* * To change this template, choose Tools | Templates * and open the template in the editor. */

package sharemanagerserver.server;

/** * * @author Administrator */ public class ServerRun { public ServerRun() { Thread t=new Thread(new FTPServer()); t.start();

} }

REPORTS

62

/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package sharemanagerserver.report;

import sharemanagerserver.alpha.*; import java.sql.Connection; import net.sf.jasperreports.engine.JasperCompileManager; import net.sf.jasperreports.engine.JasperFillManager; import net.sf.jasperreports.engine.JasperPrint; import net.sf.jasperreports.engine.JasperReport; import net.sf.jasperreports.engine.design.JasperDesign; import net.sf.jasperreports.engine.xml.JRXmlLoader; import net.sf.jasperreports.view.JasperViewer;

/** * * @author admin */ public class JasperReportGenerator {

String designFilePath;

public JasperReportGenerator(String designFilePath) { this.designFilePath = designFilePath; generateReport(); }

void generateReport() { try {


63

JasperDesign jasperDesign = JRXmlLoader.load(designFilePath); JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign); Connection con = DBConnection.getConnection(); JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, con); JasperViewer.viewReport(jasperPrint, false); } catch (Exception e) { System.out.println("Exception JasperReportGenerator: "+e); } in generationg report, generateReport() of

} }

64

Client Login /* * To change this template, choose Tools | Templates * and open the template in the editor. */ package sharemanagerclient;

import java.net.Socket; import javax.swing.JOptionPane; import sharemanagerclient.com.DBOperation; import sharemanagerclient.com.FTPConfigurationMasterBean;

/** * * @author student */ public class FTPLoginClient {

Socket s; int flag, flag1; String str;

public FTPLoginClient() { try { DBOperation objDb = new DBOperation(); FTPConfigurationMasterBean objWftpcmb = objDb.getServerPort(); s = new Socket(objWftpcmb.getFTP_Server_IP(), objWftpcmb.getFTP_Server_Port()); flag = 1;

65

} catch (Exception e) { flag = 0; JOptionPane.showMessageDialog(null, "ERROR", JOptionPane.ERROR_MESSAGE); System.exit(0); } "Unable to Connect. Try again later!",

if (flag == 1) { try { new LoginFrame(s); } catch (Exception e2) { System.out.println("Exception int FTPLoginClient()" + e2); } //dispose(); } }

USER MAINTAINENCE /* * To change this template, choose Tools | Templates * and open the template in the editor. */

package sharemanagerclient;

import javax.swing.JOptionPane; import sharemanagerclient.com.DBOperation; import sharemanagerclient.com.UsermasterBean;


66

/** * * @author admin */ public class ProfileAccountDetail extends javax.swing.JPanel {

DBOperation objDB = new DBOperation(); String AddUpdateFlag; int userId; UsermasterBean objBean;

/** Creates new form UserAccountDetail */ public ProfileAccountDetail() { initComponents(); btnSave.setEnabled(false); disable(false); userId = MainFrameClient.userid; objBean = objDB.getUserAccountDetailByUserId(userId); showUserRecord(objBean); setVisible(true); }

public void disable(boolean val) { txtUsername.setEditable(val); txtPassword.setEditable(val); ddlSecurityQuestion.setEnabled(val); txtSecurityAnswer.setEditable(val); }

public void clear() {


67

txtUsername.setText(""); txtPassword.setText(""); txtSecurityAnswer.setText("");

public void showUserRecord(UsermasterBean objBean) {

txtUserID.setText(String.valueOf(objBean.getUserId())); txtUsername.setText(objBean.getUsername()); txtPassword.setText(objBean.getPassword()); ddlSecurityQuestion.setSelectedItem(objBean.getSecurityQuestion()); txtSecurityAnswer.setText(objBean.getSecurityAnswer()); chkDownload.setSelected(objBean.isCan_Download()); chkUpload.setSelected(objBean.isCan_Upload()); }

/** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the Form Editor. */ @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-

BEGIN:initComponents private void initComponents() {

jLabel7 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();


68

jLabel2 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel(); txtSecurityAnswer = new javax.swing.JTextField(); txtPassword = new javax.swing.JPasswordField(); txtUserID = new javax.swing.JTextField(); txtUsername = new javax.swing.JTextField(); jLabel8 = new javax.swing.JLabel(); btnUpdate = new javax.swing.JButton(); btnSave = new javax.swing.JButton(); btnCancel = new javax.swing.JButton(); jPanel1 = new javax.swing.JPanel(); chkUpload = new javax.swing.JCheckBox(); chkDownload = new javax.swing.JCheckBox(); ddlSecurityQuestion = new javax.swing.JComboBox();

setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));

jLabel7.setText("Security Answer");

jLabel6.setText("Security Question");

jLabel3.setText("Password");

jLabel2.setText("Username");

jLabel1.setText("User ID");

txtUserID.setEditable(false);

jLabel8.setFont(new java.awt.Font("Courier New", 1, 18)); jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);


69

jLabel8.setText("User Account Detail");

btnUpdate.setText("Update"); btnUpdate.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnUpdateActionPerformed(evt); } });

btnSave.setText("Save"); btnSave.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnSaveActionPerformed(evt); } });

btnCancel.setText("Cancel"); btnCancel.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancelActionPerformed(evt); } });

jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("User Privilege"));

chkUpload.setText("Upload"); chkUpload.setEnabled(false); chkUpload.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { chkUploadActionPerformed(evt); }


70

});

chkDownload.setText("Download"); chkDownload.setEnabled(false);

javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); jPanel1.setLayout(jPanel1Layout); jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() .addGap(31, 31, 31) .addComponent(chkUpload) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, Short.MAX_VALUE) .addComponent(chkDownload) .addGap(43, 43, 43)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() 200,

.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELIN E) .addComponent(chkDownload) .addComponent(chkUpload)) .addContainerGap(16, Short.MAX_VALUE)) );

71

ddlSecurityQuestion.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "What is your first mobile number? ", "What is your first school name?", "What is your hobby?", "Which is your favourite color?", "Which is your favourite sport?" }));

javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel3) .addComponent(jLabel2) .addComponent(jLabel1)) .addGap(117, 117, 117)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtPassword) .addComponent(txtUserID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 149, Short.MAX_VALUE))) 60,

72

.addComponent(jLabel8,

javax.swing.GroupLayout.Alignment.TRAILING,

javax.swing.GroupLayout.DEFAULT_SIZE, 418, Short.MAX_VALUE)) .addGap(35, 35, 35)) .addGroup(layout.createSequentialGroup()

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createSequentialGroup() .addComponent(btnUpdate)

.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE,

75, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 75, javax.swing.GroupLayout.PREFERRED_SIZE))

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addComponent(jLabel6)) .addGap(71, 71, 71)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addComponent(txtSecurityAnswer)

73

.addComponent(ddlSecurityQuestion, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))) .addContainerGap()))) );

0,

layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {btnCancel, btnSave, btnUpdate});

layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addGap(35, 35, 35) .addComponent(jLabel8) .addGap(32, 32, 32)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel1) .addComponent(txtUserID, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(12, 12, 12)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
74

.addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel6) .addComponent(ddlSecurityQuestion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(16, 16, 16) javax.swing.GroupLayout.DEFAULT_SIZE,

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel7) .addComponent(txtSecurityAnswer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE,

javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18)

.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(btnUpdate, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnSave, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(btnCancel, javax.swing.GroupLayout.PREFERRED_SIZE, 20,

javax.swing.GroupLayout.PREFERRED_SIZE)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) );

layout.linkSize(javax.swing.SwingConstants.VERTICAL, {btnCancel, btnSave, btnUpdate});


75

new

java.awt.Component[]

}// </editor-fold>//GEN-END:initComponents

private

void

btnUpdateActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnUpdateActionPerformed // TODO add your handling code here: AddUpdateFlag = "update"; disable(true); btnSave.setEnabled(true); btnUpdate.setEnabled(false);

}//GEN-LAST:event_btnUpdateActionPerformed

private

void

btnSaveActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnSaveActionPerformed

String result = ""; int flag = 0; objBean.setUserId(Integer.parseInt(txtUserID.getText())); objBean.setPassword(new String(txtPassword.getPassword())); objBean.setUsername(txtUsername.getText()); objBean.setSecurityQuestion(ddlSecurityQuestion.getSelectedItem().toString()); objBean.setSecurityAnswer(txtSecurityAnswer.getText());

if (txtUserID.getText().equals("")) {

JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else if (txtUsername.getText().equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE);

"User

ID

is

missing",

"ERROR",

"Username

is

missing",

"ERROR",

76

} else if (new String(txtPassword.getPassword()).equals("")) { JOptionPane.showMessageDialog(this, JOptionPane.ERROR_MESSAGE); } else { result = objDB.updateUserAccountDetail(objBean); } "Password is missing", "ERROR",

if (result.equals("updated")) { flag = 1; objBean = objDB.getUserAccountDetailByUserId(userId); showUserRecord(objBean); JOptionPane.showMessageDialog(null, "Record has been successfully updated", "Record Updated", 1); } else if (result.equals("failed")) { JOptionPane.showMessageDialog(null, "Record not Added", "ERROR", 2); } else if (result.equals("exists")) { JOptionPane.showMessageDialog(null, "User already exists", "ERROR", 2); }

if (flag == 1) { disable(false); btnSave.setEnabled(false); btnUpdate.setEnabled(true); } }//GEN-LAST:event_btnSaveActionPerformed

private

void

btnCancelActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_btnCancelActionPerformed // TODO add your handling code here:


77

MainFrameClient.container.removeAll(); MainFrameClient.container.setVisible(false); }//GEN-LAST:event_btnCancelActionPerformed

private

void

chkUploadActionPerformed(java.awt.event.ActionEvent

evt)

{//GEN-

FIRST:event_chkUploadActionPerformed // TODO add your handling code here: }//GEN-LAST:event_chkUploadActionPerformed

// Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnCancel; private javax.swing.JButton btnSave; private javax.swing.JButton btnUpdate; private javax.swing.JCheckBox chkDownload; private javax.swing.JCheckBox chkUpload; private javax.swing.JComboBox ddlSecurityQuestion; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel7; private javax.swing.JLabel jLabel8; private javax.swing.JPanel jPanel1; private javax.swing.JPasswordField txtPassword; private javax.swing.JTextField txtSecurityAnswer; private javax.swing.JTextField txtUserID; private javax.swing.JTextField txtUsername; // End of variables declaration//GEN-END:variables }

78

FTP SERVER <?xml version="1.0" encoding="UTF-8" ?>

<Form

version="1.3"

maxVersion="1.7"

type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="3"/> </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> <AuxValue value="false"/> <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> <AuxValue value="false"/> <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> <AuxValue value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> </AuxValues> name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" name="FormSettings_autoSetComponentName" type="java.lang.Boolean"

<Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace min="-2" pref="26" max="-2" attributes="0"/>
79

<Component id="jPanel1" min="-2" max="-2" attributes="0"/> <EmptySpace max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0"> <EmptySpace max="-2" attributes="0"/> <Component id="jPanel1" min="-2" max="-2" attributes="0"/> <EmptySpace pref="28" max="32767" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Container class="javax.swing.JPanel" name="jPanel1"> <Properties> <Property name="border" type="javax.swing.border.Border"

editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> <TitledBorder title="FTP Configure"/> </Border> </Property> </Properties>

<Layout> <DimensionLayout dim="0"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace min="-2" pref="36" max="-2" attributes="0"/>
80

<Group type="103" groupAlignment="0" attributes="0"> <Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" pref="42" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" max="-2" attributes="0"> <Component id="txtPortNumber" max="32767" attributes="1"/> <Component attributes="1"/> </Group> <EmptySpace pref="35" max="32767" attributes="0"/> </Group> <Group type="102" alignment="1" attributes="0"> <EmptySpace pref="100" max="32767" attributes="0"/> <Component id="btnConnect" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="103" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> <DimensionLayout dim="1"> <Group type="103" groupAlignment="0" attributes="0"> <Group type="102" attributes="0"> <EmptySpace min="-2" pref="19" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="txtServerName" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" pref="28" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
81

id="txtServerName"

alignment="0"

pref="137"

max="32767"

<Component attributes="0"/>

id="txtPortNumber"

alignment="3"

min="-2"

max="-2"

<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace pref="31" max="32767" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnConnect" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Component class="javax.swing.JButton" name="btnConnect"> <Properties> <Property name="text" type="java.lang.String" value="Connect"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener"

parameters="java.awt.event.ActionEvent" handler="btnConnectActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnCancel"> <Properties> <Property name="text" type="java.lang.String" value="Cancel"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener"

parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
82

</Events> </Component> <Component class="javax.swing.JTextField" name="txtServerName"> </Component> <Component class="javax.swing.JLabel" name="jLabel1"> <Properties> <Property name="text" type="java.lang.String" value="Server Name"/> </Properties> </Component> <Component class="javax.swing.JLabel" name="jLabel2"> <Properties> <Property name="text" type="java.lang.String" value="Port Number"/> </Properties> </Component> <Component class="javax.swing.JTextField" name="txtPortNumber"> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener"

parameters="java.awt.event.ActionEvent" handler="txtPortNumberActionPerformed"/> </Events> </Component> </SubComponents> </Container> </SubComponents> </Form>

EMAIL package sharemanagerclient.email;

import java.util.Properties; import java.util.Date; import javax.mail.Address;


83

import javax.mail.Authenticator; import javax.mail.Message; import javax.mail.Session; import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage;

public class SendSMTP {

String result = "failed";

public String sendMail(String toEmailId, String text, String subject) { try {

//--[ Set up the default parameters Properties p = new Properties(); p.put("mail.smtp.auth", "true"); p.put("mail.transport.protocol", "smtp"); p.put("mail.smtp.host", "smtp.gmail.com"); p.put("mail.smtp.port", "25"); p.put("mail.smtp.starttls.enable", "true");

//--[ Create the session and create a new mail message Authenticator auth = new SMTPAuthenticator("gmailid", "password"); Session mailSession = Session.getInstance(p, auth); Message msg = new MimeMessage(mailSession);

//--[ Set the FROM, TO, DATE and SUBJECT fields msg.setFrom(new InternetAddress("gmailid")); String rec[] = toEmailId.split(";");

84

int count = 1; msg.setRecipients(Message.RecipientType.TO, InternetAddress.parse(rec[0])); while (count < rec.length) { msg.addRecipients(Message.RecipientType.TO, InternetAddress.parse(rec[count])); count++; }

msg.setSentDate(new Date()); msg.setSubject(subject);

//--[ Create the body of the mail msg.setText(text);

//--[ Ask the Transport class to send our mail message

Transport trans = mailSession.getTransport();

trans.connect(); Address[] ad = msg.getAllRecipients(); for (int i = 0; i < ad.length; i++) {

try { Address[] ad1 = new Address[1]; ad1[0] = ad[i];

trans.sendMessage(msg, ad1); result = "sent";

} catch (Exception e) { continue;


85

} }

} catch (Exception E) { System.out.println("Something gone wrong while sending mail!"); E.printStackTrace(); return result; }

return result; } } /* * To change this template, choose Tools | Templates * and open the template in the editor. */

package sharemanagerclient.email; import javax.mail.Authenticator; import javax.mail.PasswordAuthentication;

/** * * @author Administrator */ public class SMTPAuthenticator extends Authenticator{ private String username,password; public SMTPAuthenticator(String username,String password){ this.username=username;
86

this.password=password;

public javax.mail.PasswordAuthentication getPasswordAuthentication(){

return new PasswordAuthentication(this.username,this.password); }

87

CHAPTER-5

Testing
5.1 which testing technique used in project The most natural, and customary, way of verifying any piece of work is just to operate it in some representative situations and verify whether its Behavior is as expected. In general, it is impossible to test it under all possible operating conditions. Thus, it is necessary to find suitable test cases that provide enough evidence that the desired behavior will be exhibited in all remaining cases. Further more, in the case of software testing, the usual analogies between traditional Engineering fields and software engineering fail to provide useful suggestions. Testing is a critical activity in software engineering and should be performed as systematically as possible by stating clearly what result one expects to obtain that result. On the contrary, often in practice, testing is performed in an unstructured way without applying any criterion.

Software Testing Techniques: The important of software testing and its implication with respect to software quality cannot be overemphasized. Software testing is a critical element of software quality assurance and represents the ultimate review of specification, design and code generation. The increase in visibility of soft-ware as a system element and the attendant cost associated with a software failure are motivating forces for well-planned, through testing is not unusual for a software development organization to expand between 30 and 40% of total project effort on testing. In the extreme testing of human rated software for exampleflight control, nuclear reactor monitoring can cost 3 to 5 time as much as all other software engineering steps combined! There are two major type of testing they are 1) White Box Testing. 2) Black Box Testing.

88

White Box Testing White box some times called Glass box testing is a test case design uses the control structure of the procedural design to drive test case. Using white box testing methods, the following tests where made on the system a) All independent paths within a module have been exercised once. In our system, ensuring that case was selected and executed checked all case structures. The bugs that were prevailing in some part of the code where fixed b) All logical decisions were checked for the truth and falsity of the values. Black box Testing Black box testing focuses on the functional requirements of the software.

This is black box testing enables the software engineering to derive a set of input conditions that will fully exercise all functional requirements for a program. Black box testing is not an alternative to white box testing rather it is complementary approach that is likely to uncover a different class of errors that white box methods like.. 1) Interface errors 2) Performance in data structure 3) Performance errors 4) Initializing and termination errors Testing Objectives Testing is a process of executing a program with the intent of finding an error. A good test case is one that has a high probability of finding as yet undiscovered error A successful test is one that uncovers an as-yet undiscovered error. These objectives imply a dramatic change bin viewpoint, the move counter to the commonly held view that a successful test is one in which no error are found. Our objective is to design tests that systematically UN covers different classes of errors and to do so with a minimum amount of time and effort.

89

If testing is conducted successfully (according to the objectives stated above), if will uncover error in the softwares a secondary benefit, testing demonstrates that software function appear to be working according to specification, that behavioral and performance requirements appear to have been met. In addition, data collected as testing is conducted provide a good indication of software reliability and some indications of software quality as a whole. But testing cam not shows the absence of error and defects, it can show only that software errors and defects are presents. It is important to keep this statement mind as testing is being conducted.

Testing Principles All test should be traceable to customer requirements: - As we have seen, the objective of the software testing is to uncover errors. It follows that the most server defects (from the customers point of view) are those that cause the program to fail to meet it requirements. Tests should be planned long before testing begins: ------- Test planning can begin soon as the requirements model is complete. Detailed definition of test cases as soon as the design models have been solidified. Therefore, all tests can and design before any code has been generated. The praetor principle applies to software testing: ------ stated simply, the Praetor principle implies that 80% of all errors uncovered during testing will likely be traceable to 20%of all program components. Testing should begin in the small and progress towards testing in the large: -first test planned and executed generally focus on individual components. As progresses ,focus shifts in an attempt ton find errors in interrogated components and ultimately in the entire system The testing clusters of as

can begin be planed

Software Testing Testing is a set of activities that can be planned in advance and conducted this reason a template for software testing a set of steps in systematically. For

which we can place specific test

case design techniques and testing methods should be define for software process. A number of software testing strategies have been proposed in literature. All provide the software developer with a template for testing and have following generic characteristic.
90

Testing begin at the component level and workoutward towards the integration the entire computer based system. Different testing techniques are appropriate at different points in time.

of

Testing is conducted by the developer of the software and (large project) an independent test group. Testing and debugging are different activities, but debugging must be accommodated in any testing strategy

Features of Good S/W Testing The following are the feature of the good testing: 1. A good test has a high probability of finding an error. To achieve this goal, the tester must

understand the software and attempt to develop a mental picture of the software might fail. 2. A good test is not redundant test time and is limited. Every test should have a purpose. 3. A good test should be best of breed. 4. A good test should be neither simple nor to complex. different

91

5.2 Result(Snapshots)

92

93

94

95

96

Conclusion
Create a FTP Server to transfer files. Provide interface to users for downloading & uploading files of specific FTP server .Provide support to users to share, rename and delete files on server. To maintain various users of the application & their access rights. Maintain history of all the activities (File Downloads and Uploads) of users, for future analysis. To provide a functionality to the administrator of the application for setting up the configuration of FTP server. Users will be able to share files with other users as files will be on central repository and FTP Server will be created to support file sharing. A user friendly Graphical User Interface will be provided to easily upload and download files using FTP Server. Only registered / authorized users will be able to use this application for download & upload as per the rights available to them. Users will be able to rename and delete files uploaded by them.

6.1 Limitations 1. No other user can interprete with system 2. Files other than FTP Server cant access 3. Downloading And Uploading will be in certain limit

6.2 Future Scope Keep track of daily information exchange at the server by the administrator. Increase in processing and transfer speeds of information over the network. Decrease in processing time Reduction of errors and viruses due to absence of internet Keeping track that message should be delivered at the correct destination

97

Bibliography
Books: 1. The Complete Reference Java 2 Herbert Schildt Tata McGraw-Hill 2. Begging Java 2 Ivor Horton SPD 3. Pure JFC Swing Dr Satyaraj Pantham PHI 4. Professional Java Programming Brett Spell SPD

Websites: www.sun.java.com http://www.roseindia.net/java/ http://www.java2s.com/

98

Вам также может понравиться