Package org.jasen.interfaces

Examples of org.jasen.interfaces.ReceivedHeaderParserData


   * @throws UnknownHostException
   * @throws DNSException
   */
  public static boolean verifySenderAddress(DNSResolver dresolver, InetAddressResolver iresolver, ReceivedHeaderParser parser, String receivedHeaderLine, String senderAddress) throws JasenParseException, UnknownHostException, DNSException {

    ReceivedHeaderParserData data = parser.parse(receivedHeaderLine, iresolver);
   
    if(data == null) {
        throw new JasenParseException("Unable to parse header.", ParseErrorType.PARSE_ERROR);
    }

    // Use the InetAddress cache
    InetAddress receiverAddress = iresolver.getByName(data.getSenderIPAddress());
    String senderDomain = getDomainFromAddress(senderAddress);

    String receiverDomain = receiverAddress.getHostName();

    // Get the MX records for the sender domain
    MXRecord[] senderMXRecords = DNSUtils.getMXRecords(dresolver, senderDomain);

    if (senderMXRecords != null && senderMXRecords.length > 0) {

      // Get the root domain for both the receiver and sender
      if (!DNSUtils.isIPv4Address(receiverDomain)) {

        String senderRootDomain = DNSUtils.getRootDomain(data.getSenderHostName());
        String receiverRootDomain = DNSUtils.getRootDomain(receiverDomain);

        if (receiverRootDomain.equalsIgnoreCase(senderRootDomain)) {

          // Get the MX records for the receiver domain
          MXRecord[] receiverMXRecords = DNSUtils.getMXRecords(dresolver, receiverRootDomain);

          // The sender address is valid if one IP matches
          MXRecord senderMX = null;
          MXRecord receiverMX = null;

          if (senderMXRecords != null && senderMXRecords.length > 0) {
            if (receiverMXRecords != null && receiverMXRecords.length > 0) {
              for (int i = 0; i < senderMXRecords.length; i++) {
                senderMX = senderMXRecords[i];

                for (int j = 0; j < receiverMXRecords.length; j++) {
                  receiverMX = receiverMXRecords[j];

                  if (senderMX.getAddress().getHostAddress().equalsIgnoreCase(receiverMX.getAddress().getHostAddress())) {
                    return true;
                  }
                }
              }
            }
            else {
              return false;
            }
          }
          else {
            return false;
          }
        }
        else {
          // The IP does not match the host.  This may be a forgery but we will still test the MX
          // records against the IP address
          String mtaIPAddress = data.getSenderIPAddress();
          for (int i = 0; i < senderMXRecords.length; i++) {
            if (senderMXRecords[i].getAddress().getHostAddress().equals(mtaIPAddress)) {
              return true;
            }
          }
View Full Code Here


          boolean hostNameIsIP = false;

          String header = headers[0];

          // Parse the header
          ReceivedHeaderParserData data = null;
         
          try {
                data = parser.parse(header,resolver);
               
                if(data != null) {
//                  Get the IPAddress of the sending server
                String senderIP = data.getSenderIPAddress();

                // Get the reported hostname
                String senderHost = data.getSenderHostName();

                // If the sender host is an IP address, but not the same as the "actual"
                // IP, we have a forgery
                hostNameIsIP = DNSUtils.isIPAddress(senderHost);
View Full Code Here

   * @see org.jasen.interfaces.JasenPlugin#test(org.jasen.core.Jasen, javax.mail.internet.MimeMessage, org.jasen.interfaces.JasenMessage, org.jasen.interfaces.ParserData, org.jasen.interfaces.ReceivedHeaderParser)
   */
  public JasenTestResult test(Jasen engine, MimeMessage rawMessage,JasenMessage parsedMessage, ParserData data,ReceivedHeaderParser parser) throws JasenException {

      String[] headers;
      ReceivedHeaderParserData pdata = null;
      float fResult = unknown;
      boolean isAbsolute = false;
     
      ProbabilityTestResult result = new ProbabilityTestResult();
     
View Full Code Here

TOP

Related Classes of org.jasen.interfaces.ReceivedHeaderParserData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.