001/**
002 * Licensed to the Apache Software Foundation (ASF) under one
003 * or more contributor license agreements.  See the NOTICE file
004 * distributed with this work for additional information
005 * regarding copyright ownership.  The ASF licenses this file
006 * to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance
008 * with the License.  You may obtain a copy of the License at
009 *
010 *      http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software
013 * distributed under the License is distributed on an "AS IS" BASIS,
014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 * See the License for the specific language governing permissions and
016 * limitations under the License.
017 */
018
019package org.apache.oozie.service;
020
021import java.io.BufferedReader;
022import java.io.File;
023import java.io.FileInputStream;
024import java.io.FileNotFoundException;
025import java.io.IOException;
026import java.io.InputStreamReader;
027import java.net.URI;
028import java.nio.charset.StandardCharsets;
029import java.util.HashSet;
030import java.util.List;
031import java.util.Map;
032import java.util.ArrayList;
033import java.util.Set;
034import java.util.LinkedHashSet;
035import com.google.common.collect.Sets;
036import org.apache.commons.io.FilenameUtils;
037import org.apache.commons.lang.StringUtils;
038import org.apache.hadoop.conf.Configuration;
039import org.apache.hadoop.fs.FileSystem;
040import org.apache.hadoop.fs.Path;
041import org.apache.hadoop.security.AccessControlException;
042import org.apache.oozie.BundleJobBean;
043import org.apache.oozie.CoordinatorJobBean;
044import org.apache.oozie.ErrorCode;
045import org.apache.oozie.WorkflowJobBean;
046import org.apache.oozie.client.XOozieClient;
047import org.apache.oozie.executor.jpa.BundleJobGetJPAExecutor;
048import org.apache.oozie.executor.jpa.CoordJobInfoGetJPAExecutor;
049import org.apache.oozie.executor.jpa.BundleJobInfoGetJPAExecutor;
050import org.apache.oozie.executor.jpa.WorkflowsJobGetJPAExecutor;
051import org.apache.oozie.executor.jpa.CoordJobGetJPAExecutor;
052import org.apache.oozie.executor.jpa.JPAExecutorException;
053import org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor;
054import org.apache.oozie.executor.jpa.WorkflowJobQueryExecutor.WorkflowJobQuery;
055import org.apache.oozie.util.ConfigUtils;
056import org.apache.oozie.util.Instrumentation;
057import org.apache.oozie.util.XLog;
058
059/**
060 * The authorization service provides all authorization checks.
061 */
062public class AuthorizationService implements Service {
063
064    public static final String CONF_PREFIX = Service.CONF_PREFIX + "AuthorizationService.";
065
066    /**
067     * Configuration parameter to enable or disable Oozie admin role.
068     */
069    public static final String CONF_SECURITY_ENABLED = CONF_PREFIX + "security.enabled";
070
071    /**
072     * Configuration parameter to enable or disable Oozie admin role.
073     */
074    public static final String CONF_AUTHORIZATION_ENABLED = CONF_PREFIX + "authorization.enabled";
075
076    /**
077     * Configuration parameter to enable old behavior default group as ACL.
078     */
079    public static final String CONF_DEFAULT_GROUP_AS_ACL = CONF_PREFIX + "default.group.as.acl";
080
081    /**
082     * Configuration parameter to define admin groups, if NULL/empty the adminusers.txt file is used.
083     */
084    public static final String CONF_ADMIN_GROUPS = CONF_PREFIX + "admin.groups";
085
086    public static final String CONF_SYSTEM_INFO_AUTHORIZED_USERS = CONF_PREFIX + "system.info.authorized.users";
087
088    /**
089     * Configuration parameter to define admin users in oozie-site.xml.
090     * These admin users shall be added to the admin users found in adminusers.txt
091     */
092    public static final String CONF_ADMIN_USERS = CONF_PREFIX + "admin.users";
093
094    /**
095     * File that contains list of admin users for Oozie.
096     */
097    public static final String ADMIN_USERS_FILE = "adminusers.txt";
098
099    protected static final String INSTRUMENTATION_GROUP = "authorization";
100    protected static final String INSTR_FAILED_AUTH_COUNTER = "authorization.failed";
101
102    private Set<String> adminGroups;
103    private Set<String> adminUsers;
104    private Set<String> sysInfoAuthUsers;
105    private boolean authorizationEnabled;
106    private boolean useDefaultGroupAsAcl;
107    private boolean authorizedSystemInfo = false;
108    private final XLog log = XLog.getLog(getClass());
109    private Instrumentation instrumentation;
110
111    private String[] getTrimmedStrings(String str) {
112        if (null == str || "".equals(str.trim())) {
113            return new String[0];
114        }
115        return str.trim().split("\\s*,\\s*");
116    }
117
118    /**
119     * Initialize the service. <p> Reads the security related configuration. parameters - security enabled and list of
120     * super users.
121     *
122     * @param services services instance.
123     * @throws ServiceException thrown if the service could not be initialized.
124     */
125    public void init(Services services) throws ServiceException {
126        authorizationEnabled =
127            ConfigUtils.getWithDeprecatedCheck(services.getConf(), CONF_AUTHORIZATION_ENABLED,
128                                               CONF_SECURITY_ENABLED, false);
129        String systemInfoAuthUsers = ConfigurationService.get(CONF_SYSTEM_INFO_AUTHORIZED_USERS);
130        if (!StringUtils.isBlank(systemInfoAuthUsers)) {
131            authorizedSystemInfo = true;
132            sysInfoAuthUsers = new HashSet<>();
133            for (String user : getTrimmedStrings(systemInfoAuthUsers)) {
134                sysInfoAuthUsers.add(user);
135            }
136        }
137        if (authorizationEnabled) {
138            log.info("Oozie running with authorization enabled");
139            useDefaultGroupAsAcl = ConfigurationService.getBoolean(CONF_DEFAULT_GROUP_AS_ACL);
140            String[] str = getTrimmedStrings(Services.get().getConf().get(CONF_ADMIN_GROUPS));
141            if (str.length > 0) {
142                log.info("Admin users will be checked against the defined admin groups");
143                adminGroups = new HashSet<String>();
144                for (String s : str) {
145                    adminGroups.add(s.trim());
146                }
147            }
148            else {
149                log.info("Admin users will be checked against the 'adminusers.txt' file contents");
150                adminUsers = new HashSet<String>();
151                loadAdminUsersFromFile();
152                loadAdminUsersFromConfiguration();
153            }
154        }
155        else {
156            log.warn("Oozie running with authorization disabled");
157        }
158        instrumentation = Services.get().get(InstrumentationService.class).get();
159    }
160
161    /**
162     * Return if security is enabled or not.
163     *
164     * @return if security is enabled or not.
165     */
166    @Deprecated
167    public boolean isSecurityEnabled() {
168        return authorizationEnabled;
169    }
170
171    public boolean useDefaultGroupAsAcl() {
172        return useDefaultGroupAsAcl;
173    }
174
175    /**
176     * Return if security is enabled or not.
177     *
178     * @return if security is enabled or not.
179     */
180    public boolean isAuthorizationEnabled() {
181        return isSecurityEnabled();
182    }
183
184    /**
185     * Load the list of admin users from {@link AuthorizationService#ADMIN_USERS_FILE} </p>
186     *
187     * @throws ServiceException if the admin user list could not be loaded.
188     */
189    private void loadAdminUsersFromFile() throws ServiceException {
190        String configDir = Services.get().get(ConfigurationService.class).getConfigDir();
191        if (configDir != null) {
192            File file = new File(FilenameUtils.getFullPath(configDir)+FilenameUtils.getBaseName(configDir),
193                    FilenameUtils.getName(ADMIN_USERS_FILE));
194            if (file.exists()) {
195                try {
196                    BufferedReader br = new BufferedReader(
197                            new InputStreamReader(new FileInputStream(file), StandardCharsets.UTF_8));
198                    try {
199                        String line = br.readLine();
200                        while (line != null) {
201                            line = line.trim();
202                            if (line.length() > 0 && !line.startsWith("#")) {
203                                adminUsers.add(line);
204                            }
205                            line = br.readLine();
206                        }
207                    }
208                    catch (IOException ex) {
209                        throw new ServiceException(ErrorCode.E0160, file.getAbsolutePath(), ex);
210                    }
211                    finally {
212                        br.close();
213                    }
214                }
215                catch (IOException ex) {
216                    throw new ServiceException(ErrorCode.E0160, file.getAbsolutePath(), ex);
217                }
218            }
219            else {
220                log.warn("Admin users file not available in config dir [{0}]", configDir);
221            }
222        }
223        else {
224            log.warn("Reading configuration from classpath, running without admin users");
225        }
226    }
227
228    private void loadAdminUsersFromConfiguration() {
229        LinkedHashSet<String> adminsFromOozieSite = Sets.newLinkedHashSet();
230        adminsFromOozieSite.addAll(Services.get().get(ConfigurationService.class).getConf().getStringCollection(CONF_ADMIN_USERS));
231        if (!adminsFromOozieSite.isEmpty()) {
232            log.info("{0} admin users found in oozie-site.xml", adminsFromOozieSite.size());
233            adminUsers.addAll(adminsFromOozieSite);
234        }
235    }
236
237    /**
238     * Destroy the service. <p> This implementation does a NOP.
239     */
240    public void destroy() {
241    }
242
243    /**
244     * Return the public interface of the service.
245     *
246     * @return {@link AuthorizationService}.
247     */
248    public Class<? extends Service> getInterface() {
249        return AuthorizationService.class;
250    }
251
252    /**
253     * Check if the user belongs to the group or not.
254     *
255     * @param user user name.
256     * @param group group name.
257     * @return if the user belongs to the group or not.
258     * @throws AuthorizationException thrown if the authorization query can not be performed.
259     */
260    protected boolean isUserInGroup(String user, String group) throws AuthorizationException {
261        GroupsService groupsService = Services.get().get(GroupsService.class);
262        try {
263            return groupsService.getGroups(user).contains(group);
264        }
265        catch (IOException ex) {
266            throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex);
267        }
268    }
269
270    /**
271     * Check if the user belongs to the group or not. <p> <p> Subclasses should override the {@link #isUserInGroup}
272     * method.
273     *
274     * @param user user name.
275     * @param group group name.
276     * @throws AuthorizationException thrown if the user is not authorized for the group or if the authorization query
277     * can not be performed.
278     */
279    public void authorizeForGroup(String user, String group) throws AuthorizationException {
280        if (authorizationEnabled && !isUserInGroup(user, group)) {
281            throw new AuthorizationException(ErrorCode.E0502, user, group);
282        }
283    }
284
285    /**
286     * Return the default group to which the user belongs. <p> This implementation always returns 'users'.
287     *
288     * @param user user name.
289     * @return default group of user.
290     * @throws AuthorizationException thrown if the default group con not be retrieved.
291     */
292    public String getDefaultGroup(String user) throws AuthorizationException {
293        try {
294            return Services.get().get(GroupsService.class).getGroups(user).get(0);
295        }
296        catch (IOException ex) {
297            throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex);
298        }
299    }
300
301    /**
302     * Check if the user has admin privileges. <p> If admin is disabled it returns always <code>true</code>. <p> If
303     * admin is enabled it returns <code>true</code> if the user is in the <code>adminusers.txt</code> file.
304     *
305     * @param user user name.
306     * @return if the user has admin privileges or not.
307     */
308    protected boolean isAdmin(String user) {
309        boolean admin = false;
310        if (adminUsers != null) {
311            admin = adminUsers.contains(user);
312        }
313        else {
314            for (String adminGroup : adminGroups) {
315                try {
316                    admin = isUserInGroup(user, adminGroup);
317                    if (admin) {
318                        break;
319                    }
320                }
321                catch (AuthorizationException ex) {
322                    log.warn("Admin check failed, " + ex.toString(), ex);
323                    break;
324                }
325            }
326        }
327        return admin;
328    }
329
330    /**
331     * Check if the user is authorized to access system information.
332     *
333     * @param user user name.
334     * @param proxyUser proxy user name.
335     * @throws AuthorizationException thrown if user does not have admin priviledges.
336     */
337    public void authorizeForSystemInfo(String user, String proxyUser) throws AuthorizationException {
338        if (authorizationEnabled && authorizedSystemInfo && !(sysInfoAuthUsers.contains(user) || sysInfoAuthUsers
339                .contains(proxyUser) || isAdmin(user) || isAdmin(proxyUser))) {
340            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
341            throw new AuthorizationException(ErrorCode.E0503, user);
342        }
343    }
344
345    /**
346     * Check if the user has admin privileges. <p> Subclasses should override the {@link #isUserInGroup} method.
347     *
348     * @param user user name.
349     * @param write indicates if the check is for read or write admin tasks (in this implementation this is ignored)
350     * @throws AuthorizationException thrown if user does not have admin privileges.
351     */
352    public void authorizeForAdmin(String user, boolean write) throws AuthorizationException {
353        if (authorizationEnabled && write && !isAdmin(user)) {
354            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
355            throw new AuthorizationException(ErrorCode.E0503, user);
356        }
357    }
358
359    /**
360     * Check if the user+group is authorized to use the specified application. <p> The check is done by checking the
361     * file system permissions on the workflow application.
362     *
363     * @param user user name.
364     * @param group group name.
365     * @param appPath application path.
366     * @throws AuthorizationException thrown if the user is not authorized for the app.
367     */
368    public void authorizeForApp(String user, String group, String appPath, Configuration jobConf)
369            throws AuthorizationException {
370        try {
371            HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
372            URI uri = new Path(appPath).toUri();
373            Configuration fsConf = has.createConfiguration(uri.getAuthority());
374            FileSystem fs = has.createFileSystem(user, uri, fsConf);
375
376            Path path = new Path(appPath);
377            try {
378                if (!fs.exists(path)) {
379                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
380                    throw new AuthorizationException(ErrorCode.E0504, appPath);
381                }
382                Path wfXml = new Path(path, "workflow.xml");
383                if (!fs.exists(wfXml)) {
384                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
385                    throw new AuthorizationException(ErrorCode.E0505, appPath);
386                }
387                if (!fs.isFile(wfXml)) {
388                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
389                    throw new AuthorizationException(ErrorCode.E0506, appPath);
390                }
391                fs.open(wfXml).close();
392            }
393            catch (AccessControlException ex) {
394                incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
395                throw new AuthorizationException(ErrorCode.E0507, appPath, ex.getMessage(), ex);
396            }
397        }
398        catch (IOException ex) {
399            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
400            throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex);
401        }
402        catch (HadoopAccessorException e) {
403            throw new AuthorizationException(e);
404        }
405    }
406
407    /**
408     * Check if the user+group is authorized to use the specified application. <p> The check is done by checking the
409     * file system permissions on the workflow application.
410     *
411     * @param user user name.
412     * @param group group name.
413     * @param appPath application path.
414     * @param fileName workflow or coordinator.xml
415     * @param conf
416     * @throws AuthorizationException thrown if the user is not authorized for the app.
417     */
418    public void authorizeForApp(String user, String group, String appPath, String fileName, Configuration conf)
419            throws AuthorizationException {
420        try {
421            HadoopAccessorService has = Services.get().get(HadoopAccessorService.class);
422            URI uri = new Path(appPath).toUri();
423            Configuration fsConf = has.createConfiguration(uri.getAuthority());
424            FileSystem fs = has.createFileSystem(user, uri, fsConf);
425
426            Path path = new Path(appPath);
427            try {
428                if (!fs.exists(path)) {
429                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
430                    throw new AuthorizationException(ErrorCode.E0504, appPath);
431                }
432                if (conf.get(XOozieClient.IS_PROXY_SUBMISSION) == null) { // Only further check existence of job definition
433                    //files for non proxy submission jobs;
434                    if (!fs.isFile(path)) {
435                        Path appXml = new Path(path, fileName);
436                        if (!fs.exists(appXml)) {
437                            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
438                            throw new AuthorizationException(ErrorCode.E0505, appPath);
439                        }
440                        if (!fs.isFile(appXml)) {
441                            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
442                            throw new AuthorizationException(ErrorCode.E0506, appPath);
443                        }
444                        fs.open(appXml).close();
445                    }
446                }
447            }
448            catch (AccessControlException ex) {
449                incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
450                throw new AuthorizationException(ErrorCode.E0507, appPath, ex.getMessage(), ex);
451            }
452        }
453        catch (IOException ex) {
454            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
455            throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex);
456        }
457        catch (HadoopAccessorException e) {
458            throw new AuthorizationException(e);
459        }
460    }
461
462    private boolean isUserInAcl(String user, String aclStr) throws IOException {
463        boolean userInAcl = false;
464        if (aclStr != null && aclStr.trim().length() > 0) {
465            GroupsService groupsService = Services.get().get(GroupsService.class);
466            String[] acl = aclStr.split(",");
467            for (int i = 0; !userInAcl && i < acl.length; i++) {
468                String aclItem = acl[i].trim();
469                userInAcl = aclItem.equals(user) || groupsService.getGroups(user).contains(aclItem);
470            }
471        }
472        return userInAcl;
473    }
474
475    /**
476     * Check if the user+group is authorized to operate on the specified job. <p> Checks if the user is a super-user or
477     * the one who started the job. <p> Read operations are allowed to all users.
478     *
479     * @param user user name.
480     * @param jobId job id.
481     * @param write indicates if the check is for read or write job tasks.
482     * @throws AuthorizationException thrown if the user is not authorized for the job.
483     */
484    public void authorizeForJob(String user, String jobId, boolean write) throws AuthorizationException {
485        if (authorizationEnabled && write && !isAdmin(user)) {
486            try {
487                // handle workflow jobs
488                if (jobId.endsWith("-W")) {
489                    WorkflowJobBean jobBean = null;
490                    JPAService jpaService = Services.get().get(JPAService.class);
491                    if (jpaService != null) {
492                        try {
493                            jobBean = WorkflowJobQueryExecutor.getInstance().get(WorkflowJobQuery.GET_WORKFLOW_USER_GROUP, jobId);
494                        }
495                        catch (JPAExecutorException je) {
496                            throw new AuthorizationException(je);
497                        }
498                    }
499                    else {
500                        throw new AuthorizationException(ErrorCode.E0610);
501                    }
502                    if (jobBean != null && !jobBean.getUser().equals(user)) {
503                        if (!isUserInAcl(user, jobBean.getGroup())) {
504                            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
505                            throw new AuthorizationException(ErrorCode.E0508, user, jobId);
506                        }
507                    }
508                }
509                // handle bundle jobs
510                else if (jobId.endsWith("-B")){
511                    BundleJobBean jobBean = null;
512                    JPAService jpaService = Services.get().get(JPAService.class);
513                    if (jpaService != null) {
514                        try {
515                            jobBean = jpaService.execute(new BundleJobGetJPAExecutor(jobId));
516                        }
517                        catch (JPAExecutorException je) {
518                            throw new AuthorizationException(je);
519                        }
520                    }
521                    else {
522                        throw new AuthorizationException(ErrorCode.E0610);
523                    }
524                    if (jobBean != null && !jobBean.getUser().equals(user)) {
525                        if (!isUserInAcl(user, jobBean.getGroup())) {
526                            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
527                            throw new AuthorizationException(ErrorCode.E0509, user, jobId);
528                        }
529                    }
530                }
531                // handle coordinator jobs
532                else {
533                    CoordinatorJobBean jobBean = null;
534                    JPAService jpaService = Services.get().get(JPAService.class);
535                    if (jpaService != null) {
536                        try {
537                            jobBean = jpaService.execute(new CoordJobGetJPAExecutor(jobId));
538                        }
539                        catch (JPAExecutorException je) {
540                            throw new AuthorizationException(je);
541                        }
542                    }
543                    else {
544                        throw new AuthorizationException(ErrorCode.E0610);
545                    }
546                    if (jobBean != null && !jobBean.getUser().equals(user)) {
547                        if (!isUserInAcl(user, jobBean.getGroup())) {
548                            incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
549                            throw new AuthorizationException(ErrorCode.E0509, user, jobId);
550                        }
551                    }
552                }
553            }
554            catch (IOException ex) {
555                throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex);
556            }
557        }
558    }
559
560    /**
561     * Check if the user+group is authorized to operate on the specified jobs. <p> Checks if the user is a super-user or
562     * the one who started the jobs. <p> Read operations are allowed to all users.
563     *
564     * @param user user name.
565     * @param filter filter used to select jobs
566     * @param start starting index of the jobs in DB
567     * @param len maximum amount of jobs to select
568     * @param write indicates if the check is for read or write job tasks.
569     * @throws AuthorizationException thrown if the user is not authorized for the job.
570     */
571    public void authorizeForJobs(String user, Map<String, List<String>> filter, String jobType,
572                                 int start, int len, boolean write) throws AuthorizationException {
573        if (authorizationEnabled && write && !isAdmin(user)) {
574            try {
575                // handle workflow jobs
576                if (jobType.equals("wf")) {
577                    List<WorkflowJobBean> jobBeans = new ArrayList<WorkflowJobBean>();
578                    JPAService jpaService = Services.get().get(JPAService.class);
579                    if (jpaService != null) {
580                        try {
581                            jobBeans = jpaService.execute(new WorkflowsJobGetJPAExecutor(
582                                    filter, start, len)).getWorkflows();
583                        }
584                        catch (JPAExecutorException je) {
585                            throw new AuthorizationException(je);
586                        }
587                    }
588                    else {
589                        throw new AuthorizationException(ErrorCode.E0610);
590                    }
591                    for (WorkflowJobBean jobBean : jobBeans) {
592                        if (jobBean != null && !jobBean.getUser().equals(user)) {
593                            if (!isUserInAcl(user, jobBean.getGroup())) {
594                                    incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
595                                throw new AuthorizationException(ErrorCode.E0508, user, jobBean.getId());
596                            }
597                        }
598                    }
599                }
600                // handle bundle jobs
601                else if (jobType.equals("bundle")) {
602                    List<BundleJobBean> jobBeans = new ArrayList<BundleJobBean>();
603                    JPAService jpaService = Services.get().get(JPAService.class);
604                    if (jpaService != null) {
605                        try {
606                            jobBeans = jpaService.execute(new BundleJobInfoGetJPAExecutor(
607                                    filter, start, len)).getBundleJobs();
608                        }
609                        catch (JPAExecutorException je) {
610                            throw new AuthorizationException(je);
611                        }
612                    }
613                    else {
614                        throw new AuthorizationException(ErrorCode.E0610);
615                    }
616                    for (BundleJobBean jobBean : jobBeans){
617                        if (jobBean != null && !jobBean.getUser().equals(user)) {
618                            if (!isUserInAcl(user, jobBean.getGroup())) {
619                                incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
620                                throw new AuthorizationException(ErrorCode.E0509, user, jobBean.getId());
621                            }
622                        }
623                    }
624                }
625                // handle coordinator jobs
626                else {
627                    List<CoordinatorJobBean> jobBeans = new ArrayList<CoordinatorJobBean>();
628                    JPAService jpaService = Services.get().get(JPAService.class);
629                    if (jpaService != null) {
630                        try {
631                            jobBeans = jpaService.execute(new CoordJobInfoGetJPAExecutor(
632                                    filter, start, len)).getCoordJobs();
633                        }
634                        catch (JPAExecutorException je) {
635                            throw new AuthorizationException(je);
636                        }
637                    }
638                    else {
639                        throw new AuthorizationException(ErrorCode.E0610);
640                    }
641                    for (CoordinatorJobBean jobBean : jobBeans) {
642                        if (jobBean != null && !jobBean.getUser().equals(user)) {
643                            if (!isUserInAcl(user, jobBean.getGroup())) {
644                                incrCounter(INSTR_FAILED_AUTH_COUNTER, 1);
645                                throw new AuthorizationException(ErrorCode.E0509, user, jobBean.getId());
646                            }
647                        }
648                    }
649                }
650            }
651            catch (IOException ex) {
652                throw new AuthorizationException(ErrorCode.E0501, ex.getMessage(), ex);
653            }
654        }
655    }
656    /**
657     * Convenience method for instrumentation counters.
658     *
659     * @param name counter name.
660     * @param count count to increment the counter.
661     */
662    private void incrCounter(String name, int count) {
663        if (instrumentation != null) {
664            instrumentation.incr(INSTRUMENTATION_GROUP, name, count);
665        }
666    }
667
668    public boolean isAuthorizedSystemInfo() {
669        return authorizedSystemInfo;
670    }
671}