mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Exported AuthenticationService via RMI. Insecure for now but we can switch over
to using SSL when needed. Restructured exports of AVM specific apis to authenticate remotely and pass the ticket with each remote service call. These required some changes to jndi-client and even to the web-client which uses the AVM remote interface within the Alfresco server. Oh, the point of this is that since I'm writing some CLTs, I might as well do them correctly; we'll need the option of security sooner rather than later. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@4489 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -17,11 +17,15 @@
|
||||
|
||||
package org.alfresco.repo.avm;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.List;
|
||||
|
||||
import org.alfresco.repo.avm.clt.ClientTicketHolder;
|
||||
import org.alfresco.service.cmr.avm.AVMStoreDescriptor;
|
||||
import org.alfresco.service.cmr.avmsync.AVMDifference;
|
||||
import org.alfresco.service.cmr.avmsync.AVMSyncService;
|
||||
import org.alfresco.service.cmr.security.AuthenticationService;
|
||||
import org.springframework.context.support.FileSystemXmlApplicationContext;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
@@ -42,6 +46,11 @@ public class AVMTestRemote extends TestCase
|
||||
*/
|
||||
private AVMSyncService fAVMSync;
|
||||
|
||||
/**
|
||||
* The Authentication Service.
|
||||
*/
|
||||
private AuthenticationService fAuthService;
|
||||
|
||||
/**
|
||||
* The application context.
|
||||
*/
|
||||
@@ -52,7 +61,11 @@ public class AVMTestRemote extends TestCase
|
||||
{
|
||||
fContext = new FileSystemXmlApplicationContext("config/alfresco/remote-avm-test-context.xml");
|
||||
fAVMRemote = (AVMRemote)fContext.getBean("avmRemote");
|
||||
fAVMSync = (AVMSyncService)fContext.getBean("avmSync");
|
||||
fAVMSync = (AVMSyncService)fContext.getBean("avmSyncService");
|
||||
fAuthService = (AuthenticationService)fContext.getBean("authenticationService");
|
||||
fAuthService.authenticate("admin", "admin".toCharArray());
|
||||
String ticket = fAuthService.getCurrentTicket();
|
||||
ClientTicketHolder.SetTicket(ticket);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,18 +111,16 @@ public class AVMTestRemote extends TestCase
|
||||
// Create a directory.
|
||||
fAVMRemote.createDirectory("test2933:/", "a");
|
||||
// Write out a file.
|
||||
AVMRemoteOutputStream out =
|
||||
new AVMRemoteOutputStream(fAVMRemote.createFile("test2933:/a", "foo.txt"),
|
||||
fAVMRemote);
|
||||
OutputStream out =
|
||||
fAVMRemote.createFile("test2933:/a", "foo.txt");
|
||||
byte [] buff = "This is a plain old text file.\n".getBytes();
|
||||
out.write(buff);
|
||||
buff = "It contains text.\n".getBytes();
|
||||
out.write(buff);
|
||||
out.close();
|
||||
// Read back that file.
|
||||
AVMRemoteInputStream in =
|
||||
new AVMRemoteInputStream(fAVMRemote.getInputHandle(-1, "test2933:/a/foo.txt"),
|
||||
fAVMRemote);
|
||||
InputStream in =
|
||||
fAVMRemote.getFileInputStream(-1, "test2933:/a/foo.txt");
|
||||
buff = new byte[1024];
|
||||
assertEquals(49, in.read(buff));
|
||||
System.out.print(new String(buff));
|
||||
@@ -136,15 +147,13 @@ public class AVMTestRemote extends TestCase
|
||||
{
|
||||
buff[i] = (byte)i;
|
||||
}
|
||||
AVMRemoteOutputStream out =
|
||||
new AVMRemoteOutputStream(fAVMRemote.createFile("froo:/", "foo.dat"),
|
||||
fAVMRemote);
|
||||
OutputStream out =
|
||||
fAVMRemote.createFile("froo:/", "foo.dat");
|
||||
out.write(buff, 32, 32);
|
||||
out.close();
|
||||
// Read it back in.
|
||||
AVMRemoteInputStream in =
|
||||
new AVMRemoteInputStream(fAVMRemote.getInputHandle(-1, "froo:/foo.dat"),
|
||||
fAVMRemote);
|
||||
InputStream in =
|
||||
fAVMRemote.getFileInputStream(-1, "froo:/foo.dat");
|
||||
buff = new byte[1024];
|
||||
assertEquals(32, in.read(buff));
|
||||
in.close();
|
||||
@@ -184,14 +193,14 @@ public class AVMTestRemote extends TestCase
|
||||
// Create a directory.
|
||||
fAVMRemote.createDirectory("froo:/", "a");
|
||||
// Create a file.
|
||||
fAVMRemote.closeOutputHandle(fAVMRemote.createFile("froo:/a", "foo"));
|
||||
fAVMRemote.createFile("froo:/a", "foo").close();
|
||||
// Create another store.
|
||||
fAVMRemote.createAVMStore("broo");
|
||||
// Create a branch.
|
||||
fAVMRemote.createBranch(-1, "froo:/a", "broo:/", "a");
|
||||
List<AVMDifference> diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a");
|
||||
assertEquals(0, diffs.size());
|
||||
fAVMRemote.closeOutputHandle(fAVMRemote.createFile("froo:/a", "bar"));
|
||||
fAVMRemote.createFile("froo:/a", "bar").close();
|
||||
diffs = fAVMSync.compare(-1, "froo:/a", -1, "broo:/a");
|
||||
assertEquals(1, diffs.size());
|
||||
// Update.
|
||||
|
Reference in New Issue
Block a user