Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * See the NOTICE file distributed with this work for additional
   * information regarding copyright ownership.
   *
   * This is free software; you can redistribute it and/or modify it
   * under the terms of the GNU Lesser General Public License as
   * published by the Free Software Foundation; either version 2.1 of
   * the License, or (at your option) any later version.
   *
  * This software is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this software; if not, write to the Free
  * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  */
 package org.xwiki.crypto.signer.internal.factory;
 
Abstract base class for signer factory of Bouncy Castle based signer.

Version:
$Id: a183fef68fbad72243f44ea1a3b06c49701ff23b $
Since:
5.4RC1
 
 public abstract class AbstractBcSignerFactory extends AbstractSignerFactory implements BcSignerFactory
 {
    

Parameters:
parameters cipher parameters.
Returns:
a new native bouncy castle instance of a signer.
 
     protected abstract org.bouncycastle.crypto.Signer getSignerInstance(AsymmetricCipherParameters parameters);

    

Parameters:
parameters cipher parameters.
Returns:
a new native bouncy castle instance of a signer.
 
 
     {
         if (!(parameters instanceof AsymmetricCipherParameters)) {
             throw new IllegalArgumentException("Unexpected parameters received for signer: "
                 + parameters.getClass().getName());
         }
 
         return (AsymmetricCipherParametersparameters;
     }
 
     @Override
     public Signer getInstance(boolean forSigningCipherParameters parameters)
     {
         return new BcSigner(getSignerInstance((AsymmetricCipherParametersparameters), forSigning,
             getBcCipherParameter(getCipherParameters(parameters)),
     }
 
     @Override
     public Signer getInstance(boolean forSigningCipherParameters parametersbyte[] encoded)
     {
         return getInstance(forSigningparameters, AlgorithmIdentifier.getInstance(encoded));
     }
 
     @Override
     public Signer getInstance(boolean forSigningCipherParameters parametersAlgorithmIdentifier algId)
     {
         if (!algId.getAlgorithm().equals(
             getSignerAlgorithmIdentifier(getCipherParameters(parameters)).getAlgorithm())) {
             throw new IllegalArgumentException("Incompatible algorithm for this signer: "
                 + algId.getAlgorithm().getId());
         }
 
         return getInstance(forSigningparameters);
     }

    
Convert cipher parameters to Bouncy Castle equivalent.

Parameters:
parameters some asymmetric cipher parameters.
Returns:
equivalent bouncy castle parameters.
 
     {
         if (parameters instanceof BcAsymmetricKeyParameters) {
             return ((BcAsymmetricKeyParametersparameters).getParameters();
         }
 
         // TODO: convert parameters to compatible ones
         throw new UnsupportedOperationException("Cipher parameters are incompatible with this signer: "
             + parameters.getClass().getName());
    }
New to GrepCode? Check out our FAQ X