jdk/src/java.smartcardio/share/classes/javax/smartcardio/CardPermission.java
changeset 26219 1a19360ff122
parent 25859 3317bb8137f4
child 40266 d198987d85e1
equal deleted inserted replaced
26218:98453f165e21 26219:1a19360ff122
     1 /*
     1 /*
     2  * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    24  */
    24  */
    25 
    25 
    26 package javax.smartcardio;
    26 package javax.smartcardio;
    27 
    27 
    28 import java.io.*;
    28 import java.io.*;
    29 
    29 import java.util.StringJoiner;
    30 import java.security.Permission;
    30 import java.security.Permission;
    31 
    31 
    32 /**
    32 /**
    33  * A permission for Smart Card operations. A CardPermission consists of the
    33  * A permission for Smart Card operations. A CardPermission consists of the
    34  * name of the card terminal the permission applies to and a set of actions
    34  * name of the card terminal the permission applies to and a set of actions
   178 
   178 
   179     private static String getActions(int mask) {
   179     private static String getActions(int mask) {
   180         if (mask == A_ALL) {
   180         if (mask == A_ALL) {
   181             return S_ALL;
   181             return S_ALL;
   182         }
   182         }
   183         boolean first = true;
   183         StringJoiner sj = new StringJoiner(",");
   184         StringBuilder sb = new StringBuilder();
       
   185         for (int i = 0; i < ARRAY_MASKS.length; i++) {
   184         for (int i = 0; i < ARRAY_MASKS.length; i++) {
   186             int action = ARRAY_MASKS[i];
   185             final int action = ARRAY_MASKS[i];
   187             if ((mask & action) == action) {
   186             if ((mask & action) == action) {
   188                 if (first == false) {
   187                 sj.add(ARRAY_STRINGS[i]);
   189                     sb.append(",");
       
   190                 } else {
       
   191                     first = false;
       
   192                 }
       
   193                 sb.append(ARRAY_STRINGS[i]);
       
   194             }
   188             }
   195         }
   189         }
   196         return sb.toString();
   190         return sj.toString();
   197     }
   191     }
   198 
   192 
   199 
   193 
   200     /**
   194     /**
   201      * Returns the canonical string representation of the actions.
   195      * Returns the canonical string representation of the actions.