Newsgroup: it.comp.java
Titolo: chiedo aiuto agli esperti di java!

ciao,
sto cercando di interpretare un listato in java ma essendo ai primi
rudimenti non ci capisco letteralmente niente.
Forse c'è qualcuno abbastanza esperto da potermi aiutare.
Il listato prende due stringhe e restituisce un indirizzo url in caso
affermativo oppure un errore;in pratica è un login.
Vorrei sapere come si fa a convertire il codice html che utilizza questo
java nell'username e password.
grazie
il file java si chiama islogin.class
Ecco il listato:
import java.applet.Applet;
import java.applet.AppletContext;
import java.awt.*;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Hashtable;
public class islogin extends Applet
implements LayoutManager
{
public Dimension minimumLayoutSize(Container container)
{
return new Dimension(m_width, m_height);
}
private String decodeString(String s)
{
int i = 0;
int j = 0;
char ac[] = new char[s.length()];
for(; i < s.length(); i++)
if(s.charAt(i) == '#')
{
if(s.charAt(i + 1) == '#')
{
ac[j] = '#';
j++;
i++;
} else
if(s.charAt(i + 1) == 's')
{
ac[j] = ' ';
j++;
i++;
} else
if(s.charAt(i + 1) == 'a')
{
ac[j] = '&';
j++;
i++;
} else
if(s.charAt(i + 1) == 'l')
{
ac[j] = '<';
j++;
i++;
} else
if(s.charAt(i + 1) == 'q')
{
ac[j] = '"';
j++;
i++;
} else
if(s.charAt(i + 1) == 'g')
{
ac[j] = '>';
j++;
i++;
} else
if(s.charAt(i + 1) == 'u')
{
ac[j] = '\177';
j++;
i++;
} else
{
erroras = true;
}
} else
{
ac[j] = s.charAt(i);
j++;
}
s = new String(ac);
return lockKey(s, new String("Default user name"));
}
public boolean CreateControls()
{
if(m_fInitialized || m_Parent == null)
return false;
if(!(m_Parent instanceof Container))
return false;
Font font = m_Parent.getFont();
if(font != null)
{
Font font1 = new Font("SansSerif", font.getStyle(), 11);
m_Parent.setFont(font1);
}
Construct(m_Parent, 186, 69);
m_Parent.setLayout(this);
m_Parent.addNotify();
Dimension dimension = getDialogSize();
Insets insets = m_Parent.insets();
m_Parent.resize(insets.left + dimension.width + insets.right, insets.top +
dimension.height + insets.bottom);
if(status.compareTo(new String("P")) != 0 && status.compareTo(new
String("L")) != 0)
Btn1 = new Button(t3 + "-UNREGISTERED applet");
else
Btn1 = new Button(t3);
m_Parent.add(Btn1);
setShape(Btn1, 5, 44, 177, 14);
Txt1 = new TextField("");
Txt1.setForeground(Color.blue);
Txt1.setBackground(Color.white);
m_Parent.add(Txt1);
setShape(Txt1, 99, 7, 75, 14);
Txt2 = new TextField("");
Txt2.setForeground(Color.blue);
Txt2.setEchoCharacter('*');
Txt2.setBackground(Color.white);
m_Parent.add(Txt2);
setShape(Txt2, 99, 23, 75, 14);
setBackground(backgroundas);
Lbl1 = new Label(t1, 2);
Lbl1.setForeground(colorT);
Lbl1.setBackground(backgroundas);
m_Parent.add(Lbl1);
setShape(Lbl1, 2, 9, 95, 8);
setBackground(backgroundas);
Lbl2 = new Label(t2, 2);
Lbl2.setForeground(colorT);
Lbl2.setBackground(backgroundas);
m_Parent.add(Lbl2);
setShape(Lbl2, 2, 26, 95, 8);
m_fInitialized = true;
return true;
}
public void setShape(Component component, int i, int j, int k, int l)
{
m_map.put(component, new Rectangle(i, j, k, l));
}
private String lockKey(String s, String s1)
{
char ac[] = new char[s.length()];
ac = s.toCharArray();
int j = 0;
for(int i = 0; i < s.length(); i++)
{
char c = s1.charAt(j);
c >>= '\003';
ac[i] = (char)(ac[i] ^ c);
if(j < s1.length() - 1)
j++;
else
j = 0;
}
return new String(ac);
}
public void setShape(Component component, Rectangle rectangle)
{
m_map.put(component, new Rectangle(rectangle.x, rectangle.y,
rectangle.width, rectangle.height));
}
public Rectangle getShape(Component component)
{
Rectangle rectangle = (Rectangle)m_map.get(component);
return new Rectangle(rectangle.x, rectangle.y, rectangle.width,
rectangle.height);
}
public Dimension getDialogSize()
{
return new Dimension(m_width, m_height);
}
public void removeLayoutComponent(Component component)
{
}
protected void mapRectangle(Rectangle rectangle, int i, int j)
{
rectangle.x = (rectangle.x * i) / 4;
rectangle.y = (rectangle.y * j) / 8;
rectangle.width = (rectangle.width * i) / 4;
rectangle.height = (rectangle.height * j) / 8;
}
public String getAppletInfo()
{
return new String("Applet Web Password - calss file version 2.21, by
Innovative Solutions 1999 
http://software.ktc.lt
, applet author Tomas
Liubinas 
tomas.l...@energija.lt
. Author speaks: I think you are too damn
currious if you can read this.");
}
public Dimension preferredLayoutSize(Container container)
{
return new Dimension(m_width, m_height);
}
public boolean action(Event event, Object obj)
{
int i = 0;
if((event.target instanceof Button) || (event.target instanceof TextField))
{
boolean flag = false;
for(int j = 0; j < userCount.intValue(); j++)
if(name[j].toUpperCase().compareTo(Txt1.getText().toUpperCase()) == 0 &&
password[j].compareTo(Txt2.getText()) == 0)
{
flag = true;
i = j;
}
if(!flag)
try
{
if(iLink.compareTo("") != 0)
if(iFrame.compareTo("") == 0)
getAppletContext().showDocument(new URL(getDocumentBase(), iLink));
else
getAppletContext().showDocument(new URL(getDocumentBase(), iLink), iFrame);
}
catch(MalformedURLException _ex) { }
else
try
{
if(frame[i].compareTo("") == 0)
getAppletContext().showDocument(new URL(getDocumentBase(), link[i]));
else
getAppletContext().showDocument(new URL(getDocumentBase(), link[i]),
frame[i]);
}
catch(MalformedURLException _ex) { }
}
Txt1.setText(new String("*"));
Txt2.setText(new String("*"));
Txt1.setText(new String(""));
Txt2.setText(new String(""));
return true;
}
public void layoutContainer(Container container)
{
int i = container.countComponents();
Rectangle rectangle = new Rectangle();
int j = getCharHeight(container);
int k = getCharWidth(container);
Insets insets = container.insets();
for(int l = 0; l < i; l++)
{
Component component = container.getComponent(l);
Rectangle rectangle1 = (Rectangle)m_map.get(component);
if(rectangle1 != null)
{
rectangle.x = rectangle1.x;
rectangle.y = rectangle1.y;
rectangle.height = rectangle1.height;
rectangle.width = rectangle1.width;
mapRectangle(rectangle, k, j);
if(component instanceof Label)
{
rectangle.x -= 12;
rectangle.width += 12;
}
rectangle.x += insets.left;
rectangle.y += insets.top;
component.reshape(rectangle.x, rectangle.y, rectangle.width,
rectangle.height);
}
}
}
public String fetchFirst()
{
if(fechable.charAt(0) == '|')
fechable = new String(fechable.substring(1));
String s = new String(fechable.substring(0, fechable.indexOf('|')));
fechable = new String(fechable.substring(fechable.indexOf('|')));
return s;
}
protected int getCharHeight(Container container)
{
FontMetrics fontmetrics = container.getFontMetrics(container.getFont());
int i = fontmetrics.getHeight();
return i;
}
public void addLayoutComponent(String s, Component component)
{
}
public void init()
{
resize(280, 110);
setLayout(new FlowLayout(0));
boolean flag = true;
try
{
getParameter("checkpoint");
}
catch(Exception _ex) { }
String s = new String();
try
{
String s1 = new String(getParameter("checkpoint"));
fechable = new String(getParameter("general"));
coloras2 = new Integer(fetchFirst());
Integer integer = new Integer(fetchFirst());
colorT = new Color(integer.intValue());
t1 = new String(fetchFirst());
t2 = new String(fetchFirst());
t3 = new String(fetchFirst());
iLink = new String(fetchFirst());
iFrame = new String(fetchFirst());
Integer integer1 = new Integer(s1.toString());
String s2 = new String();
for(int i = 1; i <= integer1.intValue(); i++)
{
String s5 = new String(Integer.toString(i));
String s7 = new String(getParameter("user" + s5));
s2 = new String(s2 + s7);
}
fechable = new String(decodeString(s2));
fetchFirst();
for(; fechable.charAt(0) == '|'; fechable = new
String(fechable.substring(1)));
fetchFirst();
status = new String(fetchFirst());
if(status.compareTo(new String("L")) != 0 && status.compareTo(new
String("P")) != 0)
{
String s3 = new String(getParameter("generator"));
if(s3.compareTo(new String("Applet Web Password 2 - UNREGISTERED,
http://software.ktc.lt
")) != 0)
flag = false;
}
if(status.compareTo(new String("L")) == 0)
{
String s4 = new String(getParameter("generator"));
if(s4.compareTo(new String("Applet Web Password 2, 
http://software.ktc.lt
"))
!= 0)
flag = false;
}
userCount = new Integer(fetchFirst());
cLink = new String(fetchFirst());
cFrame = new String(fetchFirst());
name = new String[userCount.intValue()];
password = new String[userCount.intValue()];
link = new String[userCount.intValue()];
frame = new String[userCount.intValue()];
for(int j = 0; j < userCount.intValue(); j++)
{
name[j] = fetchFirst();
password[j] = fetchFirst();
String s6 = fetchFirst();
char ac[] = new char[10];
ac = s6.toCharArray();
if(ac[0] == 'd')
{
link[j] = new String(cLink);
frame[j] = new String(cFrame);
} else
{
link[j] = new String(fetchFirst());
frame[j] = new String(fetchFirst());
}
}
}
catch(Exception exception)
{
setForeground(Color.red);
setBackground(new Color(0xffffdd));
flag = false;
s = new String(exception.getMessage());
}
if(flag)
{
backgroundas = new Color(coloras2.intValue());
setBackground(new Color(coloras2.intValue()));
m_Parent = this;
CreateControls();
return;
} else
{
setBackground(Color.white);
setForeground(Color.red);
add(new Label("Applet loading error"));
add(new Label(s));
return;
}
}
public islogin()
{
fechable = new String();
status = new String("D");
m_map = new Hashtable();
}
protected int getCharWidth(Container container)
{
FontMetrics fontmetrics = container.getFontMetrics(container.getFont());
String s = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
int i = fontmetrics.stringWidth(s) / s.length();
if(i <= 0)
i = 1;
return i;
}
protected void Construct(Container container, int i, int j)
{
Rectangle rectangle = new Rectangle(0, 0, i, j);
mapRectangle(rectangle, getCharWidth(container), getCharHeight(container));
m_width = rectangle.width;
m_height = rectangle.height;
}
boolean erroras;
private String fechable;
Color colorT;
String t1;
String t2;
String t3;
String iLink;
String iFrame;
Integer coloras2;
Color backgroundas;
private String status;
private Integer userCount;
private String cLink;
private String cFrame;
private String name[];
private String password[];
private String link[];
private String frame[];
Container m_Parent;
boolean m_fInitialized;
protected Hashtable m_map;
protected int m_width;
protected int m_height;
Button Btn1;
TextField Txt1;
TextField Txt2;
Label Lbl1;
Label Lbl2;
}

 java nell'username e password.
La Username e password non sono scritte nel codice ma vengono lette da
un file (o simile) durante la init dell'applet. Quindi se stai cercando
di craccare il sito sono spiacente ma non e' cosi' che funziona.
Davide

 wrote in message
news:ammfhv$6unh8$1...@ID-18487.news.dfncis.de...
