src/java.base/share/classes/com/sun/crypto/provider/DHPublicKey.java

Print this page
rev 10552 : 8055723[core]: Replace concat String to append in StringBuilder parameters
Contributed-by: Otavio Santana <otaviojava@java.net>


 243     public BigInteger getY() {
 244         return this.y;
 245     }
 246 
 247     /**
 248      * Returns the key parameters.
 249      *
 250      * @return the key parameters
 251      */
 252     public DHParameterSpec getParams() {
 253         if (this.l != 0) {
 254             return new DHParameterSpec(this.p, this.g, this.l);
 255         } else {
 256             return new DHParameterSpec(this.p, this.g);
 257         }
 258     }
 259 
 260     public String toString() {
 261         String LINE_SEP = System.getProperty("line.separator");
 262 
 263         StringBuilder sb
 264             = new StringBuilder("SunJCE Diffie-Hellman Public Key:"
 265                                + LINE_SEP + "y:" + LINE_SEP
 266                                + Debug.toHexString(this.y)
 267                                + LINE_SEP + "p:" + LINE_SEP
 268                                + Debug.toHexString(this.p)
 269                                + LINE_SEP + "g:" + LINE_SEP
 270                                + Debug.toHexString(this.g));
 271         if (this.l != 0)
 272             sb.append(LINE_SEP + "l:" + LINE_SEP + "    " + this.l);


 273         return sb.toString();
 274     }
 275 
 276     private void parseKeyBits() throws InvalidKeyException {
 277         try {
 278             DerInputStream in = new DerInputStream(this.key);
 279             this.y = in.getBigInteger();
 280         } catch (IOException e) {
 281             throw new InvalidKeyException(
 282                 "Error parsing key encoding: " + e.toString());
 283         }
 284     }
 285 
 286     /**
 287      * Calculates a hash code value for the object.
 288      * Objects that are equal will also have the same hashcode.
 289      */
 290     public int hashCode() {
 291         return Objects.hash(y, p, g);
 292     }




 243     public BigInteger getY() {
 244         return this.y;
 245     }
 246 
 247     /**
 248      * Returns the key parameters.
 249      *
 250      * @return the key parameters
 251      */
 252     public DHParameterSpec getParams() {
 253         if (this.l != 0) {
 254             return new DHParameterSpec(this.p, this.g, this.l);
 255         } else {
 256             return new DHParameterSpec(this.p, this.g);
 257         }
 258     }
 259 
 260     public String toString() {
 261         String LINE_SEP = System.getProperty("line.separator");
 262 
 263         StringBuilder sb = new StringBuilder();
 264         sb.append("SunJCE Diffie-Hellman Public Key:").append(LINE_SEP)
 265                 .append("y:").append(LINE_SEP)
 266                 .append(Debug.toHexString(this.y)).append(LINE_SEP)
 267                 .append("p:").append(LINE_SEP)
 268                 .append(Debug.toHexString(this.p))
 269                 .append(LINE_SEP).append("g:").append(LINE_SEP)
 270                 .append(Debug.toHexString(this.g));
 271         if (this.l != 0) {
 272             sb.append(LINE_SEP).append("l:").append(LINE_SEP).append("    ")
 273                     .append(this.l);
 274         }
 275         return sb.toString();
 276     }
 277 
 278     private void parseKeyBits() throws InvalidKeyException {
 279         try {
 280             DerInputStream in = new DerInputStream(this.key);
 281             this.y = in.getBigInteger();
 282         } catch (IOException e) {
 283             throw new InvalidKeyException(
 284                 "Error parsing key encoding: " + e.toString());
 285         }
 286     }
 287 
 288     /**
 289      * Calculates a hash code value for the object.
 290      * Objects that are equal will also have the same hashcode.
 291      */
 292     public int hashCode() {
 293         return Objects.hash(y, p, g);
 294     }