Skip to content

Commit

Permalink
refactor code for easier understanding
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Zwirn committed Jul 12, 2024
1 parent dcd23fa commit c38db71
Show file tree
Hide file tree
Showing 113 changed files with 3,053 additions and 2,704 deletions.
6 changes: 4 additions & 2 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 6 additions & 10 deletions interconnect/core-legacy/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@
<artifactId>dvalin-interconnect-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.taimos</groupId>
<artifactId>dvalin-interonnect-core-legacy-exceptions</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>de.taimos</groupId>
<artifactId>dvalin-jms-core</artifactId>
<version>${project.version}</version>
</dependency>

<dependency>
<groupId>org.apache.activemq</groupId>
Expand Down Expand Up @@ -116,5 +106,11 @@
<version>${org.springframework.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>javax.jms</groupId>
<artifactId>javax.jms-api</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.ExceptionListener;
import javax.jms.JMSContext;
import javax.jms.JMSException;

/**
Expand Down Expand Up @@ -153,24 +152,4 @@ public Connection createConnection() throws JMSException {
public Connection createConnection(String userName, String password) throws JMSException {
return this.innerAdapter.createConnection(userName, password);
}

@Override
public JMSContext createContext() {
return this.innerAdapter.createContext();
}

@Override
public JMSContext createContext(String userName, String password) {
return this.innerAdapter.createContext(userName, password);
}

@Override
public JMSContext createContext(String userName, String password, int sessionMode) {
return this.innerAdapter.createContext(userName, password, sessionMode);
}

@Override
public JMSContext createContext(int sessionMode) {
return this.innerAdapter.createContext(sessionMode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
import com.google.common.base.Preconditions;

import de.taimos.dvalin.interconnect.core.exceptions.InfrastructureException;
import de.taimos.dvalin.interconnect.core.exceptions.MessageCryptoException;
import de.taimos.dvalin.interconnect.model.InterconnectMapper;
import de.taimos.dvalin.interconnect.model.InterconnectObject;
import de.taimos.dvalin.jms.exceptions.MessageCryptoException;

/**
* Connector to connect to Interconnect.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
* #L%
*/

import de.taimos.dvalin.interconnect.core.crypto.JmsMessageCryptoUtil;
import de.taimos.dvalin.interconnect.core.exceptions.InfrastructureException;
import de.taimos.dvalin.interconnect.core.exceptions.MessageCryptoException;
import de.taimos.dvalin.interconnect.core.exceptions.SerializationException;
import de.taimos.dvalin.interconnect.core.exceptions.TimeoutException;
import de.taimos.dvalin.jms.crypto.JmsMessageCryptoUtil;
import de.taimos.dvalin.jms.exceptions.MessageCryptoException;
import org.apache.activemq.command.ActiveMQTextMessage;
import org.apache.activemq.pool.PooledConnectionFactory;
import org.slf4j.Logger;
Expand Down Expand Up @@ -299,7 +299,7 @@ private static void sendToDestination(final GetDestinationAction getDestinationA
* @param replyToQueueName the name of the queue to reply to or null
* @param correlationId the correlated id
* @throws InfrastructureException on errors
* @throws MessageCryptoException on secure transport errors
* @throws MessageCryptoException on secure transport errors
*/
private static void sendToDestination(final boolean isQueue, final String destinationName, final String body, final Map<String, Object> headers, final boolean secure, final String replyToQueueName, final String correlationId) throws InfrastructureException, MessageCryptoException {
MessageConnector.sendToDestination(new GetResolveDestinationAction(isQueue, destinationName), body, headers,
Expand All @@ -314,7 +314,7 @@ private static void sendToDestination(final boolean isQueue, final String destin
* @param replyToQueueName the name of the queue to reply to or null
* @param correlationId the correlated id
* @throws InfrastructureException on errors
* @throws MessageCryptoException on secure transport errors
* @throws MessageCryptoException on secure transport errors
*/
public static void sendToDestination(final Destination destination, final String body, final Map<String, Object> headers, final boolean secure, final String replyToQueueName, final String correlationId) throws InfrastructureException, MessageCryptoException {
MessageConnector.sendToDestination(new GetSimpleDestinationAction(destination), body, headers, secure,
Expand All @@ -329,7 +329,7 @@ public static void sendToDestination(final Destination destination, final String
* @param replyToQueueName the name of the queue to reply to or null
* @param correlationId the correlated id
* @throws InfrastructureException on errors
* @throws MessageCryptoException on secure transport errors
* @throws MessageCryptoException on secure transport errors
*/
public static void sendToQueue(final String queueName, final String body, final Map<String, Object> headers, final boolean secure, final String replyToQueueName, final String correlationId) throws InfrastructureException, MessageCryptoException {
MessageConnector.sendToDestination(true, queueName, body, headers, secure, replyToQueueName, correlationId);
Expand All @@ -341,7 +341,7 @@ public static void sendToQueue(final String queueName, final String body, final
* @param headers the request headers
* @param secure enable secure transport
* @throws InfrastructureException on errors
* @throws MessageCryptoException on secure transport errors
* @throws MessageCryptoException on secure transport errors
*/
public static void sendToQueue(final String queueName, final String body, final Map<String, Object> headers, final boolean secure) throws InfrastructureException, MessageCryptoException {
MessageConnector.sendToQueue(queueName, body, headers, secure, null, null);
Expand Down Expand Up @@ -383,7 +383,7 @@ public static void sendToQueue(final String queueName, final String body, final
* @param headers the request headers
* @param secure enable secure transport
* @throws InfrastructureException on errors
* @throws MessageCryptoException on secure transport errors
* @throws MessageCryptoException on secure transport errors
*/
public static void sendToTopic(final String topicName, final String body, final Map<String, Object> headers, final boolean secure) throws InfrastructureException, MessageCryptoException {
MessageConnector.sendToDestination(false, topicName, body, headers, secure, null, null);
Expand All @@ -410,7 +410,7 @@ public static void sendToTopic(final String topicName, final String body, final
* @param secure enable secure transport
* @return the received {@link TextMessage}
* @throws InfrastructureException on errors
* @throws MessageCryptoException on crypto errors
* @throws MessageCryptoException on crypto errors
* @deprecated use receiveFromQueue instead
*/
@Deprecated
Expand Down Expand Up @@ -521,7 +521,7 @@ private static TextMessage receiveFromDestination(final GetDestinationAction get
* @param secure enable secure transport
* @return the received {@link TextMessage}
* @throws InfrastructureException on errors
* @throws MessageCryptoException on crypto errors
* @throws MessageCryptoException on crypto errors
*/
public static TextMessage receiveFromQueue(final String queueName, final String selector, final long timeout, final boolean secure) throws InfrastructureException, MessageCryptoException {
return MessageConnector.receiveFromDestination(new GetResolveDestinationAction(true, queueName), selector,
Expand All @@ -536,7 +536,7 @@ public static TextMessage receiveFromQueue(final String queueName, final String
* @param secure enable secure transport
* @return the received {@link TextMessage}s
* @throws InfrastructureException on errors
* @throws MessageCryptoException on crypto errors
* @throws MessageCryptoException on crypto errors
*/
public static List<TextMessage> receiveBulkFromQueue(final String queueName, final String selector, final int maxSize, final long timeout, final boolean secure) throws InfrastructureException, MessageCryptoException {
return MessageConnector.receiveBulkFromDestination(new GetResolveDestinationAction(true, queueName), selector,
Expand All @@ -550,7 +550,7 @@ public static List<TextMessage> receiveBulkFromQueue(final String queueName, fin
* @param secure enable secure transport
* @return the received {@link TextMessage}
* @throws InfrastructureException on errors
* @throws MessageCryptoException on crypto errors
* @throws MessageCryptoException on crypto errors
*/
public static TextMessage receiveFromTopic(final String topicName, final String selector, final long timeout, final boolean secure) throws InfrastructureException, MessageCryptoException {
return MessageConnector.receiveFromDestination(new GetResolveDestinationAction(false, topicName), selector,
Expand All @@ -565,7 +565,7 @@ public static TextMessage receiveFromTopic(final String topicName, final String
* @param secure enable secure transport
* @return the received {@link TextMessage}s
* @throws InfrastructureException on errors
* @throws MessageCryptoException on crypto errors
* @throws MessageCryptoException on crypto errors
*/
public static List<TextMessage> receiveBulkFromTopic(final String topicName, final String selector, final int maxSize, final long timeout, final boolean secure) throws InfrastructureException, MessageCryptoException {
return MessageConnector.receiveBulkFromDestination(new GetResolveDestinationAction(false, topicName), selector,
Expand All @@ -582,7 +582,7 @@ public static List<TextMessage> receiveBulkFromTopic(final String topicName, fin
* @param priority the message priority
* @return the response {@link TextMessage}
* @throws InfrastructureException on errors
* @throws MessageCryptoException on secure transport errors
* @throws MessageCryptoException on secure transport errors
*/
public static TextMessage request(final String queueName, final String body, final Map<String, Object> headers, final boolean secure, final long receiveTimeout, final long sendTimeout, final int priority) throws InfrastructureException, MessageCryptoException {
MessageConnector.checkInit();
Expand Down Expand Up @@ -712,7 +712,7 @@ public static TextMessage request(final String queueName, final String body, fin
/**
* @param txt the message to encrypt
* @return if message is secure
* @throws MessageCryptoException on crypto errors
* @throws MessageCryptoException on crypto errors
* @throws InfrastructureException on infrastructure exception
*/
public static boolean isMessageSecure(final TextMessage txt) throws MessageCryptoException, InfrastructureException {
Expand Down Expand Up @@ -751,7 +751,7 @@ public static void decryptMessage(final TextMessage txt) throws MessageCryptoExc

/**
* @param txt the message to encrypt
* @throws JMSException on JMS errors
* @throws JMSException on JMS errors
* @throws MessageCryptoException on crypto errors
*/
public static void secureMessage(final TextMessage txt) throws JMSException, MessageCryptoException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package de.taimos.dvalin.jms.crypto;
package de.taimos.dvalin.interconnect.core.crypto;

import de.taimos.dvalin.jms.exceptions.MessageCryptoException;
import org.springframework.stereotype.Service;

import de.taimos.dvalin.interconnect.core.exceptions.MessageCryptoException;

import javax.jms.JMSException;
import javax.jms.TextMessage;
Expand All @@ -12,8 +12,7 @@
*
* @author fzwirn
*/
@Service
public class CryptoService implements ICryptoService {
public abstract class ACryptoService implements ICryptoService {


@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package de.taimos.dvalin.interconnect.core.crypto;

import de.taimos.dvalin.interconnect.core.exceptions.InfrastructureException;
import de.taimos.dvalin.interconnect.core.exceptions.MessageCryptoException;

import javax.jms.JMSException;
import javax.jms.TextMessage;

/**
* Copyright 2024 Cinovo AG<br>
* <br>
*
* @author fzwirn
*/
public interface ICryptoService {

/**
* @param txt the message to encrypt
* @return if message is secure
* @throws MessageCryptoException on crypto errors
* @throws InfrastructureException on infrastructure exception
*/
boolean isMessageSecure(final TextMessage txt) throws MessageCryptoException, InfrastructureException, MessageCryptoException;

/**
* @param txt the message to encrypt
* @return the decrypted text message
* @throws MessageCryptoException on crypto errors
*/
TextMessage decryptMessage(final TextMessage txt) throws MessageCryptoException;

/**
* @param txt the message to encrypt
* @return the secured text message
* @throws JMSException on JMS errors
* @throws MessageCryptoException on crypto errors
*/
TextMessage secureMessage(final TextMessage txt) throws JMSException, MessageCryptoException;
}
Loading

0 comments on commit c38db71

Please sign in to comment.