test_class.declarator: log = LoggerFactory.getLogger(ValidateSenderIdTransformerTest.class)
test_class.modifier: private final static
test_class.original_string: private final static Logger log = LoggerFactory.getLogger(ValidateSenderIdTransformerTest.class);
test_class.type: Logger
test_class.var_name: log
test_class.declarator: transformer = null
test_class.modifier: private
test_class.original_string: private ValidateSenderIdTransformer transformer = null;
test_class.type: ValidateSenderIdTransformer
test_class.var_name: transformer
test_class.file: commons/components/commons-mule/src/test/java/org/soitoolkit/commons/mule/cert/ValidateSenderIdTransformerTest.java
test_class.identifier: ValidateSenderIdTransformerTest
test_case.body: @Test
  	public void transformMessage() throws TransformerException {
  		
  		final MuleMessage muleMessageMock = mock(MuleMessage.class);
  		
  		transformer = new ValidateSenderIdTransformer() {
  			protected X509CertificateEvaluator getX509CertificateEvaluator(String property) {
  				X509CertificateEvaluator evaluator = mock(X509CertificateEvaluator.class);
  				evaluator.setPropertyName("CN");
  				when(evaluator.evaluate(X509CertificateEvaluator.EXPR_SENDERID, muleMessageMock)).thenReturn("1234");
  				return evaluator; 
  			};
  		};
  		
  		transformer.setValidSenderIds("1234");
  		
  		transformer.transformMessage(muleMessageMock, null);
  		
  		verify(muleMessageMock, times(1)).setSessionProperty("Sender", "1234");
  	}
test_case.class_method_signature: ValidateSenderIdTransformerTest.transformMessage()
test_case.full_signature: @Test public void transformMessage()
test_case.identifier: transformMessage
test_case.invocations: mock mock setPropertyName thenReturn when evaluate setValidSenderIds transformMessage setSessionProperty verify times
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void transformMessage()
focal_class.declarator: log = LoggerFactory.getLogger(ValidateSenderIdTransformer.class)
focal_class.modifier: private static final
focal_class.original_string: private static final Logger log = LoggerFactory.getLogger(ValidateSenderIdTransformer.class);
focal_class.type: Logger
focal_class.var_name: log
focal_class.declarator: senderIdPropertyName
focal_class.modifier: private
focal_class.original_string: private String  senderIdPropertyName;
focal_class.type: String
focal_class.var_name: senderIdPropertyName
focal_class.declarator: validSenderIds
focal_class.modifier: private
focal_class.original_string: private List<String> validSenderIds;
focal_class.type: List<String>
focal_class.var_name: validSenderIds
focal_class.file: commons/components/commons-mule/src/main/java/org/soitoolkit/commons/mule/cert/ValidateSenderIdTransformer.java
focal_class.identifier: ValidateSenderIdTransformer
focal_class.interfaces: implements MuleContextAware
focal_class.class_method_signature: ValidateSenderIdTransformer.setSenderIdPropertyName(String senderIdPropertyName)
focal_class.full_signature: public void setSenderIdPropertyName(String senderIdPropertyName)
focal_class.identifier: setSenderIdPropertyName
focal_class.modifiers: public
focal_class.parameters: (String senderIdPropertyName)
focal_class.return: void
focal_class.signature: void setSenderIdPropertyName(String senderIdPropertyName)
focal_class.class_method_signature: ValidateSenderIdTransformer.setValidSenderIds(String validSenderIds)
focal_class.full_signature: public void setValidSenderIds(String validSenderIds)
focal_class.identifier: setValidSenderIds
focal_class.modifiers: public
focal_class.parameters: (String validSenderIds)
focal_class.return: void
focal_class.signature: void setValidSenderIds(String validSenderIds)
focal_class.class_method_signature: ValidateSenderIdTransformer.getX509CertificateEvaluator(String property)
focal_class.full_signature: protected X509CertificateEvaluator getX509CertificateEvaluator(String property)
focal_class.identifier: getX509CertificateEvaluator
focal_class.modifiers: protected
focal_class.parameters: (String property)
focal_class.return: X509CertificateEvaluator
focal_class.signature: X509CertificateEvaluator getX509CertificateEvaluator(String property)
focal_class.class_method_signature: ValidateSenderIdTransformer.transformMessage(MuleMessage message, String outputEncoding)
focal_class.full_signature: @Override public Object transformMessage(MuleMessage message, String outputEncoding)
focal_class.identifier: transformMessage
focal_class.modifiers: @Override public
focal_class.parameters: (MuleMessage message, String outputEncoding)
focal_class.return: Object
focal_class.signature: Object transformMessage(MuleMessage message, String outputEncoding)
focal_class.class_method_signature: ValidateSenderIdTransformer.logAndThrowError(String errorMessage)
focal_class.full_signature: private void logAndThrowError(String errorMessage)
focal_class.identifier: logAndThrowError
focal_class.modifiers: private
focal_class.parameters: (String errorMessage)
focal_class.return: void
focal_class.signature: void logAndThrowError(String errorMessage)
focal_class.superclass: extends AbstractMessageTransformer
focal_method.body: @Override
  	public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
  
  		X509CertificateEvaluator eval = this.getX509CertificateEvaluator(senderIdPropertyName);
  		
  		String senderId = (String) eval.evaluate(X509CertificateEvaluator.EXPR_SENDERID, message);
  		
  		// add to message header
  		if (senderId != null) {
  			message.setSessionProperty("Sender", senderId);
  		} else {
  			message.setSessionProperty("Sender", "");
  		}
  			
  		if (validSenderIds.contains(senderId)) {
  			log.debug("{} is a valid senderId!", senderId);
  		} else {
  			logAndThrowError("Invalid senderId [" + senderId + "], allowed senderIds are: " + validSenderIds);
  		}
  
  		return message;
      }
focal_method.class_method_signature: ValidateSenderIdTransformer.transformMessage(MuleMessage message, String outputEncoding)
focal_method.full_signature: @Override public Object transformMessage(MuleMessage message, String outputEncoding)
focal_method.identifier: transformMessage
focal_method.invocations: getX509CertificateEvaluator evaluate setSessionProperty setSessionProperty contains debug logAndThrowError
focal_method.modifiers: @Override public
focal_method.parameters: (MuleMessage message, String outputEncoding)
focal_method.return: Object
focal_method.signature: Object transformMessage(MuleMessage message, String outputEncoding)