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

File AbstractBouncyCastleInternalBinaryStringEncoder.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
7
5
1
78
36
5
0.71
1.4
5
1

Classes

Class Line # Actions
AbstractBouncyCastleInternalBinaryStringEncoder 33 7 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 24 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.crypto.internal.encoder;
21   
22    import java.io.IOException;
23    import java.io.OutputStream;
24   
25    import org.bouncycastle.util.encoders.Encoder;
26   
27    /**
28    * Abstract base class to build binary string encoder based on Bouncy Castle.
29    *
30    * @version $Id: 6eeed2bf0c5093ab7044d5bad078eec648d81358 $
31    * @since 5.4M1
32    */
 
33    public abstract class AbstractBouncyCastleInternalBinaryStringEncoder implements InternalBinaryStringEncoder
34    {
35    private final Encoder encoder;
36   
37    private final int blockSize;
38   
39    private final int charSize;
40   
41    /**
42    * Create a wrapper over the given encoder, providing size methods.
43    *
44    * @param encoder the bouncy castle encoder.
45    * @param blockSize the blocksize to report for encoding.
46    * @param charSize the blocksize to report for decoding.
47    */
 
48  130 toggle public AbstractBouncyCastleInternalBinaryStringEncoder(Encoder encoder, int blockSize, int charSize)
49    {
50  130 this.encoder = encoder;
51  130 this.blockSize = blockSize;
52  130 this.charSize = charSize;
53    }
54   
 
55  56 toggle @Override
56    public int encode(byte[] buffer, int offset, int length, OutputStream outputStream) throws IOException
57    {
58  56 return this.encoder.encode(buffer, offset, length, outputStream);
59    }
60   
 
61  220 toggle @Override
62    public int decode(byte[] buffer, int offset, int length, OutputStream outputStream) throws IOException
63    {
64  220 return this.encoder.decode(buffer, offset, length, outputStream);
65    }
66   
 
67  18 toggle @Override
68    public int getEncodingBlockSize()
69    {
70  18 return this.blockSize;
71    }
72   
 
73  12 toggle @Override
74    public int getDecodingBlockSize()
75    {
76  12 return this.charSize;
77    }
78    }