< prev index next >

src/java.base/share/classes/sun/security/x509/RFC822Name.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  62      * @throws IOException on invalid input name
  63      */
  64     public RFC822Name(String name) throws IOException {
  65         parseName(name);
  66         this.name = name;
  67     }
  68 
  69     /**
  70      * Parse an RFC822Name string to see if it is a valid
  71      * addr-spec according to IETF RFC822 and RFC2459:
  72      * [local-part@]domain
  73      * <p>
  74      * local-part@ could be empty for an RFC822Name NameConstraint,
  75      * but the domain at least must be non-empty.  Case is not
  76      * significant.
  77      *
  78      * @param name the RFC822Name string
  79      * @throws IOException if name is not valid
  80      */
  81     public void parseName(String name) throws IOException {
  82         if (name == null || name.length() == 0) {
  83             throw new IOException("RFC822Name may not be null or empty");
  84         }
  85         // See if domain is a valid domain name
  86         String domain = name.substring(name.indexOf('@')+1);
  87         if (domain.length() == 0) {
  88             throw new IOException("RFC822Name may not end with @");
  89         } else {
  90             //An RFC822 NameConstraint could start with a ., although
  91             //a DNSName may not
  92             if (domain.startsWith(".")) {
  93                 if (domain.length() == 1)
  94                     throw new IOException("RFC822Name domain may not be just .");
  95             }
  96         }
  97     }
  98 
  99     /**
 100      * Return the type of the GeneralName.
 101      */
 102     public int getType() {
 103         return (GeneralNameInterface.NAME_RFC822);
 104     }
 105 
 106     /**
 107      * Return the actual name value of the GeneralName.




  62      * @throws IOException on invalid input name
  63      */
  64     public RFC822Name(String name) throws IOException {
  65         parseName(name);
  66         this.name = name;
  67     }
  68 
  69     /**
  70      * Parse an RFC822Name string to see if it is a valid
  71      * addr-spec according to IETF RFC822 and RFC2459:
  72      * [local-part@]domain
  73      * <p>
  74      * local-part@ could be empty for an RFC822Name NameConstraint,
  75      * but the domain at least must be non-empty.  Case is not
  76      * significant.
  77      *
  78      * @param name the RFC822Name string
  79      * @throws IOException if name is not valid
  80      */
  81     public void parseName(String name) throws IOException {
  82         if (name == null || name.isEmpty()) {
  83             throw new IOException("RFC822Name may not be null or empty");
  84         }
  85         // See if domain is a valid domain name
  86         String domain = name.substring(name.indexOf('@')+1);
  87         if (domain.isEmpty()) {
  88             throw new IOException("RFC822Name may not end with @");
  89         } else {
  90             //An RFC822 NameConstraint could start with a ., although
  91             //a DNSName may not
  92             if (domain.startsWith(".")) {
  93                 if (domain.length() == 1)
  94                     throw new IOException("RFC822Name domain may not be just .");
  95             }
  96         }
  97     }
  98 
  99     /**
 100      * Return the type of the GeneralName.
 101      */
 102     public int getType() {
 103         return (GeneralNameInterface.NAME_RFC822);
 104     }
 105 
 106     /**
 107      * Return the actual name value of the GeneralName.


< prev index next >