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

File MacroBlockSignatureGenerator.java

 
testIncompatibleBlockSignature: Unsupported block [org.xwiki.rendering.block.WordBlock].
 

Coverage histogram

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

Code metrics

2
4
2
1
72
38
3
0.75
2
2
1.5

Classes

Class Line # Actions
MacroBlockSignatureGenerator 46 4 0% 3 2
0.7575%
 

Contributing tests

This file is covered by 3 tests. .

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.rendering.signature.internal;
21   
22    import java.io.IOException;
23    import java.security.GeneralSecurityException;
24   
25    import javax.inject.Inject;
26    import javax.inject.Named;
27    import javax.inject.Singleton;
28   
29    import org.xwiki.component.annotation.Component;
30    import org.xwiki.crypto.signer.CMSSignedDataGenerator;
31    import org.xwiki.crypto.signer.param.CMSSignedDataGeneratorParameters;
32    import org.xwiki.rendering.block.Block;
33    import org.xwiki.rendering.block.MacroBlock;
34    import org.xwiki.rendering.block.MacroMarkerBlock;
35    import org.xwiki.rendering.signature.BlockSignatureGenerator;
36   
37    /**
38    * Sign {@link MacroBlock} and {@link MacroMarkerBlock}.
39    *
40    * @version $Id: dc21766730f59b42c68a9199b75c67318c281c77 $
41    * @since 6.1M2
42    */
43    @Component
44    @Named("macro")
45    @Singleton
 
46    public class MacroBlockSignatureGenerator implements BlockSignatureGenerator
47    {
48    @Inject
49    @Named("macro")
50    private BlockDumper dumper;
51   
52    @Inject
53    private CMSSignedDataGenerator generator;
54   
 
55  3 toggle @Override
56    public byte[] generate(Block block, CMSSignedDataGeneratorParameters params)
57    throws GeneralSecurityException, IOException
58    {
59  2 if (!isSupported(block)) {
60  0 Test failure here throw new IllegalArgumentException("Unsupported block [" + block.getClass().getName() + "].");
61    }
62   
63  2 return generator.generate(dumper.dump(block), params);
64    }
65   
 
66  3 toggle @Override
67    public boolean isSupported(Block block)
68    {
69  3 return (block instanceof MacroBlock || block instanceof MacroMarkerBlock);
70    }
71   
72    }