org.refcodes.forwardsecrecy.AbstractCipherVersionGenerator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of refcodes-forwardsecrecy Show documentation
Show all versions of refcodes-forwardsecrecy Show documentation
Artifact for the refcodes forward secrecy framework design.
The newest version!
// /////////////////////////////////////////////////////////////////////////////
// REFCODES.ORG
// =============================================================================
// This code is copyright (c) by Siegfried Steiner, Munich, Germany, distributed
// on an "AS IS" BASIS WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, and licen-
// sed under the following (see "http://en.wikipedia.org/wiki/Multi-licensing")
// licenses:
// =============================================================================
// GNU General Public License, v3.0 ("http://www.gnu.org/licenses/gpl-3.0.html")
// together with the GPL linking exception applied; as being applied by the GNU
// Classpath ("http://www.gnu.org/software/classpath/license.html")
// =============================================================================
// Apache License, v2.0 ("http://www.apache.org/licenses/TEXT-2.0")
// =============================================================================
// Please contact the copyright holding author(s) of the software artifacts in
// question for licensing issues not being covered by the above listed licenses,
// also regarding commercial licensing models or regarding the compatibility
// with other open source licenses.
// /////////////////////////////////////////////////////////////////////////////
package org.refcodes.forwardsecrecy;
import org.refcodes.data.Text;
/**
* Default implementation of a cipher version generator.
*
* @param The type of the {@link CipherVersion} to be generated.
*/
public abstract class AbstractCipherVersionGenerator implements CipherVersionGenerator {
// /////////////////////////////////////////////////////////////////////////
// VARIABLES:
// /////////////////////////////////////////////////////////////////////////
private final CipherVersionFactory _cipherVersionFactory;
// /////////////////////////////////////////////////////////////////////////
// CONSTRUCTORS:
// /////////////////////////////////////////////////////////////////////////
/**
* Constructor for the {@link AbstractCipherVersionGenerator}. The provided
* {@link CipherVersionFactory} is used to create the actual
* {@link CipherVersion} instances generated by this
* {@link CipherVersionGenerator}.
*
* @param aCipherVersionFactory The {@link CipherVersionFactory} used to
* create the {@link CipherVersion} instances of the required type.
*/
public AbstractCipherVersionGenerator( CipherVersionFactory aCipherVersionFactory ) {
_cipherVersionFactory = aCipherVersionFactory;
}
// /////////////////////////////////////////////////////////////////////////
// METHODS:
// /////////////////////////////////////////////////////////////////////////
/**
* {@inheritDoc}
*/
@Override
public boolean hasNext() {
return true;
}
/**
* {@inheritDoc}
*/
@Override
public void remove() {
throw new UnsupportedOperationException( Text.UNSUPPORTED_OPERATION.getText() );
}
/**
* {@inheritDoc}
*/
@Override
public CV next() {
return _cipherVersionFactory.create( createCipherUid(), createCipher() );
}
// /////////////////////////////////////////////////////////////////////////
// HOOK METHODS:
// /////////////////////////////////////////////////////////////////////////
/**
* Hook factory method to be implemented by subclasses. A
* https://www.metacodes.pro algorithm can be used to generate unique cipher
* UIDs. In case the cipher UID is not unique, another one is requested
* until a cipher UID is found which is unique regarding the systems of
* forward secrecy cryptography architecture.
*
* @return A more or less unique cipher UID.
*/
protected String createCipherUid() {
return ForwardSecrecyUtility.createCipherUid();
}
/**
* Hook factory method to be implemented by subclasses. A
* https://www.metacodes.pro algorithm is to be implemented creating a good
* random cipher.
*
* @return A good random cipher.
*/
protected String createCipher() {
return ForwardSecrecyUtility.createCipher();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy