help me with a program

Discussion in 'Java' started by boris, Jul 26, 2007.

  1. boris

    boris Guest

    How to create a java program to validate date and email id entered.I
    think an algorithm will also do just fine. I am still learning java
    please help.
    boris, Jul 26, 2007
    #1
    1. Advertising

  2. boris

    Daniel Pitts Guest

    On Jul 26, 7:09 am, boris <> wrote:
    > How to create a java program to validate date and email id entered.I
    > think an algorithm will also do just fine. I am still learning java
    > please help.


    First, you should give a better subject line when posting here. "Help
    with Date and Email validation" would have been better. And simply
    "Date and Email validation" would have been even better.

    Back to your question:
    regex (java.util.Pattern) to "help" validate these, but in general, e-
    mail addresses can only be validated by sending a message with a
    "secret" to that address, and having the recipient inform your system
    of the secret.

    I once spent some time creating a regex that validates the syntax of
    an e-mail address, but it really was pointless after all.

    As for the date, you could also probably use SimpleDateFormat class to
    try to parse the date.
    Daniel Pitts, Jul 26, 2007
    #2
    1. Advertising

  3. boris

    Roedy Green Guest

    On Thu, 26 Jul 2007 07:09:20 -0700, boris <> wrote,
    quoted or indirectly quoted someone who said :

    >How to create a java program to validate date and email id entered.I
    >think an algorithm will also do just fine. I am still learning java
    >please help.


    for a very elaborate algorithm to validate email address, look at the
    code posted at http://mindprod.com/products1.html#BULK

    For code to parse a date, and in the process validate it, see
    http://mindprod.com/jgloss/calendar.html
    --
    Roedy Green Canadian Mind Products
    The Java Glossary
    http://mindprod.com
    Roedy Green, Jul 26, 2007
    #3
  4. boris

    Twisted Guest

    On Jul 26, 11:19 am, Roedy Green <>
    wrote:
    > for a very elaborate algorithm to validate email address, look at the
    > code posted athttp://mindprod.com/products1.html#BULK


    YOUR WEB SERVER HAS BEEN HACKED. TAKE IT OFFLINE AND FIX THE SECURITY
    HOLE AND THE ALTERED CONTENT ASAP.

    This is not a drill. The URL above, which I trust you intended to be
    simply informative, instead completely wedges Firefox and probably is
    trying to do something that would have much nastier consequences in
    the presence of Internet Exploder. This indicates that your webhost
    was compromised and the file contents altered (probably adding a 1x1
    iframe linking to an evil script hosted somewhere else entirely;
    that's what these jokers usually do) to try to exploit browser bugs
    and do something malicious like install spyware on visitors'
    computers.

    If you can patch the server's security yourself do so. If not, change
    hosting provider to someone other than Dreamhost (a guess but likely
    correct; there's been a lot of discussion in certain circles of their
    recent repeated major security breaches, adding exactly these sorts of
    malicious but subtle changes to honest web pages) and from your
    current provider (if different). Then fix or restore all the altered
    files (restoring every single file from a known-good backup is safest
    but may lose recent changes) and put the site back on the air.

    If you do change host, do be sure to tell them exactly, in
    excruciating detail, why you are doing so as well. Maybe they'll
    eventually shape up if they get enough such negative feedback. If you
    host yourself and can't find out how the attack was done and how to
    prevent it happening again, you probably want to change server
    software (if it's IIS then for Christ's sake change it NOW!) and you
    may want to change to professional hosting that knows what they're
    doing security-wise (i.e. not Dreamhost!) ...

    I hope this has been caught and gets fixed before anyone has genuinely
    been burned. Otherwise your excellent Java site's reputation is
    probably irretrievably in the toilet. :(
    Twisted, Jul 27, 2007
    #4
  5. boris

    Lew Guest

    Twisted wrote:
    > On Jul 26, 11:19 am, Roedy Green <>
    > wrote:
    >> for a very elaborate algorithm to validate email address, look at the
    >> code posted athttp://mindprod.com/products1.html#BULK

    >
    > YOUR WEB SERVER HAS BEEN HACKED. TAKE IT OFFLINE AND FIX THE SECURITY
    > HOLE AND THE ALTERED CONTENT ASAP.
    >
    > This is not a drill. The URL above, which I trust you intended to be
    > simply informative, instead completely wedges Firefox and probably is
    > trying to do something that would have much nastier consequences in
    > the presence of Internet Exploder. This indicates that your webhost
    > was compromised and the file contents altered (probably adding a 1x1
    > iframe linking to an evil script hosted somewhere else entirely;
    > that's what these jokers usually do) to try to exploit browser bugs
    > and do something malicious like install spyware on visitors'
    > computers.


    Works fine for me. Firefox, even. No difficulties whatsoever.

    --
    Lew
    Lew, Jul 27, 2007
    #5
  6. boris

    Twisted Guest

    On Jul 27, 7:48 am, Lew <> wrote:
    > Works fine for me. Firefox, even. No difficulties whatsoever.


    So he fixed it in at most an hour -- good. Still alarming that this
    happened. I've run into malicious iframes myself once or twice before
    but without such a drastic consequence. This time, click a link and
    boom! Dead browser, ctrl-alt-del end-task, and God knows what the
    buggy page content was trying to do probably under the faulty
    assumption that the user-agent was IE.
    Twisted, Jul 27, 2007
    #6
  7. Lew <> wrote:

    > Twisted wrote:


    > > On Jul 26, 11:19 am, Roedy Green <>
    > > wrote:
    > >> http://mindprod.com/products1.html#BULK


    > > This is not a drill. The URL above, which I trust you intended to be
    > > simply informative, instead completely wedges Firefox


    What, just because a page toasts Firefox it's indicative of some kind
    of security flaw? *shrug* Firefox may not be M$ crap, but it's got
    bugs. If it's tripping your antivirus, of course, that's a different
    story. Looking at the page source, however, I see no <iframe> tags at
    all, nor any particularly unsavory-looking script, nor does Firefox so
    much as blink. I would not be so quick to don the tin-foil hat in the
    absence of more convincing evidence.

    --
    C. Benson Manica | I appreciate all corrections, polite or otherwise.
    cbmanica(at)gmail.com |
    ----------------------| I do not currently read any posts posted through
    sdf.lonestar.org | Google groups, due to rampant unchecked spam.
    Christopher Benson-Manica, Jul 27, 2007
    #7
  8. boris

    Twisted Guest

    On Jul 27, 5:02 pm, Christopher Benson-Manica
    <> wrote:
    > Lew <> wrote:
    > > Twisted wrote:
    > > > On Jul 26, 11:19 am, Roedy Green <>
    > > > wrote:
    > > >>http://mindprod.com/products1.html#BULK
    > > > This is not a drill. The URL above, which I trust you intended to be
    > > > simply informative, instead completely wedges Firefox

    >
    > What, just because a page toasts Firefox it's indicative of some kind
    > of security flaw?


    That's a denial-of-service attack, even assuming it wasn't an attempt
    at something worse.

    > *shrug* Firefox may not be M$ crap, but it's got bugs.


    Evidently. And trying to exploit them, as the defaced site code
    evidently did, is still an attack even if they aren't M$ bugs.

    Most likely the evil script someone snuck in there tried to do
    something that would have compromised a sufficiently out of date IE
    and, being malformed in some way in order to exploit that bug, also
    tripped a less severe bug in Firefox.

    > Looking at the page source, however, I see no <iframe> tags at
    > all, nor any particularly unsavory-looking script, nor does Firefox so
    > much as blink.


    That's because it was fixed (indeed, within 1 hour of my reporting
    it). Nonetheless that page did crash Firefox and no longer does,
    meaning something on that page changed. I find it highly unlikely that
    someone of Roedy's reputation constructed the page to crash Firefox in
    the first place, which suggests it actually changed to do so and then
    changed BACK. The first change would be a defacement perpetrated by
    someone else not authorized by Roedy to alter his Web site's code and
    the second would be Roedy undoing the damage after receiving a heads-
    up.

    Unless you have an alternative theory to explain it? (Other than that
    I'm simply making this up, a theory that I know to be false even if I
    can't prove it to anyone else -- since the browser hung as soon as it
    tried to load the page I had no way of getting a look at the page
    source until it was fixed, whereupon obviously there'd be nothing
    relevant to see in said source anymore, so I don't have and could
    never have had a copy of the source with the malicious edit still
    intact. And I was sure as *hell* not going to try to access it in IE
    to get a look at the source! Maybe I should have tried viewing it in
    FF with JS disabled but it didn't occur to me until it was too late
    and the page had been fixed.)
    Twisted, Jul 28, 2007
    #8
  9. Twisted wrote:
    > since the browser hung as soon as it tried to load the page I had no
    > way of getting a look at the page source until it was fixed,


    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLConnection;

    public class Wget {
    public static void main(String[] args) throws Exception {
    URL url = new URL("http://mindprod.com/products1.html#BULK");
    URLConnection connection = url.openConnection();
    HttpURLConnection httpConn = (HttpURLConnection) connection;
    InputStreamReader isr =
    new InputStreamReader(httpConn.getInputStream());
    BufferedReader in = new BufferedReader(isr);
    String inputLine;
    while ((inputLine = in.readLine()) != null)
    System.out.println(inputLine);
    in.close();
    }
    }
    RedGrittyBrick, Jul 28, 2007
    #9
  10. boris

    Guest

    ping Roedy -- mildly curious (was Re: help me with a program)

    In article <>,
    Lew <> wrote:
    > Twisted wrote:
    > > On Jul 26, 11:19 am, Roedy Green <>
    > > wrote:
    > >> for a very elaborate algorithm to validate email address, look at the
    > >> code posted athttp://mindprod.com/products1.html#BULK

    > >
    > > YOUR WEB SERVER HAS BEEN HACKED. TAKE IT OFFLINE AND FIX THE SECURITY
    > > HOLE AND THE ALTERED CONTENT ASAP.
    > >
    > > This is not a drill. The URL above, which I trust you intended to be
    > > simply informative, instead completely wedges Firefox and probably is
    > > trying to do something that would have much nastier consequences in
    > > the presence of Internet Exploder. This indicates that your webhost
    > > was compromised and the file contents altered (probably adding a 1x1
    > > iframe linking to an evil script hosted somewhere else entirely;
    > > that's what these jokers usually do) to try to exploit browser bugs
    > > and do something malicious like install spyware on visitors'
    > > computers.

    >
    > Works fine for me. Firefox, even. No difficulties whatsoever.
    >


    Was there ever any public confirmation that the above-mentioned
    Web page was maliciously changed, and then fixed? As the revised
    subject line indicates, I'm mildly curious ....

    --
    B. L. Massingill
    ObDisclaimer: I don't speak for my employers; they return the favor.
    , Aug 4, 2007
    #10
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. pipi
    Replies:
    1
    Views:
    607
    Joseph Millar
    Jul 21, 2003
  2. Rey
    Replies:
    4
    Views:
    10,904
    Roedy Green
    Dec 12, 2003
  3. ola
    Replies:
    3
    Views:
    698
    Marco Schmidt
    Feb 16, 2004
  4. Replies:
    1
    Views:
    457
    Walter Roberson
    Aug 12, 2005
  5. Kris Stark
    Replies:
    1
    Views:
    87
    John Bokma
    Sep 8, 2005
Loading...

Share This Page