/** * Implementation of the {@code engineGetEncoded} method. * * @param format the format string (must not be {@code null}) * @return the encoded representation (not {@code null}) * @throws IOException if the given format is not {@code ASN.1} */ protected final byte[] engineGetEncoded(final String format) throws IOException { checkInit(); if ("ASN.1".equalsIgnoreCase(format)) { return engineGetEncoded(); } else { throw log.invalidFormat("ASN.1", format); } }
/** * Implementation of the {@code engineInit} method. * * @param params the encoded parameter specification * @throws IOException if decoding failed */ protected final void engineInit(final byte[] params) throws IOException { final DERDecoder decoder = new DERDecoder(params); try { parameterSpec = engineDecode(decoder); encoded = params; } catch (ASN1Exception e) { throw log.failedToDecode(e); } }
/** * Implementation of the {@code engineInit} method. * * @param paramSpec the parameter specification * @throws InvalidParameterSpecException if an argument is invalid or encoding failed */ protected final void engineInit(final AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException { final Class<P> parameterType = getParameterType(); if (parameterType.isInstance(paramSpec)) try { DEREncoder encoder = new DEREncoder(); final P cast = parameterType.cast(paramSpec); engineEncode(encoder, cast); encoded = encoder.getEncoded(); this.parameterSpec = cast; } catch (ASN1Exception e) { throw log.failedToEncode(e); } else { throw log.invalidParameterSpec(parameterType, paramSpec.getClass()); } }
/** * Implementation of the {@code engineGetParameterSpec} method. * * @param type the parameter specification type class (must not be {@code null}) * @param <T> the parameter specification type * @return the parameter specification (must not be {@code null}) * @throws InvalidParameterSpecException if the type is not supported */ protected final <T extends AlgorithmParameterSpec> T engineGetParameterSpec(final Class<T> type) throws InvalidParameterSpecException { checkInit(); if (type.isAssignableFrom(getParameterType()) && type.isInstance(parameterSpec)) { return type.cast(parameterSpec); } else { throw log.invalidParameterSpec(getParameterType(), type); } }
/** * Implementation of the {@code engineGetEncoded} method. * * @return the encoded representation (not {@code null}) */ protected final byte[] engineGetEncoded() { checkInit(); return encoded; }
/** * Implementation of the {@code engineToString} method. * * @return the string representation */ protected String engineToString() { return "AlgorithmParametersSpi for " + getParameterType(); } }
/** * Implementation of the {@code engineInit} method. * * @param params the encoded parameter specification * @param format the format (must be {@code ASN.1}) * @throws IOException if decoding failed or the format is not equal to {@code ASN.1} */ protected final void engineInit(final byte[] params, final String format) throws IOException { if ("ASN.1".equalsIgnoreCase(format)) { engineInit(params); } else { throw log.invalidFormat("ASN.1", format); } }
/** * Implementation of the {@code engineGetParameterSpec} method. * * @param type the parameter specification type class (must not be {@code null}) * @param <T> the parameter specification type * @return the parameter specification (must not be {@code null}) * @throws InvalidParameterSpecException if the type is not supported */ protected final <T extends AlgorithmParameterSpec> T engineGetParameterSpec(final Class<T> type) throws InvalidParameterSpecException { checkInit(); if (type.isAssignableFrom(getParameterType()) && type.isInstance(parameterSpec)) { return type.cast(parameterSpec); } else { throw log.invalidParameterSpec(getParameterType(), type); } }
/** * Implementation of the {@code engineGetEncoded} method. * * @return the encoded representation (not {@code null}) */ protected final byte[] engineGetEncoded() { checkInit(); return encoded; }
/** * Implementation of the {@code engineToString} method. * * @return the string representation */ protected String engineToString() { return "AlgorithmParametersSpi for " + getParameterType(); } }
/** * Implementation of the {@code engineInit} method. * * @param params the encoded parameter specification * @param format the format (must be {@code ASN.1}) * @throws IOException if decoding failed or the format is not equal to {@code ASN.1} */ protected final void engineInit(final byte[] params, final String format) throws IOException { if ("ASN.1".equalsIgnoreCase(format)) { engineInit(params); } else { throw log.invalidFormat("ASN.1", format); } }
/** * Implementation of the {@code engineGetEncoded} method. * * @param format the format string (must not be {@code null}) * @return the encoded representation (not {@code null}) * @throws IOException if the given format is not {@code ASN.1} */ protected final byte[] engineGetEncoded(final String format) throws IOException { checkInit(); if ("ASN.1".equalsIgnoreCase(format)) { return engineGetEncoded(); } else { throw log.invalidFormat("ASN.1", format); } }
/** * Implementation of the {@code engineGetParameterSpec} method. * * @param type the parameter specification type class (must not be {@code null}) * @param <T> the parameter specification type * @return the parameter specification (must not be {@code null}) * @throws InvalidParameterSpecException if the type is not supported */ protected final <T extends AlgorithmParameterSpec> T engineGetParameterSpec(final Class<T> type) throws InvalidParameterSpecException { checkInit(); if (type.isAssignableFrom(getParameterType()) && type.isInstance(parameterSpec)) { return type.cast(parameterSpec); } else { throw log.invalidParameterSpec(getParameterType(), type); } }
/** * Implementation of the {@code engineInit} method. * * @param paramSpec the parameter specification * @throws InvalidParameterSpecException if an argument is invalid or encoding failed */ protected final void engineInit(final AlgorithmParameterSpec paramSpec) throws InvalidParameterSpecException { final Class<P> parameterType = getParameterType(); if (parameterType.isInstance(paramSpec)) try { DEREncoder encoder = new DEREncoder(); final P cast = parameterType.cast(paramSpec); engineEncode(encoder, cast); encoded = encoder.getEncoded(); this.parameterSpec = cast; } catch (ASN1Exception e) { throw log.failedToEncode(e); } else { throw log.invalidParameterSpec(parameterType, paramSpec.getClass()); } }
/** * Implementation of the {@code engineGetEncoded} method. * * @return the encoded representation (not {@code null}) */ protected final byte[] engineGetEncoded() { checkInit(); return encoded; }
/** * Implementation of the {@code engineToString} method. * * @return the string representation */ protected String engineToString() { return "AlgorithmParametersSpi for " + getParameterType(); } }
/** * Implementation of the {@code engineInit} method. * * @param params the encoded parameter specification * @throws IOException if decoding failed */ protected final void engineInit(final byte[] params) throws IOException { final DERDecoder decoder = new DERDecoder(params); try { parameterSpec = engineDecode(decoder); encoded = params; } catch (ASN1Exception e) { throw log.failedToDecode(e); } }
/** * Implementation of the {@code engineInit} method. * * @param params the encoded parameter specification * @param format the format (must be {@code ASN.1}) * @throws IOException if decoding failed or the format is not equal to {@code ASN.1} */ protected final void engineInit(final byte[] params, final String format) throws IOException { if ("ASN.1".equalsIgnoreCase(format)) { engineInit(params); } else { throw log.invalidFormat("ASN.1", format); } }
/** * Implementation of the {@code engineGetEncoded} method. * * @param format the format string (must not be {@code null}) * @return the encoded representation (not {@code null}) * @throws IOException if the given format is not {@code ASN.1} */ protected final byte[] engineGetEncoded(final String format) throws IOException { checkInit(); if ("ASN.1".equalsIgnoreCase(format)) { return engineGetEncoded(); } else { throw log.invalidFormat("ASN.1", format); } }
/** * Implementation of the {@code engineGetParameterSpec} method. * * @param type the parameter specification type class (must not be {@code null}) * @param <T> the parameter specification type * @return the parameter specification (must not be {@code null}) * @throws InvalidParameterSpecException if the type is not supported */ protected final <T extends AlgorithmParameterSpec> T engineGetParameterSpec(final Class<T> type) throws InvalidParameterSpecException { checkInit(); if (type.isAssignableFrom(getParameterType()) && type.isInstance(parameterSpec)) { return type.cast(parameterSpec); } else { throw log.invalidParameterSpec(getParameterType(), type); } }