From: <bsc...@us...> - 2007-10-18 19:22:25
|
Revision: 1774 http://unicore.svn.sourceforge.net/unicore/?rev=1774&view=rev Author: bschuller Date: 2007-10-18 12:21:43 -0700 (Thu, 18 Oct 2007) Log Message: ----------- initial version of the http(s) filetransfer using the default Jetty server (needs latest uas-types and wsrflite) Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/resources/uas.config unicorex/uas-core/trunk/src/test/resources/wsrflite.xml Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2007-10-18 18:25:51 UTC (rev 1773) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -171,6 +171,8 @@ private static ArrayList<Observer>obs=new ArrayList<Observer>(); + private static JettyServer jettyServer; + public static final String writeHeader(){ return "\n UNICORE Atomic Services Implementation "+VERSION+ "\n (c) Forschungszentrum Juelich 2006-2007" + @@ -240,6 +242,10 @@ return securityProperties; } + public static JettyServer getJettyServer(){ + return jettyServer; + } + //a default configuration including the Unicore Atomic Services public static final String wsrfConfig = "<services>" @@ -534,7 +540,8 @@ long start=System.currentTimeMillis(); System.out.println(writeHeader()); deployServices(); - new JettyServer().start(); + jettyServer=new JettyServer(); + jettyServer.start(); Thread.sleep(500); runStartupCode(); initJMX(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java 2007-10-18 18:25:51 UTC (rev 1773) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -34,7 +34,6 @@ package de.fzj.unicore.uas.fts; import java.util.Map; -import java.util.logging.Level; import java.util.logging.Logger; import de.fzj.unicore.uas.UAS; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java 2007-10-18 18:25:51 UTC (rev 1773) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -131,7 +131,7 @@ * For example, the config entry * "uas.filetransfer.protocol.HTTP=my.class.for.http" * will map the given class to the HTTP protocol. - * The class must extend FileTransferImpl + * The class must extend {@link FileTransferImpl} */ public static final String CONFIG_PROTOCOL_KEY="uas.filetransfer.protocol."; Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -0,0 +1,97 @@ +package de.fzj.unicore.uas.fts.http; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.HttpURLConnection; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +import org.mortbay.jetty.servlet.DefaultServlet; +import org.mortbay.resource.FileResource; +import org.mortbay.resource.Resource; + +import de.fzj.unicore.uas.UAS; + +/** + * this servlet exposes files under a "hard to guess" URL + * + * @author schuller + */ +public class FileServlet extends DefaultServlet { + + private static final long serialVersionUID = 1L; + + private static Logger logger=Logger.getLogger(FileServlet.class.getName()); + + private static Map<String,FileResource> map=new HashMap<String,FileResource>(); + + public FileServlet(){ + + } + + public static void initialise(){ + logger.info("Initialising file serving via HTTP..."); + UAS.getJettyServer().getRootContext().addServlet(FileServlet.class.getName(), "/files/*"); + } + + public static void exposeFile(String id, String remotePath){ + logger.info("Exposing via HTTP: "+remotePath); + try{ + FileResource fr=new FileResource(new URL("file:"+remotePath)); + map.put(id,fr); + } + catch(Exception mue){ + logger.log(Level.SEVERE,"",mue); + } + + } + + public static void unExposeFile(String id){ + map.remove(id); + } + + + @Override + public Resource getResource(String pathInContext) { + logger.info("Requested resource: "+pathInContext); + String id=pathInContext.split("/")[2]; + logger.info("ID="+id); + FileResource fr=map.get(id); + logger.info("Resource="+fr); + if(fr!=null)logger.info("Path="+fr.getURL()); + return fr; + } + + + private static final int BUFFER_SIZE = 2048; + + @Override + protected void doPut(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { + + Resource r=getResource(request.getRequestURI()); + + OutputStream out = r.getOutputStream(); + InputStream in = request.getInputStream(); + + byte[] buffer = new byte[BUFFER_SIZE]; + for (int c = in.read(buffer); c != -1; c = in.read(buffer)) { + out.write(buffer, 0, c); + } + out.close(); + + response.setStatus(HttpURLConnection.HTTP_NO_CONTENT); // we return no content + } + + + +} Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -0,0 +1,84 @@ +package de.fzj.unicore.uas.fts.http; + +import java.io.InputStream; +import java.io.OutputStream; + +import javax.xml.namespace.QName; + +import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.InputStreamRequestEntity; +import org.apache.commons.httpclient.methods.PutMethod; +import org.mortbay.util.IO; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.client.BaseUASClient; +import de.fzj.unicore.uas.ft.http.AccessURLDocument; +import de.fzj.unicore.uas.security.IUASSecurityProperties; +import de.fzj.unicore.wsrflite.xfire.http.HttpUtils; + +public class HttpFileTransferClient extends BaseUASClient { + + protected String accessURL; + + protected QName RPAccessURL=AccessURLDocument.type.getDocumentElementName(); + + public HttpFileTransferClient(EndpointReferenceType epr) throws Exception { + super(epr); + doInit(); + } + + public HttpFileTransferClient(String url, EndpointReferenceType epr, IUASSecurityProperties sec) throws Exception { + super(url, epr, sec); + doInit(); + } + + public HttpFileTransferClient(String url, EndpointReferenceType epr) throws Exception { + super(url, epr); + doInit(); + } + + protected void doInit()throws Exception{ + accessURL=AccessURLDocument.Factory.parse(getResourceProperty(RPAccessURL)).getAccessURL(); + } + + /** + * read remote data and copy to the given output stream + * @param os + * @throws Exception + */ + public void readAllData(OutputStream os)throws Exception{ + HttpClient client =HttpUtils.createClient(accessURL); + client.setHostConfiguration(HttpUtils.getHostConfiguration(getSecurityProperties())); + GetMethod get=new GetMethod(accessURL); + + try{ + client.executeMethod(get); + InputStream is=get.getResponseBodyAsStream(); + //Jetty dep here might not in fact be needed... + IO.copy(is, os); + }finally{ + get.releaseConnection(); + } + } + + + /** + * read remote data and copy to the given output stream + * @param os + * @throws Exception + */ + public void writeAllData(InputStream is)throws Exception{ + HttpClient client =HttpUtils.createClient(accessURL); + client.setHostConfiguration(HttpUtils.getHostConfiguration(getSecurityProperties())); + PutMethod put=new PutMethod(accessURL); + put.setRequestEntity(new InputStreamRequestEntity(is)); + put.setContentChunked(true); + try{ + client.executeMethod(put); + }finally{ + put.releaseConnection(); + } + } + +} Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -0,0 +1,85 @@ +package de.fzj.unicore.uas.fts.http; + +import java.util.Map; + +import javax.xml.namespace.QName; + +import de.fzj.unicore.uas.ft.http.AccessURLDocument; +import de.fzj.unicore.uas.ft.http.HTTPFileTransferRPDocument; +import de.fzj.unicore.uas.fts.FileTransferImpl; +import de.fzj.unicore.wsrflite.Kernel; +import de.fzj.unicore.wsrflite.persistence.Persist; +import de.fzj.unicore.wsrflite.security.ISecurityProperties; +import de.fzj.unicore.wsrflite.utils.Utilities; +import de.fzj.unicore.wsrflite.xmlbeans.rp.ImmutableResourceProperty; + +/** + * Exposes a file using HTTP(s) via Jetty + * + * The URI for download is "cryptographically hard to guess" and + * is exposed using a WSRF resource property, thus protected + * by the usual U6 access control.<br/> + * + * Based on an idea by Roger Menday. <br/> + * + * @author schuller + * + */ +public class HttpFileTransferImpl extends FileTransferImpl{ + protected static final long serialVersionUID=1L; + + public static QName RPAccessURL=AccessURLDocument.type.getDocumentElementName(); + + @Persist + private String unique; + + @Persist + private String accessURL; + + @Override + public void initialise(String name, Map<String, Object> map)throws Exception{ + super.initialise(name, map); + FileServlet.initialise(); + String url=exposeFile(); + AccessURLDocument urlRP=AccessURLDocument.Factory.newInstance(); + urlRP.setAccessURL(url); + properties.put(RPAccessURL, new ImmutableResourceProperty(urlRP)); + logger.info("Created HTTP in directory="+workdir); + } + + private String exposeFile(){ + unique=Utilities.newUniqueID(); + String path=this.workdir+"/"+(isExport? getRawSource():getRawTarget()); + FileServlet.exposeFile(unique, path); + accessURL=makeAccessURL(unique); + return accessURL; + } + + protected String makeAccessURL(String uniqueID){ + String host=Kernel.getKernel().getProperty(Kernel.WSRF_HOST); + String port=Kernel.getKernel().getProperty(Kernel.WSRF_PORT); + String serv="/files"; + String proto="http"; + if("true".equals(Kernel.getKernel().getProperty(ISecurityProperties.WSRF_SSL))){ + proto="https"; + }; + String add=proto+"://"+host+":"+port+serv+"/"+uniqueID; + return add; + } + private void unExposeFile(){ + FileServlet.unExposeFile(unique); + } + + @Override + public void destroy() { + unExposeFile(); + super.destroy(); + } + + @Override + public QName getResourcePropertyDocumentQName() { + return HTTPFileTransferRPDocument.type.getDocumentElementName(); + } + + +} Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html 2007-10-18 19:21:43 UTC (rev 1774) @@ -0,0 +1,6 @@ +<html> +<body> +This package contains an implementation of a +http(s) file transfer using the Jetty server. +</body> +</html> \ No newline at end of file Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -0,0 +1,160 @@ +package de.fzj.unicore.uas; + +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Calendar; +import java.util.Random; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; +import org.unigrids.services.atomic.types.ProtocolType; +import org.unigrids.x2006.x04.services.sms.ExportFileDocument; +import org.unigrids.x2006.x04.services.sms.ExportFileResponseDocument; +import org.unigrids.x2006.x04.services.sms.ImportFileDocument; +import org.unigrids.x2006.x04.services.sms.ImportFileResponseDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.client.JobClient; +import de.fzj.unicore.uas.client.RByteIOClient; +import de.fzj.unicore.uas.client.StorageClient; +import de.fzj.unicore.uas.client.TSSClient; +import de.fzj.unicore.uas.fts.http.HttpFileTransferClient; +import de.fzj.unicore.wsrflite.Kernel; +import de.fzj.unicore.wsrflite.utils.StopWatch; + +/** + * runs http filetransfer tests on a newly created USspace<br/> + * + * @author schuller + */ +public class HttpTest extends AbstractJobRun{ + + String url; + EndpointReferenceType tssepr; + + String sampleStr = "010203040506070809101112131415161718192021222324252627282930"; + + StorageClient sms; + + int errors=0; + + @Override + public String getDescription() { + return "HTTP filetransfer tests"; + } + + @Override + public void doTest() { + try{ + url=Kernel.getKernel().getProperty(Kernel.WSRF_BASEURL); + tssepr=EndpointReferenceType.Factory.newInstance(); + tssepr.addNewAddress().setStringValue(url+"/"+UAS.TSS+"?res=default_targetsystem"); + TSSClient tss=new TSSClient(tssepr); + Calendar c=tss.getCurrentTime(); + assertTrue(c!=null); + runJob(tss); + + }catch(Exception e){ + e.printStackTrace(); + success=false; + } + + } + + @Override + protected void beforeStart(JobClient jms) throws Exception { + // TODO Auto-generated method stub + + } + + @Override + protected JobDefinitionDocument getJob() { + JobDefinitionDocument jdd=JobDefinitionDocument.Factory.newInstance(); + ApplicationType app=jdd.addNewJobDefinition().addNewJobDescription().addNewApplication(); + app.setApplicationName("Date"); + app.setApplicationVersion("1.0"); + return jdd; + } + + + @Override + protected void onFinish(JobClient jms) throws Exception { + sms=job.getUspaceClient(); + +// data stage in with perf measurement + RByteIOClient importClient=sms.getImport("bigfile"); + int size=128000; + int loops=100; + byte[] data=new byte[size]; + Random r=new Random(); + + StopWatch sw=new StopWatch(); + sw.start("Start import of "+size*loops/(1024*1024)+ " MBytes"); + System.out.println("Start import of "+size*loops/(1024*1024)+ " MBytes"); + for (int i = 0; i < loops; i++) { + r.nextBytes(data); + importClient.append(data); + } + sw.stop("End."); + long time=sw.getCurrentTotal(); + System.out.println("End of data import, time="+time/1000+ " sec"); + System.out.println("Rate="+(size*loops)/time+ " kB/sec."); + + //data export + RByteIOClient exportClient=sms.getExport("bigfile"); + + sw.start("Start export of "+size*loops/(1024*1024)+ " MBytes"); + System.out.println("Start export of "+size*loops/(1024*1024)+ " MBytes"); + exportClient.readAllData(new OutputStream(){ + public void write(int b) throws IOException { + } + }); + + sw.stop("End."); + time=sw.getCurrentTotal(); + System.out.println("End of rbyteio data export, time="+time/1000+ " sec"); + System.out.println("Rate="+(size*loops)/time+ " kB/sec."); + + + sw.start("Start HTTP."); + ExportFileDocument in=ExportFileDocument.Factory.newInstance(); + in.addNewExportFile().setProtocol(ProtocolType.HTTP); + in.getExportFile().setSource("/bigfile"); + ExportFileResponseDocument res=sms.ExportFile(in); + + HttpFileTransferClient ft=new HttpFileTransferClient(res.getExportFileResponse().getExportEPR()); + + ft.readAllData(new OutputStream(){ + public void write(int b) throws IOException { + } + }); + + + sw.stop("End HTTP."); + time=sw.getCurrentTotal(); + System.out.println("End of http data export, time="+time/1000+ " sec"); + System.out.println("Rate="+(size*loops)/time+ " kB/sec."); + + //test putting a file + + String testString="this is a test"; + ByteArrayInputStream bis=new ByteArrayInputStream(testString.getBytes()); + ImportFileDocument imp=ImportFileDocument.Factory.newInstance(); + imp.addNewImportFile().setProtocol(ProtocolType.HTTP); + imp.getImportFile().setDestination("/testfile"); + + ImportFileResponseDocument res2=sms.ImportFile(imp); + HttpFileTransferClient http2=new HttpFileTransferClient(res2.getImportFileResponse().getImportEPR()); + http2.writeAllData(bis); + + //and read it again + ByteArrayOutputStream os=new ByteArrayOutputStream(); + sms.getExport("/testfile").readAllData(os); + System.out.println(os.toString()); + assertTrue(os.toString().equals(testString)); + } + + +} Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-18 18:25:51 UTC (rev 1773) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-18 19:21:43 UTC (rev 1774) @@ -1,6 +1,5 @@ package de.fzj.unicore.uas; -import java.io.File; import java.util.ArrayList; import java.util.Observable; import java.util.Observer; @@ -37,7 +36,7 @@ uas.addObserver(this); sw.start("Init UAS."); //LogManager.getLogManager().reset(); - Logger.getLogger("de").setLevel(Level.WARNING); + //Logger.getLogger("de").setLevel(Level.WARNING); Logger.getLogger("org").setLevel(Level.SEVERE); Logger.getLogger("com").setLevel(Level.SEVERE); uas.startSynchronous(); @@ -46,7 +45,7 @@ protected void addTests(){ // tests.add(new RunDate()); - tests.add(new TestTSFClient()); +// tests.add(new TestTSFClient()); // tests.add(new RunCat()); // tests.add(new RunCatWithStageInFromRemoteSMS()); // tests.add(new RunStageInWithMissingDir()); @@ -58,6 +57,7 @@ // tests.add(new TestWSDL()); // tests.add(new RunServerServerTransfer()); // tests.add(new ByteIOTest()); + tests.add(new HttpTest()); } public void testAll()throws Exception{ Modified: unicorex/uas-core/trunk/src/test/resources/uas.config =================================================================== --- unicorex/uas-core/trunk/src/test/resources/uas.config 2007-10-18 18:25:51 UTC (rev 1773) +++ unicorex/uas-core/trunk/src/test/resources/uas.config 2007-10-18 19:21:43 UTC (rev 1774) @@ -67,9 +67,12 @@ # byteio uas.filetransfer.protocol.RBYTEIO=de.fzj.unicore.uas.fts.byteio.RandomByteIOImpl uas.filetransfer.protocol.SBYTEIO=de.fzj.unicore.uas.fts.byteio.StreamableByteIOImpl +#HTTP +uas.filetransfer.protocol.HTTP=de.fzj.unicore.uas.fts.http.HttpFileTransferImpl + # # What protocols should a SMS support? # -uas.sms.protocols=RBYTEIO BFT SBYTEIO +uas.sms.protocols=RBYTEIO BFT SBYTEIO HTTP Modified: unicorex/uas-core/trunk/src/test/resources/wsrflite.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2007-10-18 18:25:51 UTC (rev 1773) +++ unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2007-10-18 19:21:43 UTC (rev 1774) @@ -95,7 +95,10 @@ <interface class="de.fzj.unicore.uas.fts.byteio.StreamableByteIO" /> <implementation class="de.fzj.unicore.uas.fts.FileTransferHomeImpl"/> </service> - + <service name="FileTransferHTTP" wsrf="true" persistent="true"> + <interface class="de.fzj.unicore.uas.fts.FileTransfer" /> + <implementation class="de.fzj.unicore.uas.fts.FileTransferHomeImpl"/> + </service> <!-- the service group entry service --> <service name="ServiceGroupEntry" wsrf="true" persistent="true"> <interface class="de.fzj.unicore.wsrflite.xmlbeans.sg.ServiceGroupEntry"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-10-19 09:02:14
|
Revision: 1778 http://unicore.svn.sourceforge.net/unicore/?rev=1778&view=rev Author: bschuller Date: 2007-10-19 02:02:09 -0700 (Fri, 19 Oct 2007) Log Message: ----------- refactor storage client to allow simple use of a given protocol Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/SecurityTestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java Added Paths: ----------- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-10-19 07:59:57 UTC (rev 1777) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-10-19 09:02:09 UTC (rev 1778) @@ -37,6 +37,8 @@ import java.io.IOException; import java.io.OutputStream; import java.net.URI; +import java.util.HashMap; +import java.util.Map; import java.util.logging.Level; import javax.xml.namespace.QName; @@ -46,7 +48,6 @@ import org.unigrids.services.atomic.types.GridFileType; import org.unigrids.services.atomic.types.ProtocolDocument; import org.unigrids.services.atomic.types.ProtocolType; - import org.unigrids.x2006.x04.services.bfts.FileContentDocument; import org.unigrids.x2006.x04.services.sms.CopyDocument; import org.unigrids.x2006.x04.services.sms.CreateDirectoryDocument; @@ -100,6 +101,13 @@ */ public static QName RPFileSystem=FileSystemDocument.type.getDocumentElementName(); + + protected static Map<ProtocolType.Enum,Class<? extends FileTransferClient>>registeredClients=new HashMap<ProtocolType.Enum, Class<? extends FileTransferClient>>(); + + public static void registerClient(ProtocolType.Enum proto, Class<? extends FileTransferClient>clazz){ + registeredClients.put(proto, clazz); + logger.info("Registered filetransfer client class "+clazz+ " for protocol "+proto+"."); + } /** * connect to the service at EPR 'address' using the given URL * @param url @@ -118,6 +126,8 @@ private void doInit(){ try{ sms=makeProxy(StorageManagement.class); + registeredClients.put(ProtocolType.RBYTEIO, RByteIOClient.class); + registeredClients.put(ProtocolType.SBYTEIO, SByteIOClient.class); }catch(Exception e){ e.printStackTrace(); throw new RuntimeException("could not create sms"); @@ -331,12 +341,21 @@ throw BaseFault.createFault(e.getMessage()); } } + /** - * create a rbyteio client for exporting from the given path - * @param path - * @return + * Create a client for doing a file import, while trying to + * use the first protocol matching the given list<br/>. + * + * @param preferredProtocols - a list of protocols. The first supported one is used + * @return {@link FileTransferClient} + * @throws IOException if no suitable protocol can be found, or no matching client class is found */ - public RByteIOClient getExport(String path)throws IOException{ + public FileTransferClient getExport(String path, ProtocolType.Enum ... preferredProtocols) throws IOException{ + ProtocolType.Enum proto=getMatch(preferredProtocols); + if(proto==null)throw new IOException("No suitable Procotol found!"); + //now build a client... + Class<? extends FileTransferClient>clazz=registeredClients.get(proto); + if(clazz==null)throw new IOException("No matching client class supporting the <"+proto+"> protocol found."); try{ ExportFileDocument efd=ExportFileDocument.Factory.newInstance(); ExportFile export=efd.addNewExportFile(); @@ -345,32 +364,32 @@ export.setSource(path); EndpointReferenceType epr=ExportFile(efd).getExportFileResponse().getExportEPR(); String url=epr.getAddress().getStringValue(); - return new RByteIOClient(url,epr,(IUASSecurityProperties)securityProperties); + return clazz.getConstructor(new Class[]{String.class, EndpointReferenceType.class, IUASSecurityProperties.class}) + .newInstance(new Object[]{url, epr, (IUASSecurityProperties)securityProperties}); }catch(Exception e){ - logger.log(Level.SEVERE,"Could not create export.", e); - throw new IOException(e.getMessage()); + logger.log(Level.SEVERE,"Can't create import client.",e); + IOException ioe=new IOException(); + ioe.initCause(e); + throw ioe; } } /** - * create a rbyteio client for importing to the given path + * create a rbyteio client for exporting from the given path * @param path * @return */ + public RByteIOClient getExport(String path)throws IOException{ + return (RByteIOClient)getExport(path, ProtocolType.RBYTEIO); + } + + /** + * create a RByteio client for importing to the given path + * @param path + * @return + */ public RByteIOClient getImport(String path)throws IOException{ - try{ - ImportFileDocument ifd=ImportFileDocument.Factory.newInstance(); - ImportFile in=ifd.addNewImportFile(); - in.setIsPipe(false); - in.setProtocol(ProtocolType.RBYTEIO); - in.setDestination(path); - EndpointReferenceType epr=ImportFile(ifd).getImportFileResponse().getImportEPR(); - String url=epr.getAddress().getStringValue(); - return new RByteIOClient(url,epr,(IUASSecurityProperties)securityProperties); - }catch(Exception e){ - logger.log(Level.SEVERE,"Could not create import.", e); - throw new IOException(e.getMessage()); - } + return (RByteIOClient)getImport(path, ProtocolType.RBYTEIO); } /** @@ -379,19 +398,7 @@ * @return */ public SByteIOClient getReadStream(String path)throws IOException{ - try{ - ExportFileDocument efd=ExportFileDocument.Factory.newInstance(); - ExportFile export=efd.addNewExportFile(); - export.setIsPipe(false); - export.setProtocol(ProtocolType.SBYTEIO); - export.setSource(path); - EndpointReferenceType epr=ExportFile(efd).getExportFileResponse().getExportEPR(); - String url=epr.getAddress().getStringValue(); - return new SByteIOClient(url,epr,(IUASSecurityProperties)securityProperties); - }catch(Exception e){ - logger.log(Level.SEVERE,"Could not create export.", e); - throw new IOException(e.getMessage()); - } + return (SByteIOClient)getExport(path,ProtocolType.SBYTEIO); } /** @@ -400,19 +407,7 @@ * @return */ public SByteIOClient getWriteStream(String path)throws IOException{ - try{ - ImportFileDocument ifd=ImportFileDocument.Factory.newInstance(); - ImportFile in=ifd.addNewImportFile(); - in.setIsPipe(false); - in.setProtocol(ProtocolType.SBYTEIO); - in.setDestination(path); - EndpointReferenceType epr=ImportFile(ifd).getImportFileResponse().getImportEPR(); - String url=epr.getAddress().getStringValue(); - return new SByteIOClient(url,epr,(IUASSecurityProperties)securityProperties); - }catch(Exception e){ - logger.log(Level.SEVERE,"Could not create import.", e); - throw new IOException(e.getMessage()); - } + return (SByteIOClient)getImport(path, ProtocolType.SBYTEIO); } /** @@ -459,7 +454,7 @@ /** * Convenience method for accessing a remote file directly via its URI - * @param uri - URI of the remote file + * @param uri - URI of the remote file (including the protocol to use) * @param sec - security settings * @param writeTo - OutputStream to write the data to * @@ -507,4 +502,51 @@ }catch(Exception e){} } + /** + * Create a client for doing a file import, while trying to + * use the first protocol matching the given list<br/>. + * + * @param preferredProtocols - a list of protocols. The first supported one is used + * @return {@link FileTransferClient} + * @throws IOException if no suitable protocol can be found, or no matching client class is found + */ + public FileTransferClient getImport(String path, ProtocolType.Enum ... preferredProtocols) throws IOException{ + ProtocolType.Enum proto=getMatch(preferredProtocols); + if(proto==null)throw new IOException("No suitable Procotol found!"); + //now build a client... + Class<? extends FileTransferClient>clazz=registeredClients.get(proto); + if(clazz==null)throw new IOException("No matching client class supporting the <"+proto+"> protocol found."); + try{ + ImportFileDocument ifd=ImportFileDocument.Factory.newInstance(); + ImportFile in=ifd.addNewImportFile(); + in.setIsPipe(false); + in.setProtocol(proto); + in.setDestination(path); + EndpointReferenceType epr=ImportFile(ifd).getImportFileResponse().getImportEPR(); + String url=epr.getAddress().getStringValue(); + return clazz.getConstructor(new Class[]{String.class, EndpointReferenceType.class, IUASSecurityProperties.class}) + .newInstance(new Object[]{url, epr, (IUASSecurityProperties)securityProperties}); + }catch(Exception e){ + logger.log(Level.SEVERE,"Can't create import client.",e); + IOException ioe=new IOException(); + ioe.initCause(e); + throw ioe; + } + } + + //gets the first match, or null if no match found + private ProtocolType.Enum getMatch(ProtocolType.Enum ... preferredProtocols)throws IOException{ + try{ + for(ProtocolType.Enum p: preferredProtocols){ + + for(ProtocolType.Enum test: getSupportedProtocols()){ + if(test.equals(p))return p; + } + } + }catch(Exception e){ + logger.log(Level.SEVERE,"Can't get protocols.",e); + throw new IOException("Can't get protocols."); + } + return null; + } } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/SecurityTestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/SecurityTestSuite.java 2007-10-19 07:59:57 UTC (rev 1777) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/SecurityTestSuite.java 2007-10-19 09:02:09 UTC (rev 1778) @@ -19,7 +19,6 @@ UAS uas=new UAS("src/test/resources/secure/uas.config"); System.setProperty(HsqldbPersist.clearDBOnStartup,"true"); addTests(); - uas.addObserver(this); sw.start("Init UAS."); uas.start(); Logger.getLogger("de").setLevel(Level.SEVERE); Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java 2007-10-19 09:02:09 UTC (rev 1778) @@ -0,0 +1,103 @@ +package de.fzj.unicore.uas; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Calendar; +import java.util.Random; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; +import org.unigrids.services.atomic.types.ProtocolType; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.client.JobClient; +import de.fzj.unicore.uas.client.RByteIOClient; +import de.fzj.unicore.uas.client.StorageClient; +import de.fzj.unicore.uas.client.TSSClient; +import de.fzj.unicore.wsrflite.Kernel; +import de.fzj.unicore.wsrflite.utils.StopWatch; + +/** + * tests the basic filetransfer client functions + * + * @author schuller + */ +public class TestFileTransfer extends AbstractJobRun{ + + String url; + EndpointReferenceType tssepr; + + + @Override + public String getDescription() { + return "File transfer client tests (RBYTEIO)"; + } + + @Override + public void doTest() { + try{ + url=Kernel.getKernel().getProperty(Kernel.WSRF_BASEURL); + tssepr=EndpointReferenceType.Factory.newInstance(); + tssepr.addNewAddress().setStringValue(url+"/"+UAS.TSS+"?res=default_targetsystem"); + TSSClient tss=new TSSClient(tssepr); + Calendar c=tss.getCurrentTime(); + assertTrue(c!=null); + JobClient job=submitJob(tss); + StorageClient sms=job.getUspaceClient(); + + RByteIOClient importClient=sms.getImport("bigfile"); + + ProtocolType.Enum protocol=importClient.getProtocol(); + assertTrue(ProtocolType.RBYTEIO.equals(protocol)); + + System.out.println("Source: "+importClient.getSource()); + assertTrue(importClient.getTarget().equalsIgnoreCase("rbyteio:"+sms.getEPR().getAddress().getStringValue()+"#/bigfile")); + assertTrue(importClient.getParentStorage()!=null); + + //data stage in with perf measurement + + int size=128000; + int loops=3; + byte[] data=new byte[size]; + Random r=new Random(); + + StopWatch sw=new StopWatch(); + sw.start("Start import of "+size*loops/(1024*1024)+ " MBytes"); + System.out.println("Start import of "+size*loops/(1024*1024)+ " MBytes"); + for (int i = 0; i < loops; i++) { + r.nextBytes(data); + importClient.append(data); + } + assertTrue(size*loops==importClient.getTransferredBytes()); + + sw.stop("End."); + long time=sw.getCurrentTotal(); + System.out.println("End of data import, time="+time/1000+ " sec"); + System.out.println("Rate="+(size*loops)/time+ " kB/sec."); + + + }catch(Exception e){ + e.printStackTrace(); + success=false; + } + } + + + @Override + protected void beforeStart(JobClient jms) throws Exception { + // TODO Auto-generated method stub + + } + + @Override + protected JobDefinitionDocument getJob() { + JobDefinitionDocument jdd=JobDefinitionDocument.Factory.newInstance(); + jdd.addNewJobDefinition().setId("EmptyJob"); + return jdd; + } + + @Override + protected void onFinish(JobClient jms) throws Exception { + } + + +} Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-19 07:59:57 UTC (rev 1777) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-19 09:02:09 UTC (rev 1778) @@ -1,8 +1,6 @@ package de.fzj.unicore.uas; import java.util.ArrayList; -import java.util.Observable; -import java.util.Observer; import java.util.logging.Level; import java.util.logging.Logger; @@ -15,10 +13,8 @@ * * starts a server and runs some functional tests against it */ -public class TestSuite extends TestCase implements Observer { +public class TestSuite extends TestCase{ - private static boolean initDone=false; - protected static StopWatch sw=new StopWatch(); private static int errors=0; @@ -33,10 +29,9 @@ UAS.setProperty(HsqldbPersist.clearDBOnStartup,"true"); UAS.DISABLE_SECURITY_AND_ACCESS_CONTROL=Boolean.TRUE; addTests(); - uas.addObserver(this); sw.start("Init UAS."); //LogManager.getLogManager().reset(); - //Logger.getLogger("de").setLevel(Level.WARNING); + Logger.getLogger("de").setLevel(Level.WARNING); Logger.getLogger("org").setLevel(Level.SEVERE); Logger.getLogger("com").setLevel(Level.SEVERE); uas.startSynchronous(); @@ -57,16 +52,11 @@ // tests.add(new TestWSDL()); // tests.add(new RunServerServerTransfer()); // tests.add(new ByteIOTest()); - tests.add(new HttpTest()); +// tests.add(new HttpTest()); + tests.add(new TestFileTransfer()); } public void testAll()throws Exception{ - int t=0; - while(initDone==false ){ - Thread.sleep(1000); - t++; - if(t>20) fail("Timed out waiting for UAS startup."); - } sw.snapShot("Init done."); for(RegressionTest r: tests){ sw.snapShot("Start: \n"+r.getDescription()); @@ -93,11 +83,6 @@ if(errors>0)fail(); } - - public void update(Observable o, Object arg) { - System.out.println("UAS started."); - initDone=true; - } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-10-25 20:59:31
|
Revision: 1811 http://unicore.svn.sourceforge.net/unicore/?rev=1811&view=rev Author: bschuller Date: 2007-10-25 13:59:25 -0700 (Thu, 25 Oct 2007) Log Message: ----------- proposal for resource reservation: Unicore/X implementation Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/TargetSystem.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityException.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TDOutHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/resources/wsrflite.xml unicorex/uas-core/trunk/src/test/resources/xnjs.xml Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ReservationManagement.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ResourceReservation.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementHomeImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/MockReservation.java Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ReservationManagement.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ReservationManagement.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ReservationManagement.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,51 @@ +package de.fzj.unicore.uas; + +import javax.jws.WebService; +import javax.xml.namespace.QName; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; +import org.unigrids.x2006.x04.services.jms.TargetSystemReferenceDocument; +import org.unigrids.x2006.x04.services.reservation.ReservationReferenceDocument; +import org.unigrids.x2006.x04.services.reservation.StartTimeDocument; + +import de.fzj.unicore.wsrflite.xmlbeans.ResourceLifetime; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperties; + +/** + * Service for managing reservations + */ +@WebService(targetNamespace = "http://unigrids.org/2006/04/services/reservation", + portName="ReservationManagement") +public interface ReservationManagement extends ResourceProperties,ResourceLifetime{ + + //Namespace + public static final String NAMESPACE="http://unigrids.org/2006/04/services/reservation"; + + //Porttype + public static final QName PORT=new QName(NAMESPACE,"ReservationManagement"); + + /** + * the resource property containing the reference to the + * target system where the resources have been reserved + */ + public static QName RPTargetSystemReference = TargetSystemReferenceDocument.type.getDocumentElementName(); + + /** + * the resource property containing the start time of the + * reservation + */ + public static QName RPStartTime = StartTimeDocument.type.getDocumentElementName(); + + /** + * the resource property containing the booked resources + */ + public static QName RPResources = ResourcesDocument.type.getDocumentElementName(); + + /** + * the resource property containing the reference used + * for claiming the reservation with the batch system + */ + public static QName RPReservationReference = ReservationReferenceDocument.type.getDocumentElementName(); + + +} Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ResourceReservation.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ResourceReservation.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/ResourceReservation.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,74 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas; + +import javax.jws.WebMethod; +import javax.jws.WebService; +import javax.xml.namespace.QName; + +import org.unigrids.x2006.x04.services.reservation.ResourceReservationRequestDocument; +import org.unigrids.x2006.x04.services.reservation.ResourceReservationResponseDocument; +import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; + +import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceLifetime; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperties; + +/** + * Resource reservation service + */ +@WebService(targetNamespace = "http://unigrids.org/2006/04/services/reservation", + portName="ResourceReservation") +public interface ResourceReservation extends ResourceProperties,ResourceLifetime{ + + //Namespace + public static final String NAMESPACE="http://unigrids.org/2006/04/services/reservation"; + + //Porttype + public static final QName PORTTYPE=new QName(NAMESPACE,"ResourceReservation"); + + //action for "ReserveResources" + public static final String ACTION_RESERVE="http://unigrids.org/2006/04/services/reservation/ResourceReservation/ReserveResources"; + + /** + * resource property for advertising resource reservation support. + */ + public static final QName RP_SUPPORTS_RESERVATION=SupportsReservationDocument.type.getDocumentElementName(); + + @WebMethod(action = ACTION_RESERVE) + public ResourceReservationResponseDocument ReserveResources( + ResourceReservationRequestDocument in) + throws BaseFault; + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/TargetSystem.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/TargetSystem.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/TargetSystem.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -60,7 +60,7 @@ @WebService(targetNamespace = "http://unigrids.org/2006/04/services/tss", portName="TargetSystem") -public interface TargetSystem extends ResourceProperties, ResourceLifetime{ +public interface TargetSystem extends ResourceReservation, ResourceProperties, ResourceLifetime{ //Namespace Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -147,7 +147,8 @@ public static final String SMS="StorageManagement"; public static final String REG="Registry"; public static final String REGENTRY=ServiceGroupEntry.SERVICENAME; - + public static final String RESERVATIONS="ReservationManagement"; + // registry related public static final String IS_GLOBAL_REGISTRY="uas.registry.global"; public static final String GLOBAL_REGISTRY_ADVERTISE="uas.registry.global.advertise"; Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,81 @@ +package de.fzj.unicore.uas.client; + +import java.util.Calendar; + +import org.apache.xmlbeans.XmlObject; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesType; +import org.unigrids.x2006.x04.services.jms.TargetSystemReferenceDocument; +import org.unigrids.x2006.x04.services.reservation.ReservationPropertiesDocument; +import org.unigrids.x2006.x04.services.reservation.ReservationReferenceDocument; +import org.unigrids.x2006.x04.services.reservation.StartTimeDocument; +import org.unigrids.x2006.x04.services.tss.SubmitDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.ReservationManagement; +import de.fzj.unicore.uas.security.IUASSecurityProperties; +import de.fzj.unicore.wsrflite.utils.Utilities; + +/** + * client for managing a resource reservation + * + * @author schuller + */ +public class ReservationClient extends BaseUASClient { + + public ReservationClient(String url, EndpointReferenceType epr, + IUASSecurityProperties sec) throws Exception { + super(url, epr, sec); + } + + public ReservationClient(String url, EndpointReferenceType epr) + throws Exception { + super(url, epr); + } + + public ReservationClient(EndpointReferenceType epr) throws Exception { + super(epr); + } + + /** + * submit a job to the TSS used in this reservation + * + * @param in the submission document + * @return + */ + public JobClient submit(SubmitDocument in)throws Exception{ + JobDefinitionType job=in.getSubmit().getJobDefinition(); + EndpointReferenceType tssEPR=getTSSEpr(); + TSSClient tss=new TSSClient(tssEPR.getAddress().getStringValue(),tssEPR,getSecurityProperties()); + //add in the reservation reference... + ResourcesType rt=job.getJobDescription().getResources(); + if(rt==null)rt=job.getJobDescription().addNewResources(); + //TODO this should be more seamless :-) + String resID="<ReservationReference xmlns=\"http://www.unicore.eu/unicore/xnjs\">"+getReservationReference()+"</ReservationReference>"; + XmlObject o=XmlObject.Factory.parse(resID); + Utilities.append(o, rt); + + return tss.submit(in); + } + + public Calendar getStartTime()throws Exception{ + return StartTimeDocument.Factory.parse(getResourceProperty(ReservationManagement.RPStartTime)).getStartTime(); + } + + public String getReservationReference()throws Exception{ + return ReservationReferenceDocument.Factory.parse(getResourceProperty(ReservationManagement.RPReservationReference)).getReservationReference(); + } + + public ResourcesDocument getResources()throws Exception{ + return ResourcesDocument.Factory.parse(getResourceProperty(ReservationManagement.RPResources)); + } + public EndpointReferenceType getTSSEpr()throws Exception{ + return TargetSystemReferenceDocument.Factory.parse(getResourceProperty(ReservationManagement.RPTargetSystemReference)).getTargetSystemReference(); + } + + public ReservationPropertiesDocument getReservationPropertiesDocument() throws Exception{ + return ReservationPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().toString()); + } + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -10,8 +10,10 @@ import org.unigrids.x2006.x04.services.tsf.CreateTSRDocument; import org.unigrids.x2006.x04.services.tsf.CreateTSRResponseDocument; import org.unigrids.x2006.x04.services.tsf.TargetSystemFactoryPropertiesDocument; +import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; +import de.fzj.unicore.uas.ResourceReservation; import de.fzj.unicore.uas.TargetSystemFactory; import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; @@ -102,6 +104,11 @@ return doc; } + public boolean supportsReservation()throws Exception{ + SupportsReservationDocument resSupport=SupportsReservationDocument.Factory.parse(getResourceProperty(ResourceReservation.RP_SUPPORTS_RESERVATION)); + return resSupport.getSupportsReservation(); + } + public List<EndpointReferenceType> getTargetSystems(){ try{ EndpointReferenceType[] eprs=getResourcePropertiesDocument().getTargetSystemFactoryProperties(). Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -36,19 +36,25 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.Calendar; import java.util.List; import java.util.logging.Level; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument; import org.unigrids.services.atomic.types.StorageReferenceType; import org.unigrids.services.atomic.types.TextInfoType; +import org.unigrids.x2006.x04.services.reservation.ResourceReservationRequestDocument; +import org.unigrids.x2006.x04.services.reservation.ResourceReservationResponseDocument; import org.unigrids.x2006.x04.services.tss.ApplicationResourceType; import org.unigrids.x2006.x04.services.tss.NameDocument; import org.unigrids.x2006.x04.services.tss.SubmitDocument; import org.unigrids.x2006.x04.services.tss.SubmitResponseDocument; +import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; import org.unigrids.x2006.x04.services.tss.TargetSystemPropertiesDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; +import de.fzj.unicore.uas.ResourceReservation; import de.fzj.unicore.uas.TargetSystem; import de.fzj.unicore.uas.TargetSystemFactory; import de.fzj.unicore.uas.security.IUASSecurityProperties; @@ -240,4 +246,42 @@ return null; } + /** + * does this target system support reservation? + * + * @return true if the TSS supports reservation + * @throws Exception + */ + public boolean supportsReservation()throws Exception{ + SupportsReservationDocument resSupport=SupportsReservationDocument.Factory.parse(getResourceProperty(ResourceReservation.RP_SUPPORTS_RESERVATION)); + return resSupport.getSupportsReservation(); + } + + /** + * create a reservation + * TODO make a client for managing the reservation (and submitting?) + * + * @return {@link EndpointReferenceType} of the new reservation + * @throws Exception + */ + public EndpointReferenceType createReservation(ResourcesDocument resources, Calendar startTime)throws Exception{ + ResourceReservationRequestDocument req=ResourceReservationRequestDocument.Factory.newInstance(); + req.addNewResourceReservationRequest().setResources(resources.getResources()); + req.getResourceReservationRequest().setStartTime(startTime); + TargetSystem tss=makeProxy(TargetSystem.class); + ResourceReservationResponseDocument res=tss.ReserveResources(req); + return res.getResourceReservationResponse().getReservationReference(); + } + /** + * create a client for managing the reservation + * + * @return BaseUASClient + * @throws Exception + */ + public ReservationClient createReservationClient(ResourcesDocument resources, Calendar startTime)throws Exception{ + EndpointReferenceType epr=createReservation(resources, startTime); + ReservationClient client=new ReservationClient(epr.getAddress().getStringValue(),epr,getSecurityProperties()); + return client; + } + } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -103,6 +103,12 @@ @Persist private X500Principal owner; + /** + * the EPR of this resource + */ + @Persist + private EndpointReferenceType myEPR; + public static final String INITPARAM_SECURITYCONTEXT=UASWSResourceImpl.class.getName()+".securityContext"; /** @@ -292,11 +298,7 @@ */ protected void publish(){ try{ - EndpointReferenceType epr=AddressingUtil.newEPR(); - epr.addNewAddress().setStringValue(Utilities.makeAddress(getServiceName(),getUniqueID())); - AddressingUtil.addPortType(epr,getPortType()); - - ContentType content=null; + ContentType content=null; try{ List<XmlObject>publish=new ArrayList<XmlObject>(); for(QName q: publishedRPs()){ @@ -306,12 +308,24 @@ }catch(Exception e){ } - RegistryHandler.getRegistryClient().addRegistryEntry(epr,content); + RegistryHandler.getRegistryClient().addRegistryEntry(getEPR(),content); logger.info("Added registry entry for "+getServiceName()+"<"+getUniqueID()+">"); }catch(Exception e){ logger.log(Level.SEVERE, "Could not publish to registry",e); } } + /** + * get the EPR of this WS-Resource + * @return + */ + protected synchronized EndpointReferenceType getEPR(){ + if(myEPR==null){ + myEPR=AddressingUtil.newEPR(); + myEPR.addNewAddress().setStringValue(Utilities.makeAddress(getServiceName(),getUniqueID())); + AddressingUtil.addPortType(myEPR,getPortType()); + } + return myEPR; + } public QName getPortType() { Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementHomeImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementHomeImpl.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementHomeImpl.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,47 @@ +/********************************************************************************* + * Copyright (c) 2006-2007 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.impl.reservation; + +import de.fzj.unicore.uas.impl.UASWSResourceHomeImpl; +import de.fzj.unicore.wsrflite.xmlbeans.impl.WSResourceImpl; + +public class ReservationManagementHomeImpl extends UASWSResourceHomeImpl{ + protected static final long serialVersionUID=93485034L; + + @Override + protected WSResourceImpl doCreateInstance() { + return new ReservationManagementImpl(); + } + +} Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,84 @@ +package de.fzj.unicore.uas.impl.reservation; + +import java.util.Calendar; +import java.util.Map; +import java.util.logging.Level; + +import javax.xml.namespace.QName; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; +import org.unigrids.x2006.x04.services.jms.TargetSystemReferenceDocument; +import org.unigrids.x2006.x04.services.reservation.ReservationPropertiesDocument; +import org.unigrids.x2006.x04.services.reservation.ReservationReferenceDocument; +import org.unigrids.x2006.x04.services.reservation.StartTimeDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.ReservationManagement; +import de.fzj.unicore.uas.impl.UASWSResourceImpl; +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.persistence.Persist; +import de.fzj.unicore.wsrflite.xmlbeans.rp.ImmutableResourceProperty; + +/** + * WS resource representing a resource reservation + * + * @author schuller + */ +public class ReservationManagementImpl extends UASWSResourceImpl implements ReservationManagement { + + private static final long serialVersionUID = 1L; + + public static String INITPARAM_RESOURCES="resources"; + public static String INITPARAM_STARTTIME="starttime"; + public static String INITPARAM_TSS_REFERENCE="tss_reference"; + public static String INITPARAM_RESERVATION_REFERENCE="reservation_reference"; + + @Persist + private String reservationReference; + + @Override + public QName getResourcePropertyDocumentQName() { + return ReservationPropertiesDocument.type.getDocumentElementName(); + } + + @Override + public void initialise(String serviceName, Map<String, Object> initParams) throws Exception { + super.initialise(serviceName, initParams); + + reservationReference=(String)initParams.get(INITPARAM_RESERVATION_REFERENCE); + ReservationReferenceDocument res=ReservationReferenceDocument.Factory.newInstance(); + res.setReservationReference(reservationReference); + properties.put(RPReservationReference, new ImmutableResourceProperty(res)); + + StartTimeDocument startTime=StartTimeDocument.Factory.newInstance(); + startTime.setStartTime((Calendar)initParams.get(INITPARAM_STARTTIME)); + properties.put(RPStartTime, new ImmutableResourceProperty(startTime)); + + ResourcesDocument resources=(ResourcesDocument)initParams.get(INITPARAM_RESOURCES); + properties.put(RPResources, new ImmutableResourceProperty(resources)); + + TargetSystemReferenceDocument tssRef=TargetSystemReferenceDocument.Factory.newInstance(); + tssRef.setTargetSystemReference((EndpointReferenceType)initParams.get(INITPARAM_TSS_REFERENCE)); + properties.put(RPTargetSystemReference, new ImmutableResourceProperty(tssRef)); + + } + + /** + * on destroy(), cancel the booking on the backend + * + * TODO keep a list of reservations on the TSS? If yes, notify. + */ + @Override + public void destroy() { + try{ + XNJSFacade.getReservation().cancelReservation(reservationReference, getClient()); + } + catch(Exception e){ + logger.log(Level.WARNING,"Could not cancel resource reservation.",e); + } + super.destroy(); + } + + + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -46,8 +46,10 @@ import org.unigrids.x2006.x04.services.tsf.CreateTSRResponseDocument; import org.unigrids.x2006.x04.services.tsf.TargetSystemFactoryPropertiesDocument; import org.unigrids.x2006.x04.services.tss.ApplicationResourceType; +import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; +import de.fzj.unicore.uas.ResourceReservation; import de.fzj.unicore.uas.TargetSystemFactory; import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.impl.UASWSResourceImpl; @@ -68,6 +70,7 @@ import de.fzj.unicore.wsrflite.utils.Utilities; import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; import de.fzj.unicore.wsrflite.xmlbeans.impl.WSResourceImpl; +import de.fzj.unicore.wsrflite.xmlbeans.rp.ImmutableResourceProperty; import de.fzj.unicore.xnjs.jsdl.AbstractGrounder; /** @@ -140,6 +143,11 @@ properties.put(RPProcessor, new ProcessorResourceProperty(this)); properties.put(RPUpSince, new UpSinceResourceProperty()); + //reservation support? + SupportsReservationDocument supportsReservation=SupportsReservationDocument.Factory.newInstance(); + supportsReservation.setSupportsReservation(XNJSFacade.supportsReservation()); + properties.put(ResourceReservation.RP_SUPPORTS_RESERVATION,new ImmutableResourceProperty(supportsReservation)); + //TODO add site-specific resources publish(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -43,20 +43,26 @@ import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionType; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; import org.oasisOpen.docs.wsrf.rl2.TerminationTimeDocument.TerminationTime; import org.unigrids.services.atomic.types.StorageReferenceType; import org.unigrids.services.atomic.types.StorageTypeEnumeration; +import org.unigrids.x2006.x04.services.reservation.ResourceReservationRequestDocument; +import org.unigrids.x2006.x04.services.reservation.ResourceReservationResponseDocument; import org.unigrids.x2006.x04.services.tss.SubmitDocument; import org.unigrids.x2006.x04.services.tss.SubmitResponseDocument; +import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; import org.unigrids.x2006.x04.services.tss.TargetSystemPropertiesDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; +import de.fzj.unicore.uas.ResourceReservation; import de.fzj.unicore.uas.TargetSystem; import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.client.BaseUASClient; import de.fzj.unicore.uas.impl.UASWSResourceImpl; import de.fzj.unicore.uas.impl.bp.BPSupportImpl; import de.fzj.unicore.uas.impl.job.JobManagementImpl; +import de.fzj.unicore.uas.impl.reservation.ReservationManagementImpl; import de.fzj.unicore.uas.impl.sms.SMSBaseImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl.StorageTypes; @@ -82,8 +88,10 @@ import de.fzj.unicore.wsrflite.persistence.Persist; import de.fzj.unicore.wsrflite.utils.Utilities; import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; +import de.fzj.unicore.wsrflite.xmlbeans.rp.ImmutableResourceProperty; import de.fzj.unicore.xnjs.aaa.Client; import de.fzj.unicore.xnjs.ems.Action; +import de.fzj.unicore.xnjs.tsi.IReservation; /** * the implementation of the TargetSystem service<br/> @@ -91,7 +99,6 @@ * It uses an XNJS instance as back end. * * @author schuller - * @version $Id: TargetSystemImpl.java,v 1.9 2006/12/01 13:17:01 bdemuth Exp $ */ public class TargetSystemImpl extends UASWSResourceImpl implements TargetSystem { @@ -119,6 +126,7 @@ protected void addWSResourceInterfaces(BPSupportImpl baseProfile) { super.addWSResourceInterfaces(baseProfile); baseProfile.addWSResourceInterface(TSS_PORT); + baseProfile.addWSResourceInterface(ResourceReservation.PORTTYPE); } @Override @@ -226,6 +234,12 @@ properties.put(RPApplication, createApplicationResourceProperty()); properties.put(RPProcessor, createProcessorResourceProperty()); properties.put(RPTextInfo, new TextInfoResourceProperty()); + + //reservation support? + SupportsReservationDocument supportsReservation=SupportsReservationDocument.Factory.newInstance(); + supportsReservation.setSupportsReservation(XNJSFacade.supportsReservation()); + properties.put(ResourceReservation.RP_SUPPORTS_RESERVATION,new ImmutableResourceProperty(supportsReservation)); + //storage management: create a Home SMS Map<String,Object>initMap=new HashMap<String,Object>(); initMap.put(SMSBaseImpl.INIT_STORAGENAME,"Home"); @@ -367,5 +381,44 @@ logger.log(Level.SEVERE,"Could not destroy storages.",e); } } + + /** + * resource reservation + */ + public ResourceReservationResponseDocument ReserveResources(ResourceReservationRequestDocument in) throws BaseFault { + try{ + ResourcesDocument rd=ResourcesDocument.Factory.newInstance(); + rd.setResources(in.getResourceReservationRequest().getResources()); + Calendar startTime=in.getResourceReservationRequest().getStartTime(); + IReservation reservation=XNJSFacade.getReservation(); + if(reservation==null)throw new Exception("Reservation not supported."); + + String reservationReference=reservation.makeReservation(rd, startTime, getClient()); + EndpointReferenceType epr=createReservationResource(rd,startTime,reservationReference); + ResourceReservationResponseDocument res=ResourceReservationResponseDocument.Factory.newInstance(); + res.addNewResourceReservationResponse().setReservationReference(epr); + + return res; + }catch(Exception e){ + logger.log(Level.SEVERE,"Reservation not created.",e); + throw BaseFault.createFault("Reservation not created. Reason: "+e.getMessage()); + } + } + //create a WS Resource for the reservation and return its EPR + protected EndpointReferenceType createReservationResource(ResourcesDocument resources, Calendar startTime, String reservationReference)throws Exception{ + Map<String,Object>initMap=new HashMap<String,Object>(); + initMap.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); + initMap.put(ReservationManagementImpl.INITPARAM_RESERVATION_REFERENCE, reservationReference); + initMap.put(ReservationManagementImpl.INITPARAM_TSS_REFERENCE, getEPR()); + initMap.put(ReservationManagementImpl.INITPARAM_RESOURCES, resources); + initMap.put(ReservationManagementImpl.INITPARAM_STARTTIME, startTime); + String id=Kernel.getKernel().getServiceHome(UAS.RESERVATIONS).createWSRFServiceInstance(initMap); + EndpointReferenceType epr = AddressingUtil.newEPR(); + epr.addNewAddress().setStringValue(Utilities.makeAddress(UAS.RESERVATIONS,id)); + AddressingUtil.addUGSRefparamToEpr(epr,id); + return epr; + } + + } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityException.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityException.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityException.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -32,6 +32,7 @@ package de.fzj.unicore.uas.security; + public class SecurityException extends RuntimeException{ private static final long serialVersionUID = -3798500317088490838L; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TDOutHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TDOutHandler.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TDOutHandler.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -69,7 +69,7 @@ * inserted into the message header. * @see IUASSecurityProperties */ - public void doInit(IUASSecurityProperties sec) + public synchronized void doInit(IUASSecurityProperties sec) { this.sec = sec; assertionList=sec.getTrustDelegationTokens()!=null? Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -50,6 +50,7 @@ import de.fzj.unicore.xnjs.io.IFileTransferEngine; import de.fzj.unicore.xnjs.jsdl.AbstractGrounder; import de.fzj.unicore.xnjs.jsdl.IGrounder; +import de.fzj.unicore.xnjs.tsi.IReservation; import de.fzj.unicore.xnjs.tsi.TSI; /** @@ -331,6 +332,23 @@ return xnjs.getConfig().getTargetSystemInterface(client); } + /** + * check if the XNJS is configured to support reservation + * @return true if the XNJS supports reservation, false otherwise + */ + public static boolean supportsReservation(){ + if(didInitXNJS==false)doInit(); + return xnjs.getConfig().getReservationInterface()!=null; + } + /** + * get the reservation interface + * @return an {@link IReservation} for making reservations + */ + public static IReservation getReservation(){ + if(didInitXNJS==false)doInit(); + return xnjs.getConfig().getReservationInterface(); + } + } Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,68 @@ +package de.fzj.unicore.uas; + +import java.util.Calendar; +import java.util.List; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; +import org.unigrids.x2006.x04.services.reservation.ReservationPropertiesDocument; +import org.unigrids.x2006.x04.services.tss.SubmitDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.client.JobClient; +import de.fzj.unicore.uas.client.RegistryClient; +import de.fzj.unicore.uas.client.ReservationClient; +import de.fzj.unicore.uas.client.TSFClient; +import de.fzj.unicore.uas.client.TSSClient; +import de.fzj.unicore.wsrflite.Kernel; +import de.fzj.unicore.wsrflite.xmlbeans.client.BaseWSRFClient; + +public class TestReservation extends RunDate { + String url; + EndpointReferenceType epr; + + @Override + public void doTest() { + try{ + url=Kernel.getKernel().getProperty(Kernel.WSRF_BASEURL); + epr=EndpointReferenceType.Factory.newInstance(); + epr.addNewAddress().setStringValue(url+"/"+UAS.REG+"?res=default_registry"); + RegistryClient reg=new RegistryClient(epr); + //find a TargetSystemFactory + List<EndpointReferenceType> tsfs=reg.listServices(TargetSystemFactory.TSF_PORT); + EndpointReferenceType tsfepr=findFirstAccessibleService(tsfs); + TSFClient tsf=new TSFClient(tsfepr); + + TSSClient tss = tsf.createTSS(); + //as our config uses a dummy reservation module, we support reservations + assertTrue(tss.supportsReservation()); + ResourcesDocument resources=ResourcesDocument.Factory.newInstance(); + resources.addNewResources().addNewIndividualCPUCount().addNewExact().setDoubleValue(1024); + Calendar startTime=Calendar.getInstance(); + startTime.set(2010, 11, 24); + ReservationClient reservation=tss.createReservationClient(resources, startTime); + ReservationPropertiesDocument props=reservation.getReservationPropertiesDocument(); + System.out.println(props); + //our dummy thing always says the reference is "1234" + assertTrue("1234".equals(props.getReservationProperties().getReservationReference())); + + //now submit a job using the reservation + JobDefinitionDocument jdd=getJob(); + SubmitDocument req=SubmitDocument.Factory.newInstance(); + req.addNewSubmit().setJobDefinition(jdd.getJobDefinition()); + JobClient job=reservation.submit(req); + job.waitUntilReady(180*1000); + job.start(); + job.waitUntilDone(180*1000); + + }catch(Exception e){ + throw new RuntimeException(e); + } + } + + @Override + public String getDescription() { + return "Testing Registry and TSF clients"; + } + +} Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -53,7 +53,8 @@ // tests.add(new RunServerServerTransfer()); // tests.add(new ByteIOTest()); // tests.add(new HttpTest()); - tests.add(new TestFileTransfer()); +// tests.add(new TestFileTransfer()); + tests.add(new TestReservation()); } public void testAll()throws Exception{ Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/MockReservation.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/MockReservation.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/MockReservation.java 2007-10-25 20:59:25 UTC (rev 1811) @@ -0,0 +1,25 @@ +package de.fzj.unicore.uas.xnjs; + +import java.util.Calendar; + +import org.apache.xmlbeans.XmlObject; + +import de.fzj.unicore.xnjs.XnjsComponentImpl; +import de.fzj.unicore.xnjs.aaa.Client; +import de.fzj.unicore.xnjs.ems.ExecutionException; +import de.fzj.unicore.xnjs.tsi.IReservation; + +public class MockReservation extends XnjsComponentImpl implements IReservation { + + public void cancelReservation(String arg0, Client arg1) + throws ExecutionException { + // TODO Auto-generated method stub + + } + + public String makeReservation(XmlObject arg0, Calendar arg1, Client arg2) + throws ExecutionException { + return "1234"; + } + +} Modified: unicorex/uas-core/trunk/src/test/resources/wsrflite.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2007-10-25 20:59:25 UTC (rev 1811) @@ -78,6 +78,11 @@ <interface class="de.fzj.unicore.uas.StorageManagement" /> <implementation class="de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl"/> </service> + <!-- the reservation management service --> + <service name="ReservationManagement" wsrf="true" persistent="true"> + <interface class="de.fzj.unicore.uas.ReservationManagement" /> + <implementation class="de.fzj.unicore.uas.impl.reservation.ReservationManagementHomeImpl"/> + </service> <!-- the file transfer services --> <service name="FileTransfer" wsrf="true" persistent="true"> <interface class="de.fzj.unicore.uas.fts.FileTransfer" /> Modified: unicorex/uas-core/trunk/src/test/resources/xnjs.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/xnjs.xml 2007-10-25 20:58:05 UTC (rev 1810) +++ unicorex/uas-core/trunk/src/test/resources/xnjs.xml 2007-10-25 20:59:25 UTC (rev 1811) @@ -22,6 +22,8 @@ <eng:Grounder>de.fzj.unicore.xnjs.simple.BasicGrounder</eng:Grounder> <eng:ResourceChecker>de.fzj.unicore.xnjs.simple.BasicResourceChecker</eng:ResourceChecker> <eng:ProcessorFactory>de.fzj.unicore.xnjs.ems.processors.DefaultProcessorFactory</eng:ProcessorFactory> + <!-- dummy reservation module --> + <eng:Reservation>de.fzj.unicore.uas.xnjs.MockReservation</eng:Reservation> <!-- i/o --> <eng:FileTransferEngine>de.fzj.unicore.xnjs.io.simple.SimpleFileTransferEngine</eng:FileTransferEngine> <!-- persistence --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-10-26 15:09:32
|
Revision: 1815 http://unicore.svn.sourceforge.net/unicore/?rev=1815&view=rev Author: bschuller Date: 2007-10-26 08:09:27 -0700 (Fri, 26 Oct 2007) Log Message: ----------- use the http data transfer thingy as BFT implementation; better multi-protocol support in StorageClient Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/TestAllServicesExt.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/defaultsms/TestIODefaultSMS.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/resources/uas.config unicorex/uas-core/trunk/src/test/resources/wsrflite.xml Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -18,8 +18,13 @@ import de.fzj.unicore.wsrflite.utils.Utilities; /** - * client for managing a resource reservation - * + * Client for managing a resource reservation.<br/> + * It can be used to + * <ul> + * <li>query the reservation properties</li> + * <li>claim the booking by submitting a job including the reservation reference</li> + * <li>cancel the booking using the WSRF destroy() operation</li> + * </ul> * @author schuller */ public class ReservationClient extends BaseUASClient { @@ -39,7 +44,9 @@ } /** - * submit a job to the TSS used in this reservation + * Submit a job to the TSS used in this reservation<br/> + * If not present, the booking reference is inserted + * automatically into the resource description. * * @param in the submission document * @return @@ -48,32 +55,70 @@ JobDefinitionType job=in.getSubmit().getJobDefinition(); EndpointReferenceType tssEPR=getTSSEpr(); TSSClient tss=new TSSClient(tssEPR.getAddress().getStringValue(),tssEPR,getSecurityProperties()); - //add in the reservation reference... + //if necessary, add in the reservation reference... ResourcesType rt=job.getJobDescription().getResources(); if(rt==null)rt=job.getJobDescription().addNewResources(); - //TODO this should be more seamless :-) - String resID="<ReservationReference xmlns=\"http://www.unicore.eu/unicore/xnjs\">"+getReservationReference()+"</ReservationReference>"; - XmlObject o=XmlObject.Factory.parse(resID); - Utilities.append(o, rt); - + if(!rt.toString().contains("ReservationReference")){ + addReservationReference(rt); + } return tss.submit(in); } + /** + * add the reservation reference to the resources + * The reference is added as an XML element as follows: + * <ReservationReference xmlns="http://www.unicore.eu/unicore/xnjs">reference</ReservationReference> + * @param resources + * @throws Exception + */ + public void addReservationReference(ResourcesType resources) throws Exception{ + String resID="<u6rr:ReservationReference xmlns:u6rr=\"http://www.unicore.eu/unicore/xnjs\">"+getReservationReference()+"</u6rr:ReservationReference>"; + XmlObject o=XmlObject.Factory.parse(resID); + Utilities.append(o, resources); + } + + /** + * get the StartTime property + * @return start time for the reservation + * @throws Exception + */ public Calendar getStartTime()throws Exception{ return StartTimeDocument.Factory.parse(getResourceProperty(ReservationManagement.RPStartTime)).getStartTime(); } + /** + * get the reservation reference + * @return reservation reference String + * @throws Exception + */ public String getReservationReference()throws Exception{ return ReservationReferenceDocument.Factory.parse(getResourceProperty(ReservationManagement.RPReservationReference)).getReservationReference(); } + /** + * get the resources that have been reserved + * @return a {@link ResourcesDocument} + * @throws Exception + */ public ResourcesDocument getResources()throws Exception{ return ResourcesDocument.Factory.parse(getResourceProperty(ReservationManagement.RPResources)); } + + /** + * get the EPR of the TargetSystem where the reservation has been made + * @return an {@link EndpointReferenceType} holding the EPR + * @throws Exception + */ public EndpointReferenceType getTSSEpr()throws Exception{ return TargetSystemReferenceDocument.Factory.parse(getResourceProperty(ReservationManagement.RPTargetSystemReference)).getTargetSystemReference(); } + /** + * get the resource properties document of the Reservation WS-Resource + * + * @return a {@link ReservationPropertiesDocument} + * @throws Exception + */ public ReservationPropertiesDocument getReservationPropertiesDocument() throws Exception{ return ReservationPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().toString()); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -48,7 +48,6 @@ import org.unigrids.services.atomic.types.GridFileType; import org.unigrids.services.atomic.types.ProtocolDocument; import org.unigrids.services.atomic.types.ProtocolType; -import org.unigrids.x2006.x04.services.bfts.FileContentDocument; import org.unigrids.x2006.x04.services.sms.CopyDocument; import org.unigrids.x2006.x04.services.sms.CreateDirectoryDocument; import org.unigrids.x2006.x04.services.sms.DeleteDocument; @@ -70,7 +69,7 @@ import de.fzj.unicore.uas.StorageManagement; import de.fzj.unicore.uas.UAS; -import de.fzj.unicore.uas.fts.BaselineFileTransferImpl; +import de.fzj.unicore.uas.fts.http.HttpFileTransferClient; import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; @@ -127,6 +126,8 @@ sms=makeProxy(StorageManagement.class); registeredClients.put(ProtocolType.RBYTEIO, RByteIOClient.class); registeredClients.put(ProtocolType.SBYTEIO, SByteIOClient.class); + registeredClients.put(ProtocolType.BFT, HttpFileTransferClient.class); + }catch(Exception e){ e.printStackTrace(); throw new RuntimeException("could not create sms"); @@ -487,10 +488,8 @@ } else if(ProtocolType.BFT.equals(protocol)) { - BaseUASClient exportClient=new BaseUASClient(ftsEpr.getAddress().getStringValue(), ftsEpr,sec); - FileContentDocument fcd=FileContentDocument.Factory.parse( - exportClient.getResourceProperty(BaselineFileTransferImpl.RPFileContent)); - writeTo.write(fcd.getFileContent()); + HttpFileTransferClient exportClient=new HttpFileTransferClient(ftsEpr.getAddress().getStringValue(), ftsEpr,sec); + exportClient.readAllData(writeTo); } } catch (Exception e) { Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -33,165 +33,13 @@ package de.fzj.unicore.uas.fts; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Map; -import java.util.logging.Level; -import javax.xml.namespace.QName; - -import org.apache.xmlbeans.XmlObject; -import org.oasisOpen.docs.wsrf.rp2.InsertResourcePropertiesDocument; -import org.oasisOpen.docs.wsrf.rp2.InsertResourcePropertiesResponseDocument; -import org.oasisOpen.docs.wsrf.rp2.InsertType; -import org.unigrids.x2006.x04.services.bfts.FileContentDocument; - -import de.fzj.unicore.uas.impl.UASWSResourceImpl; -import de.fzj.unicore.uas.xnjs.XNJSFacade; -import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; -import de.fzj.unicore.xnjs.tsi.TSI; - /** - * supports the UniGrids "baseline" file transfer, which just - * has the file content as a resource property - * - * this is limited to files of 7 Megabytes max. - * + * @deprecated * @author schuller - * @version $Id: BaselineFileTransferImpl.java,v 1.6 2007/01/03 12:11:19 bschuller Exp $ */ -public class BaselineFileTransferImpl extends FileTransferImpl { +public class BaselineFileTransferImpl extends FileTransferImpl{ protected static final long serialVersionUID=123L; - - //the QName representing the filecontent property... - public static QName RPFileContent=FileContentDocument.type.getDocumentElementName(); - - @Override - public InsertResourcePropertiesResponseDocument InsertResourceProperties(InsertResourcePropertiesDocument req) throws BaseFault { - try{ - InsertType insert=req.getInsertResourceProperties().getInsert(); - FileContentDocument fd=FileContentDocument.Factory.parse(insert.newInputStream()); - byte[] content=fd.getFileContent(); - ((FileContentRP)properties.get(RPFileContent)).setProperty(content); - InsertResourcePropertiesResponseDocument resp= - InsertResourcePropertiesResponseDocument.Factory.newInstance(); - resp.addNewInsertResourcePropertiesResponse(); - return resp; - }catch(Exception e){ - throw BaseFault.createFault(e.getMessage()); - } - } - @Override - public void initialise(String name, Map<String, Object> map)throws Exception{ - super.initialise(name, map); - logger.info("Created BFT in directory="+workdir); - FileContentRP fc=new FileContentRP(workdir); - fc.setResource(this); - properties.put(RPFileContent, fc); - } - - /** - * the resource property representing the file content - */ - private class FileContentRP extends ResourceProperty<byte[]>{ - - private static final long serialVersionUID = 6166889123287130327L; - - //this should be a config param - private int max=7*1024*1024; - - private XmlObject[] xdoc; - private FileContentDocument content; - byte[] data; - private String storageRoot; - - public FileContentRP(String storageRoot){ - this.storageRoot=storageRoot; - content=FileContentDocument.Factory.newInstance(); - data=new byte[0]; - content.setFileContent(data); - xdoc=new XmlObject[]{content}; - logger.info("Created filecontent rp for base dir "+storageRoot); - } - - /* (non-Javadoc) - * @see de.fzj.unicore.wsrflite.ResourceProperty#update() - */ - @Override - public FileContentRP update() throws Exception { - if(source==null)return this; - try { - //read stuff from the tsi... - logger.finer("performing BFT... "); - TSI tsi=XNJSFacade.getStorageTSI(storageRoot, - ((UASWSResourceImpl)parentWSResource).getClient()); - InputStream is=tsi.getInputStream(source); - if(is==null){ - logger.severe("**** can't read from "+source); - throw new IOException("Can't read from source: "+source); - } - byte[] tmpdata=new byte[max]; - int l=is.read(tmpdata); - try{is.close();}catch(Exception e){} - if(l!=-1){ - logger.fine("Read "+l+" bytes, max="+max); - if(l==max) content.setFileContent(tmpdata); - else{ - try{ - data=new byte[l]; - System.arraycopy(tmpdata,0,data,0,l); - content.setFileContent(data); - } - catch(Exception e){ - e.printStackTrace(); - content.setFileContent(new byte[0]); - } - } - } - else logger.fine("Nothing to read."); - return this; - } catch (Exception e) { - // make sure we log the cause... - logger.log(Level.SEVERE,"Error performing BFT.",e); - throw e; - } - } - - @Override - public XmlObject[] getXml() { - return xdoc; - } - - - @Override - public void setProperty(byte[] fileContent ) { - try{ - logger.fine("Write to "+target); - if(fileContent==null){ - logger.severe("Nothing to write, got 'null'."); - return; - } - //write stuff to the tsi... - TSI tsi=XNJSFacade.getStorageTSI(storageRoot,((UASWSResourceImpl)parentWSResource).getClient()); - OutputStream os=tsi.getOutputStream(target); - if(os==null){ - logger.severe("**** can't write to "+target); - throw new RuntimeException("Can't write to: "+target); - } - os.write(fileContent); - os.flush(); - os.close(); - logger.fine("Written +"+fileContent.length+" bytes."); - } - catch(Exception e){ - logger.log(Level.SEVERE,"Error setting file content.",e); - } - } - } - - } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferHomeImpl.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -34,14 +34,23 @@ package de.fzj.unicore.uas.fts; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; import de.fzj.unicore.uas.UAS; +import de.fzj.unicore.uas.fts.http.HttpFileTransferImpl; import de.fzj.unicore.uas.impl.UASWSResourceHomeImpl; import de.fzj.unicore.wsrflite.exceptions.ResourceNotCreatedException; import de.fzj.unicore.wsrflite.xmlbeans.impl.WSResourceImpl; - +/** + * File transfer home<br/>. + * + * The actual class created by {@link #doCreateInstance()} is looked up dynamically + * in the UAS properties. + * + * @author schuller + */ public class FileTransferHomeImpl extends UASWSResourceHomeImpl { protected static final long serialVersionUID=2034234L; @@ -80,6 +89,7 @@ return (FileTransferImpl)Class.forName(clazz).newInstance(); } catch(Exception e){ + logger.warning("Exception : "+e.getMessage()); return new BaselineFileTransferImpl(); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -1,13 +1,10 @@ package de.fzj.unicore.uas.fts.http; -import java.math.BigInteger; import java.util.Map; import javax.xml.namespace.QName; import org.apache.xmlbeans.XmlObject; -import org.ggf.schemas.byteio.x2005.x10.randomAccess.SizeDocument; -import org.ggf.schemas.byteio.x2005.x10.randomAccess.TransferMechanismDocument; import de.fzj.unicore.uas.ft.http.AccessURLDocument; import de.fzj.unicore.uas.ft.http.HTTPFileTransferRPDocument; @@ -19,7 +16,7 @@ import de.fzj.unicore.wsrflite.xmlbeans.rp.ImmutableResourceProperty; /** - * Exposes a file using HTTP(s) via Jetty + * "Baseline" file transfer, which exposes a file using HTTP(s) via Jetty<br/> * * The URI for download is "cryptographically hard to guess" and * is exposed using a WSRF resource property, thus protected @@ -28,7 +25,6 @@ * Based on an idea by Roger Menday. <br/> * * @author schuller - * */ public class HttpFileTransferImpl extends FileTransferImpl{ protected static final long serialVersionUID=1L; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -38,17 +38,13 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.oasisOpen.docs.wsrf.rp2.InsertResourcePropertiesDocument; -import org.oasisOpen.docs.wsrf.rp2.InsertType; import org.unigrids.services.atomic.types.ProtocolType; -import org.unigrids.x2006.x04.services.bfts.FileContentDocument; import org.unigrids.x2006.x04.services.sms.ImportFileDocument; import org.unigrids.x2006.x04.services.sms.ImportFileResponseDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; -import de.fzj.unicore.uas.client.BaseUASClient; import de.fzj.unicore.uas.client.StorageClient; -import de.fzj.unicore.uas.fts.FileTransfer; +import de.fzj.unicore.uas.fts.http.HttpFileTransferClient; import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.uas.security.SecurityManager; import de.fzj.unicore.uas.security.Unicore6Tokens; @@ -113,18 +109,25 @@ public void run(){ try{ - data=readFromFile(0,128*1000); //limit BFT size! + TSI tsi=XNJSFacade.getTSI(client); + Action a=XNJSFacade.getAction(actionId); + String sourcePath=null; + if(a!=null){ + sourcePath=a.getExecutionContext().getWorkingDirectory()+sourceFile; + } + else sourcePath=sourceFile; + + logger.finer("Reading from "+sourcePath); + InputStream is=tsi.getInputStream(sourcePath); + //put to sms... String url=importEpr.getAddress().getStringValue(); - BaseUASClient c=new BaseUASClient(url,importEpr,sec); - InsertResourcePropertiesDocument insert=InsertResourcePropertiesDocument.Factory.newInstance(); - InsertType ins=insert.addNewInsertResourceProperties().addNewInsert(); - FileContentDocument fd=FileContentDocument.Factory.newInstance(); - fd.setFileContent(data); - ins.set(fd); - FileTransfer fts=(FileTransfer)c.makeProxy(FileTransfer.class); - fts.InsertResourceProperties(insert); - transferredBytes=data.length; + HttpFileTransferClient c=new HttpFileTransferClient(url,importEpr,sec); + c.writeAllData(is); + + //TODO more frequent updates somehow? Only possible with chunked transfers + transferredBytes=getDataSize(); + }catch(Exception e){ logger.log(Level.SEVERE,"Could not perform import.",e); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -39,14 +39,12 @@ import java.util.logging.Logger; import org.unigrids.services.atomic.types.ProtocolType; -import org.unigrids.x2006.x04.services.bfts.FileContentDocument; import org.unigrids.x2006.x04.services.sms.ExportFileDocument; import org.unigrids.x2006.x04.services.sms.ExportFileResponseDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; -import de.fzj.unicore.uas.client.BaseUASClient; import de.fzj.unicore.uas.client.StorageClient; -import de.fzj.unicore.uas.fts.BaselineFileTransferImpl; +import de.fzj.unicore.uas.fts.http.HttpFileTransferClient; import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.uas.security.SecurityManager; import de.fzj.unicore.uas.security.Unicore6Tokens; @@ -109,12 +107,11 @@ public void run(){ try{ String url=exportEpr.getAddress().getStringValue(); - BaseUASClient c=new BaseUASClient(url,exportEpr,sec); - FileContentDocument fc=FileContentDocument.Factory.newInstance(); - fc=FileContentDocument.Factory.parse(c.getResourceProperty(BaselineFileTransferImpl.RPFileContent)); - byte[] content=fc.getFileContent(); - dataSize=content.length; - writeToFile(content, false); + HttpFileTransferClient c=new HttpFileTransferClient(url,exportEpr,sec); + TSI tsi=XNJSFacade.getTSI(client); + createParentDirectories(path+targetFile); + OutputStream os=tsi.getOutputStream(path+targetFile,false); + c.readAllData(os); }catch(Exception e){ logger.log(Level.SEVERE,"Could not perform import.",e); } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/TestAllServicesExt.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/TestAllServicesExt.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/TestAllServicesExt.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -221,11 +221,6 @@ System.out.println(); System.out.println(exportClient.getResourcePropertyDocument()); Thread.sleep(1000); - //get stdout direct - FileContentDocument fcd=FileContentDocument.Factory.parse( - exportClient.getResourceProperty(BaselineFileTransferImpl.RPFileContent)); - String stdout=new String(fcd.getFileContent()); - System.out.println("result: "+stdout); } catch (Exception e) { // TODO Auto-generated catch block Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/defaultsms/TestIODefaultSMS.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/defaultsms/TestIODefaultSMS.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/defaultsms/TestIODefaultSMS.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -42,7 +42,6 @@ import org.unigrids.services.atomic.types.GridFileType; import org.unigrids.services.atomic.types.ProtocolType; import org.unigrids.services.atomic.types.StorageReferenceDocument; -import org.unigrids.x2006.x04.services.bfts.FileContentDocument; import org.unigrids.x2006.x04.services.sms.ExportFileDocument; import org.unigrids.x2006.x04.services.sms.ExportFileResponseDocument; import org.unigrids.x2006.x04.services.sms.ExportFileDocument.ExportFile; @@ -58,7 +57,6 @@ import de.fzj.unicore.uas.client.JobClient; import de.fzj.unicore.uas.client.StorageClient; import de.fzj.unicore.uas.client.TSSClient; -import de.fzj.unicore.uas.fts.BaselineFileTransferImpl; import de.fzj.unicore.uas.impl.job.JobManagementImpl; import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.uas.util.CreateSMSOnStartup; @@ -264,11 +262,6 @@ System.out.println(); System.out.println(exportClient.getResourcePropertyDocument()); Thread.sleep(1000); - //get stdout direct - FileContentDocument fcd=FileContentDocument.Factory.parse( - exportClient.getResourceProperty(BaselineFileTransferImpl.RPFileContent)); - String stdout=new String(fcd.getFileContent()); - System.out.println(stdout); } catch (Exception e) { // TODO Auto-generated catch block Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -34,15 +34,13 @@ String url; EndpointReferenceType tssepr; - String sampleStr = "010203040506070809101112131415161718192021222324252627282930"; - StorageClient sms; int errors=0; @Override public String getDescription() { - return "HTTP filetransfer tests"; + return "Baseline (HTTP) filetransfer tests"; } @Override @@ -118,9 +116,9 @@ System.out.println("Rate="+(size*loops)/time+ " kB/sec."); - sw.start("Start HTTP."); + sw.start("Start Baseline/HTTP."); ExportFileDocument in=ExportFileDocument.Factory.newInstance(); - in.addNewExportFile().setProtocol(ProtocolType.HTTP); + in.addNewExportFile().setProtocol(ProtocolType.BFT); in.getExportFile().setSource("/bigfile"); ExportFileResponseDocument res=sms.ExportFile(in); @@ -142,7 +140,7 @@ String testString="this is a test"; ByteArrayInputStream bis=new ByteArrayInputStream(testString.getBytes()); ImportFileDocument imp=ImportFileDocument.Factory.newInstance(); - imp.addNewImportFile().setProtocol(ProtocolType.HTTP); + imp.addNewImportFile().setProtocol(ProtocolType.BFT); imp.getImportFile().setDestination("/testfile"); ImportFileResponseDocument res2=sms.ImportFile(imp); Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestFileTransfer.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -1,7 +1,5 @@ package de.fzj.unicore.uas; -import java.io.IOException; -import java.io.OutputStream; import java.util.Calendar; import java.util.Random; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestReservation.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -15,7 +15,6 @@ import de.fzj.unicore.uas.client.TSFClient; import de.fzj.unicore.uas.client.TSSClient; import de.fzj.unicore.wsrflite.Kernel; -import de.fzj.unicore.wsrflite.xmlbeans.client.BaseWSRFClient; public class TestReservation extends RunDate { String url; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-10-26 15:09:27 UTC (rev 1815) @@ -52,9 +52,9 @@ // tests.add(new TestWSDL()); // tests.add(new RunServerServerTransfer()); // tests.add(new ByteIOTest()); -// tests.add(new HttpTest()); + tests.add(new HttpTest()); // tests.add(new TestFileTransfer()); - tests.add(new TestReservation()); +// tests.add(new TestReservation()); } public void testAll()throws Exception{ Modified: unicorex/uas-core/trunk/src/test/resources/uas.config =================================================================== --- unicorex/uas-core/trunk/src/test/resources/uas.config 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/resources/uas.config 2007-10-26 15:09:27 UTC (rev 1815) @@ -62,17 +62,16 @@ # File transfer protocols -# baseline -uas.filetransfer.protocol.BFT=de.fzj.unicore.uas.fts.BaselineFileTransferImpl +# baseline (using the default HTTP server) +uas.filetransfer.protocol.BFT=de.fzj.unicore.uas.fts.http.HttpFileTransferImpl # byteio uas.filetransfer.protocol.RBYTEIO=de.fzj.unicore.uas.fts.byteio.RandomByteIOImpl uas.filetransfer.protocol.SBYTEIO=de.fzj.unicore.uas.fts.byteio.StreamableByteIOImpl -#HTTP -uas.filetransfer.protocol.HTTP=de.fzj.unicore.uas.fts.http.HttpFileTransferImpl # # What protocols should a SMS support? # -uas.sms.protocols=RBYTEIO BFT SBYTEIO HTTP +uas.sms.protocols=BFT RBYTEIO SBYTEIO + Modified: unicorex/uas-core/trunk/src/test/resources/wsrflite.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2007-10-26 14:21:52 UTC (rev 1814) +++ unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2007-10-26 15:09:27 UTC (rev 1815) @@ -100,11 +100,7 @@ <interface class="de.fzj.unicore.uas.fts.byteio.StreamableByteIO" /> <implementation class="de.fzj.unicore.uas.fts.FileTransferHomeImpl"/> </service> - <service name="FileTransferHTTP" wsrf="true" persistent="true"> - <interface class="de.fzj.unicore.uas.fts.FileTransfer" /> - <implementation class="de.fzj.unicore.uas.fts.FileTransferHomeImpl"/> - </service> - <!-- the service group entry service --> + <!-- the service group entry service --> <service name="ServiceGroupEntry" wsrf="true" persistent="true"> <interface class="de.fzj.unicore.wsrflite.xmlbeans.sg.ServiceGroupEntry"/> <implementation class="de.fzj.unicore.uas.impl.registry.LocalRegistryEntryHomeImpl"/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-11-12 14:08:12
|
Revision: 1937 http://unicore.svn.sourceforge.net/unicore/?rev=1937&view=rev Author: bschuller Date: 2007-11-12 06:08:09 -0800 (Mon, 12 Nov 2007) Log Message: ----------- add/start filetransfers "atomically"; add nice logformatter; update sample start script Modified Paths: -------------- unicorex/uas-core/trunk/src/main/conf/logging.properties unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java unicorex/uas-core/trunk/src/main/scripts/start.sh unicorex/uas-core/trunk/src/site/apt/registry.apt Added Paths: ----------- unicorex/uas-core/trunk/src/main/conf/jmxremote.password unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java Added: unicorex/uas-core/trunk/src/main/conf/jmxremote.password =================================================================== --- unicorex/uas-core/trunk/src/main/conf/jmxremote.password (rev 0) +++ unicorex/uas-core/trunk/src/main/conf/jmxremote.password 2007-11-12 14:08:09 UTC (rev 1937) @@ -0,0 +1,9 @@ +# +# username/password for JMX +# +# this file must be read/write ONLY FOR ITS OWNER otherwise JMX complains + +monitorRole=unicore +controlRole=unicore + + Modified: unicorex/uas-core/trunk/src/main/conf/logging.properties =================================================================== --- unicorex/uas-core/trunk/src/main/conf/logging.properties 2007-11-12 13:26:31 UTC (rev 1936) +++ unicorex/uas-core/trunk/src/main/conf/logging.properties 2007-11-12 14:08:09 UTC (rev 1937) @@ -43,8 +43,8 @@ # --- ConsoleHandler --- # Override of global logging level -#java.util.logging.ConsoleHandler.level=SEVERE -#java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter +java.util.logging.ConsoleHandler.level=SEVERE +java.util.logging.ConsoleHandler.formatter=de.fzj.unicore.uas.util.LogFormatter # --- FileHandler --- # Override of global logging level @@ -53,7 +53,7 @@ # Naming style for the output file: # (The output file is placed in the directory # defined by the "user.home" System property.) -java.util.logging.FileHandler.pattern=log/uas%u.log +java.util.logging.FileHandler.pattern=logs/uas%u.log # Limiting size of output file in bytes: #java.util.logging.FileHandler.limit=50000 @@ -63,4 +63,4 @@ java.util.logging.FileHandler.count=10 # Style of output (Simple or XML): -java.util.logging.FileHandler.formatter=java.util.logging.SimpleFormatter \ No newline at end of file +java.util.logging.FileHandler.formatter=de.fzj.unicore.uas.util.LogFormatter \ No newline at end of file Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2007-11-12 13:26:31 UTC (rev 1936) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2007-11-12 14:08:09 UTC (rev 1937) @@ -175,8 +175,8 @@ private static JettyServer jettyServer; public static final String writeHeader(){ - return "\n UNICORE Atomic Services Implementation "+VERSION+ - "\n (c) Forschungszentrum Juelich 2006-2007" + + return "\n UNICORE/X "+VERSION+ + "\n (c) Forschungszentrum Juelich 2006-2008" + "\n All rights reserved.\n"; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java 2007-11-12 13:26:31 UTC (rev 1936) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java 2007-11-12 14:08:09 UTC (rev 1937) @@ -43,7 +43,6 @@ import org.ggf.schemas.byteio.x2005.x10.byteIo.TransferInformationType; import org.ggf.schemas.byteio.x2005.x10.randomAccess.AppendDocument; import org.ggf.schemas.byteio.x2005.x10.randomAccess.AppendResponseDocument; -import org.ggf.schemas.byteio.x2005.x10.randomAccess.RandomByteIORPDocument; import org.ggf.schemas.byteio.x2005.x10.randomAccess.ReadDocument; import org.ggf.schemas.byteio.x2005.x10.randomAccess.ReadResponseDocument; import org.ggf.schemas.byteio.x2005.x10.randomAccess.SizeDocument; Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java 2007-11-12 14:08:09 UTC (rev 1937) @@ -0,0 +1,107 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + *********************************************************************************/ + + +package de.fzj.unicore.uas.util; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.text.MessageFormat; +import java.util.Date; +import java.util.logging.Formatter; +import java.util.logging.Level; +import java.util.logging.LogRecord; + + +/** + * Slightly modified java.util.logging.SimpleFormatter<br/> + * Single line format, usually giving only log level, thread name, date/time and log message. + * + * @author schuller + */ +public class LogFormatter extends Formatter{ + + Date date = new Date(); + private final static String format = " {0,date} {0,time} "; + private MessageFormat formatter = new MessageFormat(format);; + + private Object args[] = new Object[]{date}; + + @SuppressWarnings("unchecked") + private String lineSeparator = (String) java.security.AccessController.doPrivileged( + new sun.security.action.GetPropertyAction("line.separator")); + + /** + * Format the given LogRecord. + * @param record the log record to be formatted. + * @return a formatted log record + */ + public synchronized String format(LogRecord record) { + StringBuffer sb = new StringBuffer(); + // Minimize memory allocations here. + date.setTime(record.getMillis()); + String message = formatMessage(record); + sb.append(record.getLevel().getLocalizedName()); + formatter.format(args,sb,null); + sb.append("["+Thread.currentThread().getName()+"] "); + sb.append(message); + sb.append(lineSeparator); + if (record.getThrown() != null) { + try { + if (record.getSourceClassName() != null) { + sb.append(record.getSourceClassName()); + } else { + sb.append(record.getLoggerName()); + } + if (record.getSourceMethodName() != null) { + sb.append(" "); + sb.append(record.getSourceMethodName()); + } + sb.append(lineSeparator); + + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + record.getThrown().printStackTrace(pw); + pw.close(); + sb.append(sw.toString()); + } catch (Exception ex) { + } + } + return sb.toString(); + } + + public static void main(String[] args){ + LogRecord rec=new LogRecord(Level.INFO,"Test123"); + rec.setThrown(new RuntimeException()); + System.out.println(new LogFormatter().format(rec)); + } + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java 2007-11-12 13:26:31 UTC (rev 1936) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java 2007-11-12 14:08:09 UTC (rev 1937) @@ -92,6 +92,7 @@ try{ List<DataStagingType> dstl=(List<DataStagingType>)action.getAjd(); List<String> ftList=new ArrayList<String>(); + List<IFileTransfer> ftInstances=new ArrayList<IFileTransfer>(); action.getProcessingContext().put(fileTransferKey,ftList); if(dstl==null){ logger.severe("Data staging expected but not found"); @@ -103,14 +104,24 @@ try{ URI source=extractSource(dst); URI target=extractTarget(dst); - logger.info("transferring: "+source+"->"+target); IFileTransfer ft=XNJSFacade.getConfiguration().getFileTransferEngine(). createFileTransfer(action,source,target); + ftList.add(ft.getUniqueId()); + ftInstances.add(ft); + }catch(Exception e){ + logger.log(Level.SEVERE,"Error adding filetransfer: "+dst,e); + setToDoneAndFailed(); + return; + } + + } + for(IFileTransfer ft:ftInstances){ + try{ ft.start(); - action.addLogTrace("Added filetransfer "+source+" -> "+target); + action.addLogTrace("Started filetransfer "+ft.getSource()+" -> "+ft.getTarget()); ftList.add(ft.getUniqueId()); }catch(Exception e){ - logger.log(Level.WARNING,"Error adding filetransfer: "+dst,e); + logger.log(Level.WARNING,"Error starting filetransfer: "+ft.getSource()+"->"+ft.getTarget()); setToDoneAndFailed(); return; } Modified: unicorex/uas-core/trunk/src/main/scripts/start.sh =================================================================== --- unicorex/uas-core/trunk/src/main/scripts/start.sh 2007-11-12 13:26:31 UTC (rev 1936) +++ unicorex/uas-core/trunk/src/main/scripts/start.sh 2007-11-12 14:08:09 UTC (rev 1937) @@ -55,6 +55,9 @@ #enable JMX (use jconsole to connect) # #OPTS=$OPTS" -Dcom.sun.management.jmxremote" +#OPTS=$OPTS" -Dcom.sun.management.jmxremote.port=9128 -Dcom.sun.management.jmxremote.authenticate=true" +#OPTS=$OPTS" -Dcom.sun.management.jmxremote.ssl=false" +#OPTS=$OPTS" -Dcom.sun.management.jmxremote.password.file=conf/jmxremote.password" # #Memory for the VM @@ -82,8 +85,8 @@ #go # -nohup $JAVA ${MEM} ${OPTS} ${DEFS} -cp ${CP} de.fzj.unicore.uas.UAS ${PARAM} >> log/startup.log 2>&1 & echo $! > LAST_PID +nohup $JAVA ${MEM} ${OPTS} ${DEFS} -cp ${CP} de.fzj.unicore.uas.UAS ${PARAM} > logs/startup.log 2>&1 & echo $! > LAST_PID -echo "Unicore atomic services starting." +echo "UNICORE/X starting." Modified: unicorex/uas-core/trunk/src/site/apt/registry.apt =================================================================== --- unicorex/uas-core/trunk/src/site/apt/registry.apt 2007-11-12 13:26:31 UTC (rev 1936) +++ unicorex/uas-core/trunk/src/site/apt/registry.apt 2007-11-12 14:08:09 UTC (rev 1937) @@ -76,7 +76,6 @@ Vsite configuration - To use a specific registry, configure the address of the registry in uas.config. The simplest is to use auto-discover the registry in your network using multicast. Then you just have to set a single property in uas.config: @@ -85,6 +84,15 @@ #switch on use of external registry uas.externalregistry.use=true +----------------------- + + The entries in the global registry are updated at a specified interval. To control this +interval, edit a property in wsrflite.xml: + ++----------------------- + <!-- default termination time for registry entries in seconds --> + <property name="unicore.wsrflite.sg.defaulttermtime" value="1800"/> ++----------------------- + * manual configuration @@ -110,8 +118,8 @@ +----------------------- + - Client configuration Make sure your clients all use the global, shared registry. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-11-15 21:16:22
|
Revision: 1973 http://unicore.svn.sourceforge.net/unicore/?rev=1973&view=rev Author: bschuller Date: 2007-11-15 13:16:14 -0800 (Thu, 15 Nov 2007) Log Message: ----------- mostly client code simplification; some documentation updates Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/BaseUASClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TransferControllerClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/RunServerServerTransfer.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/BaseUASClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/BaseUASClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/BaseUASClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -100,4 +100,7 @@ logger.log(Level.WARNING,"Receiver from epr is not a proper X500 name",e); } } + + + } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -37,7 +37,6 @@ import java.util.Calendar; import java.util.logging.Level; -import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument; import org.unigrids.services.atomic.types.StatusInfoDocument; import org.unigrids.services.atomic.types.StatusType; import org.unigrids.x2006.x04.services.jms.AbortDocument; @@ -94,11 +93,7 @@ * @param epr */ public JobPropertiesDocument getResourcePropertiesDocument()throws Exception{ - GetResourcePropertyDocumentResponseDocument grprd=GetResourcePropertyDocumentResponseDocument. - Factory.parse(getResourcePropertyDocument()); - JobPropertiesDocument doc= JobPropertiesDocument.Factory. - parse(grprd.getGetResourcePropertyDocumentResponse().newInputStream()); - return doc; + return JobPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().newInputStream()); } /** Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/ReservationClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -120,7 +120,7 @@ * @throws Exception */ public ReservationPropertiesDocument getReservationPropertiesDocument() throws Exception{ - return ReservationPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().toString()); + return ReservationPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().newInputStream()); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -44,7 +44,6 @@ import javax.xml.namespace.QName; import org.ggf.schemas.jsdl.x2005.x11.jsdl.FileSystemDocument; -import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument; import org.unigrids.services.atomic.types.GridFileType; import org.unigrids.services.atomic.types.ProtocolDocument; import org.unigrids.services.atomic.types.ProtocolType; @@ -140,11 +139,7 @@ * @param epr */ public StoragePropertiesDocument getResourcePropertiesDocument()throws Exception{ - GetResourcePropertyDocumentResponseDocument grprd=GetResourcePropertyDocumentResponseDocument. - Factory.parse(getResourcePropertyDocument()); - StoragePropertiesDocument doc=StoragePropertiesDocument.Factory. - parse(grprd.getGetResourcePropertyDocumentResponse().newInputStream()); - return doc; + return StoragePropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().newInputStream()); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSFClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -6,20 +6,21 @@ import java.util.logging.Level; import org.oasisOpen.docs.wsrf.rl2.TerminationTimeDocument.TerminationTime; -import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument; import org.unigrids.x2006.x04.services.tsf.CreateTSRDocument; import org.unigrids.x2006.x04.services.tsf.CreateTSRResponseDocument; import org.unigrids.x2006.x04.services.tsf.TargetSystemFactoryPropertiesDocument; -import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; -import de.fzj.unicore.uas.ResourceReservation; import de.fzj.unicore.uas.TargetSystemFactory; import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.wsrflite.xmlbeans.BaseFault; +/** + * Client for the TargetSystemFactory service + * + * @author schuller + */ public class TSFClient extends BaseUASClient { - public TSFClient(String endpointUrl, EndpointReferenceType epr, IUASSecurityProperties sec)throws Exception { super(endpointUrl, epr,sec); @@ -97,16 +98,11 @@ * @param epr */ public TargetSystemFactoryPropertiesDocument getResourcePropertiesDocument()throws Exception{ - GetResourcePropertyDocumentResponseDocument grprd=GetResourcePropertyDocumentResponseDocument. - Factory.parse(getResourcePropertyDocument()); - TargetSystemFactoryPropertiesDocument doc=TargetSystemFactoryPropertiesDocument.Factory. - parse(grprd.getGetResourcePropertyDocumentResponse().newInputStream()); - return doc; + return TargetSystemFactoryPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().newInputStream()); } public boolean supportsReservation()throws Exception{ - SupportsReservationDocument resSupport=SupportsReservationDocument.Factory.parse(getResourceProperty(ResourceReservation.RP_SUPPORTS_RESERVATION)); - return resSupport.getSupportsReservation(); + return getResourcePropertiesDocument().getTargetSystemFactoryProperties().getSupportsReservation(); } public List<EndpointReferenceType> getTargetSystems(){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TSSClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -41,13 +41,12 @@ import java.util.logging.Level; import org.ggf.schemas.jsdl.x2005.x11.jsdl.ResourcesDocument; -import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument; +import org.unigrids.services.atomic.types.SiteResourceType; import org.unigrids.services.atomic.types.StorageReferenceType; import org.unigrids.services.atomic.types.TextInfoType; import org.unigrids.x2006.x04.services.reservation.ResourceReservationRequestDocument; import org.unigrids.x2006.x04.services.reservation.ResourceReservationResponseDocument; import org.unigrids.x2006.x04.services.tss.ApplicationResourceType; -import org.unigrids.x2006.x04.services.tss.NameDocument; import org.unigrids.x2006.x04.services.tss.SubmitDocument; import org.unigrids.x2006.x04.services.tss.SubmitResponseDocument; import org.unigrids.x2006.x04.services.tss.SupportsReservationDocument; @@ -64,7 +63,6 @@ * client for the TargetSystem Service * * @author schuller - * @version $Id: TSSClient.java,v 1.5 2006/09/08 12:33:47 bschuller Exp $ */ public class TSSClient extends BaseUASClient { @@ -123,14 +121,28 @@ * @param epr */ public TargetSystemPropertiesDocument getResourcePropertiesDocument()throws Exception{ - GetResourcePropertyDocumentResponseDocument grprd=GetResourcePropertyDocumentResponseDocument. - Factory.parse(getResourcePropertyDocument()); - TargetSystemPropertiesDocument doc= TargetSystemPropertiesDocument.Factory. - parse(grprd.getGetResourcePropertyDocumentResponse().newInputStream()); - return doc; + return TargetSystemPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().newInputStream()); } /** + * return the service's UpSince property + * @return Calendar + * @since 1.0.1 + */ + public Calendar getUpSince()throws Exception{ + return getResourcePropertiesDocument().getTargetSystemProperties().getUpSince(); + } + + /** + * return the number of jobs on the resource + * @return the number of jobs + * @since 1.0.1 + */ + public long getNumberOfJobs()throws Exception{ + return getResourcePropertiesDocument().getTargetSystemProperties().getTotalNumberOfJobs().longValue(); + } + + /** * get the current list of jobs on this target system * @return List of job eprs */ @@ -167,8 +179,7 @@ public String getTargetSystemName(){ if(name==null){ try{ - NameDocument nd=NameDocument.Factory.parse(getResourceProperty(TargetSystem.RPName)); - name=nd.getName(); + return getResourcePropertiesDocument().getTargetSystemProperties().getName(); }catch(Exception e){ logger.log(Level.WARNING,"Can't get name from TSS.",e); } @@ -206,6 +217,20 @@ } /** + * @return the list of site specific resources + * @since 1.0.1 + */ + public List<SiteResourceType> getSiteSpecificResources() throws Exception{ + try{ + SiteResourceType[] info = getResourcePropertiesDocument().getTargetSystemProperties().getSiteResourceArray(); + return Arrays.asList(info); + }catch(Exception e){ + logger.log(Level.WARNING,"Can't get site-specific resource info from TSS.",e); + } + return null; + } + + /** * helper for retrieving a TSSClient from a given registry * @param registryURL * @return TSSClient Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TransferControllerClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TransferControllerClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/TransferControllerClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -5,12 +5,9 @@ import javax.xml.namespace.QName; import org.ggf.schemas.byteio.x2005.x10.randomAccess.SizeDocument; -import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentResponseDocument; import org.unigrids.x2006.x04.services.fts.FileTransferPropertiesDocument; -import org.unigrids.x2006.x04.services.fts.TransferredBytesDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; -import de.fzj.unicore.uas.fts.FileTransfer; import de.fzj.unicore.uas.security.IUASSecurityProperties; /** @@ -35,11 +32,7 @@ * @param epr */ public FileTransferPropertiesDocument getResourcePropertiesDocument()throws Exception{ - GetResourcePropertyDocumentResponseDocument grprd=GetResourcePropertyDocumentResponseDocument. - Factory.parse(getResourcePropertyDocument()); - FileTransferPropertiesDocument doc= FileTransferPropertiesDocument.Factory. - parse(grprd.getGetResourcePropertyDocumentResponse().newInputStream()); - return doc; + return FileTransferPropertiesDocument.Factory.parse(GetResourcePropertyDocument().getGetResourcePropertyDocumentResponse().newInputStream()); } /** * @param url @@ -54,8 +47,7 @@ */ public long getTransferredBytes(){ try{ - TransferredBytesDocument tbd=TransferredBytesDocument.Factory.parse(getResourceProperty(FileTransfer.RPTransferred)); - return tbd.getTransferredBytes(); + return getResourcePropertiesDocument().getFileTransferProperties().getTransferredBytes(); }catch(Exception e){ logger.log(Level.SEVERE,"Can't get transferred bytes information.",e); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/BaselineFileTransferImpl.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -33,12 +33,14 @@ package de.fzj.unicore.uas.fts; +import de.fzj.unicore.uas.fts.http.HttpFileTransferImpl; + /** - * @deprecated + * @deprecated please use {@link HttpFileTransferImpl} instead! * @author schuller */ -public class BaselineFileTransferImpl extends FileTransferImpl{ +public class BaselineFileTransferImpl extends HttpFileTransferImpl{ protected static final long serialVersionUID=123L; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -12,6 +12,7 @@ import de.fzj.unicore.uas.xnjs.U6FileTransfer; import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.ResourcePool; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.io.IFileTransfer; @@ -81,13 +82,12 @@ createFileTransfer(dummy,new URI("file://"+source),new URI(target)); } fileTransfers.put(getUniqueID(), ft); - Thread t=new Thread(){ + + ResourcePool.getExecutorService().execute(new Runnable(){ public void run(){ ft.start(); } - }; - t.setPriority(Thread.MAX_PRIORITY); - t.start(); + }); } @Override @@ -103,7 +103,7 @@ /** - * setup the source and target propperties of this transfer<br/> + * setup the source and target properties of this transfer<br/> * * @param rawsource * @param rawtarget Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -23,6 +23,7 @@ * this servlet exposes files under a "hard to guess" URL * * @author schuller + * @since 1.0.1 */ public class FileServlet extends DefaultServlet { Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -28,6 +28,7 @@ * Client for getting/putting a file through HTTP * * @author schuller + * @since 1.0.1 */ public class HttpFileTransferClient extends FileTransferClient{ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -28,6 +28,7 @@ * Based on an idea by Roger Menday. <br/> * * @author schuller + * @since 1.0.1 */ public class HttpFileTransferImpl extends FileTransferImpl{ protected static final long serialVersionUID=1L; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -21,6 +21,7 @@ * as well. * * @author schuller + * @since 1.0.1 */ public class UResource extends Resource { Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/package.html 2007-11-15 21:16:14 UTC (rev 1973) @@ -1,6 +1,10 @@ <html> <body> This package contains an implementation of a -http(s) file transfer using the Jetty server. +http(s) file transfer using the Jetty server. This is plugged into UNICORE 6 +as a replacement for the original "Baseline" filetransfer. +<br/> +Note: The UNICORE/X server must be accessible from outside the firewall. + </body> </html> \ No newline at end of file Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -24,7 +24,7 @@ * * @author schuller */ -public class ReservationManagementImpl extends UASWSResourceImpl implements ReservationManagement { +public class ReservationManagementImpl extends UASWSResourceImpl implements ReservationManagement { private static final long serialVersionUID = 1L; @@ -50,6 +50,7 @@ res.setReservationReference(reservationReference); properties.put(RPReservationReference, new ImmutableResourceProperty(res)); + //TODO make dynamic, query XNJS IReservation StartTimeDocument startTime=StartTimeDocument.Factory.newInstance(); startTime.setStartTime((Calendar)initParams.get(INITPARAM_STARTTIME)); properties.put(RPStartTime, new ImmutableResourceProperty(startTime)); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -603,7 +603,7 @@ if(UAS.getProperty(SMS_DIRECT_FILETRANSFER)!=null){ enableDirectFiletransfer=Boolean.parseBoolean(UAS.getProperty(SMS_DIRECT_FILETRANSFER)); } - logger.info("Filetransfers bypass gateway = "+enableDirectFiletransfer); + logger.config("Filetransfers bypass gateway = "+enableDirectFiletransfer); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogFormatter.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -46,6 +46,7 @@ * Single line format, usually giving only log level, thread name, date/time and log message. * * @author schuller + * @since 1.0.1 */ public class LogFormatter extends Formatter{ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -192,8 +192,6 @@ logger.log(Level.WARNING,"Could not determine file size for "+targetFile+".",e); } } - logger.info("GET DATASIZE "+dataSize); - return dataSize; } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/RunServerServerTransfer.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/RunServerServerTransfer.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/RunServerServerTransfer.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -12,8 +12,6 @@ String url; EndpointReferenceType tssepr; - String testString="this is an import test"; - public RunServerServerTransfer(){ } @@ -24,36 +22,41 @@ @Override protected void beforeStart(JobClient jms) throws Exception { - //tell uspace sms to fetch a file from the default_storage sms - TransferControllerClient c=jms.getUspaceClient(). - fetchFile("RBYTEIO:http://localhost:65321/services/StorageManagement?res=default_storage#test.txt1", - "/testfile"); - assertTrue(c!=null); - jms.waitUntilReady(180*1000); - while(!c.isComplete()){ + + String [] protocols=new String[]{"BFT"};//,"RBYTEIO",}; + + for(String protocol: protocols){ + System.out.println("\n\nTesting server-server transfer using <"+protocol+">\n\n"); + //tell uspace sms to fetch a file from the default_storage sms + TransferControllerClient c=jms.getUspaceClient().fetchFile(protocol+":http://localhost:65321/services/StorageManagement?res=default_storage#test.txt", + "/testfile"); + assertTrue(c!=null); + jms.waitUntilReady(180*1000); + + //Thread.sleep(3000); + + while(!c.isComplete()){ + Thread.sleep(1000); + } System.out.println(c.getResourcePropertyDocument()); System.out.println("Size of remote file = "+c.getSize()); System.out.println("Transferred = "+c.getTransferredBytes()); - Thread.sleep(500); - } - System.out.println(c.getResourcePropertyDocument()); - System.out.println("Size of remote file = "+c.getSize()); - System.out.println("Transferred = "+c.getTransferredBytes()); - - //tell uspace sms to send a file to the default_storage sms - TransferControllerClient c1=jms.getUspaceClient(). - sendFile("/testfile", - "RBYTEIO:http://localhost:65321/services/StorageManagement?res=default_storage#test1.txt"); - assertTrue(c1!=null); - jms.waitUntilReady(180*1000); - do{ + + //tell uspace sms to send a file to the default_storage sms + TransferControllerClient c1=jms.getUspaceClient().sendFile("/testfile", + protocol+":http://localhost:65321/services/StorageManagement?res=default_storage#test1.txt"); + assertTrue(c1!=null); + jms.waitUntilReady(180*1000); + do{ + System.out.println("Not complete..."); + Thread.sleep(1000); + }while(!c1.isComplete()); System.out.println(c1.getResourcePropertyDocument()); System.out.println("Size of remote file = "+c1.getSize()); System.out.println("Transferred = "+c1.getTransferredBytes()); - }while(!c1.isComplete()); + } - } @Override Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -40,7 +40,7 @@ protected void addTests(){ // tests.add(new RunDate()); -// tests.add(new TestTSFClient()); + tests.add(new TestTSFClient()); // tests.add(new RunCat()); // tests.add(new RunCatWithStageInFromRemoteSMS()); // tests.add(new RunStageInWithMissingDir()); @@ -52,7 +52,7 @@ // tests.add(new TestWSDL()); // tests.add(new RunServerServerTransfer()); // tests.add(new ByteIOTest()); - tests.add(new HttpTest()); +// tests.add(new HttpTest()); // tests.add(new TestFileTransfer()); // tests.add(new TestReservation()); } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java 2007-11-15 20:58:31 UTC (rev 1972) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java 2007-11-15 21:16:14 UTC (rev 1973) @@ -38,6 +38,10 @@ runJob(tss); + System.out.println(System.currentTimeMillis()+" "+tss.getTargetSystemName()); + System.out.println(System.currentTimeMillis()+" "+tss.getTargetSystemName()); + System.out.println(System.currentTimeMillis()+" "+tss.getTargetSystemName()); + System.out.println(tss.getResourcePropertyDocument()); tss.destroy(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-12-10 18:46:02
|
Revision: 2093 http://unicore.svn.sourceforge.net/unicore/?rev=2093&view=rev Author: bschuller Date: 2007-12-10 10:46:00 -0800 (Mon, 10 Dec 2007) Log Message: ----------- move resourceproperty classes Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/Constants.java unicorex/uas-core/trunk/src/site/apt/programmer/getstarted.apt Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ProtocolRP.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/TSSReferenceResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/WorkingDirResourceProperty.java Removed Paths: ------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/rp/ProtocolRP.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/ExecutionJSDLResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/LogResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StatusInfoResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdErrProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdOutProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/TSSReferenceResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/WorkingDirResourceProperty.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -456,7 +456,7 @@ * @return */ public static void download(URI uri, IUASSecurityProperties sec, OutputStream writeTo) - { + { try { ProtocolType.Enum protocol = ProtocolType.Enum.forString(uri.getScheme()); String storageUrl = uri.getSchemeSpecificPart(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -51,7 +51,6 @@ import org.unigrids.x2006.x04.services.fts.TransferredBytesDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; -import de.fzj.unicore.uas.fts.rp.ProtocolRP; import de.fzj.unicore.uas.impl.UASWSResourceImpl; import de.fzj.unicore.uas.xnjs.XNJSFacade; import de.fzj.unicore.wsrflite.WSRFInstance; Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ProtocolRP.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/rp/ProtocolRP.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ProtocolRP.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ProtocolRP.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,75 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.fts; + +import org.unigrids.services.atomic.types.ProtocolDocument; +import org.unigrids.services.atomic.types.ProtocolType; + +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; + +/** + * Property representing a filetransfer protocol + */ +public class ProtocolRP extends ResourceProperty<ProtocolType.Enum[]>{ + + private static final long serialVersionUID = -3186248112485716127L; + + private ProtocolDocument[] xdoc; + private ProtocolType.Enum[] protocols; + + public ProtocolRP(ProtocolType.Enum[] protocols){ + this.protocols=protocols; + xdoc=new ProtocolDocument[protocols.length]; + for(int i=0;i<protocols.length;i++){ + ProtocolType.Enum protocol= protocols[i]; + ProtocolDocument pd=ProtocolDocument.Factory.newInstance(); + pd.setProtocol(protocol); + xdoc[i]=pd; + } + } + + @Override + public ProtocolDocument[] getXml() { + return xdoc; + } + + + /** + * returns the protocol array + */ + @Override + public ProtocolType.Enum[] getProperty() { + return protocols; + } +} \ No newline at end of file Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/rp/ProtocolRP.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/rp/ProtocolRP.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/rp/ProtocolRP.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,75 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.fts.rp; - -import org.unigrids.services.atomic.types.ProtocolDocument; -import org.unigrids.services.atomic.types.ProtocolType; - -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; - -/** - * Property representing a filetransfer protocol - */ -public class ProtocolRP extends ResourceProperty<ProtocolType.Enum[]>{ - - private static final long serialVersionUID = -3186248112485716127L; - - private ProtocolDocument[] xdoc; - private ProtocolType.Enum[] protocols; - - public ProtocolRP(ProtocolType.Enum[] protocols){ - this.protocols=protocols; - xdoc=new ProtocolDocument[protocols.length]; - for(int i=0;i<protocols.length;i++){ - ProtocolType.Enum protocol= protocols[i]; - ProtocolDocument pd=ProtocolDocument.Factory.newInstance(); - pd.setProtocol(protocol); - xdoc[i]=pd; - } - } - - @Override - public ProtocolDocument[] getXml() { - return xdoc; - } - - - /** - * returns the protocol array - */ - @Override - public ProtocolType.Enum[] getProperty() { - return protocols; - } -} \ No newline at end of file Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/ExecutionJSDLResourceProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,86 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.impl.job; + +import java.util.logging.Logger; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; +import org.unigrids.x2006.x04.services.jms.ExecutionJSDLDocument; + +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; + +/** + * Contains the JSDL job description that is actually executed by the XNJS + * after incarnation + */ +public class ExecutionJSDLResourceProperty extends ResourceProperty<Object> { + protected static final long serialVersionUID=20348L; + + protected static Logger logger=Logger.getLogger(ExecutionJSDLResourceProperty.class.getName()); + + private ExecutionJSDLDocument[] xdoc; + + private String actionId; + + /** + * + * @param jobID the id of the job + */ + public ExecutionJSDLResourceProperty(String jobID){ + this.actionId=jobID; + xdoc=new ExecutionJSDLDocument[1]; + + } + + @Override + public ExecutionJSDLDocument getProperty() { + return xdoc[0]; + } + + @Override + public ExecutionJSDLDocument[] getXml() { + return xdoc; + } + + @Override + public ExecutionJSDLResourceProperty update() throws Exception{ + JobDefinitionDocument jdd=(JobDefinitionDocument)XNJSFacade.getAction(actionId).getAjd(); + ExecutionJSDLDocument ejd=ExecutionJSDLDocument.Factory.newInstance(); + ejd.setExecutionJSDL(jdd.getJobDefinition()); + xdoc[0]=ejd; + return this; + } + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -62,13 +62,6 @@ import de.fzj.unicore.uas.faults.JobNotStartedFault; import de.fzj.unicore.uas.impl.UASWSResourceImpl; import de.fzj.unicore.uas.impl.bp.BPSupportImpl; -import de.fzj.unicore.uas.impl.job.rp.ExecutionJSDLResourceProperty; -import de.fzj.unicore.uas.impl.job.rp.LogResourceProperty; -import de.fzj.unicore.uas.impl.job.rp.StatusInfoResourceProperty; -import de.fzj.unicore.uas.impl.job.rp.StdErrProperty; -import de.fzj.unicore.uas.impl.job.rp.StdOutProperty; -import de.fzj.unicore.uas.impl.job.rp.TSSReferenceResourceProperty; -import de.fzj.unicore.uas.impl.job.rp.WorkingDirResourceProperty; import de.fzj.unicore.uas.impl.sms.SMSBaseImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl.StorageTypes; Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/LogResourceProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,106 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.impl.job; + +import java.util.List; +import java.util.logging.Logger; + +import org.unigrids.x2006.x04.services.jms.LogDocument; + +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; +import de.fzj.unicore.xnjs.aaa.Client; + +/** + * Contains the job log (which is copied from the XNJS Action log) + */ +public class LogResourceProperty extends ResourceProperty<String>{ + protected static final long serialVersionUID=20348L; + + protected static Logger logger=Logger.getLogger(LogResourceProperty.class.getName()); + + private LogDocument status; + + private LogDocument[] xdoc; + + private String actionId; + + /** + * TODO + * log can be seen without access control, + * is this a security hole in the XNJS or not? + */ + private Client client; + + /** + * + * @param jobID the id of the job + */ + public LogResourceProperty(String jobID, Client client){ + status=LogDocument.Factory.newInstance(); + status.setLog(""); + xdoc=new LogDocument[]{status}; + this.actionId=jobID; + this.client=client; + } + + @Override + public String getProperty() { + return status.getLog(); + } + + @Override + public LogDocument[] getXml() { + return xdoc; + } + + @Override + public void setProperty(String log) { + status.setLog(log); + } + + /** + * + * @see de.fzj.unicore.wsrflite.ResourceProperty#update() + */ + @Override + public LogResourceProperty update() throws Exception{ + StringBuffer sb=new StringBuffer(); + List<String> l=XNJSFacade.getAction(actionId).getLog(); + for(String s:l)sb.append(s+"\n"); + status.setLog(sb.toString()); + return this; + } + +} Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java (from rev 1519, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StatusInfoResourceProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,142 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.impl.job; + +import java.math.BigInteger; +import java.util.logging.Logger; + +import org.unigrids.services.atomic.types.StatusInfoDocument; +import org.unigrids.services.atomic.types.StatusType.Enum; + +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; +import de.fzj.unicore.xnjs.aaa.Client; +import de.fzj.unicore.xnjs.ems.ActionStatus; + +/** + * Represents the job status + */ +public class StatusInfoResourceProperty extends ResourceProperty<Object> { + protected static final long serialVersionUID=20348L; + + protected static Logger logger=Logger.getLogger(StatusInfoResourceProperty.class.getName()); + + private StatusInfoDocument status; + + private StatusInfoDocument[] xdoc; + + private String actionId; + private Client client; + + /** + * + * @param jobID the id of the job + */ + public StatusInfoResourceProperty(String jobID, Client client){ + status=StatusInfoDocument.Factory.newInstance(); + status.addNewStatusInfo(); + xdoc=new StatusInfoDocument[]{status}; + this.actionId=jobID; + } + + @Override + public StatusInfoDocument[] getXml() { + return xdoc; + } + + /** + * + * @see de.fzj.unicore.wsrflite.ResourceProperty#update() + */ + @Override + public StatusInfoResourceProperty update() throws Exception{ + status.getStatusInfo().setStatus( + convertStatus( + XNJSFacade.getStatus(actionId,client))); + + Integer exitCode=XNJSFacade.getExitCode(actionId,client); + if(exitCode!=null){ + status.getStatusInfo().setExitCode(BigInteger.valueOf(exitCode.longValue())); + } + return this; + } + + /** + * converts from the XNJS action status to Unicore job status + * + * states from unigridsTypes.xsd + * + * <xsd:simpleType name="StatusType"> + <xsd:restriction base="xsd:string"> + <xsd:enumeration value="UNDEFINED"/> + <xsd:enumeration value="READY"/> + <xsd:enumeration value="QUEUED"/> + <xsd:enumeration value="RUNNING"/> + <xsd:enumeration value="SUCCESSFUL"/> + <xsd:enumeration value="FAILED"/> + <xsd:enumeration value="STAGINGIN"/> + <xsd:enumeration value="STAGINGOUT"/> + </xsd:restriction> + </xsd:simpleType> + * + * @param emsStatus + * @return UNICORE status + */ + protected Enum convertStatus(Integer emsStatus){ + int i=emsStatus.intValue(); + switch (i){ + case ActionStatus.PREPROCESSING: + return Enum.forString("STAGINGIN"); + case ActionStatus.POSTPROCESSING: + return Enum.forString("STAGINGOUT"); + case ActionStatus.RUNNING: + return Enum.forString("RUNNING"); + case ActionStatus.PENDING: + return Enum.forString("QUEUED"); + case ActionStatus.READY: + return Enum.forString("READY"); + case ActionStatus.DONE: + //figure out if success or not + if(XNJSFacade.getAction(actionId).getResult().isSuccessful()){ + return Enum.forString("SUCCESSFUL"); + } + else{ + return Enum.forString("FAILED"); + } + default: + return Enum.forString("UNDEFINED"); + } + } + +} Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdErrProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,42 @@ +package de.fzj.unicore.uas.impl.job; + +import org.unigrids.x2006.x04.services.jms.StdErrDocument; + +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; + +public class StdErrProperty extends ResourceProperty<String> { + + private static final long serialVersionUID = 1L; + + private String actionID; + + private String sErr; + + public StdErrProperty(String actionID){ + this.actionID=actionID; + sErr="stderr"; + } + + @Override + public StdErrDocument[] getXml() { + StdErrDocument s=StdErrDocument.Factory.newInstance(); + s.setStdErr(sErr); + return new StdErrDocument[]{s}; + } + + @Override + public StdErrProperty update() throws Exception { + try{ + XNJSFacade.getAction(actionID).getExecutionContext().getStderr(); + }catch(Exception e){ + sErr="stderr"; + } + return this; + } + + @Override + public String getProperty() { + return sErr; + } +} Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdOutProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,42 @@ +package de.fzj.unicore.uas.impl.job; + +import org.unigrids.x2006.x04.services.jms.StdOutDocument; + +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; + +public class StdOutProperty extends ResourceProperty<String> { + + private static final long serialVersionUID = 1L; + + private String actionID; + + private String sOut; + + public StdOutProperty(String actionID){ + this.actionID=actionID; + sOut="stdout"; + } + + @Override + public StdOutDocument[] getXml() { + StdOutDocument s=StdOutDocument.Factory.newInstance(); + s.setStdOut(sOut); + return new StdOutDocument[]{s}; + } + + @Override + public StdOutProperty update() throws Exception { + try{ + XNJSFacade.getAction(actionID).getExecutionContext().getStdout(); + }catch(Exception e){ + sOut="stdout"; + } + return this; + } + + @Override + public String getProperty() { + return sOut; + } +} Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/TSSReferenceResourceProperty.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/TSSReferenceResourceProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/TSSReferenceResourceProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/TSSReferenceResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,72 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.impl.job; + +import org.unigrids.x2006.x04.services.jms.TargetSystemReferenceDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; + +/** + * holds a reference to the TargetSystem service to which the job was submitted + */ +public class TSSReferenceResourceProperty extends ResourceProperty<EndpointReferenceType> { + protected static final long serialVersionUID=20348L; + + private TargetSystemReferenceDocument [] xdoc; + private TargetSystemReferenceDocument ref; + + public TSSReferenceResourceProperty(EndpointReferenceType epr){ + ref=TargetSystemReferenceDocument.Factory.newInstance(); + ref.setTargetSystemReference(epr); + xdoc=new TargetSystemReferenceDocument []{ref}; + } + + @Override + public TargetSystemReferenceDocument [] getXml() { + // TODO Auto-generated method stub + return xdoc; + } + + /** + * set the reference + * + * @param EndpointReferenceType + */ + @Override + public void setProperty(EndpointReferenceType epr) { + ref.setTargetSystemReference((EndpointReferenceType)epr); + } + +} Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/WorkingDirResourceProperty.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/WorkingDirResourceProperty.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/WorkingDirResourceProperty.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/WorkingDirResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -0,0 +1,74 @@ +/********************************************************************************* + * Copyright (c) 2006 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + + +package de.fzj.unicore.uas.impl.job; + +import org.unigrids.x2006.x04.services.jms.WorkingDirectoryReferenceDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; + +/** + * holds the Uspace EPR + * + * @author schuller + * @version $Id: WorkingDirResourceProperty.java,v 1.5 2006/09/08 12:33:47 bschuller Exp $ + */ +public class WorkingDirResourceProperty extends ResourceProperty<EndpointReferenceType>{ + + protected static final long serialVersionUID=20348L; + + private WorkingDirectoryReferenceDocument[] xdoc; + + private WorkingDirectoryReferenceDocument wrd; + + public WorkingDirResourceProperty(EndpointReferenceType epr){ + setProperty(epr); + } + + @Override + public WorkingDirectoryReferenceDocument[] getXml() { + return xdoc; + } + + /** + * pass in the epr + */ + @Override + public void setProperty(EndpointReferenceType newEpr) { + wrd=WorkingDirectoryReferenceDocument.Factory.newInstance(); + wrd.setWorkingDirectoryReference(newEpr); + xdoc=new WorkingDirectoryReferenceDocument[]{wrd}; + } + +} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/ExecutionJSDLResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/ExecutionJSDLResourceProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/ExecutionJSDLResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,86 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.impl.job.rp; - -import java.util.logging.Logger; - -import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; -import org.unigrids.x2006.x04.services.jms.ExecutionJSDLDocument; - -import de.fzj.unicore.uas.xnjs.XNJSFacade; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; - -/** - * Contains the JSDL job description that is actually executed by the XNJS - * after incarnation - */ -public class ExecutionJSDLResourceProperty extends ResourceProperty<Object> { - protected static final long serialVersionUID=20348L; - - protected static Logger logger=Logger.getLogger(ExecutionJSDLResourceProperty.class.getName()); - - private ExecutionJSDLDocument[] xdoc; - - private String actionId; - - /** - * - * @param jobID the id of the job - */ - public ExecutionJSDLResourceProperty(String jobID){ - this.actionId=jobID; - xdoc=new ExecutionJSDLDocument[1]; - - } - - @Override - public ExecutionJSDLDocument getProperty() { - return xdoc[0]; - } - - @Override - public ExecutionJSDLDocument[] getXml() { - return xdoc; - } - - @Override - public ExecutionJSDLResourceProperty update() throws Exception{ - JobDefinitionDocument jdd=(JobDefinitionDocument)XNJSFacade.getAction(actionId).getAjd(); - ExecutionJSDLDocument ejd=ExecutionJSDLDocument.Factory.newInstance(); - ejd.setExecutionJSDL(jdd.getJobDefinition()); - xdoc[0]=ejd; - return this; - } - -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/LogResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/LogResourceProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/LogResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,106 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.impl.job.rp; - -import java.util.List; -import java.util.logging.Logger; - -import org.unigrids.x2006.x04.services.jms.LogDocument; - -import de.fzj.unicore.uas.xnjs.XNJSFacade; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; -import de.fzj.unicore.xnjs.aaa.Client; - -/** - * Contains the job log (which is copied from the XNJS Action log) - */ -public class LogResourceProperty extends ResourceProperty<String>{ - protected static final long serialVersionUID=20348L; - - protected static Logger logger=Logger.getLogger(LogResourceProperty.class.getName()); - - private LogDocument status; - - private LogDocument[] xdoc; - - private String actionId; - - /** - * TODO - * log can be seen without access control, - * is this a security hole in the XNJS or not? - */ - private Client client; - - /** - * - * @param jobID the id of the job - */ - public LogResourceProperty(String jobID, Client client){ - status=LogDocument.Factory.newInstance(); - status.setLog(""); - xdoc=new LogDocument[]{status}; - this.actionId=jobID; - this.client=client; - } - - @Override - public String getProperty() { - return status.getLog(); - } - - @Override - public LogDocument[] getXml() { - return xdoc; - } - - @Override - public void setProperty(String log) { - status.setLog(log); - } - - /** - * - * @see de.fzj.unicore.wsrflite.ResourceProperty#update() - */ - @Override - public LogResourceProperty update() throws Exception{ - StringBuffer sb=new StringBuffer(); - List<String> l=XNJSFacade.getAction(actionId).getLog(); - for(String s:l)sb.append(s+"\n"); - status.setLog(sb.toString()); - return this; - } - -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StatusInfoResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StatusInfoResourceProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StatusInfoResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,142 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.impl.job.rp; - -import java.math.BigInteger; -import java.util.logging.Logger; - -import org.unigrids.services.atomic.types.StatusInfoDocument; -import org.unigrids.services.atomic.types.StatusType.Enum; - -import de.fzj.unicore.uas.xnjs.XNJSFacade; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; -import de.fzj.unicore.xnjs.aaa.Client; -import de.fzj.unicore.xnjs.ems.ActionStatus; - -/** - * Represents the job status - */ -public class StatusInfoResourceProperty extends ResourceProperty<Object> { - protected static final long serialVersionUID=20348L; - - protected static Logger logger=Logger.getLogger(StatusInfoResourceProperty.class.getName()); - - private StatusInfoDocument status; - - private StatusInfoDocument[] xdoc; - - private String actionId; - private Client client; - - /** - * - * @param jobID the id of the job - */ - public StatusInfoResourceProperty(String jobID, Client client){ - status=StatusInfoDocument.Factory.newInstance(); - status.addNewStatusInfo(); - xdoc=new StatusInfoDocument[]{status}; - this.actionId=jobID; - } - - @Override - public StatusInfoDocument[] getXml() { - return xdoc; - } - - /** - * - * @see de.fzj.unicore.wsrflite.ResourceProperty#update() - */ - @Override - public StatusInfoResourceProperty update() throws Exception{ - status.getStatusInfo().setStatus( - convertStatus( - XNJSFacade.getStatus(actionId,client))); - - Integer exitCode=XNJSFacade.getExitCode(actionId,client); - if(exitCode!=null){ - status.getStatusInfo().setExitCode(BigInteger.valueOf(exitCode.longValue())); - } - return this; - } - - /** - * converts from the XNJS action status to Unicore job status - * - * states from unigridsTypes.xsd - * - * <xsd:simpleType name="StatusType"> - <xsd:restriction base="xsd:string"> - <xsd:enumeration value="UNDEFINED"/> - <xsd:enumeration value="READY"/> - <xsd:enumeration value="QUEUED"/> - <xsd:enumeration value="RUNNING"/> - <xsd:enumeration value="SUCCESSFUL"/> - <xsd:enumeration value="FAILED"/> - <xsd:enumeration value="STAGINGIN"/> - <xsd:enumeration value="STAGINGOUT"/> - </xsd:restriction> - </xsd:simpleType> - * - * @param emsStatus - * @return UNICORE status - */ - protected Enum convertStatus(Integer emsStatus){ - int i=emsStatus.intValue(); - switch (i){ - case ActionStatus.PREPROCESSING: - return Enum.forString("STAGINGIN"); - case ActionStatus.POSTPROCESSING: - return Enum.forString("STAGINGOUT"); - case ActionStatus.RUNNING: - return Enum.forString("RUNNING"); - case ActionStatus.PENDING: - return Enum.forString("QUEUED"); - case ActionStatus.READY: - return Enum.forString("READY"); - case ActionStatus.DONE: - //figure out if success or not - if(XNJSFacade.getAction(actionId).getResult().isSuccessful()){ - return Enum.forString("SUCCESSFUL"); - } - else{ - return Enum.forString("FAILED"); - } - default: - return Enum.forString("UNDEFINED"); - } - } - -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdErrProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdErrProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdErrProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,42 +0,0 @@ -package de.fzj.unicore.uas.impl.job.rp; - -import org.unigrids.x2006.x04.services.jms.StdErrDocument; - -import de.fzj.unicore.uas.xnjs.XNJSFacade; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; - -public class StdErrProperty extends ResourceProperty<String> { - - private static final long serialVersionUID = 1L; - - private String actionID; - - private String sErr; - - public StdErrProperty(String actionID){ - this.actionID=actionID; - sErr="stderr"; - } - - @Override - public StdErrDocument[] getXml() { - StdErrDocument s=StdErrDocument.Factory.newInstance(); - s.setStdErr(sErr); - return new StdErrDocument[]{s}; - } - - @Override - public StdErrProperty update() throws Exception { - try{ - XNJSFacade.getAction(actionID).getExecutionContext().getStderr(); - }catch(Exception e){ - sErr="stderr"; - } - return this; - } - - @Override - public String getProperty() { - return sErr; - } -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdOutProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdOutProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/StdOutProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,42 +0,0 @@ -package de.fzj.unicore.uas.impl.job.rp; - -import org.unigrids.x2006.x04.services.jms.StdOutDocument; - -import de.fzj.unicore.uas.xnjs.XNJSFacade; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; - -public class StdOutProperty extends ResourceProperty<String> { - - private static final long serialVersionUID = 1L; - - private String actionID; - - private String sOut; - - public StdOutProperty(String actionID){ - this.actionID=actionID; - sOut="stdout"; - } - - @Override - public StdOutDocument[] getXml() { - StdOutDocument s=StdOutDocument.Factory.newInstance(); - s.setStdOut(sOut); - return new StdOutDocument[]{s}; - } - - @Override - public StdOutProperty update() throws Exception { - try{ - XNJSFacade.getAction(actionID).getExecutionContext().getStdout(); - }catch(Exception e){ - sOut="stdout"; - } - return this; - } - - @Override - public String getProperty() { - return sOut; - } -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/TSSReferenceResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/TSSReferenceResourceProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/TSSReferenceResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,72 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.impl.job.rp; - -import org.unigrids.x2006.x04.services.jms.TargetSystemReferenceDocument; -import org.w3.x2005.x08.addressing.EndpointReferenceType; - -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; - -/** - * holds a reference to the TargetSystem service to which the job was submitted - */ -public class TSSReferenceResourceProperty extends ResourceProperty<EndpointReferenceType> { - protected static final long serialVersionUID=20348L; - - private TargetSystemReferenceDocument [] xdoc; - private TargetSystemReferenceDocument ref; - - public TSSReferenceResourceProperty(EndpointReferenceType epr){ - ref=TargetSystemReferenceDocument.Factory.newInstance(); - ref.setTargetSystemReference(epr); - xdoc=new TargetSystemReferenceDocument []{ref}; - } - - @Override - public TargetSystemReferenceDocument [] getXml() { - // TODO Auto-generated method stub - return xdoc; - } - - /** - * set the reference - * - * @param EndpointReferenceType - */ - @Override - public void setProperty(EndpointReferenceType epr) { - ref.setTargetSystemReference((EndpointReferenceType)epr); - } - -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/WorkingDirResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/WorkingDirResourceProperty.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/rp/WorkingDirResourceProperty.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -1,74 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.impl.job.rp; - -import org.unigrids.x2006.x04.services.jms.WorkingDirectoryReferenceDocument; -import org.w3.x2005.x08.addressing.EndpointReferenceType; - -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; - -/** - * holds the Uspace EPR - * - * @author schuller - * @version $Id: WorkingDirResourceProperty.java,v 1.5 2006/09/08 12:33:47 bschuller Exp $ - */ -public class WorkingDirResourceProperty extends ResourceProperty<EndpointReferenceType>{ - - protected static final long serialVersionUID=20348L; - - private WorkingDirectoryReferenceDocument[] xdoc; - - private WorkingDirectoryReferenceDocument wrd; - - public WorkingDirResourceProperty(EndpointReferenceType epr){ - setProperty(epr); - } - - @Override - public WorkingDirectoryReferenceDocument[] getXml() { - return xdoc; - } - - /** - * pass in the epr - */ - @Override - public void setProperty(EndpointReferenceType newEpr) { - wrd=WorkingDirectoryReferenceDocument.Factory.newInstance(); - wrd.setWorkingDirectoryReference(newEpr); - xdoc=new WorkingDirectoryReferenceDocument[]{wrd}; - } - -} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -75,7 +75,7 @@ import de.fzj.unicore.uas.StorageManagement; import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.fts.FileTransferImpl; -import de.fzj.unicore.uas.fts.rp.ProtocolRP; +import de.fzj.unicore.uas.fts.ProtocolRP; import de.fzj.unicore.uas.impl.UASWSResourceImpl; import de.fzj.unicore.uas.impl.bp.BPSupportImpl; import de.fzj.unicore.uas.util.AddressingUtil; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/Constants.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/Constants.java 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/Constants.java 2007-12-10 18:46:00 UTC (rev 2093) @@ -38,7 +38,7 @@ public class Constants { /** - * will be removed in the 6.0.1 release + * will be removed in the 6.1 release */ @Deprecated public final static QName FLE_RESOURCE_DISAMBIGUATOR= Modified: unicorex/uas-core/trunk/src/site/apt/programmer/getstarted.apt =================================================================== --- unicorex/uas-core/trunk/src/site/apt/programmer/getstarted.apt 2007-12-10 18:32:46 UTC (rev 2092) +++ unicorex/uas-core/trunk/src/site/apt/programmer/getstarted.apt 2007-12-10 18:46:00 UTC (rev 2093) @@ -194,7 +194,7 @@ +-------------- Make sure to read up on maven or check the UNICORE pom.xml files to see some other -useful configuration options. For starters, remember that Java code goes into "rsc/main/java" and +useful configuration options. For starters, remember that Java code goes into "src/main/java" and JUnit tests go into "src/test/java". Have fun! This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2007-12-10 21:08:36
|
Revision: 2095 http://unicore.svn.sourceforge.net/unicore/?rev=2095&view=rev Author: bschuller Date: 2007-12-10 13:08:29 -0800 (Mon, 10 Dec 2007) Log Message: ----------- support multiple XNJS instances, thus allowing more complex TSF implementations Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/HomeStorageImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ApplicationsResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUCountResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUTimeResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/MemoryPerNodeResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NodesResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NumberOfJobsProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ProcessorResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/SiteSpecificResourcesRP.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/TextInfoResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/DefaultOnStartup.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/FileTransferCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/HttpTest.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/RunCatWithStageInFromRemoteSMS.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/RunStageInWithMissingDir.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestTextInfoRP.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/TestStaging.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/FileTransferImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -241,7 +241,7 @@ } protected TSI doGetTSI(String dir)throws ExecutionException{ - TSI tsi=XNJSFacade.getStorageTSI(dir,getClient()); + TSI tsi=XNJSFacade.get(xnjsReference).getStorageTSI(dir,getClient()); return tsi; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -74,11 +74,11 @@ dummy.setClient(client); if(!isExport){ - ft=XNJSFacade.getConfiguration().getFileTransferEngine(). + ft=XNJSFacade.get(xnjsReference).getConfiguration().getFileTransferEngine(). createFileTransfer(dummy,new URI(source),new URI("file://"+target)); } else{ - ft=XNJSFacade.getConfiguration().getFileTransferEngine(). + ft=XNJSFacade.get(xnjsReference).getConfiguration().getFileTransferEngine(). createFileTransfer(dummy,new URI("file://"+source),new URI(target)); } fileTransfers.put(getUniqueID(), ft); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/FileServlet.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -44,10 +44,10 @@ UAS.getJettyServer().getRootContext().addServlet(FileServlet.class.getName(), "/files/*"); } - public static void exposeFile(String id, String remotePath, Client client){ + public static void exposeFile(String id, String remotePath, Client client,String xnjsReference){ logger.finer("Exposing via HTTP: "+remotePath); try{ - UResource fr=new UResource(id,client,remotePath); + UResource fr=new UResource(id,client,remotePath,xnjsReference); map.put(id,fr); } catch(Exception mue){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -16,7 +16,6 @@ import de.fzj.unicore.wsrflite.Kernel; import de.fzj.unicore.wsrflite.security.ISecurityProperties; import de.fzj.unicore.wsrflite.utils.Utilities; -import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; import de.fzj.unicore.wsrflite.xmlbeans.rp.ImmutableResourceProperty; /** @@ -80,7 +79,7 @@ private String exposeFile(){ unique=Utilities.newUniqueID(); String path=this.workdir+"/"+(isExport? getRawSource():getRawTarget()); - FileServlet.exposeFile(unique, path, client); + FileServlet.exposeFile(unique, path, client,xnjsReference); accessURL=makeAccessURL(unique); return accessURL; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/UResource.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -30,12 +30,14 @@ private Client client; private String path; private String id; + private String xnjsReference; private long transferred=0; - public UResource(String id, Client c, String path){ + public UResource(String id, Client c, String path, String xnjsReference){ this.id=id; this.client=c; this.path=path; + this.xnjsReference=xnjsReference; } protected void updateTransferredBytes(){ @@ -70,7 +72,7 @@ @Override public InputStream getInputStream() throws IOException { try { - final InputStream is=XNJSFacade.getTSI(client).getInputStream(path); + final InputStream is=XNJSFacade.get(xnjsReference).getTSI(client).getInputStream(path); InputStream decoratedStream=new InputStream(){ @Override public int read() throws IOException { @@ -104,7 +106,7 @@ @Override public OutputStream getOutputStream() throws IOException, SecurityException { try { - final OutputStream os=XNJSFacade.getTSI(client).getOutputStream(path); + final OutputStream os=XNJSFacade.get(xnjsReference).getTSI(client).getOutputStream(path); OutputStream decoratedStream=new OutputStream(){ @Override public void write(int b) throws IOException { Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -59,6 +59,7 @@ import de.fzj.unicore.uas.security.SecurityManager; import de.fzj.unicore.uas.security.SecurityTokens; import de.fzj.unicore.uas.util.AddressingUtil; +import de.fzj.unicore.uas.xnjs.XNJSFacade; import de.fzj.unicore.wsrflite.WSRFConstants; import de.fzj.unicore.wsrflite.persistence.Persist; import de.fzj.unicore.wsrflite.utils.Utilities; @@ -109,6 +110,10 @@ @Persist private EndpointReferenceType myEPR; + @Persist + protected String xnjsReference; + + public static final String INITPARAM_SECURITYCONTEXT=UASWSResourceImpl.class.getName()+".securityContext"; /** @@ -117,6 +122,13 @@ */ public static final String INITPARAM_PUBLISH_TO_REGISTRY=UASWSResourceImpl.class.getName()+".publish"; + /** + * used for passing the ID of the XNJS instance to be used + * @see XNJSFacade#get(String) + */ + public static final String INITPARAM_XNJS_REFERENCE=UASWSResourceImpl.class.getName()+".xnjsReference"; + + public static final String SCOPE_REQUEST="request"; public static final String SCOPE_SERVER="server"; @@ -261,6 +273,8 @@ setSecurityContext(secContext); setDefaultOwner(); } + xnjsReference = (String)initParams.get(INITPARAM_XNJS_REFERENCE); + properties.put(BPSupportImpl.RPWsResourceInterfaces, new ImmutableResourceProperty(getWSResourceInterfaces())); if(getPortType()!=null)properties.put(BPSupportImpl.RPFinalWSResourceInterface, Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/ExecutionJSDLResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -53,13 +53,15 @@ private ExecutionJSDLDocument[] xdoc; private String actionId; + private String xnjsReference; /** * * @param jobID the id of the job */ - public ExecutionJSDLResourceProperty(String jobID){ + public ExecutionJSDLResourceProperty(String jobID, String xnjsReference){ this.actionId=jobID; + this.xnjsReference=xnjsReference; xdoc=new ExecutionJSDLDocument[1]; } @@ -76,7 +78,7 @@ @Override public ExecutionJSDLResourceProperty update() throws Exception{ - JobDefinitionDocument jdd=(JobDefinitionDocument)XNJSFacade.getAction(actionId).getAjd(); + JobDefinitionDocument jdd=(JobDefinitionDocument)XNJSFacade.get(xnjsReference).getAction(actionId).getAjd(); ExecutionJSDLDocument ejd=ExecutionJSDLDocument.Factory.newInstance(); ejd.setExecutionJSDL(jdd.getJobDefinition()); xdoc[0]=ejd; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/JobManagementImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -124,7 +124,7 @@ public StartResponseDocument Start(StartDocument in) throws BaseFault { StartResponseDocument res=StartResponseDocument.Factory.newInstance(); try{ - XNJSFacade.getManager().run(getUniqueID(), client); + XNJSFacade.get(xnjsReference).getManager().run(getUniqueID(), client); res.addNewStartResponse(); logger.info("Started "+getUniqueID()); return res; @@ -137,7 +137,7 @@ public AbortResponseDocument Abort(AbortDocument in) throws BaseFault { AbortResponseDocument res=AbortResponseDocument.Factory.newInstance(); try{ - XNJSFacade.getManager().abort(getUniqueID(), client); + XNJSFacade.get(xnjsReference).getManager().abort(getUniqueID(), client); res.addNewAbortResponse(); return res; }catch(Exception e){ @@ -149,7 +149,7 @@ public HoldResponseDocument Hold(HoldDocument in) throws BaseFault { HoldResponseDocument res=HoldResponseDocument.Factory.newInstance(); try{ - XNJSFacade.getManager().pause(getUniqueID(), client); + XNJSFacade.get(xnjsReference).getManager().pause(getUniqueID(), client); res.addNewHoldResponse(); return res; }catch(Exception e){ @@ -161,7 +161,7 @@ public ResumeResponseDocument Resume(ResumeDocument in) throws BaseFault { ResumeResponseDocument res=ResumeResponseDocument.Factory.newInstance(); try{ - XNJSFacade.getManager().resume(getUniqueID(), client); + XNJSFacade.get(xnjsReference).getManager().resume(getUniqueID(), client); res.addNewResumeResponse(); return res; }catch(Exception e){ @@ -189,7 +189,7 @@ logger.log(Level.INFO,"Adding action with id "+action.getUUID()+ " for client "+client); } //submit to XNJS... - XNJSFacade.getManager().add(action,client); + XNJSFacade.get(xnjsReference).getManager().add(action,client); }catch(Exception e){ logger.log(Level.SEVERE,"Could not submit job to XNJS.",e); try{ @@ -206,7 +206,7 @@ StatusInfoResourceProperty info=new StatusInfoResourceProperty( - getUniqueID(),client); + getUniqueID(),client,xnjsReference); properties.put(RPStatusInfo,info); EndpointReferenceType epr=AddressingUtil.newEPR(); @@ -219,10 +219,10 @@ ImmutableResourceProperty oJsdl=new ImmutableResourceProperty(ojd); properties.put(RPOriginalJSDL,oJsdl); - LogResourceProperty log=new LogResourceProperty(getUniqueID(),client); + LogResourceProperty log=new LogResourceProperty(getUniqueID(),client,xnjsReference); properties.put(RPLog, log); - ExecutionJSDLResourceProperty eJSDL=new ExecutionJSDLResourceProperty(getUniqueID()); + ExecutionJSDLResourceProperty eJSDL=new ExecutionJSDLResourceProperty(getUniqueID(),xnjsReference); properties.put(RPExecutionJSDL, eJSDL); //Uspace (working directory) @@ -238,8 +238,8 @@ } //stdout / error - properties.put(STDOUT, new StdOutProperty(action.getUUID())); - properties.put(STDERR, new StdErrProperty(action.getUUID())); + properties.put(STDOUT, new StdOutProperty(action.getUUID(),xnjsReference)); + properties.put(STDERR, new StdErrProperty(action.getUUID(),xnjsReference)); setDirty(); @@ -263,7 +263,7 @@ } //clean up on backend try{ - XNJSFacade.destroyAction(getUniqueID(), getClient()); + XNJSFacade.get(xnjsReference).destroyAction(getUniqueID(), getClient()); } catch(Exception e){ logger.severe("Could not destroy job on XNJS."); @@ -305,6 +305,8 @@ initMap.put(SMSBaseImpl.INIT_DIRECTORY,a.getExecutionContext().getWorkingDirectory()); initMap.put(INITPARAM_CLIENT,client); initMap.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); + initMap.put(INITPARAM_XNJS_REFERENCE, xnjsReference); + return createStorageManagementService(initMap); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/LogResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -55,6 +55,7 @@ private LogDocument[] xdoc; private String actionId; + private String xnjsReference; /** * TODO @@ -67,12 +68,13 @@ * * @param jobID the id of the job */ - public LogResourceProperty(String jobID, Client client){ + public LogResourceProperty(String jobID, Client client,String xnjsReference){ status=LogDocument.Factory.newInstance(); status.setLog(""); xdoc=new LogDocument[]{status}; this.actionId=jobID; this.client=client; + this.xnjsReference=xnjsReference; } @Override @@ -97,7 +99,7 @@ @Override public LogResourceProperty update() throws Exception{ StringBuffer sb=new StringBuffer(); - List<String> l=XNJSFacade.getAction(actionId).getLog(); + List<String> l=XNJSFacade.get(xnjsReference).getAction(actionId).getLog(); for(String s:l)sb.append(s+"\n"); status.setLog(sb.toString()); return this; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StatusInfoResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -58,16 +58,18 @@ private String actionId; private Client client; + private String xnjsReference; /** * * @param jobID the id of the job */ - public StatusInfoResourceProperty(String jobID, Client client){ + public StatusInfoResourceProperty(String jobID, Client client,String xnjsReference){ status=StatusInfoDocument.Factory.newInstance(); status.addNewStatusInfo(); xdoc=new StatusInfoDocument[]{status}; this.actionId=jobID; + this.xnjsReference=xnjsReference; } @Override @@ -83,9 +85,9 @@ public StatusInfoResourceProperty update() throws Exception{ status.getStatusInfo().setStatus( convertStatus( - XNJSFacade.getStatus(actionId,client))); + XNJSFacade.get(xnjsReference).getStatus(actionId,client))); - Integer exitCode=XNJSFacade.getExitCode(actionId,client); + Integer exitCode=XNJSFacade.get(xnjsReference).getExitCode(actionId,client); if(exitCode!=null){ status.getStatusInfo().setExitCode(BigInteger.valueOf(exitCode.longValue())); } @@ -128,7 +130,7 @@ return Enum.forString("READY"); case ActionStatus.DONE: //figure out if success or not - if(XNJSFacade.getAction(actionId).getResult().isSuccessful()){ + if(XNJSFacade.get(xnjsReference).getAction(actionId).getResult().isSuccessful()){ return Enum.forString("SUCCESSFUL"); } else{ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdErrProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -11,11 +11,14 @@ private String actionID; + private String xnjsReference; + private String sErr; - public StdErrProperty(String actionID){ + public StdErrProperty(String actionID,String xnjsReference){ this.actionID=actionID; sErr="stderr"; + this.xnjsReference=xnjsReference; } @Override @@ -28,7 +31,7 @@ @Override public StdErrProperty update() throws Exception { try{ - XNJSFacade.getAction(actionID).getExecutionContext().getStderr(); + XNJSFacade.get(xnjsReference).getAction(actionID).getExecutionContext().getStderr(); }catch(Exception e){ sErr="stderr"; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/job/StdOutProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -10,12 +10,14 @@ private static final long serialVersionUID = 1L; private String actionID; + private String xnjsReference; private String sOut; - public StdOutProperty(String actionID){ + public StdOutProperty(String actionID,String xnjsReference){ this.actionID=actionID; sOut="stdout"; + this.xnjsReference=xnjsReference; } @Override @@ -28,7 +30,7 @@ @Override public StdOutProperty update() throws Exception { try{ - XNJSFacade.getAction(actionID).getExecutionContext().getStdout(); + XNJSFacade.get(xnjsReference).getAction(actionID).getExecutionContext().getStdout(); }catch(Exception e){ sOut="stdout"; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/reservation/ReservationManagementImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -72,7 +72,7 @@ @Override public void destroy() { try{ - XNJSFacade.getReservation().cancelReservation(reservationReference, getClient()); + XNJSFacade.get(xnjsReference).getReservation().cancelReservation(reservationReference, getClient()); } catch(Exception e){ logger.log(Level.WARNING,"Could not cancel resource reservation.",e); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/HomeStorageImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/HomeStorageImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/HomeStorageImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -26,7 +26,7 @@ if(homeDirectory==null){ try{ String xlogin=getClient().getAttributes().get(Client.ATTRIBUTE_XLOGIN); - homeDirectory=XNJSFacade.getGrounder(). + homeDirectory=XNJSFacade.get(xnjsReference).getGrounder(). incarnatePath("","HOME",null,getClient()); if(logger.isLoggable(Level.FINER)){ logger.log(Level.FINER,"Setting home directory for "+ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -248,6 +248,8 @@ map.put(FileTransferImpl.INIT_SMS_WORKDIR, getStorageRoot()); map.put(FileTransferImpl.INIT_IS_EXPORT, Boolean.TRUE); map.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); + map.put(INITPARAM_XNJS_REFERENCE, xnjsReference); + if(logger.isLoggable(Level.INFO)){ logger.info("Export: "+source+" "+protocol + " from "+getStorageRoot()); @@ -284,6 +286,7 @@ map.put(FileTransferImpl.INIT_OVERWRITE, Boolean.TRUE); map.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); + map.put(INITPARAM_XNJS_REFERENCE, xnjsReference); if(logger.isLoggable(Level.INFO)){ logger.info("Import: "+target+" "+protocol @@ -327,6 +330,7 @@ map.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); map.put(FileTransferImpl.INIT_CLIENT, getClient()); + map.put(INITPARAM_XNJS_REFERENCE, xnjsReference); //create transfer resource... EndpointReferenceType epr=createTransferResource(map); @@ -361,7 +365,8 @@ map.put(FileTransferImpl.INIT_IS_EXPORT, Boolean.TRUE); map.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); - + map.put(INITPARAM_XNJS_REFERENCE, xnjsReference); + // create transfer resource... EndpointReferenceType epr = createTransferResource(map); @@ -550,7 +555,7 @@ TSI tsi=null; try{ Client client=getClient(); - tsi=XNJSFacade.getConfiguration().getStorageTSI(getStorageRoot(),client); + tsi=XNJSFacade.get(xnjsReference).getConfiguration().getStorageTSI(getStorageRoot(),client); if(logger.isLoggable(Level.FINER)){ logger.log(Level.FINER, "Got TSI for <"+getStorageRoot()+">"); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemFactoryImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -33,6 +33,7 @@ package de.fzj.unicore.uas.impl.tss; +import java.io.InputStream; import java.util.Calendar; import java.util.HashMap; import java.util.Map; @@ -75,7 +76,14 @@ import de.fzj.unicore.xnjs.jsdl.AbstractGrounder; /** - * implements the targetsystem factory + * Implements the {@link TargetSystemFactory} interface.<br/> + * + * <p>This is a fairly simplistic implementation that does not + * use all the capabilities of the interface. For all the + * TargetSystems created by this factory, the same XNJS instance + * is used. The TargetSystemDescription supplied to CreateTSR() + * is ignored.</p> + * * @author schuller * @version $Id: TargetSystemFactoryImpl.java,v 1.8 2007/01/03 12:11:14 bschuller Exp $ */ @@ -91,6 +99,9 @@ baseProfile.addWSResourceInterface(TSF_PORT); } + /** + * Create a new TargetSystem resource + */ public CreateTSRResponseDocument CreateTSR(CreateTSRDocument in) throws BaseFault { try { @@ -107,10 +118,9 @@ map.put(WSResourceImpl.INIT_INITIAL_TERMINATION_TIME, initialTT); } - //TODO log map content, such as user credentials logger.log(Level.INFO,"Creating Target System resource"); + EndpointReferenceType epr=createTargetSystem(map); - EndpointReferenceType epr=createTargetSystem(map); try{ //add job ref to the relevant resource property TSSReferenceResourceProperty ref=(TSSReferenceResourceProperty)properties.get(RPTSSReferences); @@ -134,32 +144,31 @@ super.initialise(serviceName, initArgs); //add rps - properties.put(RPApplicationResource, new ApplicationsResourceProperty()); + properties.put(RPApplicationResource, new ApplicationsResourceProperty(xnjsReference)); properties.put(RPTSSReferences, createTSSReferenceProperty()); - properties.put(RPCPUTime, new CPUTimeResourceProperty(this)); - properties.put(RPNodeCount, new NodesResourceProperty(this)); - properties.put(RPMemoryPerNode, new MemoryPerNodeResourceProperty(this)); - properties.put(RPCPUCount, new CPUCountResourceProperty(this)); - properties.put(RPProcessor, new ProcessorResourceProperty(this)); + properties.put(RPCPUTime, new CPUTimeResourceProperty(this,xnjsReference)); + properties.put(RPNodeCount, new NodesResourceProperty(this,xnjsReference)); + properties.put(RPMemoryPerNode, new MemoryPerNodeResourceProperty(this,xnjsReference)); + properties.put(RPCPUCount, new CPUCountResourceProperty(this,xnjsReference)); + properties.put(RPProcessor, new ProcessorResourceProperty(this,xnjsReference)); properties.put(RPUpSince, new UpSinceResourceProperty()); //reservation support? SupportsReservationDocument supportsReservation=SupportsReservationDocument.Factory.newInstance(); - supportsReservation.setSupportsReservation(XNJSFacade.supportsReservation()); + supportsReservation.setSupportsReservation(XNJSFacade.get(xnjsReference).supportsReservation()); properties.put(ResourceReservation.RP_SUPPORTS_RESERVATION,new ImmutableResourceProperty(supportsReservation)); - properties.put(RPSiteSpecificResources, new SiteSpecificResourcesRP(this)); + properties.put(RPSiteSpecificResources, new SiteSpecificResourcesRP(this,xnjsReference)); publish(); } /** * create new Target System and return its epr - * Creates a new XNJS if not in "single XNJS" mode + * Uses the default XNJS */ protected EndpointReferenceType createTargetSystem(Map<String,Object> initParam)throws Exception{ - XNJSFacade.initXNJS(); String id=Kernel.getKernel().getServiceHome(UAS.TSS).createWSRFServiceInstance(initParam); EndpointReferenceType epr = AddressingUtil.newEPR(); epr.addNewAddress().setStringValue( @@ -169,6 +178,27 @@ } /** + * create new Target System and return its epr + * Uses a new XNJS configured from the supplied InputStream + */ + protected EndpointReferenceType createTargetSystem(Map<String,Object> initParam, InputStream xnjsConfig)throws Exception{ + + //create a new XNJS and configure it + String xnjsRef=getUniqueID(); + XNJSFacade f=XNJSFacade.get(xnjsRef); + f.configure(xnjsConfig); + //new TSS will pick up the XNJS reference and thus use the "right" XNJS + initParam.put(INITPARAM_XNJS_REFERENCE, xnjsRef); + + String id=Kernel.getKernel().getServiceHome(UAS.TSS).createWSRFServiceInstance(initParam); + EndpointReferenceType epr = AddressingUtil.newEPR(); + epr.addNewAddress().setStringValue( + Utilities.makeAddress(UAS.TSS,id)); + AddressingUtil.addUGSRefparamToEpr(epr,id); + return epr; + } + + /** * creates a resourceproperty holding references to the (live) TargetSystem services * this TSF has created * @@ -190,8 +220,8 @@ */ protected ApplicationsResourceProperty createApplicationResourceProperty(){ try{ - ApplicationsResourceProperty arp=new ApplicationsResourceProperty(); - AbstractGrounder gr=(AbstractGrounder)XNJSFacade.getGrounder(); + ApplicationsResourceProperty arp=new ApplicationsResourceProperty(xnjsReference); + AbstractGrounder gr=(AbstractGrounder)XNJSFacade.get(xnjsReference).getGrounder(); ApplicationType[] xnjsapps=gr.getDefinedApplicationTypes(); ApplicationResourceType[] apps=new ApplicationResourceType[xnjsapps.length]; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -95,10 +95,13 @@ import de.fzj.unicore.xnjs.tsi.IReservation; /** - * the implementation of the TargetSystem service<br/> + * The implementation of the TargetSystem service.<br/> * * It uses an XNJS instance as back end. + * The XNJS is configured through a config file, which + * is referenced in the global UNICORE/X config file * + * * @author schuller */ public class TargetSystemImpl extends UASWSResourceImpl implements TargetSystem { @@ -120,6 +123,12 @@ */ public static final String INIT_TSS_NAME="TSS_NAME"; + /** + * initialisation parameter giving the id of the XNJS to be used + * if not given, the default name (defined in config file) is used + */ + public static final String INIT_XNJS_REFERENCE="XNJS_REFERENCE"; + @Persist() private String tsfID; @@ -177,7 +186,7 @@ } Client client = getClient(); - Action action = XNJSFacade.makeAction(doc); + Action action = XNJSFacade.get(xnjsReference).makeAction(doc); map.put(JobManagementImpl.INITPARAM_CLIENT,client); map.put(JobManagementImpl.INITPARAM_ACTION,action); map.put(JobManagementImpl.INITPARAM_TSS_UNIQUEID, getUniqueID()); @@ -229,16 +238,16 @@ tsfID=(String)initobjs.get(INIT_TSF_ID); // add our properties - properties.put(RPNumberOfJobs, new NumberOfJobsProperty()); + properties.put(RPNumberOfJobs, new NumberOfJobsProperty(xnjsReference)); String tssName=(String)initobjs.get(INIT_TSS_NAME); properties.put(RPName, new NameResourceProperty(tssName)); properties.put(RPApplication, createApplicationResourceProperty()); properties.put(RPProcessor, createProcessorResourceProperty()); - properties.put(RPTextInfo, new TextInfoResourceProperty()); + properties.put(RPTextInfo, new TextInfoResourceProperty(xnjsReference)); //reservation support? SupportsReservationDocument supportsReservation=SupportsReservationDocument.Factory.newInstance(); - supportsReservation.setSupportsReservation(XNJSFacade.supportsReservation()); + supportsReservation.setSupportsReservation(XNJSFacade.get(xnjsReference).supportsReservation()); properties.put(ResourceReservation.RP_SUPPORTS_RESERVATION,new ImmutableResourceProperty(supportsReservation)); //storage management: create a Home SMS @@ -250,6 +259,8 @@ tt.add(Calendar.YEAR,50); initMap.put(SMSBaseImpl.INIT_INITIAL_TERMINATION_TIME,tt); initMap.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); + initMap.put(INITPARAM_XNJS_REFERENCE, xnjsReference); + EndpointReferenceType smsEpr=createStorageManagement(initMap); @@ -257,13 +268,13 @@ properties.put(RPJobReference, createJobReferenceProperty()); - properties.put(RPCPUTime, new CPUTimeResourceProperty(this)); - properties.put(RPNodeCount, new NodesResourceProperty(this)); - properties.put(RPMemoryPerNode, new MemoryPerNodeResourceProperty(this)); - properties.put(RPCPUCount, new CPUCountResourceProperty(this)); + properties.put(RPCPUTime, new CPUTimeResourceProperty(this,xnjsReference)); + properties.put(RPNodeCount, new NodesResourceProperty(this,xnjsReference)); + properties.put(RPMemoryPerNode, new MemoryPerNodeResourceProperty(this,xnjsReference)); + properties.put(RPCPUCount, new CPUCountResourceProperty(this,xnjsReference)); properties.put(RPUpSince, new UpSinceResourceProperty()); properties.put(RPXlogin, new XLoginResourceProperty(this)); - properties.put(RPSiteSpecificResources, new SiteSpecificResourcesRP(this)); + properties.put(RPSiteSpecificResources, new SiteSpecificResourcesRP(this,xnjsReference)); //publish this in registry? @@ -317,7 +328,7 @@ * @return ApplicationsResourceProperty */ protected ApplicationsResourceProperty createApplicationResourceProperty(){ - return new ApplicationsResourceProperty(); + return new ApplicationsResourceProperty(xnjsReference); } @@ -327,7 +338,7 @@ * @return ProcessorResourceProperty */ protected ProcessorResourceProperty createProcessorResourceProperty(){ - return new ProcessorResourceProperty(this); + return new ProcessorResourceProperty(this,xnjsReference); } @@ -395,7 +406,7 @@ ResourcesDocument rd=ResourcesDocument.Factory.newInstance(); rd.setResources(in.getResourceReservationRequest().getResources()); Calendar startTime=in.getResourceReservationRequest().getStartTime(); - IReservation reservation=XNJSFacade.getReservation(); + IReservation reservation=XNJSFacade.get(xnjsReference).getReservation(); if(reservation==null)throw new Exception("Reservation not supported."); String reservationReference=reservation.makeReservation(rd, startTime, getClient()); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ApplicationsResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ApplicationsResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ApplicationsResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -57,9 +57,12 @@ private ApplicationResourceDocument[] xdoc; - public ApplicationsResourceProperty() { + private String xnjsReference; + + public ApplicationsResourceProperty(String xnjsReference) { apps = new ApplicationResourceType[0]; xdoc = new ApplicationResourceDocument[0]; + this.xnjsReference=xnjsReference; } /** @@ -68,7 +71,7 @@ @Override public ApplicationsResourceProperty update(){ try{ - ApplicationType[] xnjsapps=XNJSFacade.getDefinedApplicationTypes(); + ApplicationType[] xnjsapps=XNJSFacade.get(xnjsReference).getDefinedApplicationTypes(); ApplicationResourceType[] apps=new ApplicationResourceType[xnjsapps.length]; for(int i=0;i<apps.length;i++){ apps[i]=ApplicationResourceType.Factory.newInstance(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUCountResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUCountResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUCountResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -58,9 +58,12 @@ private IndividualCPUCountDocument[] xdoc; - public CPUCountResourceProperty(WSRFInstance res) { + private String xnjsReference; + + public CPUCountResourceProperty(WSRFInstance res, String xnjsReference) { this.parentWSResource=res; xdoc = new IndividualCPUCountDocument[1]; + this.xnjsReference=xnjsReference; } /** @@ -69,7 +72,7 @@ public CPUCountResourceProperty update(){ try{ Client client = ((UASWSResourceImpl) parentWSResource).getClient(); - ResourcesType res = XNJSFacade.getResources(client); + ResourcesType res = XNJSFacade.get(xnjsReference).getResources(client); IndividualCPUCountDocument cput=IndividualCPUCountDocument.Factory.newInstance(); RangeValueType cpuCount = res.getIndividualCPUCount(); if(cpuCount == null) { Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUTimeResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUTimeResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/CPUTimeResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -59,9 +59,12 @@ private IndividualCPUTimeDocument[] xdoc; - public CPUTimeResourceProperty(WSRFInstance res) { + private String xnjsReference; + + public CPUTimeResourceProperty(WSRFInstance res, String xnjsReference) { this.parentWSResource=res; xdoc = new IndividualCPUTimeDocument[1]; + this.xnjsReference=xnjsReference; } /** @@ -70,7 +73,7 @@ public CPUTimeResourceProperty update(){ try{ Client client = ((UASWSResourceImpl) parentWSResource).getClient(); - ResourcesType res = XNJSFacade.getResources(client); + ResourcesType res = XNJSFacade.get(xnjsReference).getResources(client); IndividualCPUTimeDocument cput=IndividualCPUTimeDocument.Factory.newInstance(); RangeValueType cpuTime = res.getIndividualCPUTime(); if(cpuTime == null){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/MemoryPerNodeResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/MemoryPerNodeResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/MemoryPerNodeResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -59,9 +59,12 @@ private IndividualPhysicalMemoryDocument[] xdoc; - public MemoryPerNodeResourceProperty(WSRFInstance res) { + private String xnjsReference; + + public MemoryPerNodeResourceProperty(WSRFInstance res,String xnjsReference) { this.parentWSResource=res; xdoc = new IndividualPhysicalMemoryDocument[1]; + this.xnjsReference=xnjsReference; } /** @@ -70,7 +73,7 @@ public MemoryPerNodeResourceProperty update(){ try{ Client client = ((UASWSResourceImpl) parentWSResource).getClient(); - ResourcesType res = XNJSFacade.getResources(client); + ResourcesType res = XNJSFacade.get(xnjsReference).getResources(client); IndividualPhysicalMemoryDocument memDoc=IndividualPhysicalMemoryDocument.Factory.newInstance(); RangeValueType mem = res.getIndividualPhysicalMemory(); if(mem == null){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NodesResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NodesResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NodesResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -58,9 +58,12 @@ private TotalResourceCountDocument[] xdoc; - public NodesResourceProperty(WSRFInstance res) { + private String xnjsReference; + + public NodesResourceProperty(WSRFInstance res,String xnjsReference) { this.parentWSResource=res; xdoc = new TotalResourceCountDocument[1]; + this.xnjsReference=xnjsReference; } /** @@ -70,7 +73,7 @@ public NodesResourceProperty update(){ try{ Client client = ((UASWSResourceImpl) parentWSResource).getClient(); - ResourcesType res = XNJSFacade.getResources(client); + ResourcesType res = XNJSFacade.get(xnjsReference).getResources(client); TotalResourceCountDocument nodesDoc=TotalResourceCountDocument.Factory.newInstance(); RangeValueType nodes = res.getTotalResourceCount(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NumberOfJobsProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NumberOfJobsProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/NumberOfJobsProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -47,17 +47,20 @@ private TotalNumberOfJobsDocument jobs; - public NumberOfJobsProperty() { + private String xnjsReference; + + public NumberOfJobsProperty(String xnjsReference) { jobs = TotalNumberOfJobsDocument.Factory.newInstance(); jobs.setTotalNumberOfJobs(BigInteger.ZERO); xdoc = new TotalNumberOfJobsDocument[]{jobs}; + this.xnjsReference=xnjsReference; } @Override public NumberOfJobsProperty update() throws Exception { long l=-1; try{ - l=XNJSFacade.getNumberOfJobs(); + l=XNJSFacade.get(xnjsReference).getNumberOfJobs(); }catch(Exception e){} jobs.setTotalNumberOfJobs(BigInteger.valueOf(l)); return this; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ProcessorResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ProcessorResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/ProcessorResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -65,10 +65,13 @@ private ProcessorDocument[] xdoc; - public ProcessorResourceProperty(WSRFInstance inst) { + private String xnjsReference; + + public ProcessorResourceProperty(WSRFInstance inst,String xnjsReference) { super(); this.parentWSResource=inst; xdoc = new ProcessorDocument [1]; + this.xnjsReference=xnjsReference; } /** @@ -80,7 +83,7 @@ processor = ProcessorType.Factory.newInstance(); Client client = ((UASWSResourceImpl) parentWSResource).getClient(); - ResourcesType res = XNJSFacade.getResources(client); + ResourcesType res = XNJSFacade.get(xnjsReference).getResources(client); RangeValueType r=res.getIndividualCPUSpeed(); if(r!=null) processor.setIndividualCPUSpeed(r); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/SiteSpecificResourcesRP.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/SiteSpecificResourcesRP.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/SiteSpecificResourcesRP.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -26,9 +26,12 @@ private String resourceSpec; - public SiteSpecificResourcesRP(WSRFInstance res) { + private String xnjsReference; + + public SiteSpecificResourcesRP(WSRFInstance res,String xnjsReference) { super(res); xdoc = new SiteResourceDocument[0]; + this.xnjsReference=xnjsReference; } public SiteResourceDocument[] getXml() { @@ -41,7 +44,7 @@ @Override public SiteSpecificResourcesRP update(){ Client client = ((UASWSResourceImpl) parentWSResource).getClient(); - ResourcesType res = XNJSFacade.getResources(client); + ResourcesType res = XNJSFacade.get(xnjsReference).getResources(client); if(res.toString()!=resourceSpec){ try{ ResourceSetting[] ssr=JSDLUtils.extractSiteSpecificResources(res); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/TextInfoResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/TextInfoResourceProperty.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/TextInfoResourceProperty.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -55,11 +55,14 @@ private List<TextInfoType> otherInfos; + private String xnjsReference; + private TextInfoDocument[] xdoc; - public TextInfoResourceProperty() { + public TextInfoResourceProperty(String xnjsReference) { otherInfos=new ArrayList<TextInfoType>(); xdoc = new TextInfoDocument[0]; + this.xnjsReference=xnjsReference; } /** @@ -68,7 +71,7 @@ @Override public TextInfoResourceProperty update(){ try{ - setProperty(XNJSFacade.getDefinedTextInfo()); + setProperty(XNJSFacade.get(xnjsReference).getDefinedTextInfo()); return this; }catch(Exception e){ logger.log(Level.SEVERE, "Could not update textinfo resourceproperty, information not available.",e); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/DefaultOnStartup.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/DefaultOnStartup.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/DefaultOnStartup.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -75,7 +75,7 @@ try{ logger.info("Initialising backend"); - XNJSFacade.initXNJS(); + XNJSFacade.get(null); } catch(Exception e){ logger.severe("Error initialising backend"); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -48,6 +48,7 @@ if(target.getScheme().equalsIgnoreCase("file") && source.getScheme().equalsIgnoreCase("bft")){ IFileTransfer t=createImport(parent,source,target); + t.setConfiguration(getConfiguration()); return t; } else if (source.getScheme().equalsIgnoreCase("file") && Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTExport.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -49,6 +49,7 @@ import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.uas.security.SecurityManager; import de.fzj.unicore.uas.security.Unicore6Tokens; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.aaa.Client; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.ems.ExecutionException; @@ -79,7 +80,12 @@ protected long transferredBytes=0; protected long dataSize=-1; + protected Configuration config; + public void setConfiguration(Configuration c){ + this.config=c; + } + public void setIsImport(boolean isImport){} public void init(Client client,String actionId, String url, EndpointReferenceType epr, @@ -109,8 +115,8 @@ public void run(){ try{ - TSI tsi=XNJSFacade.getTSI(client); - Action a=XNJSFacade.getAction(actionId); + TSI tsi=config.getTargetSystemInterface(client); + Action a=config.getInternalManager().getAction(actionId); String sourcePath=null; if(a!=null){ sourcePath=a.getExecutionContext().getWorkingDirectory()+sourceFile; @@ -133,8 +139,8 @@ //returns a byte array (at most "chunksize" bytes long) protected byte[] readFromFile(long offset,int chunkSize)throws IOException,ExecutionException{ - TSI tsi=XNJSFacade.getTSI(client); - Action a=XNJSFacade.getAction(actionId); + TSI tsi=config.getTargetSystemInterface(client); + Action a=config.getInternalManager().getAction(actionId); String sourcePath=null; if(a!=null){ sourcePath=a.getExecutionContext().getWorkingDirectory()+sourceFile; @@ -158,8 +164,8 @@ } protected TSI doGetTSI()throws ExecutionException{ - TSI tsi= XNJSFacade.getTSI(client); - Action a=XNJSFacade.getAction(actionId); + TSI tsi= config.getTargetSystemInterface(client); + Action a=config.getInternalManager().getAction(actionId); if(path==null){ path= a!=null ? a.getExecutionContext().getWorkingDirectory(): sourceFile.substring(0, sourceFile.lastIndexOf(tsi.getFileSeparator())); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTImport.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -49,6 +49,7 @@ import de.fzj.unicore.uas.security.IUASSecurityProperties; import de.fzj.unicore.uas.security.SecurityManager; import de.fzj.unicore.uas.security.Unicore6Tokens; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.aaa.Client; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.ems.ExecutionException; @@ -77,6 +78,12 @@ private long dataSize=-1; protected boolean createdParents=false; + protected Configuration config; + + public void setConfiguration(Configuration config){ + this.config=config; + } + public void init(Client client,String actionId, String url, EndpointReferenceType epr, String sourceFile, String targetFile)throws Exception{ this.client=client; @@ -96,7 +103,7 @@ ExportFileResponseDocument res=sms.ExportFile(req); exportEpr=res.getExportFileResponse().getExportEPR(); - Action a=XNJSFacade.getAction(actionId); + Action a=config.getInternalManager().getAction(actionId); if(a!=null)path=a.getExecutionContext().getWorkingDirectory(); else path=""; @@ -111,7 +118,7 @@ HttpFileTransferClient c=new HttpFileTransferClient(url,exportEpr,sec); c.registerProgressListener(this); dataSize=c.getSize(); - TSI tsi=XNJSFacade.getTSI(client); + TSI tsi=config.getTargetSystemInterface(client); createParentDirectories(path+targetFile); OutputStream os=tsi.getOutputStream(path+targetFile,false); c.readAllData(os); @@ -132,7 +139,7 @@ * @throws ExecutionException */ protected void writeToFile(byte[] data, boolean append)throws IOException,ExecutionException{ - TSI tsi=XNJSFacade.getTSI(client); + TSI tsi=config.getTargetSystemInterface(client); createParentDirectories(path+targetFile); OutputStream os=tsi.getOutputStream(path+targetFile,append); os.write(data); @@ -158,7 +165,7 @@ i++; } } - TSI t=XNJSFacade.getTSI(client); + TSI t=config.getTargetSystemInterface(client); t.begin(); t.mkdir(dir); t.commit(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/FileTransferCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/FileTransferCreator.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/FileTransferCreator.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -52,11 +52,15 @@ */ public abstract class FileTransferCreator implements IFileTransferCreator { + protected Configuration config; + public Configuration getConfiguration() { - return XNJSFacade.getConfiguration(); + return config; } - public void setConfiguration(Configuration config) {} + public void setConfiguration(Configuration config) { + this.config=config; + } public abstract IFileTransfer createFileTransfer(Action parent, URI source, URI target); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -51,11 +51,13 @@ if(target.getScheme().equalsIgnoreCase("file") && source.getScheme().equalsIgnoreCase("rbyteio")){ IFileTransfer t=createImport(parent,source,target); + t.setConfiguration(getConfiguration()); return t; } else if (source.getScheme().equalsIgnoreCase("file") && target.getScheme().equalsIgnoreCase("rbyteio")){ IFileTransfer t=createExport(parent,source,target); + t.setConfiguration(getConfiguration()); return t; } return null; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -51,11 +51,13 @@ if(target.getScheme().equalsIgnoreCase("file") && source.getScheme().equalsIgnoreCase("sbyteio")){ IFileTransfer t=createImport(parent,source,target); + t.setConfiguration(getConfiguration()); return t; } else if (source.getScheme().equalsIgnoreCase("file") && target.getScheme().equalsIgnoreCase("sbyteio")){ IFileTransfer t=createExport(parent,source,target); + t.setConfiguration(getConfiguration()); return t; } return null; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -3,10 +3,13 @@ import org.unigrids.services.atomic.types.ProtocolType; import org.w3.x2005.x08.addressing.EndpointReferenceType; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.aaa.Client; public interface U6DataMover extends Runnable { + public void setConfiguration(Configuration config); + /** * initialise this data mover * Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -86,11 +86,15 @@ private U6DataMover dataMover; + private Configuration config; + public Configuration getConfiguration() { - return XNJSFacade.getConfiguration(); + return config; } - public void setConfiguration(Configuration config) {} + public void setConfiguration(Configuration config) { + this.config=config; + } /** * create a u6 transfer Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java 2007-12-10 18:48:38 UTC (rev 2094) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java 2007-12-10 21:08:29 UTC (rev 2095) @@ -40,6 +40,7 @@ import org.ggf.schemas.jsdl.x2005.x11.jsdl.DataStagingType; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.XNJSConstants; import de.fzj.unicore.xnjs.ems.ActionResult; import de.fzj.unicore.xnjs.ems.ActionStatus; @@ -60,24 +61,13 @@ protected static Logger logger=Logger.getLogger(Unicore6FileTransferProcessor.class.getName()); private final static String fileTransferKey="FILETRANSFERS"; - - protected IExecution exec; - - protected IExecutionContextManager ecm; - - protected TSI tsi; - - protected IGrounder grounder; - - public Unicore6FileTransferProcessor(){ - super(XNJSFacade.getConfiguration()); - exec=XNJSFacade.getConfiguration().getExecutionInterface(); - ecm=XNJSFacade.getConfiguration().getExecutionContextMgr(); - grounder=XNJSFacade.getGrounder(); + + public Unicore6FileTransferProcessor(Configuration c){ + super(c); } protected void begin() throws ProcessingException { - tsi=XNJSFacade.getStorageTSI(action.getExecutionContext(). + getConfiguration().getStorageTSI(action.getExecutionContext(). getWorkingDirectory(),action.getClient()); } @@ -104,8 +94,9 @@ try{ URI source=extractSource(dst); URI target=extractTarget(dst); - IFileTransfer ft=XNJSFacade.getConfiguration().getFileTransferEngine(). + IFileTransfer ft=getConfiguration().getFileTransferEngine(). createFileTransfer(action,source,target); + ft.setConfiguration(getConfiguration()); ftList.add(ft.getUniqueId()); ftInstances.add(ft); }catch(Exception e){ @@ -171,7 +162,7 @@ return new URI(s); } else { - if(s.startsWith(tsi.getFileSeparator()))return new URI("file://"+s); + if(s.startsWith(getConfiguration().getTargetSystemInterface(action.getClient()).getFileSeparator()))return new URI("file://"+s); else return new URI("file:///"+s); } } @@ -183,7 +174,7 @@ if(ftList==null)throw new ProcessingException("Filetransfer list not found in context"); boolean running=false; for(String ftId: ftList){ - IFileTransfer ft=XNJSFacade.getConfiguration().getFileTransferEngine().getFileTransfer(ftId); + IFileTransfer ft=getConfiguration().getFileTransferEngine().getFi... [truncated message content] |
From: <bsc...@us...> - 2007-12-21 08:28:49
|
Revision: 2105 http://unicore.svn.sourceforge.net/unicore/?rev=2105&view=rev Author: bschuller Date: 2007-12-21 00:28:47 -0800 (Fri, 21 Dec 2007) Log Message: ----------- remove deprecated UniGrids style security handlers Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/ETDTrustDelegationInHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/PlainWSAuthZHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestPlainWSAuthZ.java Removed Paths: ------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TrustDelegationInHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityInHandler.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityInHandlers.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/ETDTrustDelegationInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/ETDTrustDelegationInHandler.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/ETDTrustDelegationInHandler.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -108,6 +108,7 @@ after(SAMLSecurityInHandler.class.getName()); } + @SuppressWarnings("unchecked") public void invoke(MessageContext ctx) throws Exception { if (ctx.getContextualProperty(Client.CLIENT_MODE) != null) Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/PlainWSAuthZHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/PlainWSAuthZHandler.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/PlainWSAuthZHandler.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -68,13 +68,13 @@ public PlainWSAuthZHandler() { super(); setPhase(Phase.POLICY); - after(UGSSecurityInHandler.class.getName()); after(SAMLSecurityInHandler.class.getName()); serverName=getServerName(); } /** * authorise the request using security info from the message context and */ + @SuppressWarnings("unchecked") public void invoke(MessageContext ctx) throws Exception { Client c=null; ResourceDescriptor d=null; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -215,7 +215,6 @@ AuthToken token=new AuthToken(tokens,"CONSIGNOR X509v3"); client.setAuthToken(token); client.setDistinguishedName(tokens.getConsignorCertificate().getSubjectX500Principal().getName()); - //TODO move setter to interface?! ((Unicore6Tokens)tokens).setUserName(tokens.getConsignorCertificate().getSubjectX500Principal()); } else{ Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TrustDelegationInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TrustDelegationInHandler.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/TrustDelegationInHandler.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -1,135 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.security; - -import java.io.IOException; -import java.security.cert.X509Certificate; -import java.util.HashMap; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.codehaus.xfire.MessageContext; -import org.codehaus.xfire.client.Client; -import org.codehaus.xfire.handler.AbstractHandler; -import org.codehaus.xfire.handler.Phase; - -import de.fzj.unicore.wsrflite.WSRFInstance; - -/** - * Checks trust delegation - * - * expects security context in the message context, so this depends - * on a security in handler being present - * - * @deprecated this will be removed in the 6.0.1 release - * - * use {@link ETDTrustDelegationInHandler} instead - * - * @see UGSSecurityInHandler.java - * - * @author schuller - */ -public class TrustDelegationInHandler extends AbstractHandler{ - - - protected static Logger logger = Logger.getLogger(TrustDelegationInHandler.class.getName()); - - /** - * key for storing ETD attributes in the WSRF security context - */ - public static final String KEY_ETD_ATTRIBUTES=TrustDelegationInHandler.class.getName()+".ETDAttributes"; - - /** - * creates a new handler for checking trust delegation - */ - public TrustDelegationInHandler(){ - super(); - setPhase(Phase.POLICY); - after(UGSSecurityInHandler.class.getName()); - } - - public void invoke(MessageContext ctx) throws Exception { - if(ctx.getContextualProperty(Client.CLIENT_MODE)!=null)return; - - Map<String, Object> securityCtx=(Map<String, Object>)ctx.getProperty(WSRFInstance.WSRF_SECURITYCONTEXT); - if(securityCtx==null){ - logger.info("No security context found. Maybe you need to add a security handler?"); - return; - } - SecurityTokens tokens=(SecurityTokens)securityCtx.get(SecurityTokens.KEY); - if(tokens==null){ - logger.info("No security info in headers."); - return; - } - - Map<String, String> authZmap=checkDelegation(tokens); - if(authZmap!=null){ - securityCtx.put(KEY_ETD_ATTRIBUTES, authZmap); - } - } - - protected Map<String, String> checkDelegation(SecurityTokens ugs)throws TrustDelegationException{ - //first check if user==consignor - X509Certificate user=ugs.getUserCertificate(); - X509Certificate consignor=ugs.getConsignorCertificate(); - if(logger.isLoggable(Level.FINER)){ - logger.finer("User: "+user.getSubjectX500Principal().toString()+"\n" - +"Consignor: "+consignor.getSubjectX500Principal().toString()); - } - if(user.equals(consignor))return null; - - //check if consignor is server - //TODO need policy on this? - if(SecurityManager.isServer(consignor)){ - logger.finest("Endorsed by server."); - Map<String,String> authZmap =new HashMap<String, String>(); - authZmap.put(SecurityTokens.ATTRIBUTE_ROLE, SecurityTokens.ROLE_ETD_AGENT); - return authZmap; - } - //now check if consignor is trusted - try{ - logger.finest("Checking consignor in authZ database..."); - Map<String,String> authZmap = SecurityManager.authorise(ugs); - String role=authZmap.get(SecurityTokens.ATTRIBUTE_ROLE); - if(!SecurityTokens.ROLE_ETD_AGENT.equals(role))throw new TrustDelegationException("Endorser not allowed as etd-agent for this grid node."); - return authZmap; - } - catch(IOException e){ - logger.severe("Can't authorise consignor, reason: "+e.getMessage()); - } - return null; - } - -} Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityInHandler.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityInHandler.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -1,199 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.security; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.security.cert.CertPath; -import java.security.cert.CertificateFactory; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.codehaus.xfire.MessageContext; -import org.codehaus.xfire.handler.AbstractHandler; -import org.codehaus.xfire.handler.Phase; -import org.codehaus.xfire.util.Base64; -import org.jdom.Element; -import org.jdom.Namespace; - -import de.fzj.unicore.uas.impl.UASWSResourceImpl; -import de.fzj.unicore.wsrflite.WSRFInstance; - -/** - * Old-style security in handler, that extracts certificates from soap header and places - * them in the message context - -the expected headers are: - -<Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> -<BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary" Id="7B51DCD0-1BD8-11DB-9873-C873374EE833">...</BinarySecurityToken> -<BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary" Id="7B689920-1BD8-11DB-9873-9486177DEBA2">...</BinarySecurityToken> -<BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary" Id="7B6F01C0-1BD8-11DB-9873-DFF919FFE233">...</BinarySecurityToken> -<ns1:User ID="7B51DCD0-1BD8-11DB-9873-C873374EE833" xmlns:ns1="http://unigrids.org/2006/04/types"/> -<ns2:Consignor ID="7B689920-1BD8-11DB-9873-9486177DEBA2" xmlns:ns2="http://unigrids.org/2006/04/types"/> -<ns3:Endorser ID="7B6F01C0-1BD8-11DB-9873-DFF919FFE233" xmlns:ns3="http://unigrids.org/2006/04/types"/> -</Security> - - - * - * @deprecated Use {@link SAMLSecurityInHandler} instead. This class will be removed in the UNICORE 6.0.1 release. - * - * @author schuller - * - */ -public class UGSSecurityInHandler extends AbstractHandler{ - - - protected static Logger logger = Logger.getLogger(UGSSecurityInHandler.class.getName()); - - //these are from unicore/gs 2.0.x (renamed for clarity) - public final static String WSU = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; - public final static String WSU_ID = "Id"; - public final static String WSS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; - public final static String WSS_SECURITY = "Security"; - public final static String WSS_BINARY_SECURITY_TOKEN = "BinarySecurityToken"; - public final static String WSS_ENCODING_TYPE = "EncodingType"; - public final static String WSS_VALUETYPE = "ValueType"; - public final static String WSS_ENCODING_BASE64 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary"; - public final static String WSS_VALUETYPE_X509V3 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"; - public final static String WSS_VALUETYPE_PKIPATH = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1"; - public final static String WSS_VALUETYPE_PKCS7 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#PKCS7"; - public final static String USER = "User"; - public final static String CONSIGNOR = "Consignor"; - public final static String ENDORSER = "Endorser"; - public final static String UNIGRIDS= "http://unigrids.org/2006/04/types"; - - public static final String UGSToken=UGSSecurityInHandler.class.getName()+"_ugstokens"; - - /** - * creates a new handler for unicore/gs lookalike security - */ - public UGSSecurityInHandler(){ - super(); - setPhase(Phase.POLICY); - } - - public void invoke(MessageContext ctx) throws Exception { - try{ - Element h=null; - Map<String,Object> map=null; - Element headers=ctx.getInMessage().getHeader(); - if(headers!=null) { - h=headers.getChild("Security",Namespace.getNamespace(WSS)); - } - - if(h==null){ - logger.finer("No security info in request."); - map=new HashMap<String,Object>(); - } - else { - map=extractSecurityContext(h); - logger.finer("Read security info from request (set log to finest to see it) "); - } - //set scope to request - try{ - logger.finer("Setting scope to 'request'"); - map.put(UASWSResourceImpl.SCOPE_KEY,UASWSResourceImpl.SCOPE_REQUEST); - }catch(Exception e){ - logger.severe("Error setting scope."); - } - ctx.setProperty(WSRFInstance.WSRF_SECURITYCONTEXT, map); - }catch(Exception e){ - logger.log(Level.SEVERE,"Error retrieving security headers",e); - } - } - - /** - * extract security things from the "wss:Security" header - * - * @param header - * @return map - */ - protected Map<String,Object> extractSecurityContext(Element header){ - Map<String,Object>map=new HashMap<String,Object>(); - CertPath user=extract(USER,header); - CertPath consignor=extract(CONSIGNOR,header); - CertPath endorser=extract(ENDORSER,header); - -// U5Tokens have been removed -// Unicore5Tokens ugs=new Unicore5Tokens(user,consignor,endorser); -// map.put(UGSToken,ugs); -// if(logger.isLoggable(Level.FINEST)){ -// logger.finest("Have info from headers:"+ugs); -// } - return map; - } - - /** - * extract a certpath from the security header - * - * @param ugsElement - * @param h - * @return - */ - protected CertPath extract (String ugsElement, Element h) - { - try{ - Element ugs=h.getChild(ugsElement,Namespace.getNamespace(UNIGRIDS)); - String ugsID=ugs.getAttributeValue("ID"); - List secTokens=h.getChildren(WSS_BINARY_SECURITY_TOKEN,Namespace.getNamespace(WSS)); - String secToken=""; - //find the right token based on id... - for(Object o: secTokens){ - Element e=(Element)o; - if(ugsID.equals(e.getAttribute(WSU_ID).getValue())){ - secToken=e.getText(); - break; - } - } - String valueType=WSS_VALUETYPE_PKIPATH; - byte[] cpb=Base64.decode(secToken); - - InputStream is = new ByteArrayInputStream(cpb); - CertificateFactory cf = CertificateFactory.getInstance("X.509"); - - if (valueType.equals(WSS_VALUETYPE_PKIPATH)){ - return cf.generateCertPath(is); - } - else logger.severe("Received value type not understood: "+valueType); - }catch(Exception e){ - return null; - } - return null; - } - -} Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestPlainWSAuthZ.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestPlainWSAuthZ.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestPlainWSAuthZ.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -17,7 +17,6 @@ import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.client.UASClientFactory; import de.fzj.unicore.uas.security.PlainWSAuthZHandler; -import de.fzj.unicore.uas.security.UGSSecurityInHandler; import de.fzj.unicore.uas.security.util.ResourceDescriptor; import de.fzj.unicore.wsrflite.Kernel; import de.fzj.unicore.wsrflite.persistence.HsqldbPersist; @@ -47,7 +46,6 @@ Service s = XFireKernel.exposeAsService("test", IExample.class, ExampleService.class, false); - s.addInHandler(new UGSSecurityInHandler()); s.addInHandler(new MyAuthZHandler()); } Deleted: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityInHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityInHandlers.java 2007-12-19 15:45:13 UTC (rev 2104) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityInHandlers.java 2007-12-21 08:28:47 UTC (rev 2105) @@ -1,166 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.security; - -import java.io.ByteArrayInputStream; -import java.util.HashMap; -import java.util.Map; - -import org.codehaus.xfire.service.Service; -import org.w3.x2005.x08.addressing.EndpointReferenceDocument; -import org.w3.x2005.x08.addressing.EndpointReferenceType; - -import de.fzj.unicore.uas.Registry; -import de.fzj.unicore.uas.UAS; -import de.fzj.unicore.uas.client.BaseUASClient; -import de.fzj.unicore.uas.impl.registry.RegistryHomeImpl; -import de.fzj.unicore.uas.impl.registry.RegistryImpl; -import de.fzj.unicore.uas.security.IUASSecurityProperties; -import de.fzj.unicore.uas.security.TrustDelegationInHandler; -import de.fzj.unicore.uas.security.UASSecurityProperties; -import de.fzj.unicore.uas.security.UGSSecurityInHandler; -import de.fzj.unicore.uas.security.UGSSecurityOutHandler; -import de.fzj.unicore.uas.security.util.ForwardingWS; -import de.fzj.unicore.uas.security.util.ForwardingWSHomeImpl; -import de.fzj.unicore.uas.util.AddressingUtil; -import de.fzj.unicore.wsrflite.Home; -import de.fzj.unicore.wsrflite.Kernel; -import de.fzj.unicore.wsrflite.WSRFInstance; -import de.fzj.unicore.wsrflite.persistence.PersistenceManager; -import de.fzj.unicore.wsrflite.security.ISecurityProperties; -import de.fzj.unicore.wsrflite.xfire.JettyTestCase; -import de.fzj.unicore.wsrflite.xfire.XFireKernel; -import de.fzj.unicore.wsrflite.xmlbeans.WSResource; -import de.fzj.unicore.wsrflite.xmlbeans.impl.WSResourceImpl; - -public class TestSecurityInHandlers extends JettyTestCase { - - private static String serviceName=UAS.REG; - private static String defaultId="default_registry"; - - private static String url; - private static String fwUrl; - - //security settings... - private static String secProps= - ISecurityProperties.WSRF_SSL + "=true"+"\n"+ - ISecurityProperties.WSRF_SSL_CLIENTAUTH + "=false" +"\n"+ - ISecurityProperties.WSRF_SSL_KEYSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ - ISecurityProperties.WSRF_SSL_KEYTYPE + "=JKS"+"\n"+ - ISecurityProperties.WSRF_SSL_KEYPASS + "=the!user"+"\n"+ - - ISecurityProperties.WSRF_SSL_TRUSTSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ - ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ - ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ - ISecurityProperties.WSRF_WSS+ "=false"+"\n"+ - IUASSecurityProperties.UAS_OUTHANDLER_NAME+"="+UGSSecurityOutHandler.class.getName()+"\n"+ - "" - ; - - protected void setUp()throws Exception{ - Kernel.getKernel().setProperty(Kernel.WSRF_BASEURL, getBaseurl()); - url=getBaseurl()+"/"+serviceName+"?res="+defaultId; - fwUrl=getBaseurl()+"/forward?res=test123"; - new UAS(); - super.setUp(); - } - protected void tearDown() throws Exception { - } - - @Override - protected void addServices() throws Exception { - IUASSecurityProperties sec=new UASSecurityProperties(new ByteArrayInputStream(secProps.getBytes())); - Service s=XFireKernel.exposeAsService(serviceName,Registry.class,RegistryHomeImpl.class,true); - UGSSecurityOutHandler h=new UGSSecurityOutHandler(); - h.doInit(sec); - s.addOutHandler(h); - s.addInHandler(new UGSSecurityInHandler()); - s.addInHandler(new TrustDelegationInHandler()); - - //deploy default registry as example ws resource - Home regHome=Kernel.getKernel().getServiceHome(serviceName); - if(regHome!=null){ - Map<String,Object>map=new HashMap<String,Object>(); - map.put(WSResourceImpl.INIT_UNIQUE_ID,defaultId); - regHome.destroyWSRFServiceInstance(defaultId); - regHome.createWSRFServiceInstance(map); - //store - RegistryImpl regWSR=(RegistryImpl)regHome.getWSRFServiceInstance(defaultId); - PersistenceManager.persist(regWSR); - - } - else System.out.println("Error."); - - //deploy forwarding service... - s=XFireKernel.exposeAsService("forward",WSResource.class,ForwardingWSHomeImpl.class,true); - h=new UGSSecurityOutHandler(); - h.doInit(sec); - s.addOutHandler(h); - s.addInHandler(new UGSSecurityInHandler()); - s.addInHandler(new TrustDelegationInHandler()); - //deploy one instance of forwarding service - Home home=Kernel.getKernel().getServiceHome("forward"); - if(home!=null){ - Map<String,Object>map=new HashMap<String,Object>(); - map.put(WSResourceImpl.INIT_UNIQUE_ID,"test123"); - home.destroyWSRFServiceInstance("test123"); - home.createWSRFServiceInstance(map); - //store - WSRFInstance fw=home.getWSRFServiceInstance("test123"); - PersistenceManager.persist(fw); - } - else System.out.println("Error."); - - EndpointReferenceType epr=EndpointReferenceType.Factory.newInstance(); - epr.addNewAddress().setStringValue(url); - ForwardingWS.sendTo=epr; - - } - - public void testForward()throws Exception{ - - EndpointReferenceDocument eprd=EndpointReferenceDocument.Factory.newInstance(); - EndpointReferenceType epr=eprd.addNewEndpointReference(); - epr.addNewAddress().setStringValue(fwUrl); - AddressingUtil.addUGSRefparamToEpr(epr,"test123"); - System.out.println(fwUrl+"\n"+eprd); - - UASSecurityProperties sec=new UASSecurityProperties( - new ByteArrayInputStream(secProps.getBytes())); - - BaseUASClient client=new BaseUASClient(fwUrl,epr,sec); - client.getResourcePropertyDocument(); - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-02 14:12:36
|
Revision: 2110 http://unicore.svn.sourceforge.net/unicore/?rev=2110&view=rev Author: bschuller Date: 2008-01-02 06:12:33 -0800 (Wed, 02 Jan 2008) Log Message: ----------- allow defining additional storages for target systems (SF feature request #1812080) Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/StorageReferenceResourceProperty.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java unicorex/uas-core/trunk/src/test/resources/uas.config Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddOnStorageDescriptionFactory.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/StorageClient.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -120,6 +120,11 @@ doInit(); } + public StorageClient(EndpointReferenceType address) throws Exception{ + super(address); + doInit(); + } + private void doInit(){ try{ sms=makeProxy(StorageManagement.class); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/UASWSResourceImpl.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -110,6 +110,11 @@ @Persist private EndpointReferenceType myEPR; + /** + * each set of services (TSS, SMS, JMS etc instances) may use its own XNJS instance. + * This variable contains an ID to this XNJS instance. If it is null, the + * default XNJS is used + */ @Persist protected String xnjsReference; @@ -205,6 +210,7 @@ /** * get the trust delegation chain that was extracted from the request */ + @SuppressWarnings("unchecked") public List<TrustDelegation> getTrustDelegationTokens(){ return(List<TrustDelegation>)getSecurityContext().get(ETDTrustDelegationInHandler.TRUST_DELEGATION_CHAIN); } @@ -256,7 +262,7 @@ //make sure client will be initialised once per request client=null; try{ - properties.put(BPSupportImpl.RPResourcePropertyNames, baseProfile.getRPNamesProperty(properties.keySet())); + properties.put(BPSupportImpl.RPResourcePropertyNames, BPSupportImpl.getRPNamesProperty(properties.keySet())); }catch(Exception e){} } @@ -265,6 +271,7 @@ * if present, get the security context from the init map */ @Override + @SuppressWarnings("unchecked") public void initialise(String serviceName, Map<String, Object> initParams)throws Exception{ super.initialise(serviceName, initParams); Map<String,Object> secContext=(Map<String,Object>) Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -0,0 +1,80 @@ +package de.fzj.unicore.uas.impl.sms; + +import java.util.Map; +import java.util.logging.Level; + +import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory; +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.xnjs.aaa.Client; + +/** + * A storage defined by an environment setting for the current user.<br/> + * + * The storage root directory is resolved dynamically using the TSI to + * lookup the environment variable. The variable to use is set using an + * initialisation parameter for this class, see {@link #initialise(String, Map)}.<br/> + * + * For example, a storage "WORK" could be defined for each user by the environment + * variable "$WORK", which might differ per user.<br/> + * + * See also {@link AddOnStorageDescriptionFactory} for information how to configure + * storages for target systems.<br/> + * + * @author schuller + * @since 1.1 + */ +public class ContextualStorageImpl extends SMSBaseImpl { + + private static final long serialVersionUID = 1L; + + private transient String directory=null; + + /** + * initialisation parameter key for specifying the environment variable to use + */ + public static final String INIT_VARIABLENAME=ContextualStorageImpl.class.getName()+"_variable"; + + public ContextualStorageImpl() { + super(); + } + + @Override + public void initialise(String name, Map<String,Object>initobjs)throws Exception{ + super.initialise(name, initobjs); + variableName=(String)initobjs.get(INIT_VARIABLENAME); + } + + /** + * dynamically resolves the storage root directory + */ + @Override + protected String getStorageRoot() { + if(directory==null){ + try{ + String xlogin=getClient().getAttributes().get(Client.ATTRIBUTE_XLOGIN); + directory=XNJSFacade.get(xnjsReference).getGrounder(). + incarnatePath("",variableName,null,getClient()); + if(logger.isLoggable(Level.FINER)){ + logger.log(Level.FINER,"Setting storage directory for "+variableName+" ["+ + getClient().getDistinguishedName() + +"+ xlogin='"+xlogin+"']" + +" to <"+directory+">"); + } + }catch(Exception e){ + logger.log(Level.SEVERE,"Could not retrieve directory "+variableName,e); + } + if(!directory.endsWith(getSeparator()))directory=directory+sep; + } + + return directory; + } + + @Override + public void postActivate() { + super.postActivate(); + directory=null; + } + + + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/SMSBaseImpl.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -114,6 +114,9 @@ @Persist() protected String workdir; + + @Persist + protected String variableName; @Persist() private Boolean enableDirectFiletransfer=Boolean.FALSE; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -51,13 +51,15 @@ /** * the types of storages</br> * HOME: mapped to current user's home + * VARIABLE: mapped to an environment variable from the current user * FIXEDPATH: mapped to a fixed path (e.g. uspace, or "/tmp") * CUSTOM: other, needs a class to instantiate */ public static enum StorageTypes { HOME, FIXEDPATH, - CUSTOM + CUSTOM, + VARIABLE } public static final String INIT_STORAGETYPE=StorageManagementHomeImpl.class.getName()+".storagetype"; @@ -96,7 +98,12 @@ if (st.equals(StorageTypes.CUSTOM)){ clazz=(String)map.get(INIT_STORAGECLASS); return super.createWSRFServiceInstance(map); - } + } + if (st.equals(StorageTypes.VARIABLE)){ + clazz=ContextualStorageImpl.class.getName(); + return super.createWSRFServiceInstance(map); + } + } return null; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -63,6 +63,7 @@ import de.fzj.unicore.uas.impl.bp.BPSupportImpl; import de.fzj.unicore.uas.impl.job.JobManagementImpl; import de.fzj.unicore.uas.impl.reservation.ReservationManagementImpl; +import de.fzj.unicore.uas.impl.sms.ContextualStorageImpl; import de.fzj.unicore.uas.impl.sms.SMSBaseImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl.StorageTypes; @@ -80,7 +81,9 @@ import de.fzj.unicore.uas.impl.tss.rp.TextInfoResourceProperty; import de.fzj.unicore.uas.impl.tss.rp.UpSinceResourceProperty; import de.fzj.unicore.uas.impl.tss.rp.XLoginResourceProperty; +import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory; import de.fzj.unicore.uas.util.AddressingUtil; +import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory.AddOnStorageDescription; import de.fzj.unicore.uas.xnjs.XNJSFacade; import de.fzj.unicore.wsrflite.Kernel; import de.fzj.unicore.wsrflite.messaging.Message; @@ -97,19 +100,25 @@ /** * The implementation of the TargetSystem service.<br/> * - * It uses an XNJS instance as back end. - * The XNJS is configured through a config file, which - * is referenced in the global UNICORE/X config file + * It uses an XNJS instance as back end. The XNJS is configured + * through a config file, which is referenced in the global + * UNICORE/X config file<br/> * + * Each target system instance has a HOME storage attached, which will expose + * the current user's home directory.<br/> * + * Further configuration options: + * <ul> + * <li>attach more storages, @see {@link AddOnStorageDescriptionFactory}</li> + * </ul> + * * @author schuller */ public class TargetSystemImpl extends UASWSResourceImpl implements TargetSystem { private static final long serialVersionUID = -5620223989507126985L; - protected static Logger logger = Logger.getLogger(TargetSystemImpl.class - .getName()); + protected static Logger logger = Logger.getLogger(TargetSystemImpl.class.getName()); /** * initialisation parameter giving the unique ID of the TSF @@ -251,6 +260,7 @@ supportsReservation.setSupportsReservation(XNJSFacade.get(xnjsReference).supportsReservation()); properties.put(ResourceReservation.RP_SUPPORTS_RESERVATION,new ImmutableResourceProperty(supportsReservation)); + //storage management: create a Home SMS Map<String,Object>initMap=new HashMap<String,Object>(); initMap.put(SMSBaseImpl.INIT_STORAGENAME,"Home"); @@ -263,10 +273,11 @@ initMap.put(INITPARAM_XNJS_REFERENCE, xnjsReference); EndpointReferenceType smsEpr=createStorageManagement(initMap); + properties.put(RPStorageReference, createStorageReferenceResourceProperty(smsEpr,StorageTypeEnumeration.HOME)); + createAdditionalStorages(); + - properties.put(RPStorageReference, createStorageReferenceResourceProperty(smsEpr,StorageTypeEnumeration.HOME)); - properties.put(RPJobReference, createJobReferenceProperty()); properties.put(RPCPUTime, new CPUTimeResourceProperty(this,xnjsReference)); @@ -290,6 +301,42 @@ } } + //create additional storages defined in the config file... + protected void createAdditionalStorages(){ + AddOnStorageDescriptionFactory asdf=new AddOnStorageDescriptionFactory(UAS.getProperties()); + for(AddOnStorageDescription a: asdf.getDescriptions()){ + createStorageResource(a.getName(), a.getPathSpec(), a.getStorageType()); + logger.config("Added "+a.toString()); + } + } + + protected void createStorageResource(String name, String pathSpec, StorageTypes type){ + StorageReferenceResourceProperty srp=(StorageReferenceResourceProperty)properties.get(RPStorageReference); + + Map<String,Object>initMap=new HashMap<String,Object>(); + initMap.put(SMSBaseImpl.INIT_STORAGENAME,name); + initMap.put(StorageManagementHomeImpl.INIT_STORAGETYPE,type); + + //configure the path for the SMS + if(StorageTypes.VARIABLE.equals(type)){ + initMap.put(ContextualStorageImpl.INIT_VARIABLENAME, pathSpec); + } + + if(StorageTypes.FIXEDPATH.equals(type)){ + initMap.put(SMSBaseImpl.INIT_DIRECTORY, pathSpec); + } + + //set "infinite" tt, because the SMS will be destroyed together with this TSS + Calendar tt=Calendar.getInstance(); + tt.add(Calendar.YEAR,50); + initMap.put(SMSBaseImpl.INIT_INITIAL_TERMINATION_TIME,tt); + initMap.put(INITPARAM_SECURITYCONTEXT, getSecurityContext()); + initMap.put(INITPARAM_XNJS_REFERENCE, xnjsReference); + + EndpointReferenceType smsEpr=createStorageManagement(initMap); + srp.add(smsEpr); + } + /** * create new Job and return its epr * @param initialisation params @@ -399,7 +446,9 @@ } try{ //shutdown the xnjs instance - XNJSFacade.get(xnjsReference).shutdown(); + if(xnjsReference!=null){ + XNJSFacade.get(xnjsReference).shutdown(); + } }catch(Exception e){ logger.log(Level.SEVERE,"Could not shutdown the XNJS instance.",e); } @@ -442,6 +491,7 @@ AddressingUtil.addUGSRefparamToEpr(epr,id); return epr; } + + - } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/StorageReferenceResourceProperty.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/StorageReferenceResourceProperty.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/rp/StorageReferenceResourceProperty.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -33,8 +33,12 @@ package de.fzj.unicore.uas.impl.tss.rp; +import java.util.ArrayList; +import java.util.List; + import org.unigrids.services.atomic.types.StorageReferenceDocument; import org.unigrids.services.atomic.types.StorageReferenceType; +import org.unigrids.services.atomic.types.StorageTypeEnumeration; import org.w3.x2005.x08.addressing.EndpointReferenceType; import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperty; @@ -49,42 +53,66 @@ protected static final long serialVersionUID=20348L; private StorageReferenceDocument[] xdoc; - private StorageReferenceType[] types; + private List<StorageReferenceType> types=new ArrayList<StorageReferenceType>(); public StorageReferenceResourceProperty(StorageReferenceType[] types){ setProperty(types); } public StorageReferenceResourceProperty(EndpointReferenceType[] eprs){ - this.types=new StorageReferenceType[eprs.length]; - xdoc=new StorageReferenceDocument[types.length]; - for(int i=0;i<xdoc.length;i++){ - StorageReferenceType t= types[i]; + for(int i=0;i<eprs.length;i++){ + StorageReferenceType t=StorageReferenceType.Factory.newInstance(); t.setStorageEndpointReference(eprs[i]); - StorageReferenceDocument sref=StorageReferenceDocument.Factory.newInstance(); - sref.setStorageReference(t); - xdoc[i]=sref; + xdoc[i]=StorageReferenceDocument.Factory.newInstance(); + xdoc[i].setStorageReference(t); + types.add(t); } + } @Override public void setProperty(StorageReferenceType[] eprs) { - this.types=eprs; + types=new ArrayList<StorageReferenceType>(); xdoc=new StorageReferenceDocument[eprs.length]; - for(int i=0;i<xdoc.length;i++){ - StorageReferenceType t= eprs[i]; - StorageReferenceDocument sref=StorageReferenceDocument.Factory.newInstance(); - sref.setStorageReference(t); - xdoc[i]=sref; + for(int i=0;i<eprs.length;i++){ + xdoc[i]=StorageReferenceDocument.Factory.newInstance(); + xdoc[i].setStorageReference(eprs[i]); + types.add(eprs[i]); } } /** + * append a StorageReference to this resource property + * @param epr + */ + public synchronized void add(StorageReferenceType epr){ + types.add(epr); + StorageReferenceDocument[] xdoc1=new StorageReferenceDocument[types.size()]; + int l=xdoc.length; + System.arraycopy(xdoc,0,xdoc1,0,l); + xdoc1[xdoc.length]=StorageReferenceDocument.Factory.newInstance(); + xdoc1[xdoc.length].setStorageReference(epr); + xdoc=xdoc1; + } + + /** + * Append a StorageReference to this resource property + * The type is set to "Work", if this is not what you want, use + * add(StorageReferenceType) instead + * @param epr + */ + public synchronized void add(EndpointReferenceType epr){ + StorageReferenceDocument sms=StorageReferenceDocument.Factory.newInstance(); + sms.addNewStorageReference().setStorageEndpointReference(epr); + sms.getStorageReference().setType(StorageTypeEnumeration.WORK); + add(sms.getStorageReference()); + } + /** * @return StorageReferenceType[] */ @Override public StorageReferenceType[] getProperty() { - return types; + return types.toArray(new StorageReferenceType[types.size()]); } @Override Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddOnStorageDescriptionFactory.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddOnStorageDescriptionFactory.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddOnStorageDescriptionFactory.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -0,0 +1,112 @@ +package de.fzj.unicore.uas.util; + +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import de.fzj.unicore.uas.UAS; +import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl.StorageTypes; + +/** + * parses the supplied properties, these may contain + * storage descriptions as follows:<br/> + * <code> + * uas.targetsystem.storage.N=XXXX + * uas.targetsystem.storage.N.type=... + * uas.targetsystem.storage.N.path=... + * </code> + * where <code>N</code> is a string for disambiguating various storages + * (e.g. "1", "2", etc may be used) + * <br/> + * + * Examples: + * + * <code> + * uas.targetsystem.storage.1=DEISAHOME + * uas.targetsystem.storage.type.1=VARIABLE + * uas.targetsystem.storage.path.1=DEISA_HOME + * </code> + * will attach a storage defined per-user by evaluating the + * $DEISA_HOME environment variable <br/> + * + * <code> + * uas.targetsystem.storage.2=TEMP + * uas.targetsystem.storage.type.2=FIXEDPATH + * uas.targetsystem.storage.path.2=/tmp + * </code> + * will attach a storage defined using the supplied path<br/> + * + * TODO handle detailed permissions + */ +public class AddOnStorageDescriptionFactory{ + + public static final String PREFIX="uas.targetsystem.storage."; + public static final String SUFFIX_TYPE=".type"; + public static final String SUFFIX_PATH=".path"; + + List<AddOnStorageDescription>list=new ArrayList<AddOnStorageDescription>(); + + /** + * Will parse UAS.getProperties() + */ + public AddOnStorageDescriptionFactory(){ + this(UAS.getProperties()); + } + /** + * @param props - the properties to parse (usually UAS.getProperties()) + */ + public AddOnStorageDescriptionFactory(Properties props){ + for(Object k: props.keySet()){ + String key=(String)k; + if(!key.trim().startsWith(PREFIX))continue; + if(key.endsWith(SUFFIX_PATH)||key.endsWith(SUFFIX_TYPE))continue; + + //extract the identifier + String id=key.substring(key.lastIndexOf(".")+1); + String name=props.getProperty(key); + String type=props.getProperty(PREFIX+id+SUFFIX_TYPE); + String path=props.getProperty(PREFIX+id+SUFFIX_PATH); + + AddOnStorageDescription asd=new AddOnStorageDescription(name,path,type); + list.add(asd); + } + } + + public List<AddOnStorageDescription> getDescriptions() { + return list; + } + + public class AddOnStorageDescription{ + + private String name, pathSpec; + private StorageTypes type; + + public AddOnStorageDescription(String name, String pathSpec, String type){ + this.name=name; + this.pathSpec=pathSpec; + this.type=StorageTypes.valueOf(type); + } + + public String getName() { + return name; + } + + public String getPathSpec() { + return pathSpec; + } + + public String getType() { + return type.toString(); + } + + public StorageTypes getStorageType() { + return type; + } + + public String toString(){ + return "Storage description: name="+name+", type="+type+" ,pathSpec="+pathSpec; + } + } + +} + Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -374,6 +374,11 @@ //TODO check xnjs.stop() public void shutdown()throws Exception{ + //do not shutdown the default instance + if(DEFAULT_INSTANCE.equals(id)){ + logger.warning("Tried to shutdown default XNJS, ignoring..."); + return; + } xnjs.stop(); //allow instance to be GC'ed xnjsInstances.put(id, null); Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -39,9 +39,9 @@ } protected void addTests(){ -// tests.add(new RunDate()); -// tests.add(new TestTSFClient()); -// tests.add(new RunCat()); + tests.add(new RunDate()); + tests.add(new TestTSFClient()); + tests.add(new RunCat()); // tests.add(new RunCatWithStageInFromRemoteSMS()); // tests.add(new RunStageInWithMissingDir()); // tests.add(new ServiceDiscoveryTest()); @@ -52,7 +52,7 @@ // tests.add(new TestWSDL()); // tests.add(new RunServerServerTransfer()); // tests.add(new ByteIOTest()); - tests.add(new HttpTest()); +// tests.add(new HttpTest()); // tests.add(new TestFileTransfer()); // tests.add(new TestReservation()); } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestTSFClient.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -7,6 +7,7 @@ import org.w3.x2005.x08.addressing.EndpointReferenceType; import de.fzj.unicore.uas.client.RegistryClient; +import de.fzj.unicore.uas.client.StorageClient; import de.fzj.unicore.uas.client.TSFClient; import de.fzj.unicore.uas.client.TSSClient; import de.fzj.unicore.uas.impl.tss.TargetSystemFactoryImpl; @@ -36,6 +37,11 @@ //assert we have text info properties assertTrue(tss.getTextInfo().size()==2); + //assert that we have the addon storage mapped to /tmp + assertTrue(tss.getStorages().size()==2); + StorageClient sms2=new StorageClient(tss.getStorages().get(1)); + System.out.println(sms2.getResourcePropertiesDocument()); + runJob(tss); System.out.println(System.currentTimeMillis()+" "+tss.getTargetSystemName()); Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java 2008-01-02 14:12:33 UTC (rev 2110) @@ -33,26 +33,23 @@ package de.fzj.unicore.uas.impl; -import javax.xml.namespace.QName; +import java.util.List; +import java.util.Properties; import junit.framework.TestCase; import org.apache.xmlbeans.SchemaProperty; -import org.apache.xmlbeans.XmlObject; -import org.apache.xmlbeans.XmlOptions; -import org.apache.xmlbeans.XmlQName; import org.ggf.schemas.byteio.x2005.x10.byteIo.TransferInformationType; import org.ggf.schemas.byteio.x2005.x10.byteIo.TransferInformationTypeDocument; -import org.jdom.Element; import org.unigrids.x2006.x04.services.fts.FileTransferPropertiesDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; -import de.fzj.unicore.uas.TargetSystem; import de.fzj.unicore.uas.client.RegistryClient; import de.fzj.unicore.uas.fts.byteio.ByteIO; import de.fzj.unicore.uas.fts.byteio.RandomByteIO; +import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory; import de.fzj.unicore.uas.util.AddressingUtil; -import de.fzj.unicore.wsrflite.utils.Utilities; +import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory.AddOnStorageDescription; import de.fzj.unicore.wsrflite.xmlbeans.impl.CurrentTimeProperty; public class TestVarious extends TestCase{ @@ -134,4 +131,34 @@ } } + public void testTSSAttachedStorageDescription(){ + Properties p=new Properties(); + p.put("uas.targetsystem.storage.1","WORK"); + p.put("uas.targetsystem.storage.1.type","VARIABLE"); + p.put("uas.targetsystem.storage.1.path","WORK"); + + p.put("uas.targetsystem.storage.2","TEMP"); + p.put("uas.targetsystem.storage.2.type","FIXEDPATH"); + p.put("uas.targetsystem.storage.2.path","/tmp"); + + AddOnStorageDescriptionFactory asdFactory=new AddOnStorageDescriptionFactory(p); + List<AddOnStorageDescription>list=asdFactory.getDescriptions(); + assertTrue(list.size()==2); + + p=new Properties(); + p.put("uas.targetsystem.storage.1","WORK"); + p.put("uas.targetsystem.storage.1.type","VARIABLE"); + p.put("uas.targetsystem.storage.1.path","MY_WORK"); + + asdFactory=new AddOnStorageDescriptionFactory(p); + list=asdFactory.getDescriptions(); + assertTrue(list.size()==1); + AddOnStorageDescription asd=asdFactory.getDescriptions().get(0); + assertNotNull(asd); + System.out.println(asd); + assertEquals("WORK", asd.getName()); + assertEquals("VARIABLE", asd.getType()); + assertEquals("MY_WORK", asd.getPathSpec()); + } + } Modified: unicorex/uas-core/trunk/src/test/resources/uas.config =================================================================== --- unicorex/uas-core/trunk/src/test/resources/uas.config 2008-01-02 10:17:22 UTC (rev 2109) +++ unicorex/uas-core/trunk/src/test/resources/uas.config 2008-01-02 14:12:33 UTC (rev 2110) @@ -74,4 +74,11 @@ # uas.sms.protocols=BFT RBYTEIO SBYTEIO +# +# additional storage attached to TSS +# +uas.targetsystem.storage.1=TEMP +uas.targetsystem.storage.1.type=FIXEDPATH +uas.targetsystem.storage.1.path=/tmp + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-02 21:33:41
|
Revision: 2113 http://unicore.svn.sourceforge.net/unicore/?rev=2113&view=rev Author: bschuller Date: 2008-01-02 13:33:36 -0800 (Wed, 02 Jan 2008) Log Message: ----------- nice helper for building XACML rules Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java 2008-01-02 21:33:36 UTC (rev 2113) @@ -0,0 +1,308 @@ +package de.fzj.unicore.uas.security.util; + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +import com.sun.xacml.EvaluationCtx; +import com.sun.xacml.Rule; +import com.sun.xacml.Target; +import com.sun.xacml.TargetMatch; +import com.sun.xacml.attr.AnyURIAttribute; +import com.sun.xacml.attr.AttributeDesignator; +import com.sun.xacml.attr.AttributeValue; +import com.sun.xacml.attr.StringAttribute; +import com.sun.xacml.attr.X500NameAttribute; +import com.sun.xacml.cond.Apply; +import com.sun.xacml.cond.EqualFunction; +import com.sun.xacml.cond.Function; +import com.sun.xacml.cond.FunctionBase; +import com.sun.xacml.cond.FunctionFactory; +import com.sun.xacml.cond.GeneralBagFunction; +import com.sun.xacml.ctx.Result; + +/** + * helper to generate XACML rules using a nice, "fluent" API, + * based on the SUN XACML 1.0 implementation, + * + * @author schuller + */ +public class RuleBuilder { + + private int decision; + + private Apply condition; + + private Target target; + + private String serviceSpec; + + private String role; + + private String description; + private String id; + + public RuleBuilder(){ + } + + public RuleBuilder permit(){ + this.decision=Result.DECISION_PERMIT; + return this; + } + + public RuleBuilder denyAccess(){ + this.decision=Result.DECISION_DENY; + return this; + } + + public RuleBuilder forRole(String role){ + condition=getConditionRoleMatches(role); + this.role=role; + return this; + } + + public RuleBuilder ifOwnerMatches(){ + condition=getConditionOwnerMatches(); + return this; + } + + public RuleBuilder withDescription(String description){ + this.description=description; + return this; + } + + public RuleBuilder withID(String id){ + this.id=id; + return this; + } + + public RuleBuilder onService(String serviceName){ + this.target=buildTargetFromServiceSpec(serviceName); + this.serviceSpec=serviceName; + return this; + } + + public RuleBuilder onServiceInstance(String serviceName, String instanceID){ + this.target=buildTargetFromServiceSpec(serviceName, instanceID); + this.serviceSpec=serviceName; + return this; + } + + + /** + * + * allow the given role access to the specified service + * @param role - client role (e.g. "user" or "admin") + * @param serviceSpec + * @oparam description a description of this rule + * @return + */ + public Rule buildRule(){ + try{ + String desc=description!=null?description:""; + //TODO dynamically adapt rule id + String ruleID=id!=null?id:"Permit:"+serviceSpec+"_for_"+role; + Rule r=new Rule(new URI(ruleID),decision,desc, + target, + condition); + return r; + }catch(Exception e){ + e.printStackTrace(); + + } + return null; + } + + + + /** + * + * @param serviceSpec + * @return + */ + private Target buildTargetFromServiceSpec(String serviceSpec){ + try{ + Function f=EqualFunction.getEqualInstance( + EqualFunction.NAME_ANYURI_EQUAL, + AnyURIAttribute.identifier); + + AttributeValue v=AnyURIAttribute.getInstance(serviceSpec); + + AttributeDesignator eval=new AttributeDesignator( + AttributeDesignator.RESOURCE_TARGET, + new URI(AnyURIAttribute.identifier), + new URI(EvaluationCtx.RESOURCE_ID), + true); + + TargetMatch tm=new TargetMatch(TargetMatch.RESOURCE,f,eval,v); + List<Object> r=new ArrayList<Object>(); + r.add(tm); + + List<Object> rs=new ArrayList<Object>(); + rs.add(r); + Target t=new Target(null,rs,null); + return t; + }catch(Exception e){ + e.printStackTrace(); + return null; + } + } + + /** + * + * @param serviceSpec + * @param instanceID + * @return + */ + private Target buildTargetFromServiceSpec(String serviceSpec, String instanceID){ + try{ + //resource match: service name + Function f=EqualFunction.getEqualInstance( + EqualFunction.NAME_ANYURI_EQUAL, + AnyURIAttribute.identifier); + AttributeValue v=AnyURIAttribute.getInstance(serviceSpec); + AttributeDesignator eval=new AttributeDesignator( + AttributeDesignator.RESOURCE_TARGET, + new URI(AnyURIAttribute.identifier), + new URI(EvaluationCtx.RESOURCE_ID), + false); + + TargetMatch tm=new TargetMatch(TargetMatch.RESOURCE,f,eval,v); + List<Object> r=new ArrayList<Object>(); + r.add(tm); + + //resource match: instance id + Function f2=EqualFunction.getEqualInstance( + EqualFunction.NAME_STRING_EQUAL, + StringAttribute.identifier); + AttributeValue v2=StringAttribute.getInstance(instanceID); + + AttributeDesignator eval2=new AttributeDesignator( + AttributeDesignator.RESOURCE_TARGET, + new URI(StringAttribute.identifier), + new URI("urn:unicore:wsresource"), + false); + + TargetMatch tm2=new TargetMatch(TargetMatch.RESOURCE,f2,eval2,v2); + r.add(tm2); + + + List<Object> rs=new ArrayList<Object>(); + rs.add(r); + Target t=new Target(null,rs,null); + return t; + }catch(Exception e){ + e.printStackTrace(); + return null; + } + } + + /** + * returns a Condition expressing that the given role has to be matched + * @param role + * @return + */ + private Apply getConditionRoleMatches(String role){ + try { + FunctionFactory factory = FunctionFactory.getGeneralInstance(); + Function applyFunction = null; + applyFunction = + factory.createFunction(FunctionBase.FUNCTION_NS+"string"+ + GeneralBagFunction.NAME_BASE_ONE_AND_ONLY); + + AttributeDesignator eval=new AttributeDesignator( + AttributeDesignator.SUBJECT_TARGET, + new URI(StringAttribute.identifier), + new URI("role"), + true); + + List<Object> applyArgs=new ArrayList<Object>(); + applyArgs.add(eval); + + //the Apply element containing the subject attr designator + Apply apply=new Apply(applyFunction,applyArgs,false); + + //args for the condition + List<Object> conditionArgs=new ArrayList<Object>(); + conditionArgs.add(apply); + AttributeValue value=new StringAttribute(role); + conditionArgs.add(value); + + //function the condition uses + Function conditionFunction=EqualFunction.getEqualInstance( + EqualFunction.NAME_STRING_EQUAL, + StringAttribute.identifier); + + //the final condition + Apply cond=new Apply(conditionFunction,conditionArgs,true); + return cond; + + + } catch(Exception e) { + e.printStackTrace(); + } + return null; + } + + /** + * returns a Condition expressing that the owner of a resource has + * to be matched + * + * @param role + * @return + */ + private Apply getConditionOwnerMatches(){ + try { + FunctionFactory factory = FunctionFactory.getGeneralInstance(); + + Function applyFunction1=factory.createFunction(FunctionBase.FUNCTION_NS+"x500Name"+ + GeneralBagFunction.NAME_BASE_ONE_AND_ONLY); + + AttributeDesignator eval1=new AttributeDesignator( + AttributeDesignator.SUBJECT_TARGET, + new URI(X500NameAttribute.identifier), + new URI("urn:oasis:names:tc:xacml:1.0:subject:subject-id"), + true); + + List<Object> applyArgs1=new ArrayList<Object>(); + applyArgs1.add(eval1); + + //the first Apply element containing the subject attr designator + Apply apply1=new Apply(applyFunction1,applyArgs1,false); + + Function applyFunction2=factory.createFunction(FunctionBase.FUNCTION_NS+"x500Name"+ + GeneralBagFunction.NAME_BASE_ONE_AND_ONLY); + + AttributeDesignator eval2 =new AttributeDesignator( + AttributeDesignator.RESOURCE_TARGET, + new URI(X500NameAttribute.identifier), + new URI("owner"), + true); + List<Object> applyArgs2=new ArrayList<Object>(); + applyArgs2.add(eval2); + //the second Apply element containing the subject attr designator + Apply apply2=new Apply(applyFunction2,applyArgs2,false); + + //args for the condition + List<Object> conditionArgs=new ArrayList<Object>(); + conditionArgs.add(apply1); + conditionArgs.add(apply2); + + + //function the condition uses + Function conditionFunction=EqualFunction.getEqualInstance( + EqualFunction.NAME_X500NAME_EQUAL, + X500NameAttribute.identifier); + + //the final condition + Apply cond=new Apply(conditionFunction,conditionArgs,true); + return cond; + + + } catch(Exception e) { + e.printStackTrace(); + } + return null; + } + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java 2008-01-02 16:04:28 UTC (rev 2112) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java 2008-01-02 21:33:36 UTC (rev 2113) @@ -32,7 +32,7 @@ /** * allow the given role access to the specified service - * @param role + * @param role - client role (e.g. "user" or "admin") * @param serviceSpec * @oparam description a description of this rule * @return Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java 2008-01-02 16:04:28 UTC (rev 2112) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java 2008-01-02 21:33:36 UTC (rev 2113) @@ -2,7 +2,10 @@ import java.io.ByteArrayOutputStream; +import com.sun.xacml.Indenter; + import junit.framework.TestCase; +import de.fzj.unicore.uas.security.util.RuleBuilder; import de.fzj.unicore.uas.security.util.RuleFactory; public class TestRuleFactory extends TestCase { @@ -17,10 +20,20 @@ } public void test2(){ - assertNotNull(RuleFactory.buildOwnerBasedAllowRule("targetsystem","")); + assertNotNull(RuleFactory.buildOwnerBasedAllowRule("targetsystem","")); + RuleFactory.buildOwnerBasedAllowRule("targetsystem","").encode(System.out); } public void test3(){ assertNotNull(RuleFactory.buildRoleBasedAllowRule("user", "TargetSystemService", "")); } + public void testRuleBuilder1(){ + RuleBuilder r=new RuleBuilder(); + + r.denyAccess().forRole("user").onServiceInstance("TargetSystemService", "foo"); + + r.buildRule().encode(System.out,new Indenter(2)); + + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-03 08:09:51
|
Revision: 2114 http://unicore.svn.sourceforge.net/unicore/?rev=2114&view=rev Author: bschuller Date: 2008-01-03 00:09:48 -0800 (Thu, 03 Jan 2008) Log Message: ----------- minor cleanup Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java Added Paths: ----------- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java Removed Paths: ------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java 2008-01-02 21:33:36 UTC (rev 2113) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java 2008-01-03 08:09:48 UTC (rev 2114) @@ -45,7 +45,7 @@ public RuleBuilder(){ } - public RuleBuilder permit(){ + public RuleBuilder permitAccess(){ this.decision=Result.DECISION_PERMIT; return this; } @@ -55,6 +55,17 @@ return this; } + /** + * set the action (i.e. web service method name) this rule refers to + * + * @param method - the name of the webservice method (e.g., "GetResourceProperty") + * @return this rule builder + */ + public RuleBuilder forMethod(String method){ + + return this; + } + public RuleBuilder forRole(String role){ condition=getConditionRoleMatches(role); this.role=role; @@ -66,22 +77,35 @@ return this; } - public RuleBuilder withDescription(String description){ + public RuleBuilder setDescription(String description){ this.description=description; return this; } - public RuleBuilder withID(String id){ + public RuleBuilder setID(String id){ this.id=id; return this; } + /** + * set the web service this rule refers to + * + * @param serviceName - the name of the web service + * @return this builder + */ public RuleBuilder onService(String serviceName){ this.target=buildTargetFromServiceSpec(serviceName); this.serviceSpec=serviceName; return this; } + /** + * set the WSRF instance this rule refers to + * + * @param serviceName - the name of the service + * @param instanceID - the unique ID + * @return this builder + */ public RuleBuilder onServiceInstance(String serviceName, String instanceID){ this.target=buildTargetFromServiceSpec(serviceName, instanceID); this.serviceSpec=serviceName; @@ -90,12 +114,7 @@ /** - * - * allow the given role access to the specified service - * @param role - client role (e.g. "user" or "admin") - * @param serviceSpec - * @oparam description a description of this rule - * @return + * build the resulting rule and return it */ public Rule buildRule(){ try{ @@ -120,7 +139,7 @@ * @param serviceSpec * @return */ - private Target buildTargetFromServiceSpec(String serviceSpec){ + protected Target buildTargetFromServiceSpec(String serviceSpec){ try{ Function f=EqualFunction.getEqualInstance( EqualFunction.NAME_ANYURI_EQUAL, @@ -154,7 +173,7 @@ * @param instanceID * @return */ - private Target buildTargetFromServiceSpec(String serviceSpec, String instanceID){ + protected Target buildTargetFromServiceSpec(String serviceSpec, String instanceID){ try{ //resource match: service name Function f=EqualFunction.getEqualInstance( @@ -198,11 +217,24 @@ } /** - * returns a Condition expressing that the given role has to be matched + * returns a condition expressing that the given role has to be matched * @param role * @return */ - private Apply getConditionRoleMatches(String role){ + protected Apply getConditionRoleMatches(String role){ + return getConditionAttributeMatches("role", role); + } + + + /** + * returns a condition expressing that the attribute defined by attributeID + * has to match the supplied value + * + * @param attributeID + * @param attributeValue + * @return + */ + protected Apply getConditionAttributeMatches(String attributeID, String attributeValue){ try { FunctionFactory factory = FunctionFactory.getGeneralInstance(); Function applyFunction = null; @@ -213,7 +245,7 @@ AttributeDesignator eval=new AttributeDesignator( AttributeDesignator.SUBJECT_TARGET, new URI(StringAttribute.identifier), - new URI("role"), + new URI(attributeID), true); List<Object> applyArgs=new ArrayList<Object>(); @@ -225,7 +257,7 @@ //args for the condition List<Object> conditionArgs=new ArrayList<Object>(); conditionArgs.add(apply); - AttributeValue value=new StringAttribute(role); + AttributeValue value=new StringAttribute(attributeValue); conditionArgs.add(value); //function the condition uses @@ -251,7 +283,7 @@ * @param role * @return */ - private Apply getConditionOwnerMatches(){ + protected Apply getConditionOwnerMatches(){ try { FunctionFactory factory = FunctionFactory.getGeneralInstance(); Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java 2008-01-02 21:33:36 UTC (rev 2113) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleFactory.java 2008-01-03 08:09:48 UTC (rev 2114) @@ -1,234 +0,0 @@ -package de.fzj.unicore.uas.security.util; - -import java.net.URI; -import java.util.ArrayList; -import java.util.List; - -import com.sun.xacml.EvaluationCtx; -import com.sun.xacml.Rule; -import com.sun.xacml.Target; -import com.sun.xacml.TargetMatch; -import com.sun.xacml.attr.AnyURIAttribute; -import com.sun.xacml.attr.AttributeDesignator; -import com.sun.xacml.attr.AttributeValue; -import com.sun.xacml.attr.StringAttribute; -import com.sun.xacml.attr.X500NameAttribute; -import com.sun.xacml.cond.Apply; -import com.sun.xacml.cond.EqualFunction; -import com.sun.xacml.cond.Function; -import com.sun.xacml.cond.FunctionBase; -import com.sun.xacml.cond.FunctionFactory; -import com.sun.xacml.cond.GeneralBagFunction; -import com.sun.xacml.ctx.Result; - -/** - * helper to generate XACML rules - * @author schuller - */ -public class RuleFactory { - - private RuleFactory(){ - } - - /** - * allow the given role access to the specified service - * @param role - client role (e.g. "user" or "admin") - * @param serviceSpec - * @oparam description a description of this rule - * @return - */ - public static Rule buildRoleBasedAllowRule(String role, String serviceSpec, String description){ - try{ - String desc=description!=null?description:""; - String ruleID="Permit:"+serviceSpec+"_for_"+role; - Target t=buildTargetFromServiceSpec(serviceSpec); - Rule r=new Rule(new URI(ruleID),Result.DECISION_PERMIT,desc, - t, - getConditionRoleMatches(role)); - return r; - }catch(Exception e){ - e.printStackTrace(); - } - return null; - } - - /** - * allow the owner of a service access to the specified service - * @param role - * @param serviceSpec - * @return - */ - public static Rule buildOwnerBasedAllowRule(String serviceSpec, String description){ - try{ - String desc=description!=null?description:""; - String ruleID="Permit:"+serviceSpec+"_for_owner"; - Target t=buildTargetFromServiceSpec(serviceSpec); - Rule r=new Rule(new URI(ruleID),Result.DECISION_PERMIT,desc, - t, - getConditionOwnerMatches()); - return r; - }catch(Exception e){ - e.printStackTrace(); - } - return null; - } - - - public static Rule buildRoleBasedDenyRule(String role, String serviceSpec, String description){ - try{ - String desc=description!=null?description:""; - String ruleID="Deny:"+role+":"+serviceSpec; - Target t=buildTargetFromServiceSpec(serviceSpec); - Rule r=new Rule(new URI(ruleID),Result.DECISION_DENY,desc, - t, - getConditionRoleMatches(role)); - return r; - }catch(Exception e){ - e.printStackTrace(); - } - return null; - } - - /** - * a target that is identified by a URI - * - * @param serviceSpec - * @return - */ - public static Target buildTargetFromServiceSpec(String serviceSpec){ - try{ - Function f=EqualFunction.getEqualInstance( - EqualFunction.NAME_ANYURI_EQUAL, - AnyURIAttribute.identifier); - - AttributeValue v=AnyURIAttribute.getInstance(serviceSpec); - - AttributeDesignator eval=new AttributeDesignator( - AttributeDesignator.RESOURCE_TARGET, - new URI(AnyURIAttribute.identifier), - new URI(EvaluationCtx.RESOURCE_ID), - true); - - TargetMatch tm=new TargetMatch(TargetMatch.RESOURCE,f,eval,v); - List<Object> r=new ArrayList<Object>(); - r.add(tm); - - List<Object> rs=new ArrayList<Object>(); - rs.add(r); - Target t=new Target(null,rs,null); - return t; - }catch(Exception e){ - e.printStackTrace(); - return null; - } - } - - /** - * returns a Condition expressing that the given role has to be matched - * @param role - * @return - */ - public static Apply getConditionRoleMatches(String role){ - try { - FunctionFactory factory = FunctionFactory.getGeneralInstance(); - Function applyFunction = null; - applyFunction = - factory.createFunction(FunctionBase.FUNCTION_NS+"string"+ - GeneralBagFunction.NAME_BASE_ONE_AND_ONLY); - - AttributeDesignator eval=new AttributeDesignator( - AttributeDesignator.SUBJECT_TARGET, - new URI(StringAttribute.identifier), - new URI("role"), - true); - - List<Object> applyArgs=new ArrayList<Object>(); - applyArgs.add(eval); - - //the Apply element containing the subject attr designator - Apply apply=new Apply(applyFunction,applyArgs,false); - - //args for the condition - List<Object> conditionArgs=new ArrayList<Object>(); - conditionArgs.add(apply); - AttributeValue value=new StringAttribute(role); - conditionArgs.add(value); - - //function the condition uses - Function conditionFunction=EqualFunction.getEqualInstance( - EqualFunction.NAME_STRING_EQUAL, - StringAttribute.identifier); - - //the final condition - Apply cond=new Apply(conditionFunction,conditionArgs,true); - return cond; - - - } catch(Exception e) { - e.printStackTrace(); - } - return null; - } - - /** - * returns a Condition expressing that the owner of a resource has - * to be matched - * - * @param role - * @return - */ - public static Apply getConditionOwnerMatches(){ - try { - FunctionFactory factory = FunctionFactory.getGeneralInstance(); - - Function applyFunction1=factory.createFunction(FunctionBase.FUNCTION_NS+"x500Name"+ - GeneralBagFunction.NAME_BASE_ONE_AND_ONLY); - - AttributeDesignator eval1=new AttributeDesignator( - AttributeDesignator.SUBJECT_TARGET, - new URI(X500NameAttribute.identifier), - new URI("urn:oasis:names:tc:xacml:1.0:subject:subject-id"), - true); - - List<Object> applyArgs1=new ArrayList<Object>(); - applyArgs1.add(eval1); - - //the first Apply element containing the subject attr designator - Apply apply1=new Apply(applyFunction1,applyArgs1,false); - - Function applyFunction2=factory.createFunction(FunctionBase.FUNCTION_NS+"x500Name"+ - GeneralBagFunction.NAME_BASE_ONE_AND_ONLY); - - AttributeDesignator eval2 =new AttributeDesignator( - AttributeDesignator.RESOURCE_TARGET, - new URI(X500NameAttribute.identifier), - new URI("owner"), - true); - List<Object> applyArgs2=new ArrayList<Object>(); - applyArgs2.add(eval2); - //the second Apply element containing the subject attr designator - Apply apply2=new Apply(applyFunction2,applyArgs2,false); - - //args for the condition - List<Object> conditionArgs=new ArrayList<Object>(); - conditionArgs.add(apply1); - conditionArgs.add(apply2); - - - //function the condition uses - Function conditionFunction=EqualFunction.getEqualInstance( - EqualFunction.NAME_X500NAME_EQUAL, - X500NameAttribute.identifier); - - //the final condition - Apply cond=new Apply(conditionFunction,conditionArgs,true); - return cond; - - - } catch(Exception e) { - e.printStackTrace(); - } - return null; - } - -} Copied: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java (from rev 2113, unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java) =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java 2008-01-03 08:09:48 UTC (rev 2114) @@ -0,0 +1,20 @@ +package de.fzj.unicore.security; + +import junit.framework.TestCase; + +import com.sun.xacml.Indenter; + +import de.fzj.unicore.uas.security.util.RuleBuilder; + +public class TestRuleBuilder extends TestCase { + + public void testRuleBuilder1(){ + RuleBuilder r=new RuleBuilder(); + + r.denyAccess().forRole("user").onServiceInstance("TargetSystemService", "foo"); + + r.buildRule().encode(System.out,new Indenter(2)); + + } + +} Deleted: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java 2008-01-02 21:33:36 UTC (rev 2113) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleFactory.java 2008-01-03 08:09:48 UTC (rev 2114) @@ -1,39 +0,0 @@ -package de.fzj.unicore.security; - -import java.io.ByteArrayOutputStream; - -import com.sun.xacml.Indenter; - -import junit.framework.TestCase; -import de.fzj.unicore.uas.security.util.RuleBuilder; -import de.fzj.unicore.uas.security.util.RuleFactory; - -public class TestRuleFactory extends TestCase { - - public void test1(){ - String target="http://localhost/"; - ByteArrayOutputStream bos=new ByteArrayOutputStream(); - RuleFactory.buildTargetFromServiceSpec( - target).encode(bos); - assertTrue(bos.toString().contains(target)); - assertNotNull(RuleFactory.getConditionRoleMatches("user")); - } - - public void test2(){ - assertNotNull(RuleFactory.buildOwnerBasedAllowRule("targetsystem","")); - RuleFactory.buildOwnerBasedAllowRule("targetsystem","").encode(System.out); - } - public void test3(){ - assertNotNull(RuleFactory.buildRoleBasedAllowRule("user", "TargetSystemService", "")); - } - - public void testRuleBuilder1(){ - RuleBuilder r=new RuleBuilder(); - - r.denyAccess().forRole("user").onServiceInstance("TargetSystemService", "foo"); - - r.buildRule().encode(System.out,new Indenter(2)); - - } - -} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mr...@us...> - 2008-01-06 20:08:47
|
Revision: 2120 http://unicore.svn.sourceforge.net/unicore/?rev=2120&view=rev Author: mri1706 Date: 2008-01-06 12:08:26 -0800 (Sun, 06 Jan 2008) Log Message: ----------- SAML VOMS Support for U6: handlers, test classes and resources Modified Paths: -------------- unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java unicorex/uas-core/trunk/src/test/resources/samlvomsassertion.xml Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-01-06 20:08:26 UTC (rev 2120) @@ -0,0 +1,169 @@ +/********************************************************************************* + * Copyright (c) 2007-2008 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DEVELOPED IN THE CONTEXT OF THE OMII-EUROPE PROJECT. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + +package de.fzj.unicore.uas.security; + +import java.io.ByteArrayOutputStream; +import java.security.cert.CertPath; +import java.security.cert.CertificateException; +import java.security.cert.CertificateFactory; +import java.security.cert.X509Certificate; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.logging.Level; +import java.util.logging.Logger; +import java.util.Iterator; + +import org.codehaus.xfire.MessageContext; +import org.codehaus.xfire.addressing.AddressingHeaders; +import org.codehaus.xfire.addressing.AddressingInHandler; +import org.codehaus.xfire.handler.AbstractHandler; +import org.codehaus.xfire.handler.Phase; +import org.codehaus.xfire.soap.SoapConstants; +import org.codehaus.xfire.transport.http.XFireServletController; +import org.jdom.Attribute; +import org.jdom.Element; +import org.jdom.Namespace; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; + +import pl.edu.icm.unicore.security.UnicoreSecurityFactory; +import pl.edu.icm.unicore.security.ValidationResult; +import pl.edu.icm.unicore.security.consignor.ConsignorAPI; +import pl.edu.icm.unicore.security.consignor.ConsignorAssertion; +import pl.edu.icm.unicore.security.user.UserAssertion; +import xmlbeans.org.oasis.saml2.assertion.AssertionDocument; +import de.fzj.unicore.uas.UAS; +import de.fzj.unicore.uas.impl.UASWSResourceImpl; +import de.fzj.unicore.wsrflite.WSRFInstance; +import de.fzj.unicore.xnjs.aaa.Client; + +/** + * SAML VOMS Security Out Handler + * + * @author Morris Riedel + */ +public class SAMLVOMSSecurityInHandler extends AbstractHandler +{ + protected static Logger logger = Logger.getLogger( + SAMLVOMSSecurityInHandler.class.getName()); + + // SAML VOMS assertions are transported in WS-Security extensions + public static final Namespace WSSE_NS = + Namespace.getNamespace("docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"); + + // cross-check: Should be same namespace as used by K. Benedyczak + // within the SAMLSecurityInHandler -> OK + public static final Namespace SAML2_NS = + Namespace.getNamespace("urn:oasis:names:tc:SAML:2.0:assertion"); + + public SAMLVOMSSecurityInHandler() + { + setPhase(Phase.POLICY); + after(AddressingInHandler.class.getName()); + } + + /** + * Retrieves the SAML VOMS assertions from the + * WS-Security extensions and put it + * into the security context for later evaluations + */ + public void invoke(MessageContext ctx) throws Exception + { + logger.fine("Invoking SAMLVOMSSecurityInHandler"); + + // get the SOAP header + Element header = ctx.getInMessage().getHeader(); + + if (header == null) + { + logger.severe("Missing SOAP header"); + return ; + } + + // printout header + logger.fine("Got the following SOAP header: \n"); + ByteArrayOutputStream bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(header, bos); + logger.fine(bos.toString()); + + // get wsse extensions + List extensions = header.getChildren("Security", WSSE_NS); + + // Should be only ONE wsse element (so far) + Element wsseElement = (Element) extensions.get(0); + bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(wsseElement, bos); + logger.fine(bos.toString()); + + // get SAML VOMS assertions + List assertions = wsseElement.getChildren("Assertion", SAML2_NS); + + // get SAML VOMS assertion (also only ONE so far allowed) + Element samlVomsAssertion = (Element) assertions.get(0); + bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); + logger.fine(bos.toString()); + + + + + //TBD: Discuss with Bernd if the following is in-line with + // later PDP checks... + + + + + // get the security context + Map<String, Object> securityCtx = (Map<String, Object>) ctx + .getProperty(WSRFInstance.WSRF_SECURITYCONTEXT); + if (securityCtx == null) + { + logger.fine("No security context found, new one is created..."); + securityCtx = new HashMap<String,Object>(); + } + + // put the SAML VOMS assertion in the security context + securityCtx.put("VOMS", samlVomsAssertion); + + // set the updated security context + ctx.setProperty(WSRFInstance.WSRF_SECURITYCONTEXT, securityCtx); + } + +} + + + Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java 2008-01-06 20:08:26 UTC (rev 2120) @@ -0,0 +1,126 @@ +/********************************************************************************* + * Copyright (c) 2007-2008 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DEVELOPED IN THE CONTEXT OF THE OMII-EUROPE PROJECT. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + +package de.fzj.unicore.uas.security; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.File; +import java.security.cert.CertificateEncodingException; +import java.security.cert.X509Certificate; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.codehaus.xfire.MessageContext; +import org.codehaus.xfire.client.Client; +import org.codehaus.xfire.handler.Phase; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; + +import pl.edu.icm.unicore.security.user.UserAssertion; +import xmlbeans.org.oasis.saml2.assertion.AssertionDocument; + +/** + * SAML VOMS Security Out Handler + * + * @author Morris Riedel + */ +public class SAMLVOMSSecurityOutHandler +extends SecurityOutHandler { + + private static final Logger logger = Logger.getLogger(SAMLVOMSSecurityOutHandler.class.getName()); + + protected IUASSecurityProperties sec; + + private Element samlVomsAssertion; + + public SAMLVOMSSecurityOutHandler() + { + super(); + setPhase(Phase.POLICY); + } + + /** + * Get the active SAML VOMS assertion out of security properties. + * Prepares a JDOM element to be inserted during invocation. + */ + public void doInit(IUASSecurityProperties sec) + { + logger.info("Initializing SAMLVOMSSecurityOutHandler"); + + this.sec = sec; + + // MRi, TBD: Permanent link to src/test MUST be removed + // MRi, TBD: Bernd/Bastian to add a property for active SAML VOMS credential + try + { + // create a new DOM document from SAML VOMS Assertion test file + samlVomsAssertion = new SAXBuilder().build(new File("src/test/resources/samlvomsassertion.xml")).getRootElement(); + logger.info("Using the following SAML VOMS assertion for tests:\n "); + + ByteArrayOutputStream bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); + logger.info(bos.toString()); + + } catch (Exception e) + { + logger.warning("Could not load the SAML VOMS assertion from file: " + e.getMessage()); + } + } + + /** + * Adding the SAML VOMS assertion into the SOAP header. + * + */ + public void invoke(MessageContext context) throws Exception + { + logger.info("Invoking SAMLVOMSSecurityOutHandler"); + + // Retrieve the SOAP header + Element h = context.getOutMessage().getOrCreateHeader(); + + // add the SAML VOMS assertion in the header + logger.info("Putting the following SAML VOMS assertion into the header:\n "); + ByteArrayOutputStream bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); + logger.info(bos.toString()); + h.addContent((Element)samlVomsAssertion.clone()); + + } +} + + Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-01-06 20:08:26 UTC (rev 2120) @@ -0,0 +1,136 @@ +/********************************************************************************* + * Copyright (c) 2007-2008 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DEVELOPED IN THE CONTEXT OF THE OMII-EUROPE PROJECT. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + +package de.fzj.unicore.security; + +import java.io.ByteArrayInputStream; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.security.auth.x500.X500Principal; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocument; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.security.testservices.IExample; +import de.fzj.unicore.uas.UAS; +import de.fzj.unicore.uas.client.BaseUASClient; +import de.fzj.unicore.uas.security.IUASSecurityProperties; +import de.fzj.unicore.uas.security.SAMLSecurityOutHandler; +import de.fzj.unicore.uas.security.SAMLVOMSSecurityOutHandler; +import de.fzj.unicore.uas.security.TDOutHandler; +import de.fzj.unicore.uas.security.UASSecurityProperties; +import de.fzj.unicore.wsrflite.Kernel; +import de.fzj.unicore.wsrflite.persistence.HsqldbPersist; +import de.fzj.unicore.wsrflite.security.ISecurityProperties; + +/** + * Tests to check if the SAML-based VOMS handlers work. + * + * @author Morris Riedel + */ +public class TestSAMLVOMSHandlers +extends TestCase { + + private static boolean haveInit=false; + + /** + * Setup test environment, start UAS + */ + protected void setUp()throws Exception{ + if(haveInit)return; + System.out.println("Starting UAS..."); + System.setProperty(HsqldbPersist.clearDBOnStartup,"true"); + UAS uas=new UAS("src/test/resources/secure/uas.config.simple"); + UAS.setProperty(HsqldbPersist.clearDBOnStartup,"true"); + uas.startSynchronous(); + + Logger.getLogger("de").setLevel(Level.ALL); + Logger.getLogger("org").setLevel(Level.SEVERE); + Logger.getLogger("com").setLevel(Level.SEVERE); + haveInit=true; + } + + private static String secPropsOut= + ISecurityProperties.WSRF_SSL + "=true"+"\n"+ + ISecurityProperties.WSRF_SSL_CLIENTAUTH + "=false" +"\n"+ + ISecurityProperties.WSRF_SSL_KEYSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ + ISecurityProperties.WSRF_SSL_KEYTYPE + "=JKS"+"\n"+ + ISecurityProperties.WSRF_SSL_KEYPASS + "=the!user"+"\n"+ + + ISecurityProperties.WSRF_SSL_TRUSTSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ + ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ + ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ + ISecurityProperties.WSRF_WSS+ "=false"+"\n"+ + IUASSecurityProperties.UAS_OUTHANDLER_NAME+"=" + SAMLVOMSSecurityOutHandler.class.getName()+"\n"+ + "" + ; + + /** + * Test the SAML VOMS handlers. + * The out handler is configured by using the "secPropsOut" above. + * The in handler is configured for the ExampleService according to + * 'src/test/resources/secure/uas.config.simple'. + */ + public void testHandlers(){ + try{ + // establish security + IUASSecurityProperties sec=new UASSecurityProperties(new ByteArrayInputStream(secPropsOut.getBytes())); + + // check which user + String userDN=sec.getUser().getSubjectX500Principal().getName(); + assertTrue(userDN.contains("Demo User")); + + // prepare call to example service + String url=Kernel.getKernel().getProperty(Kernel.WSRF_BASEURL)+"/ExampleService"; + EndpointReferenceType epr=EndpointReferenceType.Factory.newInstance(); + epr.addNewAddress().setStringValue(url); + BaseUASClient c=new BaseUASClient(url, epr, sec); + IExample service=c.makeProxy(IExample.class); + + // call to example service + GetResourcePropertyDocument in=GetResourcePropertyDocument.Factory.newInstance(); + in.setGetResourceProperty(new QName("foo")); + service.getTime(in); + + }catch(Exception e){ + e.printStackTrace(); + fail(e.getMessage()); + } + } + +} Added: unicorex/uas-core/trunk/src/test/resources/samlvomsassertion.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/samlvomsassertion.xml (rev 0) +++ unicorex/uas-core/trunk/src/test/resources/samlvomsassertion.xml 2008-01-06 20:08:26 UTC (rev 2120) @@ -0,0 +1,48 @@ +<wsse:Security xmlns:wsse="docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"> + <saml:Assertion ID="_1234567890abcdefghilmnopqrstuvz" IssueInstant="2007-04-22T14:34:10.059Z" Version="2.0" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"> + <saml:Issuer Format="urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName">CN=omii002.cnaf.infn.it,L=CNAF,OU=Host,O=INFN,C=IT</saml:Issuer> + <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> + <ds:SignedInfo> + <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/> + <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/> + <ds:Reference URI="#_1234567890abcdefghilmnopqrstuvz"> + <ds:Transforms> + <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/> + <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"> + <ec:InclusiveNamespaces PrefixList="ds saml xs" xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#"/> + </ds:Transform> + </ds:Transforms> + <ds:DigestMethod Algorithm="http://www.w3.org/2001/04/xmlenc#sha256"/> + <ds:DigestValue/> + </ds:Reference> + </ds:SignedInfo> + <ds:SignatureValue/> + <ds:KeyInfo> + <ds:X509Data> + <ds:X509Certificate>CRYPTIC</ds:X509Certificate> + </ds:X509Data> + </ds:KeyInfo> + </ds:Signature> + <saml:Subject> + <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:x509SubjectName">CN=Morris Riedel,OU=ZAM,OU=Forschungszentrum Juelich GmbH,O=GridGermany,C=DE</saml:NameID> + <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:holder-of-key"> + <saml:SubjectConfirmationData> + <ds:KeyInfo xmlns:ds="http://www.w3.org/2000/09/xmldsig#"> + <ds:X509Data> + <ds:X509Certificate>CRYPTIC</ds:X509Certificate> + </ds:X509Data> + </ds:KeyInfo> + </saml:SubjectConfirmationData> + </saml:SubjectConfirmation> + </saml:Subject> + <saml:Conditions NotBefore="2007-04-22T14:34:10.060Z" NotOnOrAfter="2007-04-23T02:34:10.060Z"/> + <saml:AttributeStatement> + <saml:Attribute xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="http://voms.forge.cnaf.infn.it/group" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified"> + <saml:AttributeValue xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">/omiieurope/fzj/production</saml:AttributeValue> + <saml:AttributeValue xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">/omiieurope/fzj/analysis</saml:AttributeValue> + <saml:AttributeValue xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">/omiieurope</saml:AttributeValue> + <saml:AttributeValue xsi:type="xs:string" xmlns:xs="http://www.w3.org/2001/XMLSchema">/omiieurope/fzj</saml:AttributeValue> + </saml:Attribute> + </saml:AttributeStatement> + </saml:Assertion> +</wsse:Security> \ No newline at end of file Modified: unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple =================================================================== --- unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple 2008-01-04 10:28:49 UTC (rev 2119) +++ unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple 2008-01-06 20:08:26 UTC (rev 2120) @@ -54,8 +54,13 @@ <service name="ExampleService" wsrf="false"> <interface class="de.fzj.unicore.security.testservices.IExample" /> <implementation class="de.fzj.unicore.security.testservices.ExampleService"/> + <handler type="in" class="de.fzj.unicore.uas.security.PlainWSAuthZHandler"/> + <!-- MRi for SAML-VOMS + <handler type="in" class="de.fzj.unicore.uas.security.SAMLSecurityInHandler"/> - <handler type="in" class="de.fzj.unicore.uas.security.PlainWSAuthZHandler"/> + --> + <handler type="in" class="de.fzj.unicore.uas.security.SAMLVOMSSecurityInHandler"/> + </service> </services> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-10 09:42:27
|
Revision: 2128 http://unicore.svn.sourceforge.net/unicore/?rev=2128&view=rev Author: bschuller Date: 2008-01-10 01:42:25 -0800 (Thu, 10 Jan 2008) Log Message: ----------- fix sbyteio implementation (currentPosition was not updated) Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/SByteIOClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/StreamableByteIOImpl.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/StreamingDatatransfer.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/SByteIOClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/SByteIOClient.java 2008-01-10 08:17:38 UTC (rev 2127) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/SByteIOClient.java 2008-01-10 09:42:25 UTC (rev 2128) @@ -123,7 +123,7 @@ try{ return doSeekRead(StreamableByteIO.SBYTIO_ORIGIN_CURRENT,offset,numBytes); }catch(Exception e){ - e.printStackTrace(); + logger.log(Level.SEVERE,"Read error.",e); } return null; } @@ -138,7 +138,7 @@ try{ return doSeekRead(StreamableByteIO.SBYTIO_ORIGIN_BEGINNING,offset,numBytes); }catch(Exception e){ - e.printStackTrace(); + logger.log(Level.SEVERE,"Read error.",e); } return null; } @@ -147,7 +147,7 @@ try{ doWrite(data, offset, origin); }catch(Exception e){ - e.printStackTrace(); + logger.log(Level.SEVERE,"Write error.",e); } } @@ -155,7 +155,7 @@ try{ doWrite(data,0,StreamableByteIO.SBYTIO_ORIGIN_CURRENT); }catch(Exception e){ - e.printStackTrace(); + logger.log(Level.SEVERE,"Append error.",e); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/StreamableByteIOImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/StreamableByteIOImpl.java 2008-01-10 08:17:38 UTC (rev 2127) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/StreamableByteIOImpl.java 2008-01-10 09:42:25 UTC (rev 2128) @@ -135,6 +135,7 @@ if (read > 0) { os.write(data,0,read); currentPosition+=read; + setDirty(); } return os.toByteArray(); } @@ -171,16 +172,19 @@ }finally{ try{f.close();}catch(Exception e){} } - return res; } else{ if(!SBYTIO_ORIGIN_CURRENT.equalsIgnoreCase(origin)){ throw new BaseFault("Can't fulfil write request. Only seek-origin/current is supported."); } doWrite(data, offset); - return res; + } - }catch(Exception e){ + currentPosition+=data.length; + setDirty(); + return res; + } + catch(Exception e){ logger.log(Level.SEVERE,"",e); throw BaseFault.createFault("Could not perform write: "+e.getMessage()); } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/StreamingDatatransfer.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/StreamingDatatransfer.java 2008-01-10 08:17:38 UTC (rev 2127) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/StreamingDatatransfer.java 2008-01-10 09:42:25 UTC (rev 2128) @@ -6,6 +6,7 @@ import java.util.Random; import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; +import org.unigrids.services.atomic.types.GridFileType; import org.w3.x2005.x08.addressing.EndpointReferenceType; import de.fzj.unicore.uas.client.JobClient; @@ -61,6 +62,11 @@ System.out.println("End of data import, time="+time/1000+ " sec"); System.out.println("Rate="+(size*loops)/time+ " kB/sec."); + //do an ls to check the file is there + GridFileType ls=sms.listProperties("bigfile"); + System.out.println("Size of remote file = "+ls.getSize()+ " bytes."); + assertTrue(size*loops==ls.getSize()); + //data export SByteIOClient exportClient=sms.getReadStream("bigfile"); sw.start("Start export of "+size*loops/(1024*1024)+ " MBytes"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-11 20:23:54
|
Revision: 2140 http://unicore.svn.sourceforge.net/unicore/?rev=2140&view=rev Author: bschuller Date: 2008-01-11 12:23:49 -0800 (Fri, 11 Jan 2008) Log Message: ----------- make VOMS in handler a more robust; fix "secured test" config; remove obsolete UGS handler; various cosmetic changes Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RequestBuilder.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddressingUtil.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple unicorex/uas-core/trunk/src/test/resources/wsrflite.xml Removed Paths: ------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityOutHandler.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -93,6 +93,7 @@ * WS-Security extensions and put it * into the security context for later evaluations */ + @SuppressWarnings("unchecked") public void invoke(MessageContext ctx) throws Exception { logger.fine("Invoking SAMLVOMSSecurityInHandler"); @@ -117,24 +118,34 @@ // get wsse extensions List extensions = header.getChildren("Security", WSSE_NS); + if(extensions.size()==0){ + logger.fine("No WS security header found."); + //TODO should we set some property that we do not have SAML/VOMS stuff? + return; + } // Should be only ONE wsse element (so far) Element wsseElement = (Element) extensions.get(0); if(logger.isLoggable(Level.FINE)){ bos=new ByteArrayOutputStream(); new XMLOutputter(Format.getPrettyFormat()).output(wsseElement, bos); - logger.fine(bos.toString()); + logger.fine("Extracted WS Security header:\n"+bos.toString()); } // get SAML VOMS assertions List assertions = wsseElement.getChildren("Assertion", SAML2_NS); + if(assertions.size()==0){ + logger.fine("No SAML assertions found in WS Security header."); + //TODO should we set some property that we do not have SAML/VOMS stuff? + return; + } // get SAML VOMS assertion (also only ONE so far allowed) Element samlVomsAssertion = (Element) assertions.get(0); if(logger.isLoggable(Level.FINE)){ bos=new ByteArrayOutputStream(); new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); - logger.fine(bos.toString()); + logger.fine("Extracted SAML assertion:\n"+bos.toString()); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -276,7 +276,9 @@ //handle additional attributes for(AttributeHandlingCallback a: attribHandlingCallbacks){ Map<String, String> attribs=a.extractAttributes(tokens); - client.getAttributes().putAll(attribs); + if(attribs!=null){ + client.getAttributes().putAll(attribs); + } } logger.fine("Client info: "+client); @@ -359,7 +361,7 @@ } }catch(Exception e){ - logger.log(Level.FINER,"Authorisation failure.",e); + logger.log(Level.INFO,"Authorisation failure.",e); throw new AuthorisationException("Access denied, because: "+e); } Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityOutHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityOutHandler.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UGSSecurityOutHandler.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -1,214 +0,0 @@ -/********************************************************************************* - * Copyright (c) 2006 Forschungszentrum Juelich GmbH - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * (1) Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer at the end. Redistributions in - * binary form must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * DISCLAIMER - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - ********************************************************************************/ - - -package de.fzj.unicore.uas.security; - -import java.io.File; -import java.io.FileInputStream; -import java.security.KeyStore; -import java.security.cert.CertPath; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; -import java.security.cert.X509Certificate; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.codehaus.xfire.MessageContext; -import org.codehaus.xfire.client.Client; -import org.codehaus.xfire.handler.Phase; -import org.codehaus.xfire.util.Base64; -import org.jdom.Element; -import org.jdom.Namespace; -import org.jdom.output.Format; -import org.jdom.output.XMLOutputter; - -/** - * Old-style out handler that inserts certificates into the soap header - -Supports ETD as follows:</br> -Consignor/Endorser cert is always server identity. The User cert is taken from -the security properties. If User cert is not explicitly given, the server identity is -used as User cert. - -<Security soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="1" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"> -<BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary" Id="7B51DCD0-1BD8-11DB-9873-C873374EE833">...</BinarySecurityToken> -<BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary" Id="7B689920-1BD8-11DB-9873-9486177DEBA2">...</BinarySecurityToken> -<BinarySecurityToken ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary" Id="7B6F01C0-1BD8-11DB-9873-DFF919FFE233">...</BinarySecurityToken> -<ns1:User ID="7B51DCD0-1BD8-11DB-9873-C873374EE833" xmlns:ns1="http://unigrids.org/2006/04/types"/> -<ns2:Consignor ID="7B689920-1BD8-11DB-9873-9486177DEBA2" xmlns:ns2="http://unigrids.org/2006/04/types"/> -<ns3:Endorser ID="7B6F01C0-1BD8-11DB-9873-DFF919FFE233" xmlns:ns3="http://unigrids.org/2006/04/types"/> -</Security> - - * @deprecated Use {@link SAMLSecurityOutHandler} instead. This class will be removed in the UNICORE 6.0.1 release. - * - * @author schuller - */ -public class UGSSecurityOutHandler extends SecurityOutHandler{ - - protected IUASSecurityProperties sec; - - protected static Logger logger = Logger.getLogger(UGSSecurityOutHandler.class.getName()); - - //these are from unicore/gs 2.0.x (renamed for clarity) - public final static String WSU = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"; - public final static String WSU_ID = "Id"; - public final static String WSS = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"; - public final static String WSS_SECURITY = "Security"; - public final static String WSS_BINARY_SECURITY_TOKEN = "BinarySecurityToken"; - public final static String WSS_ENCODING_TYPE = "EncodingType"; - public final static String WSS_VALUETYPE = "ValueType"; - public final static String WSS_ENCODING_BASE64 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#Base64Binary"; - public final static String WSS_VALUETYPE_X509V3 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"; - public final static String WSS_VALUETYPE_PKIPATH = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509PKIPathv1"; - public final static String WSS_VALUETYPE_PKCS7 = "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#PKCS7"; - public final static String USER = "User"; - public final static String CONSIGNOR = "Consignor"; - public final static String ENDORSER = "Endorser"; - public final static String UNIGRIDS= "http://unigrids.org/2006/04/types"; - - - public static String base64Token=null; - - private static XMLOutputter o; - - /** - * creates a new handler for unicore/gs lookalike security - */ - public UGSSecurityOutHandler(){ - super(); - setPhase(Phase.POLICY); - o=new XMLOutputter(); - o.setFormat(Format.getPrettyFormat()); - } - - public void doInit(IUASSecurityProperties sec){ - this.sec=sec; - if(base64Token==null)base64Token=Base64.encode(loadCertificate()); - } - - /** - * load the user/endorser certificate to use - * this is loaded from the ssl keystore - * @return - */ - protected byte[] loadCertificate(){ - String keystoreName=sec.getKeystore(); - String keystoreType=sec.getKeystoreType(); - String keystorePassword=sec.getKeystorePassword(); - String keystoreAlias=sec.getKeystoreAlias(); - try{ - KeyStore keyStore; - logger.info("Open keystore: " + keystoreName); - keyStore = KeyStore.getInstance(keystoreType); - File f = new File(keystoreName); - keyStore.load(new FileInputStream(f), keystorePassword.toCharArray()); - logger.info("Keystore: " + keystoreName + " successfully loaded"); - if(keystoreAlias==null){ - keystoreAlias=keyStore.aliases().nextElement(); - logger.info("No alias supplied, loading <"+keystoreAlias+">"); - } - else logger.info("Loading <"+keystoreAlias+">"); - Certificate[] certificate=keyStore.getCertificateChain(keystoreAlias); - CertificateFactory factory=CertificateFactory.getInstance("X.509"); - CertPath path=factory.generateCertPath(Arrays.asList(certificate)); - return path.getEncoded(); - }catch(Exception e){ - //always deadly, so we will throw a runtime exeption - logger.log(Level.SEVERE,"Could not load certificate from keystore.",e); - throw new RuntimeException(e); - } - } - - public void invoke(MessageContext ctx) throws Exception { - //do nothing if not client call - Boolean clientMode = (Boolean)ctx.getProperty(Client.CLIENT_MODE); - if(clientMode == null || !clientMode.booleanValue())return; - Element h=ctx.getOutMessage().getOrCreateHeader(); - h.addContent(makeSecurityElement(sec.getUser())); - if(logger.isLoggable(Level.FINEST)){ - logger.finest("security header added: "+o.outputString(h)); - } - } - - protected Element makeSecurityElement(X509Certificate user)throws Exception{ - X509Certificate[] l=new X509Certificate[]{user}; - CertPath cp=CertificateFactory.getInstance("X.509").generateCertPath(Arrays.asList(l)); - Element my=new Element(WSS_SECURITY); - my.setNamespace(Namespace.getNamespace("wss",WSS)); - my.setAttribute("mustUnderstand","1"); - List<Element> c=new ArrayList<Element>(); - addHeader(USER,c,getBase64EncodedUserCert(cp)); - addHeader(CONSIGNOR,c,base64Token); - addHeader(ENDORSER,c,base64Token); - my.addContent(c); - return my; - } - - private String getBase64EncodedUserCert(CertPath user){ - if(user==null)return base64Token; - try{ - return Base64.encode(user.getEncoded()); - }catch(Exception e){ - logger.log(Level.SEVERE, "Can't encode cert!",e); - return null; - } - } - - protected void addHeader(String role, List<Element> c, String base64){ - String id=UUID.randomUUID().toString(); - c.add(0,makeBinaryToken(id, base64)); - c.add(makeUGS(id, role)); - } - - protected Element makeBinaryToken(String id, String base64){ - Element my=new Element(WSS_BINARY_SECURITY_TOKEN); - my.setNamespace(Namespace.getNamespace("wss",WSS)); - my.setAttribute(WSS_VALUETYPE,WSS_VALUETYPE_PKIPATH); - my.setAttribute(WSS_ENCODING_TYPE,WSS_ENCODING_BASE64); - my.setAttribute(WSU_ID,id); - my.addContent(base64); - return my; - } - - protected Element makeUGS(String id, String role){ - Element my=new Element(role); - my.setNamespace(Namespace.getNamespace("uni",UNIGRIDS)); - my.setAttribute("ID", id); - return my; - } - -} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RequestBuilder.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RequestBuilder.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RequestBuilder.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -34,6 +34,7 @@ import java.net.URI; import java.util.HashSet; +import java.util.List; import java.util.Set; import javax.security.auth.x500.X500Principal; @@ -103,8 +104,12 @@ for(AttributeHandlingCallback aac: attribHandlingCallbacks) { - for(Attribute a: aac.getSubjectAttributes(c, action, res)) - attributes.add(a); + List<Attribute> attrList = aac.getSubjectAttributes(c, action, res); + if(attrList!=null){ + for(Attribute a: attrList){ + attributes.add(a); + } + } } /* Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddressingUtil.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddressingUtil.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/AddressingUtil.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -139,7 +139,7 @@ EndpointReferenceType epr=EndpointReferenceType.Factory.newInstance(); try{ if(!UAS.getSecurityProperties().isSslEnabled())return epr; - addServerIdentity(epr, SecurityManager.getServerCert().getSubjectX500Principal().getName()); + addServerIdentity(epr, SecurityManager.getServerDistinguishedName()); }catch(Exception e){ } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -84,7 +84,7 @@ sec.setAddTrustDelegation(true); TDOutHandler h=new TDOutHandler(); h.doInit(sec); - System.out.println("++++ "+h.getAssertionList().get(0).getXML()); + assertTrue(h.getAssertionList().get(0).getXML().toString().contains("CN=foo")); } } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java 2008-01-11 20:23:49 UTC (rev 2140) @@ -1,6 +1,8 @@ package de.fzj.unicore.security; import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; import junit.framework.TestCase; @@ -24,6 +26,7 @@ SimplePDP pdp; protected void setUp()throws Exception { + Logger.getLogger("de").setLevel(Level.OFF); UAS.setProperty(IUASSecurityProperties.UAS_CHECKACCESS_PDPCONFIG, PDP_CONFIG); Class.forName("com.sun.xacml.finder.impl.CurrentEnvModule"); pdp=new SimplePDP(); Modified: unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple =================================================================== --- unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/test/resources/secure/wsrflite.xml.simple 2008-01-11 20:23:49 UTC (rev 2140) @@ -55,11 +55,8 @@ <interface class="de.fzj.unicore.security.testservices.IExample" /> <implementation class="de.fzj.unicore.security.testservices.ExampleService"/> <handler type="in" class="de.fzj.unicore.uas.security.PlainWSAuthZHandler"/> - <!-- MRi for SAML-VOMS - - <handler type="in" class="de.fzj.unicore.uas.security.SAMLSecurityInHandler"/> - --> - <handler type="in" class="de.fzj.unicore.uas.security.SAMLVOMSSecurityInHandler"/> + <handler type="in" class="de.fzj.unicore.uas.security.SAMLSecurityInHandler"/> + <handler type="in" class="de.fzj.unicore.uas.security.SAMLVOMSSecurityInHandler"/> </service> </services> Modified: unicorex/uas-core/trunk/src/test/resources/wsrflite.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2008-01-11 19:59:06 UTC (rev 2139) +++ unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2008-01-11 20:23:49 UTC (rev 2140) @@ -13,7 +13,6 @@ <property name="unicore.wsrflite.host" value="localhost"/> <property name="unicore.wsrflite.port" value="65321"/> - <!-- persistence settings --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-16 21:16:08
|
Revision: 2161 http://unicore.svn.sourceforge.net/unicore/?rev=2161&view=rev Author: bschuller Date: 2008-01-16 13:15:54 -0800 (Wed, 16 Jan 2008) Log Message: ----------- fix issue with server/server transfer; minor API cleanup Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/FileTransferClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/UASClientFactory.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UASSecurityProperties.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/CreateSMSOnStartup.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/load/LoadTester.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestDelegation.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/functional/SecuredTestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/TestStaging.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -551,5 +551,18 @@ notifyInitDone(); } + protected Level getLevelProperty(String name, Level defaultValue) { + String val = getProperty(name); + if (val == null) { + return defaultValue; + } + try { + return Level.parse(val.trim()); + } catch (Exception ex) { + return defaultValue; + } + } + + } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/FileTransferClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/FileTransferClient.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/FileTransferClient.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -58,7 +58,7 @@ public abstract class FileTransferClient extends BaseUASClient { protected Logger logger=Logger.getLogger(FileTransferClient.class.getName()); - + /** * @param url * @param epr Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/JobClient.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -38,6 +38,7 @@ import java.util.logging.Level; import org.unigrids.services.atomic.types.StatusInfoDocument; +import org.unigrids.services.atomic.types.StatusInfoType; import org.unigrids.services.atomic.types.StatusType; import org.unigrids.x2006.x04.services.jms.AbortDocument; import org.unigrids.x2006.x04.services.jms.HoldDocument; @@ -103,10 +104,8 @@ * @throws Exception */ public StorageClient getUspaceClient()throws Exception{ - String address=getResourceProperty(JobManagement.RPWorkingDir); - WorkingDirectoryReferenceDocument uEpr= - WorkingDirectoryReferenceDocument.Factory.parse(address); - StorageClient storageClient=new StorageClient(uEpr.getWorkingDirectoryReference(), (IUASSecurityProperties)securityProperties); + EndpointReferenceType epr=getResourcePropertiesDocument().getJobProperties().getWorkingDirectoryReference(); + StorageClient storageClient=new StorageClient(epr, (IUASSecurityProperties)securityProperties); return storageClient; } @@ -211,8 +210,7 @@ */ public StatusType.Enum getStatus(){ try{ - return StatusInfoDocument.Factory.parse( - getResourceProperty(JobManagement.RPStatusInfo)).getStatusInfo().getStatus(); + return getResourcePropertiesDocument().getJobProperties().getStatusInfo().getStatus(); }catch(Exception e){ logger.log(Level.SEVERE,"Can't get status."); return null; @@ -225,14 +223,34 @@ */ public Integer getExitCode(){ try{ - BigInteger exitCode=StatusInfoDocument.Factory.parse(getResourceProperty(JobManagement.RPStatusInfo)).getStatusInfo().getExitCode(); - return exitCode!=null? exitCode.intValue():null; + StatusInfoType sit=getResourcePropertiesDocument().getJobProperties().getStatusInfo(); + if(sit.isSetExitCode()){ + BigInteger exitCode=sit.getExitCode(); + return exitCode!=null? exitCode.intValue():null; + } }catch(Exception e){ logger.log(Level.SEVERE,"Can't get exit code.",e); - return null; } + return null; } + + /** + * return the progress of the job + * @return a value between 0 and 1 or <code>null</code> if progress value not available + */ + public Float getProgress(){ + try{ + if(getResourcePropertiesDocument().getJobProperties().getStatusInfo().isSetProgress()){ + return getResourcePropertiesDocument().getJobProperties().getStatusInfo().getProgress(); + } + }catch(Exception e){ + logger.log(Level.SEVERE,"Can't get progress.",e); + } + return null; + + } + public Calendar getSubmissionTime(){ if(submissionTime==null) { Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -143,7 +143,10 @@ r.setBytesPerBlock(bytesPerBlock); r.setStartOffset(BigInteger.valueOf(offset)); r.setStride(stride); + ReadResponseDocument res=fts.read(req); + + byte[] data=ByteIO.decode( RandomByteIO.TRANSFER_SIMPLE, res.getReadResponse().getTransferInformation()); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/UASClientFactory.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/UASClientFactory.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/UASClientFactory.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -40,7 +40,6 @@ import javax.net.ssl.SSLSocket; -import org.codehaus.xfire.client.XFireProxy; import org.codehaus.xfire.handler.Handler; import de.fzj.unicore.uas.security.DSigOutHandler; @@ -49,6 +48,7 @@ import de.fzj.unicore.uas.security.UASSecurityProperties; import de.fzj.unicore.wsrflite.security.ISecurityProperties; import de.fzj.unicore.wsrflite.xfire.CheckUnderstoodHeadersHandler; +import de.fzj.unicore.wsrflite.xfire.ReliableProxy; import de.fzj.unicore.wsrflite.xfire.XFireClientFactory; import de.fzj.unicore.wsrflite.xfire.http.AuthSSLProtocolSocketFactory; @@ -73,7 +73,7 @@ //best probably in the WSRFlite code if(sec!=null){ try{ - XFireProxy xp=(XFireProxy)Proxy.getInvocationHandler(proxy); + ReliableProxy xp=(ReliableProxy)Proxy.getInvocationHandler(proxy); xp.getClient().setProperty(DSigOutHandler.DO_NOT_SIGN, !((UASSecurityProperties)sec).doSignMessage()); } catch(Exception e){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/ServerToServerFileTransferImpl.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -1,9 +1,14 @@ package de.fzj.unicore.uas.fts; +import java.io.IOException; +import java.io.ObjectOutputStream; +import java.io.OutputStream; +import java.io.Serializable; import java.net.URI; import java.util.Collections; import java.util.HashMap; import java.util.Map; +import java.util.logging.Level; import javax.xml.namespace.QName; @@ -13,6 +18,7 @@ import de.fzj.unicore.uas.xnjs.U6FileTransfer; import de.fzj.unicore.uas.xnjs.XNJSFacade; import de.fzj.unicore.wsrflite.ResourcePool; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.io.IFileTransfer; @@ -37,7 +43,7 @@ //store filetransfers statically, because they are updated from a separate thread private static Map<String, IFileTransfer>fileTransfers=Collections.synchronizedMap(new HashMap<String, IFileTransfer>()); - private IFileTransfer ft; + private transient IFileTransfer ft; @Override public void initialise(String sname, Map<String, Object> map) throws Exception { @@ -72,14 +78,15 @@ protected void createTransfer()throws Exception{ Action dummy=new Action(); dummy.setClient(client); - + Configuration config=XNJSFacade.get(xnjsReference).getConfiguration(); if(!isExport){ - ft=XNJSFacade.get(xnjsReference).getConfiguration().getFileTransferEngine(). + ft=config.getFileTransferEngine(). createFileTransfer(dummy,new URI(source),new URI("file://"+target)); } else{ - ft=XNJSFacade.get(xnjsReference).getConfiguration().getFileTransferEngine(). + ft=config.getFileTransferEngine(). createFileTransfer(dummy,new URI("file://"+source),new URI(target)); + } fileTransfers.put(getUniqueID(), ft); @@ -120,5 +127,28 @@ properties.put(RPTarget, new TargetResourceProperty(stt2)); target=isExport ? rawtarget: workdir+rawtarget; } + + + @Override + public Map<String, Serializable> passivate() { + + //check properties + if(logger.isLoggable(Level.FINEST)){ + for(Object o: properties.values()){ + try{ + OutputStream nOs=new OutputStream(){ + public void write(int b) throws IOException { + } + }; + ObjectOutputStream os=new ObjectOutputStream(nOs); + os.writeObject(o); + } + catch(Exception e){ + logger.log(Level.SEVERE,"Class "+o.getClass().getName()+" is not serialisable."); + } + } + } + return super.passivate(); + } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UASSecurityProperties.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UASSecurityProperties.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/UASSecurityProperties.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -41,7 +41,6 @@ import java.security.PrivateKey; import java.security.cert.X509Certificate; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Properties; import java.util.logging.Level; @@ -112,7 +111,7 @@ logger.info("Copying security props: "+toString()); UASSecurityProperties clone=(UASSecurityProperties)super.clone(); clone.properties=(Properties)this.properties.clone(); - clone.tdTokens=new ArrayList<TrustDelegation>(tdTokens); + clone.tdTokens=tdTokens!=null?new ArrayList<TrustDelegation>(tdTokens):null; return clone; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/CreateSMSOnStartup.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/CreateSMSOnStartup.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/CreateSMSOnStartup.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -40,11 +40,8 @@ import java.util.logging.Level; import java.util.logging.Logger; -import org.w3.x2005.x08.addressing.EndpointReferenceType; - import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.impl.UASWSResourceImpl; -import de.fzj.unicore.uas.impl.registry.RegistryHandler; import de.fzj.unicore.uas.impl.sms.SMSBaseImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl; import de.fzj.unicore.uas.impl.sms.StorageManagementHomeImpl.StorageTypes; Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogHandler.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/util/LogHandler.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -45,7 +45,7 @@ private FileOutputStream lockStream; private File files[]; private static final int MAX_LOCKS = 100; - DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd_HH:mm:ss"); + DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd_HH-mm-ss_"); private static java.util.HashMap locks = new java.util.HashMap(); // A metered stream is a subclass of OutputStream that Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/BFTCreator.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -34,6 +34,7 @@ import java.net.URI; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.io.IFileTransfer; @@ -44,6 +45,12 @@ */ public class BFTCreator extends FileTransferCreator { + public BFTCreator(){} + + public BFTCreator(Configuration config){ + this.config=config; + } + public IFileTransfer createFileTransfer(Action parent, URI source, URI target) { if(target.getScheme().equalsIgnoreCase("file") && source.getScheme().equalsIgnoreCase("bft")){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOCreator.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -36,6 +36,7 @@ import org.unigrids.services.atomic.types.ProtocolType; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.io.IFileTransfer; @@ -47,6 +48,12 @@ */ public class RByteIOCreator extends FileTransferCreator { + public RByteIOCreator(){} + + public RByteIOCreator(Configuration config) { + this.config=config; + } + public IFileTransfer createFileTransfer(Action parent, URI source, URI target) { if(target.getScheme().equalsIgnoreCase("file") && source.getScheme().equalsIgnoreCase("rbyteio")){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOCreator.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -36,6 +36,7 @@ import org.unigrids.services.atomic.types.ProtocolType; +import de.fzj.unicore.xnjs.Configuration; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.io.IFileTransfer; @@ -47,6 +48,12 @@ */ public class SByteIOCreator extends FileTransferCreator { + public SByteIOCreator() {} + + public SByteIOCreator(Configuration config) { + this.config=config; + } + public IFileTransfer createFileTransfer(Action parent, URI source, URI target) { if(target.getScheme().equalsIgnoreCase("file") && source.getScheme().equalsIgnoreCase("sbyteio")){ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/XNJSFacade.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -97,7 +97,7 @@ r.doDefaultInit(); } xnjsInstances.put(ref, r); - r.setID(xnjsReference); + r.setID(ref); } return r; } @@ -166,9 +166,9 @@ "Try setting the FileTransferEngine parameter in the XNJS config file!"); return; } - fte.registerFileTransferCreator(new RByteIOCreator()); - fte.registerFileTransferCreator(new SByteIOCreator()); - fte.registerFileTransferCreator(new BFTCreator()); + fte.registerFileTransferCreator(new RByteIOCreator(xnjs.getConfig())); + fte.registerFileTransferCreator(new SByteIOCreator(xnjs.getConfig())); + fte.registerFileTransferCreator(new BFTCreator(xnjs.getConfig())); } @@ -238,7 +238,10 @@ try{ Action a=xnjs.getConfig().getInternalManager().getAction(id); if(a!=null)return a.getExecutionContext().getProgress(); - else return null; + else { + logger.info("Can't get progress for action "+id+", not found on XNJS."); + return null; + } }catch(Exception e){ logger.log(Level.SEVERE,"",e); return null; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/load/LoadTester.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/load/LoadTester.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/client/functional/load/LoadTester.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -245,7 +245,6 @@ String certs="src/main/certs"; p.setProperty(ISecurityProperties.WSRF_SSL,"true"); - p.setProperty(ISecurityProperties.WSRF_WSS,"false"); p.setProperty(ISecurityProperties.WSRF_SSL_CLIENTAUTH,"false"); p.setProperty(ISecurityProperties.WSRF_SSL_KEYSTORE,certs+"/user-keystore.jks"); p.setProperty(ISecurityProperties.WSRF_SSL_KEYTYPE,"JKS"); Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestDelegation.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestDelegation.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestDelegation.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -59,7 +59,6 @@ ISecurityProperties.WSRF_SSL_TRUSTSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ - ISecurityProperties.WSRF_WSS+ "=false"+"\n"+ IUASSecurityProperties.UAS_OUTHANDLER_NAME+"="+TDOutHandler.class.getName()+" " + DSigOutHandler.class.getName() + "\n"+ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLHandlers.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -51,7 +51,6 @@ ISecurityProperties.WSRF_SSL_TRUSTSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ - ISecurityProperties.WSRF_WSS+ "=false"+"\n"+ IUASSecurityProperties.UAS_OUTHANDLER_NAME+"=" + SAMLSecurityOutHandler.class.getName()+"\n"+ "" ; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -38,7 +38,6 @@ import java.util.logging.Level; import java.util.logging.Logger; -import javax.security.auth.x500.X500Principal; import javax.xml.namespace.QName; import junit.framework.TestCase; @@ -50,9 +49,7 @@ import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.client.BaseUASClient; import de.fzj.unicore.uas.security.IUASSecurityProperties; -import de.fzj.unicore.uas.security.SAMLSecurityOutHandler; import de.fzj.unicore.uas.security.SAMLVOMSSecurityOutHandler; -import de.fzj.unicore.uas.security.TDOutHandler; import de.fzj.unicore.uas.security.UASSecurityProperties; import de.fzj.unicore.wsrflite.Kernel; import de.fzj.unicore.wsrflite.persistence.HsqldbPersist; @@ -95,7 +92,6 @@ ISecurityProperties.WSRF_SSL_TRUSTSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ - ISecurityProperties.WSRF_WSS+ "=false"+"\n"+ IUASSecurityProperties.UAS_OUTHANDLER_NAME+"=" + SAMLVOMSSecurityOutHandler.class.getName()+"\n"+ "" ; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/functional/SecuredTestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/functional/SecuredTestSuite.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/functional/SecuredTestSuite.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -64,7 +64,6 @@ ISecurityProperties.WSRF_SSL_TRUSTSTORE + "=src/main/certs/user-keystore.jks" +"\n"+ ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ - ISecurityProperties.WSRF_WSS+ "=false"+"\n"+ IUASSecurityProperties.UAS_OUTHANDLER_NAME+"="+DSigOutHandler.class.getName() +" "+TDOutHandler.class.getName()+"\n"; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/TestStaging.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/TestStaging.java 2008-01-16 20:35:41 UTC (rev 2160) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/xnjs/TestStaging.java 2008-01-16 21:15:54 UTC (rev 2161) @@ -12,7 +12,6 @@ import de.fzj.unicore.uas.UAS; import de.fzj.unicore.xnjs.ems.Action; import de.fzj.unicore.xnjs.io.IFileTransfer; -import de.fzj.unicore.xnjs.io.http.HttpTransferCreator; import de.fzj.unicore.xnjs.io.simple.CopyTransferCreator; public class TestStaging extends TestCase{ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-01-24 21:05:49
|
Revision: 2222 http://unicore.svn.sourceforge.net/unicore/?rev=2222&view=rev Author: bschuller Date: 2008-01-24 13:05:46 -0800 (Thu, 24 Jan 2008) Log Message: ----------- helper client class for dealing with multicast calls to or round-robin use of services Modified Paths: -------------- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java unicorex/uas-core/trunk/src/test/resources/secure/uas.config unicorex/uas-core/trunk/src/test/resources/secure/uas.config.simple unicorex/uas-core/trunk/src/test/resources/uas.config Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiWSRFClient.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestMultiClient.java Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java 2008-01-24 21:05:46 UTC (rev 2222) @@ -0,0 +1,76 @@ +package de.fzj.unicore.uas.client; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Method; +import java.util.List; +import java.util.Random; + +/** + * Proxy invocation handler calling underlying proxies in a multicast + * or round-robin fashion<br/> + * + * @see MultiWSRFClient + * @author schuller + */ +public class MultiInvocationHandler<Target> implements InvocationHandler { + + private int mode=MultiWSRFClient.MULTICAST; + + private List<Target>targets; + + private Random rand=new Random(); + + private MultiWSRFClient<?>client; + + public MultiInvocationHandler(MultiWSRFClient<?> client){ + this.client=client; + } + + public void setMode(int mode){ + this.mode=mode; + } + + public void setTargets(List<Target> clients){ + this.targets=clients; + } + + /** + * invokes the given method on all or a subset of the + * clients + */ + public Object invoke(Object proxy, Method method, Object[] args) + throws Throwable { + boolean errors=false; + if(mode==MultiWSRFClient.MULTICAST){ + Object last=null; + for(Target t: targets){ + try{ + last=method.invoke(t, args); + }catch(Exception e){ + //TODO + errors=true; + } + } + client.setErrorsOccurred(errors); + return last; + } + else if (mode==MultiWSRFClient.ROUNDROBIN){ + int next=rand.nextInt(targets.size()); + System.out.println("calling "+next); + return method.invoke(targets.get(next), args); + } + + else if (mode==MultiWSRFClient.ROUNDROBIN_RETRY_ON_FAILURE){ + int c=0; + while(true && c<client.getMaxRetries()){ + int next=rand.nextInt(targets.size()); + try{ + c++; + return method.invoke(targets.get(next), args); + }catch(Exception e){} + } + } + return null; + } + +} Added: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiWSRFClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiWSRFClient.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiWSRFClient.java 2008-01-24 21:05:46 UTC (rev 2222) @@ -0,0 +1,134 @@ +/** Copyright (c) 2008 Forschungszentrum Juelich GmbH + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * (1) Redistributions of source code must retain the above copyright notice, + * this list of conditions and the disclaimer at the end. Redistributions in + * binary form must reproduce the above copyright notice, this list of + * conditions and the following disclaimer in the documentation and/or other + * materials provided with the distribution. + * + * (2) Neither the name of Forschungszentrum Juelich GmbH nor the names of its + * contributors may be used to endorse or promote products derived from this + * software without specific prior written permission. + * + * DISCLAIMER + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + ********************************************************************************/ + +package de.fzj.unicore.uas.client; + +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; +import java.util.ArrayList; +import java.util.List; + +import de.fzj.unicore.wsrflite.xfire.ReliableProxy.RetryDecider; + + +/** + * Talks to multiple WSRF services in a round-robin or multicast fashion.<br/> + * + * + * + * TODO support for plain ws + * + * @author schuller + */ +public class MultiWSRFClient<T extends BaseUASClient> { + + public static final int MULTICAST=1; + + public static final int ROUNDROBIN=2; + + public static final int ROUNDROBIN_RETRY_ON_FAILURE=3; + + + private List<T> clients=new ArrayList<T>(); + + private int mode=MULTICAST; + + private int maxRetries=10; + + //any errors from the last call? + private boolean errorsOccurred; + + public void addClient(T client){ + clients.add(client); + } + + public boolean removeClient(T client){ + return clients.remove(client); + } + + /** + * sets the {@link RetryDecider} retry policy on + * all the clients + * + * @param policy - the retry policy + */ + public void setGlobalRetryPolicy(RetryDecider policy){ + for(T c: clients)c.setRetryHandler(policy); + } + + public void setMode(int mode){ + this.mode=mode; + } + + /** + * create a proxy for the given interface + * + * @param <Target> + * @param target + * @return + * @throws Exception + */ + @SuppressWarnings("unchecked") + public <Target> Target makeProxy(Class<Target> target)throws Exception { + List<Target>proxies=new ArrayList<Target>(); + for(T client: clients){ + proxies.add(client.makeProxy(target)); + } + InvocationHandler h=getInvocationHandler(proxies); + Object proxy=Proxy.newProxyInstance(target.getClassLoader(), new Class[]{target}, h); + return (Target)proxy; + } + + protected <Target> InvocationHandler getInvocationHandler(final List<Target>targets){ + MultiInvocationHandler<Target> h=new MultiInvocationHandler<Target>(this); + h.setMode(mode); + h.setTargets(targets); + return h; + } + + + protected int getMaxRetries(){ + return maxRetries; + } + + public void setMaxRetries(int maxRetries) { + this.maxRetries = maxRetries; + } + + void setErrorsOccurred(boolean errors){ + this.errorsOccurred=errors; + } + + public boolean getErrorsOccurred(){ + return errorsOccurred; + } + +} Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestMultiClient.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestMultiClient.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestMultiClient.java 2008-01-24 21:05:46 UTC (rev 2222) @@ -0,0 +1,70 @@ +package de.fzj.unicore.uas; + +import org.ggf.schemas.jsdl.x2005.x11.jsdl.ApplicationType; +import org.ggf.schemas.jsdl.x2005.x11.jsdl.JobDefinitionDocument; +import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocument; +import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocumentDocument1; +import org.w3.x2005.x08.addressing.EndpointReferenceType; + +import de.fzj.unicore.uas.client.BaseUASClient; +import de.fzj.unicore.uas.client.JobClient; +import de.fzj.unicore.uas.client.MultiWSRFClient; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceLifetime; +import de.fzj.unicore.wsrflite.xmlbeans.ResourceProperties; + +public class TestMultiClient extends AbstractJobRun{ + + String url; + EndpointReferenceType tssepr; + + @Override + public String getDescription() { + return "Testing the multicast/roundrobin web service client."; + } + + @Override + protected JobDefinitionDocument getJob() { + JobDefinitionDocument jdd=JobDefinitionDocument.Factory.newInstance(); + ApplicationType app=jdd.addNewJobDefinition().addNewJobDescription().addNewApplication(); + app.setApplicationName("Date"); + app.setApplicationVersion("1.0"); + return jdd; + } + + @Override + protected void beforeStart(JobClient job) { + System.out.println("Job submitted at: "+job.getSubmissionTime()); + } + + @Override + protected void onFinish(JobClient job) throws Exception{ + + MultiWSRFClient<BaseUASClient>mc=new MultiWSRFClient<BaseUASClient>(); + mc.addClient(job); + mc.addClient(tss); + + //get RP on all clients in the multi-client + ResourceProperties rp=mc.makeProxy(ResourceProperties.class); + GetResourcePropertyDocumentDocument1 in=GetResourcePropertyDocumentDocument1.Factory.newInstance(); + in.addNewGetResourcePropertyDocument(); + rp.GetResourcePropertyDocument(in); + + assertTrue(!mc.getErrorsOccurred()); + + //try round robin + mc.setMode(MultiWSRFClient.ROUNDROBIN); + rp=mc.makeProxy(ResourceProperties.class); + GetResourcePropertyDocument getRP=GetResourcePropertyDocument.Factory.newInstance(); + getRP.setGetResourceProperty(ResourceLifetime.RPterminationTimeQName); + System.out.println(rp.GetResourceProperty(getRP)); + System.out.println(rp.GetResourceProperty(getRP)); + System.out.println(rp.GetResourceProperty(getRP)); + System.out.println(rp.GetResourceProperty(getRP)); + + getStdout(job); + + + } + + +} Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2008-01-24 16:30:52 UTC (rev 2221) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2008-01-24 21:05:46 UTC (rev 2222) @@ -1,10 +1,15 @@ package de.fzj.unicore.uas; import java.util.ArrayList; +import java.util.HashMap; +import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; import junit.framework.TestCase; +import de.fzj.unicore.uas.impl.UASWSResourceImpl; +import de.fzj.unicore.wsrflite.Home; +import de.fzj.unicore.wsrflite.Kernel; import de.fzj.unicore.wsrflite.persistence.HsqldbPersist; import de.fzj.unicore.wsrflite.utils.StopWatch; @@ -39,6 +44,11 @@ Logger.getLogger("com").setLevel(Level.SEVERE); uas.startSynchronous(); System.err.println("Startup time: "+(System.currentTimeMillis()-start)+" ms."); + //create a "default" TSS + Home h=Kernel.getKernel().getServiceHome(UAS.TSS); + Map<String,Object>initObj=new HashMap<String, Object>(); + initObj.put(UASWSResourceImpl.INIT_UNIQUE_ID,"default_targetsystem"); + h.createWSRFServiceInstance(initObj); } protected void addTests(){ @@ -50,7 +60,7 @@ // tests.add(new ServiceDiscoveryTest()); // tests.add(new RunSMSTest()); // tests.add(new BPSupportTest()); - tests.add(new RunBulkDatatransfer()); +// tests.add(new RunBulkDatatransfer()); // tests.add(new StreamingDatatransfer()); // tests.add(new TestWSDL()); // tests.add(new RunServerServerTransfer()); @@ -58,6 +68,7 @@ // tests.add(new HttpTest()); // tests.add(new TestFileTransfer()); // tests.add(new TestReservation()); + tests.add(new TestMultiClient()); } public void testAll()throws Exception{ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java 2008-01-24 16:30:52 UTC (rev 2221) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java 2008-01-24 21:05:46 UTC (rev 2222) @@ -108,18 +108,5 @@ assertEquals(o.getStorageReference().getStorageEndpointReference().getAddress().getStringValue(), "foo"); } - - public void testJobStatus(){ - try{ - StatusInfoDocument status=StatusInfoDocument.Factory.parse(new File("src/test/resources/documents/status1.xml")); - assertTrue(status.getStatusInfo().isSetProgress()); - assertTrue(status.getStatusInfo().isSetExitCode()); - System.out.println(status); - }catch(Exception e){ - e.printStackTrace(); - fail(e.getMessage()); - } - } - - + } Modified: unicorex/uas-core/trunk/src/test/resources/secure/uas.config =================================================================== --- unicorex/uas-core/trunk/src/test/resources/secure/uas.config 2008-01-24 16:30:52 UTC (rev 2221) +++ unicorex/uas-core/trunk/src/test/resources/secure/uas.config 2008-01-24 21:05:46 UTC (rev 2222) @@ -25,7 +25,7 @@ # startup: add # -default_storage SMS instance # -default_targetsystem TSS instance -uas.onstartup=de.fzj.unicore.uas.util.DefaultOnStartup de.fzj.unicore.uas.util.CreateSMSOnStartup de.fzj.unicore.uas.util.CreateTSSOnStartup +uas.onstartup=de.fzj.unicore.uas.util.DefaultOnStartup de.fzj.unicore.uas.util.CreateSMSOnStartup # Modified: unicorex/uas-core/trunk/src/test/resources/secure/uas.config.simple =================================================================== --- unicorex/uas-core/trunk/src/test/resources/secure/uas.config.simple 2008-01-24 16:30:52 UTC (rev 2221) +++ unicorex/uas-core/trunk/src/test/resources/secure/uas.config.simple 2008-01-24 21:05:46 UTC (rev 2222) @@ -49,10 +49,6 @@ uas.security.simpleuudb=src/test/resources/secure/test.uudb -# security handler -uas.security.in.handler.classname=de.fzj.unicore.uas.security.UGSSecurityInHandler -uas.security.out.handler.classname=de.fzj.unicore.uas.security.UGSSecurityOutHandler - #set to true to use just a single XNJS for all targetsystems uas.use.singleton.xnjs=true Modified: unicorex/uas-core/trunk/src/test/resources/uas.config =================================================================== --- unicorex/uas-core/trunk/src/test/resources/uas.config 2008-01-24 16:30:52 UTC (rev 2221) +++ unicorex/uas-core/trunk/src/test/resources/uas.config 2008-01-24 21:05:46 UTC (rev 2222) @@ -25,7 +25,7 @@ # startup: add # -default_storage SMS instance # -default_targetsystem TSS instance -uas.onstartup=de.fzj.unicore.uas.util.DefaultOnStartup de.fzj.unicore.uas.util.CreateSMSOnStartup de.fzj.unicore.uas.util.CreateTSSOnStartup +uas.onstartup=de.fzj.unicore.uas.util.DefaultOnStartup de.fzj.unicore.uas.util.CreateSMSOnStartup # This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-02-15 09:03:30
|
Revision: 2313 http://unicore.svn.sourceforge.net/unicore/?rev=2313&view=rev Author: bschuller Date: 2008-02-15 01:03:28 -0800 (Fri, 15 Feb 2008) Log Message: ----------- doc Modified Paths: -------------- unicorex/uas-core/trunk/src/main/conf/registry_uas.config unicorex/uas-core/trunk/src/main/conf/uas.config unicorex/uas-core/trunk/src/main/conf/wsrflite.xml unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java unicorex/uas-core/trunk/src/site/apt/admin.apt unicorex/uas-core/trunk/src/site/apt/configuration.apt unicorex/uas-core/trunk/src/site/site.xml unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java Modified: unicorex/uas-core/trunk/src/main/conf/registry_uas.config =================================================================== --- unicorex/uas-core/trunk/src/main/conf/registry_uas.config 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/main/conf/registry_uas.config 2008-02-15 09:03:28 UTC (rev 2313) @@ -30,40 +30,25 @@ # # Should the UAS try to discover an external registry via multicast? # -uas.registry.autodiscover=true +uas.registry.autodiscover=false # # site name # -uas.targetsystem.sitename=UAS-WSRFLite-XNJS +uas.targetsystem.sitename=REGISTRY - # # runnables to be executed on startup # uas.onstartup=de.fzj.unicore.uas.util.RegistryStartup -# -# path for default storage server -# -#defaultsms.workdir=/tmp # # "YOU MAY WANT TO REVIEW" section # -# -# security handler class -# -uas.security.in.handler.classname=de.fzj.unicore.uas.security.UGSSecurityInHandler # -#set to true to use just a single XNJS for all targetsystems -# -uas.use.singleton.xnjs=true - - -# # File transfer protocols # # baseline Modified: unicorex/uas-core/trunk/src/main/conf/uas.config =================================================================== --- unicorex/uas-core/trunk/src/main/conf/uas.config 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/main/conf/uas.config 2008-02-15 09:03:28 UTC (rev 2313) @@ -28,52 +28,36 @@ # # Should the UAS try to discover an external registry via multicast? # -uas.registry.autodiscover=true +uas.externalregistry.autodiscover=true +# +# Should the UAS use an external registry? +# +uas.externalregistry.use=false # # manually specify URL of external registry, uncomment to use # -#uas.externalregistry=http://zam461.zam.kfa-juelich.de:7777/services/Registry +#uas.externalregistry.url=http://zam461.zam.kfa-juelich.de:7777/services/Registry -# -# epr: "to" address -# only used when uas.externalregistry is provided above -uas.externalregistry.epr=true -uas.externalregistry.epr.to=http://zam461.zam.kfa-juelich.de:7777/services/Registry?res=default_registry -uas.externalregistry.epr.resid=default_registry # -#optional: read epr from file: -# only used when uas.externalregistry is provided above -#uas.externalregistry.file=conf/registry.xml - -# # site name # -uas.targetsystem.sitename=FZJ-UAS-WSRFLite-XNJS +uas.targetsystem.sitename=DEMO-SITE # # runnables to be executed on startup # -uas.onstartup=de.fzj.unicore.uas.util.DefaultOnStartup de.fzj.unicore.uas.util.CreateSMSOnStartup -# -# path for default storage server -# -defaultsms.workdir=storage +uas.onstartup=de.fzj.unicore.uas.util.DefaultOnStartup # # YOU MAY WANT TO REVIEW # -# -#set to true to use just a single XNJS for all targetsystems -# -uas.use.singleton.xnjs=true - # # File transfer protocols # Modified: unicorex/uas-core/trunk/src/main/conf/wsrflite.xml =================================================================== --- unicorex/uas-core/trunk/src/main/conf/wsrflite.xml 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/main/conf/wsrflite.xml 2008-02-15 09:03:28 UTC (rev 2313) @@ -50,11 +50,7 @@ <property name="unicore.wsrflite.ssl.truststore" value="demo_keystore"/> <property name="unicore.wsrflite.ssl.truststorepass" value="demo123"/> <property name="unicore.wsrflite.ssl.truststoretype" value="JKS"/> - - <!-- WS-Security, future option ;) --> - <property name="unicore.wsrflite.wss" value="false"/> - <!-- Service Group --> <!-- default termination time for registry entries in seconds --> <property name="unicore.wsrflite.sg.defaulttermtime" value="1800"/> Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/UAS.java 2008-02-15 09:03:28 UTC (rev 2313) @@ -94,7 +94,7 @@ public class UAS { protected static Logger logger=Logger.getLogger(UAS.class.getName()); - public static final String VERSION="1.1-SNAPSHOT"; + public static final String VERSION="1.1 rc"; /** * for unit testing, should the security and access control be disabled Modified: unicorex/uas-core/trunk/src/site/apt/admin.apt =================================================================== --- unicorex/uas-core/trunk/src/site/apt/admin.apt 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/site/apt/admin.apt 2008-02-15 09:03:28 UTC (rev 2313) @@ -20,7 +20,43 @@ bin/stop.sh +-------- + +* Logging + Check the files in the logs/ directory. + + The logging levels can be set by editing the 'conf/logging.properties' file, and restarting UNICORE/X +(or using the JMX 'UAS' MBean to force a config reload). + + The following example config file configures logging so that log files are rotated daily, +and the file name includes the date/time. + ++------------------- +handlers=java.util.logging.ConsoleHandler,de.fzj.unicore.uas.util.LogHandler + +#global log level +.level=INFO + +#example: log detailed security info +de.fzj.unicore.uas.security.level=FINER + +#configure console handler (writes to STDOUT) +java.util.logging.ConsoleHandler.level=SEVERE +java.util.logging.ConsoleHandler.formatter=de.fzj.unicore.uas.util.LogFormatter + +#configure log file handler +LogHandler.level=ALL +LogHandler.append=true +#logfile name, embed the date in the name (%d will be expanded as YYYY-MM-DD_HH-MM-SS) +LogHandler.pattern=logs/gateway%d.log + +#configure date rollover, to write one file per day +#Format: <number><H|D|M|Y>, for example 12H to rollover every 12 hours +LogHandler.rollover=1D + ++------------------- + + * Administration and monitoring The health of a UNICORE/X container, and things like running services, lifetimes, etc. can be @@ -65,11 +101,4 @@ TODO - -* Logging - Check the files in the log/ directory. - - The logging levels can be set by editing the 'conf/logging.properties' file, and restarting UNICORE/X. - - Modified: unicorex/uas-core/trunk/src/site/apt/configuration.apt =================================================================== --- unicorex/uas-core/trunk/src/site/apt/configuration.apt 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/site/apt/configuration.apt 2008-02-15 09:03:28 UTC (rev 2313) @@ -68,6 +68,22 @@ *---------------+-----------------------+---------------------------+-------------------+----------------------------+ +Gateway + + The gateway address is usually hard-coded into conf/wsrflite.xml, and on the gateway side +there is an entry VSITE_NAME=address pointing to the UNICORE/X container. In some +scenarios it's convenient to auto-register with a gateway. This can be enabled using the following properties. + +*---------------+-----------------------+---------------------------+---------------------------+-------------------+ +|<<config file>>|<<property name>> |<<range of values>> |<<default value>> |<<description>> | +*---------------+-----------------------+---------------------------+---------------------------+-------------------+ +|uas.config |uas.gatewayregistration|true or false |false |whether autoregistration should be enabled| +*---------------+-----------------------+---------------------------+---------------------------+-------------------+ +| |uas.gatewayregistration.updateinterval|an integer |30 |registration refresh interval | +*---------------+-----------------------+---------------------------+-------------------+---------------------------+ + + Note that on the gateway side autoregistration needs to be enabled as well! + Registry There is an instance of the Registry service within each UNICORE/X service container. @@ -91,6 +107,16 @@ |wsrflite.xml |unicore.wsrflite.sg.defaulttermtime|a long value |"180" |alive-check interval for registry entries; an external registry will dictate its own value to the local registry| *---------------+-----------------------------------+-------------------+-------------------+-------------------+ + The following property configures UNICORE/X to run as a global registry. See also the {{{registry.html}registry guide}} for details. + +*---------------+-----------------------------------+-------------------+-------------------+-------------------+ +|<<config file>>|<<property name>> |<<range of values>>|<<default value>> |<<description>> | +*---------------+-----------------------------------+-------------------+-------------------+-------------------+ +|uas.config |uas.registry.global |"true", "false" |"false" |if set to "true", the server acts as "global" registry| +*---------------+-----------------------------------+-------------------+-------------------+-------------------+ +|uas.config |uas.onstartup |space-separated list of class names |n/a | add "de.fzj.unicore.uas.util.RegistryStartup" to configure the global registry | +*---------------+-----------------------------------+-------------------+-------------------+-------------------+ + Startup code In order to provide a flexible initialization process for the UAS, we Modified: unicorex/uas-core/trunk/src/site/site.xml =================================================================== --- unicorex/uas-core/trunk/src/site/site.xml 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/site/site.xml 2008-02-15 09:03:28 UTC (rev 2313) @@ -1,5 +1,5 @@ <?xml version="1.0" encoding="ISO-8859-1"?> -<project name="Unicore WSRF Lite"> +<project name="UNICORE/X"> <bannerLeft> <name>UNICORE/X</name> <src>images/unicorelogo.gif</src> Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java 2008-02-15 09:03:28 UTC (rev 2313) @@ -8,13 +8,22 @@ public class TestRuleBuilder extends TestCase { - public void testRuleBuilder1(){ + public void xtestRuleBuilder1(){ RuleBuilder r=new RuleBuilder(); - r.denyAccess().forRole("user").onServiceInstance("TargetSystemService", "foo"); + r.denyAccess().forRole("user").onServiceInstance("TargetSystemService", "default_targetsystem"); r.buildRule().encode(System.out,new Indenter(2)); } + public void testRuleBuilder2(){ + RuleBuilder r=new RuleBuilder(); + + r.permitAccess().forRole("admin").onServiceInstance("TargetSystemService","default_targetsystem").forMethod("Destroy"); + + r.buildRule().encode(System.out,new Indenter(2)); + + } + } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestXacmlPDP.java 2008-02-15 09:03:28 UTC (rev 2313) @@ -41,6 +41,7 @@ String action=""; ResourceDescriptor res=new ResourceDescriptor("AdminService","", ""); RequestCtx request=RequestBuilder.buildRequest(c, action, res); + request.encode(System.out); ResponseCtx response=pdp.evaluate(request); //evaluate results. If "Deny" or indeterminate, throw exception. boolean permit=true; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java 2008-02-15 08:46:06 UTC (rev 2312) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java 2008-02-15 09:03:28 UTC (rev 2313) @@ -45,6 +45,7 @@ import org.w3.x2005.x08.addressing.EndpointReferenceType; import de.fzj.unicore.uas.client.RegistryClient; +import de.fzj.unicore.uas.discovery.GatewayRegistration; import de.fzj.unicore.uas.fts.byteio.ByteIO; import de.fzj.unicore.uas.fts.byteio.RandomByteIO; import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-02-22 07:10:05
|
Revision: 2360 http://unicore.svn.sourceforge.net/unicore/?rev=2360&view=rev Author: bschuller Date: 2008-02-21 23:10:03 -0800 (Thu, 21 Feb 2008) Log Message: ----------- allow passing in voms credential in security properties; minor other stuff Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/IUASSecurityProperties.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/IUASSecurityProperties.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/IUASSecurityProperties.java 2008-02-22 07:04:28 UTC (rev 2359) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/IUASSecurityProperties.java 2008-02-22 07:10:03 UTC (rev 2360) @@ -125,6 +125,12 @@ public void setProperty(String key, String value); /** + * get a property + * @param key + */ + public String getProperty(String key); + + /** * returns the name of the security handler class for outbound messages */ public String getOutHandlerClassName(); Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-02-22 07:04:28 UTC (rev 2359) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-02-22 07:10:03 UTC (rev 2360) @@ -35,7 +35,6 @@ package de.fzj.unicore.uas.security; import java.io.ByteArrayOutputStream; -import java.io.IOException; import java.net.URI; import java.net.URISyntaxException; import java.util.ArrayList; @@ -45,6 +44,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.apache.xmlbeans.XmlObject; import org.codehaus.xfire.MessageContext; import org.codehaus.xfire.addressing.AddressingInHandler; import org.codehaus.xfire.handler.AbstractHandler; @@ -54,6 +54,10 @@ import org.jdom.output.Format; import org.jdom.output.XMLOutputter; +import xmlbeans.org.oasis.saml2.assertion.AssertionDocument; +import xmlbeans.org.oasis.saml2.assertion.AttributeStatementType; +import xmlbeans.org.oasis.saml2.assertion.AttributeType; + import com.sun.xacml.attr.StringAttribute; import de.fzj.unicore.uas.security.util.AttributeHandlingCallback; @@ -62,17 +66,6 @@ import de.fzj.unicore.wsrflite.WSRFInstance; import de.fzj.unicore.xnjs.aaa.Client; -import org.apache.xmlbeans.XmlObject; - -// SAML2 -import xmlbeans.org.oasis.saml2.assertion.AssertionDocument; -import xmlbeans.org.oasis.saml2.assertion.impl.AssertionDocumentImpl; -import xmlbeans.org.oasis.saml2.assertion.AssertionType; -import xmlbeans.org.oasis.saml2.assertion.AttributeDocument; -import xmlbeans.org.oasis.saml2.assertion.AttributeStatementType; -import xmlbeans.org.oasis.saml2.assertion.AttributeType; -import xmlbeans.org.oasis.saml2.assertion.AttributeValueDocument; - /** * SAML VOMS Security In Handler * @@ -88,12 +81,13 @@ protected static Logger logger = Logger.getLogger( SAMLVOMSSecurityInHandler.class.getName()); + public static final String VOMS_ASSERTION="unicore.saml.voms.assertion"; + // SAML VOMS assertions are transported in WS-Security extensions public static final Namespace WSSE_NS = Namespace.getNamespace("docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"); - // cross-check: Should be same namespace as used by K. Benedyczak - // within the SAMLSecurityInHandler -> OK + // assertions are in this namespace public static final Namespace SAML2_NS = Namespace.getNamespace("urn:oasis:names:tc:SAML:2.0:assertion"); @@ -197,11 +191,11 @@ bos=new ByteArrayOutputStream(); new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); AssertionDocument assertionDoc = AssertionDocument.Factory.parse( bos.toString() ); - logger.info("Created SAML Assertion for subject:\n " + assertionDoc.getAssertion().getSubject()) ; + logger.finer("Created SAML Assertion for subject:\n " + assertionDoc.getAssertion().getSubject()) ; // put the SAML VOMS assertion into the security tokens SecurityTokens tokens=((SecurityTokens)securityCtx.get(SecurityTokens.KEY)); - tokens.getContext().put("VOMS", assertionDoc); + tokens.getContext().put(VOMS_ASSERTION, assertionDoc); // set the updated security context ctx.setProperty(WSRFInstance.WSRF_SECURITYCONTEXT, securityCtx); @@ -236,8 +230,7 @@ String group=attrs.get("VOMS_group_0"); if(group!=null){ try{ - logger.info("Found the following group: " + group); - + logger.finer("Found the following group: " + group); //TODO align attribute names with other VO impl. result.add(new com.sun.xacml.ctx.Attribute(new URI("urn:unicore:voms:group"), null, null, new StringAttribute(group))); @@ -252,8 +245,8 @@ public Map<String,String> extractAttributes(SecurityTokens tokens) { // Tokens are SAML 2 Assertions - AssertionDocument assertionDoc = (AssertionDocument)tokens.getContext().get("VOMS"); - logger.info("Analysing attributes for SAML Assertion of subject:\n " + assertionDoc.getAssertion().getSubject()) ; + AssertionDocument assertionDoc = (AssertionDocument)tokens.getContext().get(VOMS_ASSERTION); + logger.finer("Analysing attributes for SAML Assertion of subject:\n " + assertionDoc.getAssertion().getSubject()) ; // map of attributes as result Map<String,String> result = new HashMap<String,String>(); @@ -268,11 +261,10 @@ // adding all attribute values to map for (int i = 0; i < attributeValues.length; i++) { - logger.info("Adding attribute:\n" + attributeValues[i].xmlText() ); + logger.finer("Adding attribute:\n" + attributeValues[i].xmlText() ); String plainAttributeValue = attributeValues[i].getDomNode().getChildNodes().item(0).getNodeValue(); result.put("VOMS_group_" + i, plainAttributeValue); } - return result; } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java 2008-02-22 07:04:28 UTC (rev 2359) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java 2008-02-22 07:10:03 UTC (rev 2360) @@ -34,8 +34,10 @@ package de.fzj.unicore.uas.security; +import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.File; +import java.util.logging.Level; import java.util.logging.Logger; import org.codehaus.xfire.MessageContext; @@ -58,6 +60,7 @@ protected IUASSecurityProperties sec; public static final String VOMS_ASSERTION="unicore.saml.voms.assertion"; + public static final String VOMS_ASSERTION_FILE="unicore.saml.voms.assertion.file"; private Element samlVomsAssertion; @@ -78,19 +81,24 @@ this.sec = sec; - // MRi, TBD: Permanent link to src/test MUST be removed - // MRi, TBD: Bernd/Bastian to add a property for active SAML VOMS credential try { - - // create a new DOM document from SAML VOMS Assertion test file - samlVomsAssertion = new SAXBuilder().build(new File("src/test/resources/samlvomsassertion.xml")).getRootElement(); - logger.info("Using the following SAML VOMS assertion for tests:\n "); - - ByteArrayOutputStream bos=new ByteArrayOutputStream(); - new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); - logger.info(bos.toString()); - + String fileName=sec.getProperty(VOMS_ASSERTION_FILE); + if(fileName!=null){ + // create a new DOM document from SAML VOMS Assertion test file + samlVomsAssertion = new SAXBuilder().build(new File(fileName)).getRootElement(); + } + String assertionXML=sec.getProperty(VOMS_ASSERTION); + if(assertionXML!=null){ + //create a new DOM document from SAML VOMS Assertion + ByteArrayInputStream in=new ByteArrayInputStream(assertionXML.getBytes()); + samlVomsAssertion = new SAXBuilder().build(in).getRootElement(); + } + if(logger.isLoggable(Level.FINER)){ + ByteArrayOutputStream bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); + logger.finer("VOMS Assertion: "+bos.toString()); + } } catch (Exception e) { logger.warning("Could not load the SAML VOMS assertion from file: " + e.getMessage()); @@ -103,16 +111,16 @@ */ public void invoke(MessageContext context) throws Exception { - logger.info("Invoking SAMLVOMSSecurityOutHandler"); - + logger.finer("Invoking SAMLVOMSSecurityOutHandler"); // Retrieve the SOAP header Element h = context.getOutMessage().getOrCreateHeader(); - - // add the SAML VOMS assertion in the header - logger.info("Putting the following SAML VOMS assertion into the header:\n "); - ByteArrayOutputStream bos=new ByteArrayOutputStream(); - new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); - logger.info(bos.toString()); + if(logger.isLoggable(Level.FINER)){ + // add the SAML VOMS assertion in the header + logger.info("Putting the following SAML VOMS assertion into the header:"); + ByteArrayOutputStream bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); + logger.finer(bos.toString()); + } h.addContent((Element)samlVomsAssertion.clone()); } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-02-22 07:04:28 UTC (rev 2359) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-02-22 07:10:03 UTC (rev 2360) @@ -78,7 +78,7 @@ UAS.setProperty(HsqldbPersist.clearDBOnStartup,"true"); uas.startSynchronous(); - Logger.getLogger("de").setLevel(Level.ALL); + Logger.getLogger("de").setLevel(Level.INFO); Logger.getLogger("org").setLevel(Level.SEVERE); Logger.getLogger("com").setLevel(Level.SEVERE); haveInit=true; @@ -95,6 +95,8 @@ ISecurityProperties.WSRF_SSL_TRUSTTYPE + "=JKS"+"\n"+ ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ IUASSecurityProperties.UAS_OUTHANDLER_NAME+"=" + SAMLVOMSSecurityOutHandler.class.getName()+"\n"+ + //pass in assertion in a file + SAMLVOMSSecurityOutHandler.VOMS_ASSERTION_FILE+"=src/test/resources/samlvomsassertion.xml \n"+ "" ; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-02-22 07:38:53
|
Revision: 2364 http://unicore.svn.sourceforge.net/unicore/?rev=2364&view=rev Author: bschuller Date: 2008-02-21 23:38:51 -0800 (Thu, 21 Feb 2008) Log Message: ----------- clean up storage types a bit. Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java unicorex/uas-core/trunk/src/site/apt/configuration.apt Added Paths: ----------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/PathedStorageImpl.java Removed Paths: ------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/FixedStorageImpl.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java 2008-02-22 07:17:29 UTC (rev 2363) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/ContextualStorageImpl.java 2008-02-22 07:38:51 UTC (rev 2364) @@ -7,32 +7,14 @@ import de.fzj.unicore.uas.xnjs.XNJSFacade; /** - * A storage defined by an environment setting for the current user.<br/> + * A storage serving files from a fixed path, such as "/work" * - * The storage root directory is resolved dynamically using the TSI to - * lookup the environment variable. The variable to use is set using an - * initialisation parameter for this class, see {@link #initialise(String, Map)}.<br/> - * - * For example, a storage "WORK" could be defined for each user by the environment - * variable "$WORK", which might differ per user.<br/> - * - * See also {@link AddOnStorageDescriptionFactory} for information how to configure - * storages for target systems.<br/> - * * @author schuller - * @since 1.1 */ public class ContextualStorageImpl extends SMSBaseImpl { private static final long serialVersionUID = 1L; - private transient String directory=null; - - /** - * initialisation parameter key for specifying the environment variable to use - */ - public static final String INIT_VARIABLENAME=ContextualStorageImpl.class.getName()+"_variable"; - public ContextualStorageImpl() { super(); } @@ -40,39 +22,16 @@ @Override public void initialise(String name, Map<String,Object>initobjs)throws Exception{ super.initialise(name, initobjs); - variableName=(String)initobjs.get(INIT_VARIABLENAME); + workdir=(String)initobjs.get(SMSBaseImpl.INIT_DIRECTORY); + if(workdir==null)throw new IllegalArgumentException("Work directory cannot be null."); + if(!workdir.endsWith(getSeparator()))workdir+=sep; + logger.info("SMS init in <"+workdir+">"); } - /** - * dynamically resolves the storage root directory - */ + @Override protected String getStorageRoot() { - if(directory==null){ - try{ - String xlogin=getClient().getXlogin().getUserName(null); - directory=XNJSFacade.get(xnjsReference).getGrounder(). - incarnatePath("",variableName,null,getClient()); - if(logger.isLoggable(Level.FINER)){ - logger.log(Level.FINER,"Setting storage directory for "+variableName+" ["+ - getClient().getDistinguishedName() - +"+ xlogin='"+xlogin+"']" - +" to <"+directory+">"); - } - }catch(Exception e){ - logger.log(Level.SEVERE,"Could not retrieve directory "+variableName,e); - } - if(!directory.endsWith(getSeparator()))directory=directory+sep; - } - - return directory; + return workdir; } - - @Override - public void customPostActivate() { - directory=null; - } - - } Deleted: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/FixedStorageImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/FixedStorageImpl.java 2008-02-22 07:17:29 UTC (rev 2363) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/FixedStorageImpl.java 2008-02-22 07:38:51 UTC (rev 2364) @@ -1,27 +0,0 @@ -package de.fzj.unicore.uas.impl.sms; - -import java.util.Map; - -public class FixedStorageImpl extends SMSBaseImpl { - - private static final long serialVersionUID = 127434398224713301L; - - public FixedStorageImpl() { - super(); - } - - @Override - protected String getStorageRoot() { - return workdir; - } - - @Override - public void initialise(String name, Map<String, Object> initobjs) throws Exception { - super.initialise(name, initobjs); - workdir=(String)initobjs.get(SMSBaseImpl.INIT_DIRECTORY); - if(workdir==null)throw new IllegalArgumentException("Work directory cannot be null."); - if(!workdir.endsWith(getSeparator()))workdir+=sep; - logger.info("SMS init in <"+workdir+">"); - } - -} Copied: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/PathedStorageImpl.java (from rev 1303, unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/FixedStorageImpl.java) =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/PathedStorageImpl.java (rev 0) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/PathedStorageImpl.java 2008-02-22 07:38:51 UTC (rev 2364) @@ -0,0 +1,44 @@ +package de.fzj.unicore.uas.impl.sms; + +import java.util.Map; + +import de.fzj.unicore.uas.xnjs.XNJSFacade; +import de.fzj.unicore.xnjs.ems.ExecutionException; + +/** + * a storage where the path is resolved on each request. This allows + * having environment variables in the path specification, for + * example /work/$PROJECT/files + * + * @author schuller + */ +public class PathedStorageImpl extends SMSBaseImpl { + + private static final long serialVersionUID = 127434398224713301L; + + public PathedStorageImpl() { + super(); + } + + //TODO optimise a bit to avoid unneeded name resolution! + @Override + protected String getStorageRoot() { + try{ + return XNJSFacade.get(xnjsReference).getTSI(getClient()).resolve(workdir); + } + catch(ExecutionException e){ + logger.warning("Could not resolve location: "+workdir+", reason: "+e.getMessage()); + return workdir; + } + } + + @Override + public void initialise(String name, Map<String, Object> initobjs) throws Exception { + super.initialise(name, initobjs); + workdir=(String)initobjs.get(SMSBaseImpl.INIT_DIRECTORY); + if(workdir==null)throw new IllegalArgumentException("Work directory cannot be null."); + if(!workdir.endsWith(getSeparator()))workdir+=sep; + logger.info("SMS init in <"+workdir+">"); + } + +} Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java 2008-02-22 07:17:29 UTC (rev 2363) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/sms/StorageManagementHomeImpl.java 2008-02-22 07:38:51 UTC (rev 2364) @@ -51,8 +51,8 @@ /** * the types of storages</br> * HOME: mapped to current user's home - * VARIABLE: mapped to an environment variable from the current user - * FIXEDPATH: mapped to a fixed path (e.g. uspace, or "/tmp") + * VARIABLE: actual path is looked up using the TSI, resolving any variables + * FIXEDPATH: mapped to a fixed path (e.g. "/opt/unicore/files") * CUSTOM: other, needs a class to instantiate */ public static enum StorageTypes { @@ -92,7 +92,7 @@ return super.createWSRFServiceInstance(map); } if (st.equals(StorageTypes.FIXEDPATH)){ - clazz=FixedStorageImpl.class.getName(); + clazz=ContextualStorageImpl.class.getName(); return super.createWSRFServiceInstance(map); } if (st.equals(StorageTypes.CUSTOM)){ @@ -100,7 +100,7 @@ return super.createWSRFServiceInstance(map); } if (st.equals(StorageTypes.VARIABLE)){ - clazz=ContextualStorageImpl.class.getName(); + clazz=PathedStorageImpl.class.getName(); return super.createWSRFServiceInstance(map); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2008-02-22 07:17:29 UTC (rev 2363) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/impl/tss/TargetSystemImpl.java 2008-02-22 07:38:51 UTC (rev 2364) @@ -317,14 +317,9 @@ initMap.put(SMSBaseImpl.INIT_STORAGENAME,name); initMap.put(StorageManagementHomeImpl.INIT_STORAGETYPE,type); - //configure the path for the SMS - if(StorageTypes.VARIABLE.equals(type)){ - initMap.put(ContextualStorageImpl.INIT_VARIABLENAME, pathSpec); - } + //configure the path for the SMS + initMap.put(SMSBaseImpl.INIT_DIRECTORY, pathSpec); - if(StorageTypes.FIXEDPATH.equals(type)){ - initMap.put(SMSBaseImpl.INIT_DIRECTORY, pathSpec); - } //set "infinite" tt, because the SMS will be destroyed together with this TSS Calendar tt=Calendar.getInstance(); Modified: unicorex/uas-core/trunk/src/site/apt/configuration.apt =================================================================== --- unicorex/uas-core/trunk/src/site/apt/configuration.apt 2008-02-22 07:17:29 UTC (rev 2363) +++ unicorex/uas-core/trunk/src/site/apt/configuration.apt 2008-02-22 07:38:51 UTC (rev 2364) @@ -278,5 +278,8 @@ uas.targetsystem.storage.2=DEISA_HOME uas.targetsystem.storage.2.type=VARIABLE -uas.targetsystem.storage.2.path=DEISA_HOME +uas.targetsystem.storage.2.path=$DEISA_HOMES +------------------- + + + Note::: the variable resolution only works with the classic Perl TSI, not with the embedded Java TSI. \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-02-22 07:47:38
|
Revision: 2365 http://unicore.svn.sourceforge.net/unicore/?rev=2365&view=rev Author: bschuller Date: 2008-02-21 23:47:37 -0800 (Thu, 21 Feb 2008) Log Message: ----------- 1.1 rc Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/AttributeHandlingCallback.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestAttributeHelper.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestCredentialCache.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestBPSupport.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestTextInfoRP.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/registry/TestRegistryDiscover.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/AttributeHandlingCallback.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/AttributeHandlingCallback.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/AttributeHandlingCallback.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -66,7 +66,7 @@ public List<Attribute> getSubjectAttributes (Client client, String action, ResourceDescriptor res); /** - * retrieve a map attributes for adding to the client attributes + * retrieve a map of attributes for adding to the client attributes * * @param tokens * @return Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/util/RuleBuilder.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -74,6 +74,16 @@ return this; } + public RuleBuilder ifSubjectHasOptionalAttribute(String attributeID, String attributeValue){ + condition=getConditionAttributeMatches(attributeID, attributeValue,false); + return this; + } + + public RuleBuilder ifSubjectHasRequiredAttribute(String attributeID, String attributeValue){ + condition=getConditionAttributeMatches(attributeID, attributeValue,true); + return this; + } + public RuleBuilder ifOwnerMatches(){ condition=getConditionOwnerMatches(); return this; @@ -208,7 +218,7 @@ * @return */ protected Apply getConditionRoleMatches(String role){ - return getConditionAttributeMatches("role", role); + return getConditionAttributeMatches("role", role, true); } @@ -218,9 +228,10 @@ * * @param attributeID * @param attributeValue + * param mustBePresent - if true, failure to find the designated attribute will result in "Indeterminate" * @return */ - protected Apply getConditionAttributeMatches(String attributeID, String attributeValue){ + protected Apply getConditionAttributeMatches(String attributeID, String attributeValue,boolean mustBePresent){ try { FunctionFactory factory = FunctionFactory.getGeneralInstance(); Function applyFunction = null; @@ -232,7 +243,7 @@ AttributeDesignator.SUBJECT_TARGET, new URI(StringAttribute.identifier), new URI(attributeID), - true); + mustBePresent); List<Object> applyArgs=new ArrayList<Object>(); applyArgs.add(eval); Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestAttributeHelper.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestAttributeHelper.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestAttributeHelper.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -4,10 +4,9 @@ import java.util.Iterator; import java.util.Map; +import junit.framework.TestCase; import de.fzj.unicore.uas.util.PropertyHelper; -import junit.framework.TestCase; - public class TestAttributeHelper extends TestCase { public void test1(){ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestCredentialCache.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestCredentialCache.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestCredentialCache.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -3,8 +3,8 @@ import java.util.HashMap; import java.util.Map; +import junit.framework.TestCase; import de.fzj.unicore.uas.security.util.CredentialCache; -import junit.framework.TestCase; public class TestCredentialCache extends TestCase{ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestRuleBuilder.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -10,20 +10,25 @@ public void xtestRuleBuilder1(){ RuleBuilder r=new RuleBuilder(); - r.denyAccess().forRole("user").onServiceInstance("TargetSystemService", "default_targetsystem"); - r.buildRule().encode(System.out,new Indenter(2)); - } public void testRuleBuilder2(){ RuleBuilder r=new RuleBuilder(); - r.permitAccess().forRole("admin").onServiceInstance("TargetSystemService","default_targetsystem").forMethod("Destroy"); + r.buildRule().encode(System.out,new Indenter(2)); + } + + + public void testRuleBuilder3(){ + RuleBuilder r=new RuleBuilder(); + r.permitAccess().ifSubjectHasRequiredAttribute("urn:unicore:voms:group","admins").onServiceInstance("TargetSystemService","default_targetsystem").forMethod("Destroy"); + r.buildRule().encode(System.out,new Indenter(2)); } + } Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/TestSuite.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -53,11 +53,11 @@ protected void addTests(){ // tests.add(new RunDate()); -// tests.add(new TestTSFClient()); +// tests.add(new TestTSFClient()); // tests.add(new RunCat()); // tests.add(new RunCatWithStageInFromRemoteSMS()); // tests.add(new RunStageInWithMissingDir()); -// tests.add(new ServiceDiscoveryTest()); + tests.add(new ServiceDiscoveryTest()); // tests.add(new RunSMSTest()); // tests.add(new BPSupportTest()); // tests.add(new RunBulkDatatransfer()); @@ -68,7 +68,7 @@ // tests.add(new HttpTest()); // tests.add(new TestFileTransfer()); // tests.add(new TestReservation()); - tests.add(new TestMultiClient()); +// tests.add(new TestMultiClient()); } public void testAll()throws Exception{ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestBPSupport.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestBPSupport.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestBPSupport.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -8,9 +8,6 @@ import junit.framework.TestCase; -import org.apache.xmlbeans.SchemaProperty; -import org.apache.xmlbeans.SchemaType; -import org.apache.xmlbeans.XmlBeans; import org.apache.xmlbeans.XmlObject; import org.ggf.baseprofile.FinalWSResourceInterfaceDocument; import org.ggf.baseprofile.ResourcePropertyNamesDocument; @@ -18,7 +15,6 @@ import de.fzj.unicore.uas.impl.bp.BPSupportImpl; import de.fzj.unicore.uas.impl.job.JobManagementImpl; import de.fzj.unicore.uas.impl.sms.HomeStorageImpl; -import de.fzj.unicore.xnjs.beans.idb.TargetSystemPropertiesDocument; public class TestBPSupport extends TestCase{ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestRPs.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -33,13 +33,11 @@ package de.fzj.unicore.uas.impl; -import java.io.File; import java.math.BigInteger; import junit.framework.TestCase; import org.apache.xmlbeans.XmlObject; -import org.unigrids.services.atomic.types.StatusInfoDocument; import org.unigrids.services.atomic.types.StorageReferenceDocument; import org.unigrids.services.atomic.types.StorageReferenceType; import org.unigrids.services.atomic.types.StorageTypeEnumeration; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestTextInfoRP.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestTextInfoRP.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestTextInfoRP.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -1,10 +1,11 @@ package de.fzj.unicore.uas.impl; +import junit.framework.TestCase; + import org.unigrids.services.atomic.types.TextInfoType; import de.fzj.unicore.uas.UAS; import de.fzj.unicore.uas.impl.tss.rp.TextInfoResourceProperty; -import junit.framework.TestCase; public class TestTextInfoRP extends TestCase{ Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/TestVarious.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -45,7 +45,6 @@ import org.w3.x2005.x08.addressing.EndpointReferenceType; import de.fzj.unicore.uas.client.RegistryClient; -import de.fzj.unicore.uas.discovery.GatewayRegistration; import de.fzj.unicore.uas.fts.byteio.ByteIO; import de.fzj.unicore.uas.fts.byteio.RandomByteIO; import de.fzj.unicore.uas.util.AddOnStorageDescriptionFactory; Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/registry/TestRegistryDiscover.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/registry/TestRegistryDiscover.java 2008-02-22 07:38:51 UTC (rev 2364) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/uas/impl/registry/TestRegistryDiscover.java 2008-02-22 07:47:37 UTC (rev 2365) @@ -8,9 +8,6 @@ import junit.framework.TestCase; import de.fzj.unicore.uas.UAS; -import de.fzj.unicore.uas.impl.registry.MulticastRegistryFinder; -import de.fzj.unicore.uas.impl.registry.MulticastRegistryServer; -import de.fzj.unicore.uas.impl.registry.RegistryHandler; public class TestRegistryDiscover extends TestCase { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <mr...@us...> - 2008-03-06 14:07:34
|
Revision: 2446 http://unicore.svn.sourceforge.net/unicore/?rev=2446&view=rev Author: mri1706 Date: 2008-03-06 06:07:29 -0800 (Thu, 06 Mar 2008) Log Message: ----------- fix in namespace for WSSE, added http:// Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-03-05 17:35:31 UTC (rev 2445) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityInHandler.java 2008-03-06 14:07:29 UTC (rev 2446) @@ -86,7 +86,7 @@ // SAML VOMS assertions are transported in WS-Security extensions public static final Namespace WSSE_NS = - Namespace.getNamespace("docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"); + Namespace.getNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"); // assertions are in this namespace public static final Namespace SAML2_NS = Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java 2008-03-05 17:35:31 UTC (rev 2445) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SAMLVOMSSecurityOutHandler.java 2008-03-06 14:07:29 UTC (rev 2446) @@ -59,7 +59,7 @@ // SAML VOMS assertions are transported in WS-Security extensions public static final Namespace WSSE_NS = - Namespace.getNamespace("docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"); + Namespace.getNamespace("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-01.xsd"); // assertions are in this namespace public static final Namespace SAML2_NS = Modified: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-03-05 17:35:31 UTC (rev 2445) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSAMLVOMSHandlers.java 2008-03-06 14:07:29 UTC (rev 2446) @@ -35,13 +35,19 @@ package de.fzj.unicore.security; import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; import java.util.logging.Level; import java.util.logging.Logger; +import org.jdom.Element; import javax.xml.namespace.QName; import junit.framework.TestCase; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; import org.oasisOpen.docs.wsrf.rl2.CurrentTimeDocument; import org.oasisOpen.docs.wsrf.rp2.GetResourcePropertyDocument; import org.w3.x2005.x08.addressing.EndpointReferenceType; @@ -96,12 +102,13 @@ ISecurityProperties.WSRF_SSL_TRUSTPASS + "=the!user"+"\n"+ IUASSecurityProperties.UAS_OUTHANDLER_NAME+"=" + SAMLVOMSSecurityOutHandler.class.getName()+"\n"+ //pass in assertion in a file - //SAMLVOMSSecurityOutHandler.VOMS_ASSERTION_FILE+"=src/test/resources/samlvomsassertion.xml \n"+ - SAMLVOMSSecurityOutHandler.VOMS_ASSERTION + - "=<saml:Assertion ID=\"_1234567890abcdefghilmnopqrstuvz\" IssueInstant=\"2007-04-22T14:34:10.059Z\" Version=\"2.0\" xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"/>" - // Edit here some more tags... + //SAMLVOMSSecurityOutHandler.VOMS_ASSERTION_FILE+"=src/test/resources/samlvomsassertion.xml \n" + // using a SAML assertion + //SAMLVOMSSecurityOutHandler.VOMS_ASSERTION + + //"=<saml:Assertion ID=\"_1234567890abcdefghilmnopqrstuvz\" IssueInstant=\"2007-04-22T14:34:10.059Z\" Version=\"2.0\" xmlns:saml=\"urn:oasis:names:tc:SAML:2.0:assertion\"></saml:Assertion>" - +"\n"+ + + // +"\n"+ "" ; @@ -116,6 +123,25 @@ // establish security IUASSecurityProperties sec=new UASSecurityProperties(new ByteArrayInputStream(secPropsOut.getBytes())); + // Test Option A: Using assertion in a file + //sec.setProperty(SAMLVOMSSecurityOutHandler.VOMS_ASSERTION_FILE,"src/test/resources/samlvomsassertion.xml"); + + // Test Option B: Using assertion passed (here indirectly read from a file) + String fileName = "src/test/resources/samlvomsassertion.xml"; + Element samlVomsAssertion = new SAXBuilder().build(new File(fileName.trim())).getRootElement(); + ByteArrayOutputStream bos=new ByteArrayOutputStream(); + new XMLOutputter(Format.getPrettyFormat()).output(samlVomsAssertion, bos); + sec.setProperty(SAMLVOMSSecurityOutHandler.VOMS_ASSERTION, bos.toString() ); + System.out.println("Passed VOMS SAML Assertion: \n"+ bos.toString()); + + + + + + + + + // check which user String userDN=sec.getUser().getSubjectX500Principal().getName(); assertTrue(userDN.contains("Demo User")); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-03-17 13:43:35
|
Revision: 2507 http://unicore.svn.sourceforge.net/unicore/?rev=2507&view=rev Author: bschuller Date: 2008-03-17 06:43:32 -0700 (Mon, 17 Mar 2008) Log Message: ----------- allow to configure a chain of IAuthoriser classes Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java unicorex/uas-core/trunk/src/site/apt/configuration.apt Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java 2008-03-17 12:20:27 UTC (rev 2506) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/security/SecurityManager.java 2008-03-17 13:43:32 UTC (rev 2507) @@ -88,7 +88,7 @@ private static XacmlPDP pdp=null; - private static IAuthoriser auth=null; + private static IAuthoriser[] auth=null; private static X509Certificate serverCert=null; private static X509Certificate gatewayCert=null; @@ -193,7 +193,10 @@ */ public static Map<String,String> authorise(SecurityTokens tokens)throws IOException{ if(auth==null)makeAuthoriser(); - Map<String,String>map = auth.authorise(tokens); + Map<String,String>map=new HashMap<String,String>(); + for (IAuthoriser a: auth){ + map.putAll(a.authorise(tokens)); + } return map; } @@ -202,17 +205,23 @@ String authClass=UAS.getProperty(IUASSecurityProperties.UAS_AUTHORISER); if(authClass==null){ logger.debug("No authoriser configured."); - auth=new NullAuthoriser(); + auth=new IAuthoriser[]{new NullAuthoriser()}; } else { - logger.debug("Using IAuthoriser class <"+authClass+">"); - - try{ - auth=(IAuthoriser)(Class.forName(authClass).newInstance()); - }catch(Exception e){ - logger.fatal("Can't create authoriser.",e); - System.exit(1); + logger.debug("Using IAuthoriser classes <"+authClass+">"); + String[] authClasses=authClass.split(" "); + List<IAuthoriser>res=new ArrayList<IAuthoriser>(); + for(String spec: authClasses){ + if(spec.trim().length()==0)continue; + try{ + res.add((IAuthoriser)(Class.forName(spec).newInstance())); + }catch(Exception e){ + logger.fatal("Can't create authoriser. Check the value of " + + "the configuration property "+IUASSecurityProperties.UAS_AUTHORISER,e); + System.exit(1); + } } + auth=res.toArray(new IAuthoriser[res.size()]); } } Modified: unicorex/uas-core/trunk/src/site/apt/configuration.apt =================================================================== --- unicorex/uas-core/trunk/src/site/apt/configuration.apt 2008-03-17 12:20:27 UTC (rev 2506) +++ unicorex/uas-core/trunk/src/site/apt/configuration.apt 2008-03-17 13:43:32 UTC (rev 2507) @@ -193,7 +193,7 @@ *---------------+-----------------------------------+-------------------+-------------------+-------------------+ |<<config file>>|<<property name>> |<<range of values>>|<<default value>> |<<description>> | *---------------+-----------------------------------+-------------------+-------------------+-------------------+ -|uas.config |uas.security.authoriser |class name | | | +|uas.config |uas.security.authoriser |space separated list of class names | | Java classes used for retrieving authZ attributes| *---------------+-----------------------------------+-------------------+-------------------+-------------------+ | |xuudb_host |http(s)://hostname | | Scheme + host of the XUUDB query service| *---------------+-----------------------------------+-------------------+-------------------+-------------------+ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-03-17 19:49:20
|
Revision: 2512 http://unicore.svn.sourceforge.net/unicore/?rev=2512&view=rev Author: bschuller Date: 2008-03-17 12:49:18 -0700 (Mon, 17 Mar 2008) Log Message: ----------- better filetransfer error reporting; set loglevels from JMX console; clean up testcase Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/RandomByteIOImpl.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdmin.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdminMBean.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOExport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOImport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOExport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOImport.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java Added Paths: ----------- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityManager.java Removed Paths: ------------- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestGetPeerCert.java Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/MultiInvocationHandler.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -56,7 +56,6 @@ } else if (mode==MultiWSRFClient.ROUNDROBIN){ int next=rand.nextInt(targets.size()); - System.out.println("calling "+next); return method.invoke(targets.get(next), args); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/RByteIOClient.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -203,7 +203,7 @@ os.write(data); } }catch(Exception e){ - logger.fatal("IO error",e); + logger.error("IO error",e); throw new IOException("IO Error: "+e.getMessage()); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/RandomByteIOImpl.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/RandomByteIOImpl.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/byteio/RandomByteIOImpl.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -102,6 +102,7 @@ logger.fatal("Could not perform read().",e); status=STATUS_FAILED; description="Could not perform read for request "+req; + setDirty(); throw BaseFault.createFault(e.getMessage()); } } @@ -130,6 +131,7 @@ logger.fatal("Could not perform write().",e); status=STATUS_FAILED; description="Could not perform write for request "+req; + setDirty(); throw BaseFault.createFault(e.getMessage()); } } @@ -153,6 +155,7 @@ logger.fatal("Could not perform append().",e); status=STATUS_FAILED; description="Could not perform append for request "+req; + setDirty(); throw BaseFault.createFault(e.getMessage()); } } @@ -175,6 +178,7 @@ logger.fatal("Could not perform append().",e); status=STATUS_FAILED; description="Could not perform truncAppend for request "+req; + setDirty(); throw BaseFault.createFault(e.getMessage()); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/fts/http/HttpFileTransferClient.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -9,6 +9,7 @@ import javax.xml.namespace.QName; import org.apache.commons.httpclient.HttpClient; +import org.apache.commons.httpclient.HttpStatus; import org.apache.commons.httpclient.methods.GetMethod; import org.apache.commons.httpclient.methods.InputStreamRequestEntity; import org.apache.commons.httpclient.methods.PutMethod; @@ -71,7 +72,11 @@ totalBytesTransferred=Long.valueOf(0); long start=System.currentTimeMillis(); try{ - client.executeMethod(get); + int result=client.executeMethod(get); + //check for 200 response + if(result<200 || result >299 ){ + throw new IOException("Can't read remote data, server returned "+HttpStatus.getStatusText(result)); + } InputStream is=get.getResponseBodyAsStream(); copy(is, os); }finally{ Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdmin.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdmin.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdmin.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -2,6 +2,7 @@ import java.security.cert.X509Certificate; +import org.apache.log4j.Level; import org.apache.log4j.LogManager; import org.apache.log4j.Logger; @@ -91,12 +92,15 @@ logger.info("JMX ACTION: set REQUIRE_SIGNATURES to "+!rs); } - public void reReadLoggingConfig(){ + public String setLogLevel(String log, String level){ + Level l=Level.toLevel(level); try{ - LogManager.resetConfiguration(); + LogManager.getLogger(log).setLevel(l); }catch(Exception e){ - logger.fatal("",e); + logger.error("",e); + return "Failed: "+e.getMessage(); } - logger.info("JMX ACTION: re-reading logging configuration"); + logger.info("JMX ACTION: level for logger <"+log+"> changed to <"+l.toString()+">"); + return "Level set to "+l.toString(); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdminMBean.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdminMBean.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/jmx/UASAdminMBean.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -32,7 +32,7 @@ public void toggleRequireSignatures(); - public void reReadLoggingConfig(); + public String setLogLevel(String logger, String level); } \ No newline at end of file Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOExport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOExport.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOExport.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -78,7 +78,7 @@ }catch(Exception e){ logger.fatal("Could not perform import.",e); - //so? + throw new FileTransferException(e); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOImport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOImport.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/RByteIOImport.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -83,7 +83,7 @@ }catch(Exception e){ logger.fatal("Could not perform import.",e); - //so? + throw new FileTransferException(e); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOExport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOExport.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOExport.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -74,7 +74,7 @@ } }catch(Exception e){ logger.fatal("Could not perform import.",e); - //so? + throw new FileTransferException(e); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOImport.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOImport.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/SByteIOImport.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -84,7 +84,7 @@ } }catch(Exception e){ logger.fatal("Could not perform import.",e); - //so? + throw new FileTransferException(e); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6DataMover.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -43,4 +43,10 @@ */ public long getDataSize(); + /** + * run the file transfer + * + * @throws FileTransferException + */ + public void run(); } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/U6FileTransfer.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -175,7 +175,7 @@ } catch(Exception e){ status=Status.FAILED; - statusMessage="Error during filetransfer."; + statusMessage="Error during filetransfer: "+e.getCause(); logger.fatal("Error during filetransfer. Set to FAILED",e); } } Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/xnjs/Unicore6FileTransferProcessor.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -103,7 +103,6 @@ for(IFileTransfer ft:ftInstances){ try{ ft.start(); - System.out.println("FT Status "+ft.getStatus()); action.addLogTrace("Started filetransfer "+ft.getSource()+" -> "+ft.getTarget()); }catch(Exception e){ logger.fatal("Error starting filetransfer: "+ft.getSource()+"->"+ft.getTarget()); @@ -176,6 +175,8 @@ } if(ft.getStatus()==IFileTransfer.Status.FAILED){ logger.debug("File transfer "+ft.getUniqueId()+" failed."); + action.addLogTrace("Filetransfer FAILED: "+ft.getSource()+" -> "+ft.getTarget()+ + ", error message: "+ft.getStatusMessage()); setToDoneAndFailed(); return; } Deleted: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestGetPeerCert.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestGetPeerCert.java 2008-03-17 18:17:26 UTC (rev 2511) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestGetPeerCert.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -1,33 +0,0 @@ -package de.fzj.unicore.security; - -import java.security.cert.X509Certificate; -import java.util.logging.Level; -import java.util.logging.Logger; - -import junit.framework.TestCase; -import de.fzj.unicore.uas.UAS; -import de.fzj.unicore.uas.security.SecurityManager; -import de.fzj.unicore.wsrflite.persistence.HsqldbPersist; - -public class TestGetPeerCert extends TestCase { - - protected void setUp()throws Exception{ - System.out.println("Starting UAS..."); - System.setProperty(HsqldbPersist.clearDBOnStartup,"true"); - UAS uas=new UAS("src/test/resources/secure/uas.config.simple"); - UAS.setProperty(HsqldbPersist.clearDBOnStartup,"true"); - uas.startSynchronous(); - Logger.getLogger("de").setLevel(Level.SEVERE); - Logger.getLogger("org").setLevel(Level.SEVERE); - Logger.getLogger("com").setLevel(Level.SEVERE); - } - - public void test1(){ - X509Certificate c=SecurityManager.getGatewayCert(); - assertNotNull(c); - String dn=c.getSubjectX500Principal().getName(); - assertTrue(dn.contains("NJS Test Certificate")); - } - - -} Added: unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityManager.java =================================================================== --- unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityManager.java (rev 0) +++ unicorex/uas-core/trunk/src/test/java/de/fzj/unicore/security/TestSecurityManager.java 2008-03-17 19:49:18 UTC (rev 2512) @@ -0,0 +1,58 @@ +package de.fzj.unicore.security; + +import java.io.IOException; +import java.security.cert.X509Certificate; +import java.util.HashMap; +import java.util.Map; + +import junit.framework.TestCase; +import de.fzj.unicore.uas.UAS; +import de.fzj.unicore.uas.security.AuthorisationException; +import de.fzj.unicore.uas.security.IAuthoriser; +import de.fzj.unicore.uas.security.IUASSecurityProperties; +import de.fzj.unicore.uas.security.SecurityManager; +import de.fzj.unicore.uas.security.SecurityTokens; +import de.fzj.unicore.wsrflite.persistence.HsqldbPersist; + +public class TestSecurityManager extends TestCase implements IAuthoriser { + + protected void initUAS()throws Exception{ + System.out.println("Starting UAS..."); + System.setProperty(HsqldbPersist.clearDBOnStartup,"true"); + UAS uas=new UAS("src/test/resources/secure/uas.config.simple"); + UAS.setProperty(HsqldbPersist.clearDBOnStartup,"true"); + uas.startSynchronous(); + } + + public void testGetPeerCert(){ + try{ + initUAS(); + X509Certificate c=SecurityManager.getGatewayCert(); + assertNotNull(c); + String dn=c.getSubjectX500Principal().getName(); + assertTrue(dn.contains("NJS Test Certificate")); + }catch(Exception e){ + e.printStackTrace(); + fail(); + } + } + + public void testAuthZChain()throws Exception{ + calls=0; + String auth=this.getClass().getName()+" "+this.getClass().getName(); + UAS.setProperty(IUASSecurityProperties.UAS_AUTHORISER, auth); + Map<String,String>res=SecurityManager.authorise(null); + assertNotNull(res); + assertEquals(calls,2); + } + + public static int calls=0; + + public Map<String, String> authorise(SecurityTokens tokens) throws IOException, AuthorisationException { + Map<String,String>res=new HashMap<String,String>(); + res.put("foo", "bar1"); + res.put("x1", "y1"); + calls++; + return res; + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <bsc...@us...> - 2008-04-04 08:28:30
|
Revision: 2654 http://unicore.svn.sourceforge.net/unicore/?rev=2654&view=rev Author: bschuller Date: 2008-04-04 01:28:27 -0700 (Fri, 04 Apr 2008) Log Message: ----------- different sync on registry client Modified Paths: -------------- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/LocalRegistryClient.java unicorex/uas-core/trunk/src/test/resources/wsrflite.xml Modified: unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/LocalRegistryClient.java =================================================================== --- unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/LocalRegistryClient.java 2008-04-04 08:02:11 UTC (rev 2653) +++ unicorex/uas-core/trunk/src/main/java/de/fzj/unicore/uas/client/LocalRegistryClient.java 2008-04-04 08:28:27 UTC (rev 2654) @@ -82,6 +82,7 @@ private Registry reg; private EndpointReferenceType epr; private String url; + private Object lock=new Object(); public LocalRegistryClient(String resID)throws Exception { epr=EndpointReferenceType.Factory.newInstance(); @@ -103,8 +104,12 @@ * @return * @throws Exception */ - public synchronized AddResponseDocument addRegistryEntry(AddDocument in) throws Exception{ - if(reg==null)reg=(Registry)makeProxy(); + public AddResponseDocument addRegistryEntry(AddDocument in) throws Exception{ + synchronized(lock){ + if(reg==null){ + reg=(Registry)makeProxy(); + } + } return reg.Add(in); } Modified: unicorex/uas-core/trunk/src/test/resources/wsrflite.xml =================================================================== --- unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2008-04-04 08:02:11 UTC (rev 2653) +++ unicorex/uas-core/trunk/src/test/resources/wsrflite.xml 2008-04-04 08:28:27 UTC (rev 2654) @@ -40,7 +40,6 @@ <!-- SSL --> <property name="unicore.wsrflite.ssl" value="false"/> - <property name="unicore.wsrflite.ssl.clientauth" value="true"/> <property name="unicore.wsrflite.ssl.keystore" value="certs/server-keystore.p12"/> @@ -50,10 +49,10 @@ <property name="unicore.wsrflite.ssl.truststore" value="certs/server-truststore.jks"/> <property name="unicore.wsrflite.ssl.truststorepass" value="the!njs"/> <property name="unicore.wsrflite.ssl.truststoretype" value="JKS"/> - - <!-- WS-Security --> - - <property name="unicore.wsrflite.wss" value="false"/> + + <!-- Jetty server settings --> + <property name="unicore.wsrflite.jetty.gzip.enable" value="true"/> + <property name="unicore.wsrflite.jetty.gzip.minGzipSize" value="0"/> <!-- the atomic services --> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |