|
By the way, your function createSalt() creates a new salt every time you call it!
When you want to compare the original value and the database value, you hat to write the salt into a variable, then set it to your object, write to database, then retrieve from the database.
|
|
|
|
|
public void run(){
for(int i=0;i<totalThread;++i){
Thread x=new Thread(new RequestProcessor(documentRootDirectory,indexfileName));
x.start();
}
System.out.println("coonection accepted"+server.getLocalPort());
System.out.println("Dokumen root"+documentRootDirectory);
while(true){
try{
Socket request=server.accept();
RequestProcessor.startProcessing();
}
catch(IOException ex){
}
}
}
error message from this program : method RequestProcessor can't not implemented with given types,
althaugh i have create class RequestProcessor from one package, can you help me to integrated the totalThread with RequestProcessor? the error start when i try to instance new Thread.
thx.
|
|
|
|
|
|
How to read this XML file:
I need to read attribute name/value pair and element contents.
="1.0"="UTF-8"
<idmef:IDMEF-Message xmlns:idmef="http://iana.org/idmef" version="1.0">
<idmef:Alert messageid="abc123456789">
<idmef:Analyzer analyzerid="bc-sensor01">
<idmef:Node category="dns">
<idmef:name>sensor.example.com</idmef:name>
</idmef:Node>
</idmef:Analyzer>
<idmef:CreateTime ntpstamp="0xbc71f4f5.0xef449129">2000-03-09T10:01:25.93464Z</idmef:CreateTime>
<idmef:Source ident="a1a2" spoofed="yes">
<idmef:Node ident="a1a2-1">
<idmef:Address ident="a1a2-2" category="ipv4-addr">
<idmef:address>192.0.2.200</idmef:address>
</idmef:Address>
</idmef:Node>
</idmef:Source>
<idmef:Target ident="b3b4">
<idmef:Node>
<idmef:Address ident="b3b4-1" category="ipv4-addr">
<idmef:address>192.0.2.50</idmef:address>
</idmef:Address>
</idmef:Node>
</idmef:Target>
<idmef:Target ident="c5c6">
<idmef:Node ident="c5c6-1" category="nisplus">
<idmef:name>lollipop</idmef:name>
</idmef:Node>
</idmef:Target>
<idmef:Target ident="d7d8">
<idmef:Node ident="d7d8-1">
<idmef:location>Cabinet B10</idmef:location>
<idmef:name>Cisco.router.b10</idmef:name>
</idmef:Node>
</idmef:Target>
<idmef:Classification text="Ping-of-death detected">
<idmef:Reference origin="cve">
<idmef:name>CVE-1999-128</idmef:name>
<idmef:url>http://www.cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-1999-128</idmef:url>
</idmef:Reference>
</idmef:Classification>
</idmef:Alert>
</idmef:IDMEF-Message>
|
|
|
|
|
I showed you how to find information on reading CSV files, no doubt you can do the same for XML.
Use the best guess
|
|
|
|
|
I know how to read xml file but I have a problem with this file.
|
|
|
|
|
peniya wrote: I know how to read xml file but I have a problem with this file. Then you need to explain what that problem is; please don't expect people to guess it.
Use the best guess
|
|
|
|
|
How to write this code?
I have .csv file. Content of file like as follow:
A,B
B,C
A,F
F,G
G,H
B,D
I have to read this file and output should be :
A _ B _ C
| |_ D
|_F _ G_ H
How to write this code to get this output?
modified 30-Jul-13 12:41pm.
|
|
|
|
|
peniya wrote: I have to use swing You don't use swing to read a file. Look at these links[^].
Use the best guess
|
|
|
|
|
For output I should use swing.
and I know how to read .csv file, but my problem is with output.
how to get that output.
|
|
|
|
|
That question is impossible to answer in a forum like this. Go and find some swing tutorials and learn about what features are available to hlep you format your output.
Use the best guess
|
|
|
|
|
hi i have problem selecting the numbers that is not in the single/double qoutes . let say we have this text below .
123
<style color="#767676">
8787
i want to select just the 123 and 8787 , nothing else
how should i do this with regular expression in javascript
|
|
|
|
|
|
private static void insertRecord() throws SQLException
{
Connection con = null;
Statement statement = null;
try
{
PreparedStatement PS = Connectionstring().prepareStatement("INSERT INTO LoginDetails(Username,Password) VALUES (?,?)");
String User = tf_Uname.getText();
String _Pass = new String(tf_pass.getPassword());
MessageDigest md = null;
try {
md = MessageDigest.getInstance("SHA-256");
}
catch (NoSuchAlgorithmException e)
{
e.printStackTrace();
}
md.update(_Pass.getBytes());
byte byteData[] = md.digest();
StringBuffer sb = new StringBuffer();
for (int i = 0; i < byteData.length; i++) {
sb.append(Integer.toString((byteData[i] & 0xff) + 0x100, 16).substring(1));
}
System.out.println("Hex format : " + sb.toString());
StringBuffer hexString = new StringBuffer();
for (int i=0;i<byteData.length;i++)
{
String hex=Integer.toHexString(0xff & byteData[i]);
if(hex.length()==1) hexString.append('0');
hexString.append(hex);
}
System.out.println("Hex format : " + hexString.toString());
PS.setString(1, User);
PS.setString(2, _Pass);
PS.executeUpdate();
JOptionPane.showMessageDialog(null,"Your Data has been Inserted","Data Inserted",JOptionPane.INFORMATION_MESSAGE);
}
catch (SQLException e)
{
System.out.println(e.getMessage());
}
finally
{
if (statement != null)
{
statement.close();
JOptionPane.showMessageDialog(null,"Statement is closed","Statement",JOptionPane.INFORMATION_MESSAGE);
}
if (con != null)
{
con.close();
JOptionPane.showMessageDialog(null,"Connection is closed!","Connection",JOptionPane.INFORMATION_MESSAGE );
}
}
}
I'm getting the right output but could not able to save the hash password into the database it's being stored as a Text.
|
|
|
|
|
Hello chdboy please check this line
PS.setString(1, User);
PS.setString(2, _Pass);
PS.executeUpdate();
you have provided normal text to user and password field
While you need to provide hex code in this line no 1 and 2
|
|
|
|
|
Thanks a lot ...now let's see if there is a problem in getting hex code back to the string when user enter details .
|
|
|
|
|
You shouldn't need to, that means anyone else can, and your system is not secure. Passwords should use one-way hashes so they can never be converted back to the original string. See Secure Password Authentication Explained Simply[^].
Use the best guess
|
|
|
|
|
I am new to Java and Web Development. I need to build a Java server App, which has to interact with MySQL DB stored procedures and fetch rows and return to client.
1. Client can be from Http request from web browser
2. An Android app
3. Desktop app
4. and others
Now my question is; should the server App be
1.JSP
2.Servlet
3.WebService
Load balancing should be done for Server App, and server App is going to be 3-tire
Please advice the Pro/Cons in each case.
|
|
|
|
|
This question is far too broad for a technical forum such as this. You need to do your own research and study before deciding which technologies will be best to address your problem.
Use the best guess
|
|
|
|
|
I want to validate Username and Password matching from my sql Database,but it didn't work.Even if the text fields are blank it does not give any error.
private static void selectfromdb() throws SQLException
{
Statement stmt = Connectionstring().createStatement();
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails where Username='"+tf_Fname+"' AND Password ='"+tf_Lname+"'");
while (rs.next())
{
String x = tf_Fname.getText();
String pass = new String(tf_Lname.getPassword());
if (x.equals(rs.getString("Username")))
{
if (pass.equals(rs.getString("Password")))
{
JOptionPane.showMessageDialog(null,"Login Successful! ","Success",JOptionPane.WARNING_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(null,"Login UNSuccessful! ","UNSuccessful",JOptionPane.WARNING_MESSAGE);
}
}
}
}
|
|
|
|
|
Try this
private static void selectfromdb() throws SQLException
{
Statement stmt = Connectionstring().createStatement();
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails where Username='"+tf_Fname+"' AND Password ='"+tf_Lname+"'");
rs.last();
int rowcount = rs.getRow();
if(rowcount ==0){
JOptionPane.showMessageDialog(null,"Login UNSuccessful! ","UNSuccessful",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(null,"Login Successful! ","Success",JOptionPane.WARNING_MESSAGE);
}
}
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Blue_Boy wrote:
ResultSet rs = stmt.executeQuery("SELECT Username,Password FROM LoginDetails where Username='"+tf_Fname+"' AND Password ='"+tf_Lname+"'");
It is really bad form to give sample code that can lead to SQL injection[^].
Use the best guess
|
|
|
|
|
I didn't gave example to use query which is able to inject, the user used by him/herself, i just gave solution how to manage login case.
I Love T-SQL
"VB.NET is developed with C#.NET"
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
In both the cases even if it's right password it shows "Login UNSuccessful"
|
|
|
|
|
Use your debugger to step through the code and see what values your variables contain at each stage.
Use the best guess
|
|
|
|