src/java.base/share/classes/javax/crypto/CryptoPermission.java

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


 352     }
 353 
 354     /**
 355      * Returns the AlgorithmParameterSpec
 356      * associated with this CryptoPermission
 357      * object.
 358      */
 359     final AlgorithmParameterSpec getAlgorithmParameterSpec() {
 360         return algParamSpec;
 361     }
 362 
 363     /**
 364      * Returns a string describing this CryptoPermission.  The convention is to
 365      * specify the class name, the algorithm name, the maximum allowable
 366      * key size, and the name of the exemption mechanism, in the following
 367      * format: '("ClassName" "algorithm" "keysize" "exemption_mechanism")'.
 368      *
 369      * @return information about this CryptoPermission.
 370      */
 371     public String toString() {
 372         StringBuilder buf = new StringBuilder(100);
 373         buf.append("(CryptoPermission " + alg + " " + maxKeySize);

 374         if (algParamSpec != null) {
 375             if (algParamSpec instanceof RC2ParameterSpec) {
 376                 buf.append(" , effective " +
 377                     ((RC2ParameterSpec)algParamSpec).getEffectiveKeyBits());

 378             } else if (algParamSpec instanceof RC5ParameterSpec) {
 379                 buf.append(" , rounds " +
 380                     ((RC5ParameterSpec)algParamSpec).getRounds());
 381             }
 382         }
 383         if (exemptionMechanism != null) { // OPTIONAL
 384             buf.append(" " + exemptionMechanism);
 385         }
 386         buf.append(")");
 387         return buf.toString();
 388     }
 389 
 390     private boolean impliesExemptionMechanism(String exemptionMechanism) {
 391         if (this.exemptionMechanism == null) {
 392             return true;
 393         }
 394 
 395         if (exemptionMechanism == null) {
 396             return false;
 397         }
 398 
 399         if (this.exemptionMechanism.equals(exemptionMechanism)) {
 400             return true;
 401         }
 402 
 403         return false;
 404     }
 405 
 406     private boolean impliesParameterSpec(boolean checkParam,
 407                                          AlgorithmParameterSpec algParamSpec) {




 352     }
 353 
 354     /**
 355      * Returns the AlgorithmParameterSpec
 356      * associated with this CryptoPermission
 357      * object.
 358      */
 359     final AlgorithmParameterSpec getAlgorithmParameterSpec() {
 360         return algParamSpec;
 361     }
 362 
 363     /**
 364      * Returns a string describing this CryptoPermission.  The convention is to
 365      * specify the class name, the algorithm name, the maximum allowable
 366      * key size, and the name of the exemption mechanism, in the following
 367      * format: '("ClassName" "algorithm" "keysize" "exemption_mechanism")'.
 368      *
 369      * @return information about this CryptoPermission.
 370      */
 371     public String toString() {
 372         StringBuilder sb = new StringBuilder(100);
 373         sb.append("(CryptoPermission ").append(alg).append(' ')
 374                 .append(maxKeySize);
 375         if (algParamSpec != null) {
 376             if (algParamSpec instanceof RC2ParameterSpec) {
 377                 sb.append(" , effective ")
 378                         .append(((RC2ParameterSpec) algParamSpec)
 379                                 .getEffectiveKeyBits());
 380             } else if (algParamSpec instanceof RC5ParameterSpec) {
 381                 sb.append(" , rounds ").append(
 382                         ((RC5ParameterSpec) algParamSpec).getRounds());
 383             }
 384         }
 385         if (exemptionMechanism != null) { // OPTIONAL
 386             sb.append(' ').append(exemptionMechanism);
 387         }
 388         sb.append(')');
 389         return sb.toString();
 390     }
 391 
 392     private boolean impliesExemptionMechanism(String exemptionMechanism) {
 393         if (this.exemptionMechanism == null) {
 394             return true;
 395         }
 396 
 397         if (exemptionMechanism == null) {
 398             return false;
 399         }
 400 
 401         if (this.exemptionMechanism.equals(exemptionMechanism)) {
 402             return true;
 403         }
 404 
 405         return false;
 406     }
 407 
 408     private boolean impliesParameterSpec(boolean checkParam,
 409                                          AlgorithmParameterSpec algParamSpec) {