/** * Get user/password from URI. * * @throws Exception if something goes wrong */ public void testUserPasswordURI() throws Exception { EndpointURI endpointUri = new MuleEndpointURI("legstar-wmq://user:[email protected]", muleContext); endpointUri.initialise(); assertEquals("legstar-wmq", endpointUri.getScheme()); assertEquals("legstar-wmq", endpointUri.getSchemeMetaInfo()); assertEquals("CICS01.BRIDGE.REQUEST.QUEUE", endpointUri.getAddress()); assertEquals("user:password", endpointUri.getUserInfo()); assertEquals("user", endpointUri.getUser()); assertEquals("password", endpointUri.getPassword()); }
@Override protected void doConnect() throws Exception { if (folder == null || !folder.isOpen()) { Store store = castConnector().getSessionDetails(endpoint).newStore(); EndpointURI uri = endpoint.getEndpointURI(); String encoding = endpoint.getEncoding(); String user = (uri.getUser() != null ? URLDecoder.decode(uri.getUser(), encoding) : null); String pass = (uri.getPassword() != null ? URLDecoder.decode(uri.getPassword(), encoding) : null); store.connect(uri.getHost(), uri.getPort(), user, pass); folder = store.getFolder(castConnector().getMailboxFolder()); ensureFolderIsOpen(folder); if (castConnector().getMoveToFolder() != null) { moveToFolder = store.getFolder(castConnector().getMoveToFolder()); ensureFolderIsOpen(moveToFolder); } } }
protected void doConnect() throws Exception { if (transport == null) { try { transport = castConnector().getSessionDetails(endpoint).newTransport(); EndpointURI uri = endpoint.getEndpointURI(); transport.connect(uri.getHost(), uri.getPort(), uri.getUser(), uri.getPassword()); } catch (Exception e) { throw new EndpointException( org.mule.config.i18n.MessageFactory.createStaticMessage( "Unable to connect to mail transport."), e); } } }
protected void sendMailMessage(Message message) throws MessagingException { // sent date message.setSentDate(Calendar.getInstance().getTime()); /* * Double check that the transport is still connected as some SMTP servers may * disconnect idle connections. */ if (!transport.isConnected()) { EndpointURI uri = endpoint.getEndpointURI(); if (logger.isInfoEnabled()) { logger.info("Connection closed by remote server. Reconnecting."); } transport.connect(uri.getHost(), uri.getPort(), uri.getUser(), uri.getPassword()); } transport.sendMessage(message, message.getAllRecipients()); if (logger.isDebugEnabled()) { StringBuffer msg = new StringBuffer(); msg.append("Email message sent with subject'") .append(message.getSubject()) .append("' sent- "); msg.append(", From: ").append(MailUtils.mailAddressesToString(message.getFrom())).append(" "); msg.append(", To: ") .append(MailUtils.mailAddressesToString(message.getRecipients(Message.RecipientType.TO))) .append(" "); msg.append(", Cc: ") .append(MailUtils.mailAddressesToString(message.getRecipients(Message.RecipientType.CC))) .append(" "); msg.append(", Bcc: ") .append(MailUtils.mailAddressesToString(message.getRecipients(Message.RecipientType.BCC))) .append(" "); msg.append(", ReplyTo: ").append(MailUtils.mailAddressesToString(message.getReplyTo())); logger.debug(msg.toString()); } }