code: private ParsedPermission parsePermission() throws Exception {
          ParsedPermission permission = new ParsedPermission();
          lookahead = st.nextToken();
          if (lookahead == StreamTokenizer.TT_WORD) {
              permission.setPermissionType(st.sval);
          } else {
              throw new Exception("ER021: Permission type expected.");
          }
  
          lookahead = st.nextToken();
          if (lookahead == '\"') {
              permission.setPermissionName(st.sval);
          } else {
              // java.security.AllPermission possibility
              if (lookahead == ';') {
                  return permission;
              }
              throw new Exception("ER022: Permission name or or [;] expected.");
          }
  
          lookahead = st.nextToken();
          if (lookahead == ',') {
              lookahead = st.nextToken();
              boolean shouldBeSigned = false;
  
              if (lookahead == '\"') {
                  String actionsWords = st.sval;
                  permission.setActions(actionsWords);
  
                  lookahead = st.nextToken();
                  switch (lookahead) {
                      case ',':
                          shouldBeSigned = true;
                          break;
                      case ';':
                          return permission;
                      default:
                          throw new Exception("ER023: Unexpected symbol, expected [,] or [;].");
                  }
                  lookahead = st.nextToken();
              }
  
              if (lookahead == StreamTokenizer.TT_WORD) {
                  String signedByWord = st.sval;
                  if (!signedByWord.toLowerCase().equals("signedby")) {
                      throw new Exception("ER024: [signedBy] expected but was [" + signedByWord + "].");
                  }
              } else if (shouldBeSigned) {
                  throw new Exception("ER025: [signedBy] expected after [,].");
              } else {
                  throw new Exception("ER026: Actions or [signedBy] expected after [,].");
              }
              lookahead = st.nextToken();
              if (lookahead == '\"') {
                  permission.setSignedBy(st.sval);
              } else {
                  throw new Exception("ER027: signedBy attribute expected.");
              }
              lookahead = st.nextToken();
          }
  
          if (lookahead == ';') {
              return permission;
          } else {
              throw new Exception("ER028: [;] expected.");
          }
  
      }
docs: Private method for parsing permission part of policy entry.
  
  @return parsed permission part of policy entry
  @throws throws Exception when any problem occurred during parsing permission