1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.mail.internal.script

File ProgrammingRightsScriptServicePermissionChecker.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart8.png
54% of files have more coverage

Code metrics

0
3
1
1
57
27
2
0.67
3
1
2

Classes

Class Line # Actions
ProgrammingRightsScriptServicePermissionChecker 42 3 0% 2 1
0.7575%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.mail.internal.script;
21   
22    import javax.inject.Inject;
23    import javax.inject.Named;
24    import javax.inject.Singleton;
25    import javax.mail.MessagingException;
26   
27    import org.xwiki.component.annotation.Component;
28    import org.xwiki.mail.script.ScriptServicePermissionChecker;
29    import org.xwiki.security.authorization.AccessDeniedException;
30    import org.xwiki.security.authorization.ContextualAuthorizationManager;
31    import org.xwiki.security.authorization.Right;
32   
33    /**
34    * The current document must have Programming Rights for emails to be authorized for sending.
35    *
36    * @version $Id: ed2c02884cdcf00093fefb239b5534931145676f $
37    * @since 6.4M2
38    */
39    @Component
40    @Named("programmingrights")
41    @Singleton
 
42    public class ProgrammingRightsScriptServicePermissionChecker implements ScriptServicePermissionChecker
43    {
44    @Inject
45    private ContextualAuthorizationManager authorizationManager;
46   
 
47  4 toggle @Override
48    public void check() throws MessagingException
49    {
50    // If the current document doesn't have Programming Rights then do not authorize the mail to be sent.
51  4 try {
52  4 this.authorizationManager.checkAccess(Right.PROGRAM);
53    } catch (AccessDeniedException e) {
54  0 throw new MessagingException("The Current document doesn't have the Programming Rights", e);
55    }
56    }
57    }