logo
down
shadow

FakeFtpServer with Apache camel - fake user can't even login?


FakeFtpServer with Apache camel - fake user can't even login?

By : Антон Александрович
Date : November 21 2020, 09:01 AM
I wish did fix the issue. There are few things to correct.
the user home in the UserAccount is manadory for the WindowsFakeFileSystem you need to instruct Camel not to step into each directory (see stepwise changing directories, otherwise the access by Camel will fail on a CWD C: (C: is the drive letter of the user home)
code :
public class WindowsAbsolutePath {

    public static void main(String[] args) throws Exception {
        FakeFtpServer fakeFtpServer = new FakeFtpServer();
        fakeFtpServer.setServerControlPort(2222);

        fakeFtpServer.addUserAccount(new UserAccount("ftpUser", "ftpPassword", "C:\\home"));
        WindowsFakeFileSystem fileSystem = new WindowsFakeFileSystem();
        // if the user home is not part of a `FileEntry` it must be explicit added
        fileSystem.add(new DirectoryEntry("C:\\home"));
        fileSystem.add(new FileEntry("C:\\a\\ftp\\some_file.xml", "windows absolute path"));

        fakeFtpServer.setFileSystem(fileSystem);
        fakeFtpServer.start();

        CamelContext context = new DefaultCamelContext();
        RouteBuilder rb = new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // directory with absolute Windows path
                from("ftp://ftpUser@localhost:2222/C:/a/ftp?password=ftpPassword"
                        + "&passiveMode=true&stepwise=false")
                        .to("file:///tmp/local");
            }
        };

        context.addRoutes(rb);
        context.start();
        TimeUnit.SECONDS.sleep(3);
        context.stop();

        fakeFtpServer.stop();
    }
}
public class WindowsRelativePath {

    public static void main(String[] args) throws Exception {
        FakeFtpServer fakeFtpServer = new FakeFtpServer();
        fakeFtpServer.setServerControlPort(2222);

        fakeFtpServer.addUserAccount(new UserAccount("ftpUser", "ftpPassword", "C:\\home"));
        WindowsFakeFileSystem fileSystem = new WindowsFakeFileSystem();
        fileSystem.add(new FileEntry("C:\\home\\a\\ftp\\some_file.xml",
            "Windows relative path"));

        fakeFtpServer.setFileSystem(fileSystem);
        fakeFtpServer.start();

        CamelContext context = new DefaultCamelContext();
        RouteBuilder rb = new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // directory with path relative to user home
                from("ftp://ftpUser@localhost:2222/a/ftp?password=ftpPassword"
                        + "&passiveMode=true&stepwise=false")
                        .to("file:///tmp/local");
            }
        };

        context.addRoutes(rb);
        context.start();
        TimeUnit.SECONDS.sleep(3);
        context.stop();

        fakeFtpServer.stop();
    }
}
public class UnixAbsolutePath {

    public static void main(String[] args) throws Exception {
        FakeFtpServer fakeFtpServer = new FakeFtpServer();
        fakeFtpServer.setServerControlPort(2222);

        fakeFtpServer.addUserAccount(new UserAccount("ftpUser", "ftpPassword",
            "/home/remote"));
        UnixFakeFileSystem fileSystem = new UnixFakeFileSystem();
        fileSystem.add(new DirectoryEntry("/home/remote"));
        fileSystem.add(new FileEntry("/a/ftp/some_file.xml", "Unix absolute path"));

        fakeFtpServer.setFileSystem(fileSystem);
        fakeFtpServer.start();

        CamelContext context = new DefaultCamelContext();
        RouteBuilder rb = new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // directory with absolute path
                from("ftp://ftpUser@localhost:2222//a/ftp?password=ftpPassword"
                        + "&passiveMode=true")
                        .to("file:///tmp/local");
            }
        };

        context.addRoutes(rb);
        context.start();
        TimeUnit.SECONDS.sleep(3);
        context.stop();

        fakeFtpServer.stop();
    }
}
public class UnixRelativePath {

    public static void main(String[] args) throws Exception {
        FakeFtpServer fakeFtpServer = new FakeFtpServer();
        fakeFtpServer.setServerControlPort(2222);

        fakeFtpServer.addUserAccount(new UserAccount("ftpUser", "ftpPassword",
             "/home/remote"));
        UnixFakeFileSystem fileSystem = new UnixFakeFileSystem();
        fileSystem.add(new FileEntry("/home/remote/a/ftp/some_file.xml",
             "Unix relative path"));

        fakeFtpServer.setFileSystem(fileSystem);
        fakeFtpServer.start();

        CamelContext context = new DefaultCamelContext();
        RouteBuilder rb = new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                // directory with path relative to user home
                from("ftp://ftpUser@localhost:2222/a/ftp?password=ftpPassword"
                        + "&passiveMode=true")
                        .to("file:///tmp/local");
            }
        };

        context.addRoutes(rb);
        context.start();
        TimeUnit.SECONDS.sleep(3);
        context.stop();

        fakeFtpServer.stop();
    }
}


Share : facebook icon twitter icon
Redirect user after successful (fake) login in OpenID Offline Provider

Redirect user after successful (fake) login in OpenID Offline Provider


By : user3260989
Date : March 29 2020, 07:55 AM
I wish this helpful for you Check this example: OpenID and OAuth using DotNetOpenAuth in ASP.NET MVC
code :
public ActionResult OpenId(string openIdUrl)
{
    var response = Openid.GetResponse();
    if (response == null)
    {
        // User submitting Identifier
        Identifier id;
        if (Identifier.TryParse(openIdUrl, out id))
        {
            try
            {
                var request = Openid.CreateRequest(openIdUrl);
                var fetch = new FetchRequest();
                fetch.Attributes.AddRequired(WellKnownAttributes.Contact.Email);
                fetch.Attributes.AddRequired(WellKnownAttributes.Name.First);
                fetch.Attributes.AddRequired(WellKnownAttributes.Name.Last);
                request.AddExtension(fetch);
                return request.RedirectingResponse.AsActionResult();
            }
            catch (ProtocolException ex)
            {
                _logger.Error("OpenID Exception...", ex);
                return RedirectToAction("LoginAction");
            }
        }
        _logger.Info("OpenID Error...invalid url. url='" + openIdUrl + "'");
        return RedirectToAction("Login");
    }

    // OpenID Provider sending assertion response
    switch (response.Status)
    {
        case AuthenticationStatus.Authenticated:
            var fetch = response.GetExtension<FetchResponse>();
            string firstName = "unknown";
            string lastName = "unknown";
            string email = "unknown";
            if(fetch!=null)
            {
                firstName = fetch.GetAttributeValue(WellKnownAttributes.Name.First);
                lastName = fetch.GetAttributeValue(WellKnownAttributes.Name.Last);
                email = fetch.GetAttributeValue(WellKnownAttributes.Contact.Email);
            }
            // Authentication       
            FormsAuthentication.SetAuthCookie(userName: email, createPersistentCookie: false);
            // Redirection
            return RedirectToAction("Index", "Products");
        case AuthenticationStatus.Canceled:
            _logger.Info("OpenID: Cancelled at provider.");
            return RedirectToAction("Login");
        case AuthenticationStatus.Failed:
            _logger.Error("OpenID Exception...", response.Exception);
            return RedirectToAction("Login");
    }
    return RedirectToAction("Login");
}
Apache Camel Resequencer with Apache Camel SEDA queue?

Apache Camel Resequencer with Apache Camel SEDA queue?


By : Heath Hoffman
Date : March 29 2020, 07:55 AM
hope this fix your issue Finally I solved this not using the resequencer. I used the PriorityBlockingQueueFactory and in the comparator I use a similar resequencer to camel:
code :
    <bean id="priorityQueueFactory"
        class="org.apache.camel.component.seda.PriorityBlockingQueueFactory">
        <property name="comparator">
            <bean class="com.sg.sgf.service.queues.MyExchangeComparator" />
        </property>
    </bean>
        <route>
            <from uri="seda:priority?queueFactory=#priorityQueueFactory&amp;size=100&amp;concurrentConsumers=5&amp;pollTimeout=10000" />
            <!-- <resequence>
                <batch-config batchSize="300" batchTimeout="40000"
                    allowDuplicates="true" />
                <simple>in.header.priority</simple> -->
                <to uri="exec:cat" />       <!-- the actual executable is set in the job that is passed to the queue -->
                <to uri="bean:batchjobMonitor" />
                <to uri="log:output" />
            <!-- </resequence> -->
        </route>
Apache camel sftp org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert java.io.In

Apache camel sftp org.apache.camel.NoTypeConversionAvailableException: No type converter available to convert java.io.In


By : Tsung-Yi Cæsar Li
Date : March 29 2020, 07:55 AM
wish of those help In the end the following camel context route worked for me with guidance of shelldragon :
code :
 <route id="route5">
            <from id="_from5" uri="direct:sftpGetCDRs"/>
            <process id="_process1" ref="sftpGetDirLocation"/>
            <log id="_log17" message="property ${exchangeProperty.ftpGetDirectory}"/>
            <pollEnrich id="_pollEnrich1" timeout="0" uri="sftp://{{HOST}}//home/admin/ROSS_PULL_CDR/resellers/temp/${body.directoryLocation}/?consumer.delay=60000&amp;username={{USER}}&amp;password={{PASSWD}}"/>
            <log id="_log18" message="${body}"/>
            <to id="_to2" uri="file://{{DB_DIR_LOC}}/temp/?fileName=${exchangeProperty.ftpGetDirectory}&amp;autoCreate=true"/>
        </route>
Apache Camel throws java.lang.NoSuchMethodError: org.apache.camel.util.ObjectHelper.notNull

Apache Camel throws java.lang.NoSuchMethodError: org.apache.camel.util.ObjectHelper.notNull


By : KKH
Date : March 29 2020, 07:55 AM
I hope this helps . This smells like you have multiple different versions of camel JARs on the classpath. Can you double check that thet camel JARs are ALL the SAME version.
Apache Camel with JBoss Fuse 6.2 failed to execute goal org.apache.camel:camel-maven-plugin

Apache Camel with JBoss Fuse 6.2 failed to execute goal org.apache.camel:camel-maven-plugin


By : Pichponreay
Date : March 29 2020, 07:55 AM
I wish did fix the issue. When trying to execute JBoss Fuse 6.2 based project (Local camel context) it's throwing error as below: , Adding another Plugin Repository for Red Hat resolved the issue.
Related Posts Related Posts :
  • IntelliJ - include pom.xml dependencies in lib directory
  • Tomcat 7 : Filtering lifecycle events
  • JSONException: Names must be strings
  • Build Spark JavaRDD List from DropResult objects
  • Include css file in richlet with zk
  • Jackson CSV's WRAP_AS_ARRAY
  • Priority for a web request in Java web applications
  • Is there a better way to format this timestamp to ISO8601?
  • Issue with Spring Scope
  • How to declare and use an array of dictionaries from Python in Java and filter them?
  • Wrong weekdays from Calendar.getDisplayName()
  • ClassNotFoundException when creating new ClassPathXmlApplicationContext
  • Java Method Call from Thread
  • Remove background noise from image to make text more clear for OCR
  • PostgreSQL query always return true
  • How to connect FX controller with main app
  • Is there a difference between these two code snippets, and if so what?
  • When two interfaces have conflicting return types, why does one method become default?
  • Updating database throws errors in To Do List app
  • Where does the url come from?
  • Dagger 2 issue overriding single provides annotated method from a module in a library which app uses
  • Better way then If(x instanceof y) in Java?
  • how to debug maven enunciate plugin tomcat web service
  • Spring Context Initialization fails when upgrading to version 4.2.3
  • spring boot cannot connect to rabbitmq
  • How to Run Unit Test in Parallel Across All Modules Using Maven?
  • Getting the next Value in a ArrayList(Not working)
  • How to wait for a MouseListener mouse press?
  • Java RMI: Blocking for void method return?
  • Get Table Properties out of Hive using Java API
  • Read CSV file and write to another CSV - ArrayIndexOutOfBoundsException and pattern difficuties
  • Set LineChart(javafx) style to a child element
  • ArrayList how catch exception on one item from constructor
  • java.lang.NumberFormatException: For input string: " 1"
  • Dekker's Algorithm not working fine for three processes
  • Maven javadoc plugin - package does not exist
  • NotOLE2FileException: Invalid header signature; read 0x0000000000000000, expected 0xE11AB1A1E011CFD0
  • NullPointerExcpetion on findViewById
  • Java ArrayList initialization
  • Problems on making a Tic Tac Toe Game in Java
  • how to set proxy server details on WebServiceTemplate
  • How can I get a Class object form primitive?
  • How to count rows and Columns of excel sheet in Java
  • Should I split up texture atlas?
  • JavaFX freezing issue
  • What is the JavaFX equivalent of androids AsyncTask?
  • Zenity bash command not working with Java
  • GSON serialize multiple properties to sub object
  • How to convert some elements that satisfy a particular condition in a 2d array into a list in java?
  • Setting LinkedList nodes to null
  • Java Swing ignore text size on JButton
  • Collision detection for separate class instances - Processing Java
  • handle unreal numbers, jump to catch
  • Java - 100 decimal places in variable
  • Cancel previously shown toast before showing new toast
  • projectile motion sim - 'illegal start of type' error
  • How to print out the whole contents of a stack?
  • How to find variable name from a list of class in a package
  • how can i make this dialog close when socket is accepted?
  • I have created a small book program, I am new to java. Can't find what the error or mistake in this code?
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co