Hi Stefano, by my understanding the mailserver should take care about valid format of the given data. So I think throwing the IllegalArgumentException is the best we can do.
bye Norman Am Samstag, den 23.02.2008, 13:55 +0100 schrieb Stefano Bagnara: > Norman Maurer ha scritto: > > What you guy think should we maybe use a checked exception ? > > As far as I can tell the SPF check MUST return one of the return codes > defined by the RFC, so PermErrorException or NoneException seems to be > the best answer.. but I have to reread the SPF RFC to see if they > specify what to do with malformed email addresses. > > We should leave all the None/PermError that was there before this change > and simply catch the NPE reported by the user and rethrow a > None/PermError (depending on the RFC). > > Stefano > > > Cheers > > Norman > > > > Am Freitag, den 22.02.2008, 14:17 +0000 schrieb [EMAIL PROTECTED]: > >> Author: norman > >> Date: Fri Feb 22 06:17:19 2008 > >> New Revision: 630214 > >> > >> URL: http://svn.apache.org/viewvc?rev=630214&view=rev > >> Log: > >> Throw IllegalArgumentException on invalid data given for SPFSession. See > >> JSPF-60 > >> > >> Modified: > >> > >> james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPFSession.java > >> james/jspf/trunk/src/main/java/org/apache/james/jspf/impl/SPF.java > >> > >> Modified: > >> james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPFSession.java > >> URL: > >> http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPFSession.java?rev=630214&r1=630213&r2=630214&view=diff > >> ============================================================================== > >> --- > >> james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPFSession.java > >> (original) > >> +++ > >> james/jspf/trunk/src/main/java/org/apache/james/jspf/core/SPFSession.java > >> Fri Feb 22 06:17:19 2008 > >> @@ -86,23 +86,22 @@ > >> * The helo provided by the sender > >> * @param clientIP > >> * The ipaddress of the client > >> - * @throws PermErrorException > >> + * @throws IllegalArgumentException > >> * Get thrown if invalid data get passed > >> - * @throws NoneException > >> - * Get thrown if no valid emailaddress get passed > >> + * > >> */ > >> - public SPFSession(String mailFrom, String heloDomain, String > >> clientIP) throws PermErrorException, NoneException { > >> + public SPFSession(String mailFrom, String heloDomain, String > >> clientIP) { > >> super(); > >> this.mailFrom = mailFrom.trim(); > >> this.hostName = heloDomain.trim(); > >> - this.ipAddress = IPAddr.getProperIpAddress(clientIP.trim()); > >> - > >> + > >> try { > >> + this.ipAddress = IPAddr.getProperIpAddress(clientIP.trim()); > >> // get the in Address > >> this.inAddress = IPAddr.getInAddress(clientIP); > >> } catch (PermErrorException e) { > >> // throw an exception cause the ip was not rfc conform > >> - throw new PermErrorException(e.getMessage()); > >> + throw new IllegalArgumentException(e.getMessage()); > >> } > >> > >> // setup the data! > >> @@ -119,7 +118,7 @@ > >> * @throws NoneException > >> * Get thrown if an invalid emailaddress get passed > >> */ > >> - private void setupData(String mailFrom, String helo) throws > >> NoneException { > >> + private void setupData(String mailFrom, String helo) { > >> > >> // if nullsender is used [EMAIL PROTECTED] will be used as email > >> if (mailFrom.equals("")) { > >> @@ -131,7 +130,7 @@ > >> > >> // should never be bigger as 2 ! > >> if (fromParts.length > 2) { > >> - throw new NoneException("Not a valid email address " + > >> mailFrom); > >> + throw new IllegalArgumentException("Not a valid email > >> address " + mailFrom); > >> } else if (fromParts.length == 2) { > >> this.currentSenderPart = fromParts[0]; > >> this.senderDomain = fromParts[1]; > >> > >> Modified: > >> james/jspf/trunk/src/main/java/org/apache/james/jspf/impl/SPF.java > >> URL: > >> http://svn.apache.org/viewvc/james/jspf/trunk/src/main/java/org/apache/james/jspf/impl/SPF.java?rev=630214&r1=630213&r2=630214&view=diff > >> ============================================================================== > >> --- james/jspf/trunk/src/main/java/org/apache/james/jspf/impl/SPF.java > >> (original) > >> +++ james/jspf/trunk/src/main/java/org/apache/james/jspf/impl/SPF.java Fri > >> Feb 22 06:17:19 2008 > >> @@ -313,13 +313,8 @@ > >> SPFSession spfData = null; > >> > >> // Setup the data > >> - try { > >> - spfData = new SPFSession(mailFrom, hostName, ipAddress); > >> - } catch (PermErrorException e1) { > >> - spfData.setCurrentResultExpanded(e1.getResult()); > >> - } catch (NoneException e1) { > >> - spfData.setCurrentResultExpanded(e1.getResult()); > >> - } > >> + spfData = new SPFSession(mailFrom, hostName, ipAddress); > >> + > >> > >> SPFChecker resultHandler = new DefaultSPFChecker(); > >> > >> > >> > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: [EMAIL PROTECTED] > >> For additional commands, e-mail: [EMAIL PROTECTED] > >> > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: [EMAIL PROTECTED] > > For additional commands, e-mail: [EMAIL PROTECTED] > > > > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
