Alternative WebDav server connected to JackRabbit - webdav

I am looking for an alternative to JackRabbit SimpleWebdavServer (but still connected to JackRabbit repo).
We have JackRabbit exposed via SimpleWebdavServer. Users can edit doc/docx files stored in repository. Problem is with versioned (checked in) files - JackRabbit apparently does not support auto-checkout/checkin and I am not able to tell MS Word to do checkout/ckeckin. So I am looking for WebDav server implementation that is able do checkout/checkin automatically.

You could look at Milton. Its a purpose built webdav server framework which allows you to abstract access to any data store such as Jackrabbit. Milton supports Dav level 2 (ie locking) and is compatible with all major clients and operating systems. Milton doesnt provide the UI but there are examples showing how to open documents.
Here is a an example implementation:
#Get
public InputStream getImageFile(Image image) throws IOException {
return MyImageUtils.openInputStream(content);
}
#PutChild
public Image uploadImage(Image image, byte[] bytes, ImagesRoot root) throws IOException {
MyImageUtils.writeByteArrayToFile(image, bytes);
return image;
}
There is a bit more to it, you also need methods to locate resources and provide metadata like uniqueID, modified date, etc.
Here's the hello world controller:
https://github.com/miltonio/milton2/blob/master/examples/tuts-anno1/src/main/java/com/helloworld/HelloWorldController.java

Related

Where the vales like Userid and passwords are stored in SSO of BTDF

I have a query regarding BTDF SSO config setting. I am beginner with BizTalk.
I am looking for SSO storage where credentials are stored and retrieved from SSO. I have built-in app located at C:\Program Files (x86)\Deployment Framework for BizTalk 6.0\Framework\DeployToolsork\DeployTools
Could anyone tell me how to store and retrieve from existing SSO config like SSOSettingsEditor which is the default provided by BTDF.
Using BTDF, you can store your configurations as provided in SettingsFileGenerator.xml in BizTalk SSODB. BTDF automatically store your configuration if IncludeSSO property is set to true in btdfproj file.
If you have provided your credential details in SettingsFileGenerator.xml file then only you will find them in SSODB.
You should use SSOSettingsEditor to retrieve or make changes to the configurations. In SSOSettingsEditor, type in your application name and press enter.
Refer to link: BTDF IncludeSSO
BTDF provides a library for modifying SSO Settings that it uses. The method is uses is slightly different from the default Microsoft sample SSO client, so take care regarding which one you're using.
Per that link, the class provides these methods:
namespace SSOSettingsFileManager
{
public static class SSOSettingsManager
{
public static void WriteSetting(string affiliateApplication, string propertyName, string propertyValue);
}
}
It should be fairly straightforward to call that method once you've added a reference to the SSOSettingsFileReader.dll in whatever C# project you have generating your password or updating it, i.e.
string newPassword = GenerateMyPassword();
SSOSettingsFileManager.SSOSettingsManager.WriteSetting("MyApplicationName", "Password", newPassword;);
You could also look at the source of how he's doing it if you want to implement the method yourself.

Change certain resource strings with robolectric

I have a working robolectric and want to test a component of my application that does HTTP request. Since I don't want these requests to go to my live server but instead to a local test server I want to override a string resources (that contains the servers hostname) during testing.
However, I'm not capable of finding anything in the robolectric documentation that goes remotely in the direction I want :(
I've faced a similar issue in Robolectric 3; you can override a resource at application level using Mockito partial mocks.
First, you tell Robolectric to used a partially mocked Application and to return that when the application context is used: (thanks to this answer: https://stackoverflow.com/a/31386831/327648)
RuntimeEnvironment.application = spy(RuntimeEnvironment.application);
when(RuntimeEnvironment.application.getApplicationContext())
.thenReturn(RuntimeEnvironment.application);
Then you partially mock the Resources object:
Resources spiedResources = spy(app.getResources());
when(app.getResources())
.thenReturn(spiedResources);
Then you can do the real override:
when(spiedResources.getString(R.string.server_address))
.thenReturn("local server address");
I hope this helps.
You can use the technique mentioned at http://robolectric.blogspot.com/2013/04/the-test-lifecycle-in-20.html
This will allow you to override getResources() and use spying to return a hardcoded String or (by default) the String loaded from res/values:
#Override
public Resources getResources() {
Resources resources = spy(super.getResources());
when(resources.getString(R.string.server_address)).thenReturn("local test server address");
return resources;
}

What is the query string of a BlazeDS request?

I have a Tomcat service running on localhost:8080 and I have installed BlazeDS. I created and configured a simple hello world application like this...
package com.adobe.remoteobjects;
import java.util.Date;
public class RemoteServiceHandler {
public RemoteServiceHandler()
{
//This is required for the Blaze DS to instantiate the class
}
public String getResults(String name)
{
String result = “Hi ” + name + “, the time is : ” + new Date();
return result;
}
}
With what query string can I invoke RemoteServiceHandler to my Tomcat instance via just a browser? Something like... http://localhost:8080/blazeds/?xyz
Unfortunately you can't. First the requests (and responses) are encoded in AMF and second I believe they have to be POSTs. If you dig through the BlazeDS source code and the Flex SDK's RPC library you can probably figure out what it's sending. But AFAIK this hasn't been documented anywhere else.
I think that AMFX (which is AMF in XML) will work for you, using HTTPChannel instead of AMFChannel.
From http://livedocs.adobe.com/blazeds/1/blazeds_devguide/help.html?content=lcarch_2.html#1073189, Channels and channel sets:
Flex clients can use different channel
types such as the AMFChannel and
HTTPChannel. Channel selection depends
on a number of factors, including the
type of application you are building.
If non-binary data transfer is
required, you would use the
HTTPChannel, which uses a non-binary
format called AMFX (AMF in XML). For
more information about channels, see
Channels and endpoints.
This way you can use simple netcat to send the request.
Not sure how authentication will be handled though, you will probably need do a login using Flash, extract the authentication cookie and then submit it as part of your request.
Please update this thread once you make progress so that we all can learn.

Dynamic download link algorithm

I have seen a couple of websites that have a dynamic download link.
They ask for a valid email address and send the dynamically created download link to that address.
E.X. www.mysite.domain/hashvalue1
But how they do that, since the file exists on the domain in a specific location?
www.mysite.domain/downloads
Is there any guide around this?
They use "UrlRewrite" and a ASP.NET HttpHandler.
UrlRewrite: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
Handler: Downlaod.ashx
using System;
using System.Web;
public class GetDownload : IHttpHandler
{
private static string file = "your file location";
public void ProcessRequest (HttpContext context)
{
if(UsersHasRights(context))
{
context.Response.TransmitFile(file);
}
}
public bool IsReusable
{
get { return false; }
}
}
Yes, Web URL does not have to correspond to the actual file location.
The easiest way to implement this in .NET is to create an IHttpHandler which uses Response.TransmitFile based on hash value.
In this case, URL would be www.mysite.domain/file.ashx?hash=hashvalue1.
You can get better URLs if you use Routing (ASP.NET 3.5 SP1) or some kind of URL rewriter.
This may not be most efficient or best way to do but can solve your problem. You have file at specific location on the server and you know it when user clicks or request for downloading. You get email address and together from file name or path and email create hash you can add some salt to it to really randomize it even if same user requests the same file again and again. Now put this hash, filename and salt (if you have one) into a database table. You can also have expirey date-time for link.
You can send user link like this site.com/files.dld?hash and implement IHttpHandler to handle this extension (see this answer by Andrey Shchekin). Here is also an article describing use of HttpHandler to provide download of zip files.

Posting base64 encoded files to an asp.net 1.1 page

We are making an automated patching application and would like to post files on production server through asp.net page (or maybe a web service), since we can only access production server via http. The page should accept files and store them to appropriate location. The path to files will be declared in external XML file.
So, is it possible posting a base64 encoded files within body tag and HOW? maybe even any better approach?
If you plan to use Base64 encoding.
Take a look at
System.Convert.ToBase64String()
System.Convert.FromBase64String()
System.Convert.ToBase64CharArray()
System.Convert.FromBase64CharArray()
See Using XML CDATA nodes to send files via a Web Service
why not create a webservice which accepts an object like:
class postfile
{
public byte[] fileByte;
public string fileName;
}
Then add a web reference in your client app.
.net will serialize the object for you.
You will need to secure this using wse security and might require the service use impersonation to write the file on the server.

Resources