Class CardHolder

java.lang.Object
org.jpos.core.CardHolder
All Implemented Interfaces:
Serializable, Cloneable, Loggeable

public class CardHolder extends Object implements Cloneable, Serializable, Loggeable
This class is called 'CardHolder', but a better name could have been 'Card' At some point we'll deprecate this one and create a new 'Card' class.
Since:
jPOS 1.1
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • parseTrack2

      public void parseTrack2(String s) throws InvalidCardException
      extract pan/exp/trailler from track2
      Parameters:
      s - a valid track2
      Throws:
      InvalidCardException - if card data is invalid
    • setTrack1

      public void setTrack1(String track1)
      Sets the track1 data.
      Parameters:
      track1 - card's track1
    • getTrack1

      public String getTrack1()
      Returns the track 1 raw data.
      Returns:
      the track1 string, or null
    • hasTrack1

      public boolean hasTrack1()
      Returns true if track1 data is present.
      Returns:
      true if we have a track1
    • getNameOnCard

      Returns the cardholder name from track1.
      Returns:
      the Name written on the card (from track1)
    • getTrack2

      public String getTrack2()
      Returns a reconstructed track 2 string, or null if track 2 data is absent.
      Returns:
      reconstructed track2 or null
    • hasTrack2

      public boolean hasTrack2()
      Returns true if track2 data is (potentially) present.
      Returns:
      true if we have a (may be valid) track2
    • setSecurityCode

      public void setSecurityCode(String securityCode)
      assigns securityCode to this CardHolder object
      Parameters:
      securityCode - Card's security code
    • getSecurityCode

      Returns the card security code (CVV/CVC), or null.
      Returns:
      securityCode (or null)
    • hasSecurityCode

      public boolean hasSecurityCode()
      Returns true if a security code is present.
      Returns:
      true if we have a security code
    • getTrailler

      Deprecated.
      use getTrailer()
      Returns:
      trailer (may be null)
    • setTrailler

      @Deprecated public void setTrailler(String trailer)
      Deprecated.
      use setTrailer
      Set Card's trailer
      Parameters:
      trailer - Card's trailer
    • getTrailer

      public String getTrailer()
      Returns the card trailer string.
      Returns:
      card trailer
    • setTrailer

      public void setTrailer(String trailer)
      Sets the card trailer string.
      Parameters:
      trailer - card trailer
    • setPAN

      public void setPAN(String pan) throws InvalidCardException
      Sets Primary Account Number
      Parameters:
      pan - Primary Account NUmber
      Throws:
      InvalidCardException - if the PAN is too short or fails validation
    • getPAN

      public String getPAN()
      Returns the Primary Account Number.
      Returns:
      Primary Account Number
    • getBIN

      public String getBIN(int len)
      Returns the first len digits of the PAN (the BIN).
      Parameters:
      len - number of BIN digits to return
      Returns:
      the BIN prefix
    • getBIN

      public String getBIN()
      Get the traditional 6-digit BIN (Bank Issuer Number) from the PAN
      Returns:
      6-digit bank issuer number
    • setEXP

      public void setEXP(String exp) throws InvalidCardException
      Set Expiration Date
      Parameters:
      exp - card expiration date
      Throws:
      InvalidCardException - if card data is invalid
    • getEXP

      public String getEXP()
      Get Expiration Date
      Returns:
      card expiration date
    • isExpired

      public boolean isExpired()
      Y2K compliant expiration check
      Returns:
      true if card is expired (or expiration is invalid)
    • isExpired

      public boolean isExpired(Date currentDate)
      Y2K compliant expiration check
      Parameters:
      currentDate - current system's date
      Returns:
      true if card is expired (or expiration is invalid)
    • isValidCRC

      public boolean isValidCRC()
      Returns true if the PAN passes the Luhn (mod-10) check.
      Returns:
      true if the Luhn check passes
    • isValidCRC

      public static boolean isValidCRC(String p)
      Returns true if the given PAN passes the Luhn (mod-10) check.
      Parameters:
      p - the PAN to validate
      Returns:
      true if the Luhn check passes
    • dump

      public void dump(PrintStream p, String indent)
      dumps CardHolder basic information
      by default we do not dump neither track1/2 nor securityCode for security reasons.
      Specified by:
      dump in interface Loggeable
      Parameters:
      p - a PrintStream usually suplied by Logger
      indent - ditto
      See Also:
    • getServiceCode

      Returns the service code from track2, or three blanks if not available.
      Returns:
      ServiceCode (if available) or a String with three blanks
    • seemsManualEntry

      public boolean seemsManualEntry()
      Returns true if this card appears to have been entered manually.
      Returns:
      true if manual entry is suspected
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object