Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • web2/EJB-EncryptionBean
  • wilsonsf/EJB-EncryptionBean
2 results
Show changes
Showing
with 300 additions and 79 deletions
package br.ufrn.imd.web2.encryption;
import javax.ejb.Remote;
@Remote
public interface EncryptionRemote extends EncryptionCommon {
}
package br.ufrn.imd.imd0409.encryption;
package br.ufrn.imd.web2.encryption;
import javax.jws.WebService;
@WebService(name = "EncryptionService")
public interface EncryptionWS extends EncryptionCommonBusiness {
public interface EncryptionWS extends EncryptionCommon {
}
<?xml version="1.0" encoding="UTF-8"?>
<ejb-jar xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:ejb="http://java.sun.com/xml/ns/javaee/ejb-jar_3_0.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/ejb-jar_3_1.xsd"
version="3.1">
<enterprise-beans>
<session>
<ejb-name>EncryptionBean</ejb-name>
<env-entry>
<env-entry-name>ciphersPassphrase</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>OverriddenPassword</env-entry-value>
</env-entry>
<env-entry>
<env-entry-name>messageDigestAlgorithm</env-entry-name>
<env-entry-type>java.lang.String</env-entry-type>
<env-entry-value>SHA</env-entry-value>
</env-entry>
</session>
</enterprise-beans>
</ejb-jar>
\ No newline at end of file
/*
* JBoss, Home of Professional Open Source.
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* 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 br.ufrn.imd.web2.encryption;
import java.util.logging.Logger;
import junit.framework.TestCase;
/**
* Common base for centralizing test logic used
* for the Encryption POJO and EncryptionEJB
*
* @author <a href="mailto:alr@jboss.org">ALR</a>
*/
public class EncryptionTestCaseSupport
{
// ---------------------------------------------------------------------------||
// Class Members -------------------------------------------------------------||
// ---------------------------------------------------------------------------||
/**
* Logger
*/
private static final Logger log = Logger.getLogger(EncryptionTestCaseSupport.class.getName());
/**
* A simple String used in testing
*/
private static final String TEST_STRING = "EJB 3.1 Examples Test String";
// ---------------------------------------------------------------------------||
// Test Support --------------------------------------------------------------||
// ---------------------------------------------------------------------------||
/**
* Ensures that the hashing functions are working as expected:
*
* 1) Passing through the hash returns a result inequal to the input
* 2) Comparison upon the hash result and the original input matches
*
* @param service The service to use (either POJO or EJB)
* @throws Throwable
*/
protected void assertHashing(final EncryptionCommon service) throws Throwable
{
// Log
log.info("assertHashing");
// Declare the input
final String input = TEST_STRING;
// Hash
final String hash = service.hash(input);
log.info("Hash of \"" + input + "\": " + hash);
// Test that the has function had some effect
TestCase.assertNotSame("The hash function had no effect upon the supplied input", input, hash);
// Get the comparison result
final boolean equal = service.compare(hash, input);
// Test that the input matches the hash we'd gotten
TestCase.assertTrue("The comparison of the input to its hashed result failed", equal);
}
/**
* Ensures that the encryption functions are working as expected:
*
* 1) Passing through the encryption returns a result inequal to the input
* 2) Round-trip through decryption again returns a result equal to the original input
*
* @param service The service to use (either POJO or EJB)
* @throws Throwable
*/
protected void assertEncryption(final EncryptionCommon service) throws Throwable
{
// Log
log.info("assertEncryption");
// Declare the input
final String input = TEST_STRING;
// Hash
final String encrypted = service.encrypt(input);
log.info("Encrypted result of \"" + input + "\": " + encrypted);
// Test that the has function had some effect
TestCase.assertNotSame("The encryption function had no effect upon the supplied input", input, encrypted);
// Get the round-trip result
final String roundTrip = service.decrypt(encrypted);
// Test that the result matches the original input
TestCase.assertEquals("The comparison of the input to its encrypted result failed", input, roundTrip);
}
}
/*
* JBoss, Home of Professional Open Source.
* Copyright 2009, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
* 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 br.ufrn.imd.web2.encryption;
import java.util.logging.Logger;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* Tests to ensure that the business methods of the EncryptionEJB
* are working as expected
*
* @author <a href="mailto:alr@jboss.org">ALR</a>
*/
public class EncryptionUnitTestCase extends EncryptionTestCaseSupport
{
// ---------------------------------------------------------------------------||
// Class Members -------------------------------------------------------------||
// ---------------------------------------------------------------------------||
/**
* Logger
*/
private static final Logger log = Logger.getLogger(EncryptionUnitTestCase.class.getName());
/**
* POJO Encryption Service
*/
private static EncryptionBean encryptionService;
// ---------------------------------------------------------------------------||
// Lifecycle -----------------------------------------------------------------||
// ---------------------------------------------------------------------------||
/**
* Initializes the suite, invoked once before any tests are run
*/
@BeforeClass
public static void initialize() throws Throwable
{
// Create the encryption service as a POJO
encryptionService = new EncryptionBean();
encryptionService.initialize(); // We call init manually here
}
// ---------------------------------------------------------------------------||
// Tests ---------------------------------------------------------------------||
// ---------------------------------------------------------------------------||
/*
* These tests will use the POJO set up in test initialization
*/
/**
* @see {@link EncryptionTestCaseSupport#assertHashing(EncryptionCommonBusiness)}
*/
@Test
public void testHashing() throws Throwable
{
// Log
log.info("testHashing");
// Test via superclass
this.assertHashing(encryptionService);
}
/**
* @see {@link EncryptionTestCaseSupport#assertEncryption(EncryptionCommonBusiness)}
*/
@Test
public void testEncryption() throws Throwable
{
// Log
log.info("testEncryption");
// Test via superclass
this.assertEncryption(encryptionService);
}
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
<!-- ===================================================================== -->
<!-- Log4j Configuration -->
<!-- ===================================================================== -->
<!--
| For more configuration information and examples see the Jakarta Log4j
| website: http://jakarta.apache.org/log4j
-->
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/" debug="false">
<!-- ============================== -->
<!-- Append messages to the console -->
<!-- ============================== -->
<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
<param name="Target" value="System.out"/>
<param name="Threshold" value="INFO"/>
<layout class="org.apache.log4j.PatternLayout">
<param name="ConversionPattern" value="%d %-5r %-5p [%c] (%t:%x) %m%n"/>
</layout>
</appender>
<!-- ================ -->
<!-- Limit categories -->
<!-- ================ -->
<category name="org.jboss.ejb3.examples">
<priority value="ALL"/>
</category>
<!-- ======================= -->
<!-- Setup the Root category -->
<!-- ======================= -->
<root>
<appender-ref ref="CONSOLE"/>
</root>
</log4j:configuration>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="ejbModule"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.jboss.ide.eclipse.as.core.server.runtime.runtimeTarget/WildFly 9.x Runtime">
<attributes>
<attribute name="owner.project.facets" value="jst.utility"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/java">
<attributes>
<attribute name="owner.project.facets" value="java"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Encryption-BeanClient</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.source=1.7
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="Encryption-BeanClient">
<wb-resource deploy-path="/" source-path="/ejbModule"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="WildFly 9.x Runtime"/>
<fixed facet="jst.utility"/>
<fixed facet="java"/>
<installed facet="java" version="1.7"/>
<installed facet="jst.utility" version="1.0"/>
</faceted-project>
Manifest-Version: 1.0
Class-Path:
package br.ufrn.imd.imd0409.encryption;
public interface EncryptionLocalBusiness extends EncryptionCommonBusiness {
}
package br.ufrn.imd.imd0409.encryption;
public interface EncryptionRemoteBusiness extends EncryptionCommonBusiness {
}
/target/