Added shibboleth support (untested)
authorChristos Stathis <chstath@ebs.gr>
Thu, 11 Aug 2011 16:41:44 +0000 (19:41 +0300)
committerChristos Stathis <chstath@ebs.gr>
Thu, 11 Aug 2011 16:41:44 +0000 (19:41 +0300)
src/gr/grnet/pithos/resources/database.png [deleted file]
src/gr/grnet/pithos/resources/greenled.png [deleted file]
src/gr/grnet/pithos/resources/redled.png [deleted file]
src/gr/grnet/pithos/resources/windowlist.png [deleted file]
src/gr/grnet/pithos/resources/xclock.png [deleted file]
src/gr/grnet/pithos/resources/yellowled.png [deleted file]
src/gr/grnet/pithos/web/client/Configuration.java
src/gr/grnet/pithos/web/client/Configuration.properties
src/gr/grnet/pithos/web/client/FileList.java
src/gr/grnet/pithos/web/client/Pithos.java
src/gr/grnet/pithos/web/client/StatusPanel.java

diff --git a/src/gr/grnet/pithos/resources/database.png b/src/gr/grnet/pithos/resources/database.png
deleted file mode 100644 (file)
index ee17b38..0000000
Binary files a/src/gr/grnet/pithos/resources/database.png and /dev/null differ
diff --git a/src/gr/grnet/pithos/resources/greenled.png b/src/gr/grnet/pithos/resources/greenled.png
deleted file mode 100644 (file)
index ac8972e..0000000
Binary files a/src/gr/grnet/pithos/resources/greenled.png and /dev/null differ
diff --git a/src/gr/grnet/pithos/resources/redled.png b/src/gr/grnet/pithos/resources/redled.png
deleted file mode 100644 (file)
index afa4772..0000000
Binary files a/src/gr/grnet/pithos/resources/redled.png and /dev/null differ
diff --git a/src/gr/grnet/pithos/resources/windowlist.png b/src/gr/grnet/pithos/resources/windowlist.png
deleted file mode 100644 (file)
index 9f0104a..0000000
Binary files a/src/gr/grnet/pithos/resources/windowlist.png and /dev/null differ
diff --git a/src/gr/grnet/pithos/resources/xclock.png b/src/gr/grnet/pithos/resources/xclock.png
deleted file mode 100755 (executable)
index 31e66e4..0000000
Binary files a/src/gr/grnet/pithos/resources/xclock.png and /dev/null differ
diff --git a/src/gr/grnet/pithos/resources/yellowled.png b/src/gr/grnet/pithos/resources/yellowled.png
deleted file mode 100644 (file)
index b09507d..0000000
Binary files a/src/gr/grnet/pithos/resources/yellowled.png and /dev/null differ
index d193e12..c4bf89a 100644 (file)
@@ -44,27 +44,15 @@ import com.google.gwt.i18n.client.Constants;
  */
 public interface Configuration extends Constants {
        /**
-        * @return the name of the service
-        */
-       @DefaultStringValue("pithos")
-       String serviceName();
-
-       /**
         * @return the login URL
         */
-       @DefaultStringValue("pithos/login")
+       @DefaultStringValue("/login")
        String loginUrl();
 
        /**
-        * @return the logout URL
-        */
-       @DefaultStringValue("/pithos/login")
-       String logoutUrl();
-
-       /**
         * @return the authentication cookie name
         */
-       @DefaultStringValue("_gss_a")
+       @DefaultStringValue("_pithos2_a")
        String authCookie();
 
        /**
@@ -85,5 +73,4 @@ public interface Configuration extends Constants {
         */
        @DefaultStringValue("")
        String version();
-
 }
index b869e3d..b743b18 100644 (file)
 # or implied, of GRNET S.A.
 #
 
-serviceName=Pithos
-loginUrl=pithos/login
-logoutUrl=/Shibboleth.sso/Logout
-authCookie=_pithos_a
+loginUrl=/login
+authCookie=_pithos2_a
 cookieSeparator=|
 apiPath=/v1/
 version=2.0
\ No newline at end of file
index e9db15b..55ba207 100644 (file)
@@ -421,17 +421,6 @@ public class FileList extends Composite {
 
                selectionModel = new MultiSelectionModel<File>(keyProvider);
 
-                Handler selectionHandler = new SelectionChangeEvent.Handler() {
-             @Override 
-             public void onSelectionChange(SelectionChangeEvent event) {
-                if(getSelectedFiles().size() == 1)
-                        app.setCurrentSelection(getSelectedFiles().get(0));
-                else
-                        app.setCurrentSelection(getSelectedFiles());
-             }
-         };
-         selectionModel.addSelectionChangeHandler(selectionHandler);
-         
                celltable.setSelectionModel(selectionModel, GSSSelectionEventManager.<File> createDefaultManager());
                celltable.setPageSize(Pithos.VISIBLE_FILE_COUNT);
                
@@ -507,8 +496,6 @@ public class FileList extends Composite {
 //                     showingStats = "" + (startIndex + 1) + " - " + max + " of " + count + " files" + " (" + FileResource.getFileSizeAsString(folderTotalSize) + ")";
                }
                showCellTable();
-               updateCurrentlyShowingStats();
-
        }
 
        /**
@@ -551,13 +538,6 @@ public class FileList extends Composite {
        }
 
        /**
-        * Update status panel with currently showing file stats.
-        */
-       public void updateCurrentlyShowingStats() {
-               app.getStatusPanel().updateCurrentlyShowing(showingStats);
-       }
-       
-       /**
         * Fill the file cache with data.
         */
        public void setFiles(final List<File> _files) {
index 7732612..153664f 100644 (file)
@@ -149,7 +149,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
         * An aggregate image bundle that pulls together all the images for this
         * application into a single bundle.
         */
-       public interface Images extends ClientBundle, TopPanel.Images, StatusPanel.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images {
+       public interface Images extends ClientBundle, TopPanel.Images, FilePropertiesDialog.Images, MessagePanel.Images, FileList.Images {
 
                @Source("gr/grnet/pithos/resources/document.png")
                ImageResource folders();
@@ -266,7 +266,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
                 int tabIndex = event.getSelectedItem();
                 switch (tabIndex) {
                     case 0:
-                        fileList.updateCurrentlyShowingStats();
                         break;
                 }
             }
@@ -321,7 +320,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
         outer.add(topPanel);
         outer.add(messagePanel);
         outer.add(splitPanel);
-        statusPanel = new StatusPanel(this, Pithos.images);
+        statusPanel = new StatusPanel();
         outer.add(statusPanel);
         outer.setWidth("100%");
         outer.setCellHorizontalAlignment(messagePanel, HasHorizontalAlignment.ALIGN_CENTER);
@@ -402,36 +401,41 @@ public class Pithos implements EntryPoint, ResizeHandler {
         * Parse and store the user credentials to the appropriate fields.
         */
        private boolean parseUserCredentials() {
-               Configuration conf = (Configuration) GWT.create(Configuration.class);
-               String cookie = conf.authCookie();
-               String auth = Cookies.getCookie(cookie);
-               if (auth == null) {
-                       authenticateUser();
-            return false;
-        }
-        else {
-            String[] authSplit = auth.split("\\" + conf.cookieSeparator(), 2);
-            if (authSplit.length != 2) {
+        username = Window.Location.getParameter("user");
+        token = Window.Location.getParameter("token");
+        Configuration conf = (Configuration) GWT.create(Configuration.class);
+        if (username == null || username.length() == 0 || token == null || token.length() == 0) {
+            String cookie = conf.authCookie();
+            String auth = Cookies.getCookie(cookie);
+            if (auth == null) {
                 authenticateUser();
                 return false;
             }
             else {
-                username = authSplit[0];
-                token = authSplit[1];
-                return true;
+                String[] authSplit = auth.split("\\" + conf.cookieSeparator(), 2);
+                if (authSplit.length != 2) {
+                    authenticateUser();
+                    return false;
+                }
+                else {
+                    username = authSplit[0];
+                    token = authSplit[1];
+                    return true;
+                }
             }
         }
-       }
+        else {
+            Cookies.setCookie(conf.authCookie(), username + conf.cookieSeparator() + token);
+            return true;
+        }
+    }
 
     /**
         * Redirect the user to the login page for authentication.
         */
        protected void authenticateUser() {
                Configuration conf = (Configuration) GWT.create(Configuration.class);
-
-//        Window.Location.assign(GWT.getModuleBaseURL() + conf.loginUrl() + "?next=" + Window.Location.getHref());
-        Cookies.setCookie(conf.authCookie(), "test" + conf.cookieSeparator() + "0000");
-        Window.Location.assign(GWT.getModuleBaseURL() + "pithos.html");
+        Window.Location.assign(Window.Location.getHost() + conf.loginUrl() + "?next=" + Window.Location.getHref());
        }
 
     private void fetchAccount() {
@@ -441,7 +445,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
             @Override
             public void onSuccess(AccountResource result) {
                 account = result;
-                statusPanel.displayStats(account);
                 inner.selectTab(0);
                 if (account.getContainers().isEmpty())
                     createHomeContainers();
@@ -484,20 +487,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
     }
 
        /**
-        * Clear the cookie and redirect the user to the logout page.
-        */
-       void logout() {
-               Configuration conf = (Configuration) GWT.create(Configuration.class);
-               String cookie = conf.authCookie();
-               String domain = Window.Location.getHostName();
-               String path = Window.Location.getPath();
-               Cookies.setCookie(cookie, "", null, domain, path, false);
-        String baseUrl = GWT.getModuleBaseURL();
-        String homeUrl = baseUrl.substring(0, baseUrl.indexOf(path));
-               Window.Location.assign(homeUrl + conf.logoutUrl());
-       }
-
-       /**
         * Creates an HTML fragment that places an image & caption together, for use
         * in a group header.
         *
@@ -515,7 +504,7 @@ public class Pithos implements EntryPoint, ResizeHandler {
 
        private void onWindowResized(int height) {
                // Adjust the split panel to take up the available room in the window.
-               int newHeight = height - splitPanel.getAbsoluteTop() - 44;
+               int newHeight = height - splitPanel.getAbsoluteTop() - 60;
                if (newHeight < 1)
                        newHeight = 1;
                splitPanel.setHeight("" + newHeight);
@@ -528,31 +517,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
                onWindowResized(height);
        }
 
-       public boolean isFileListShowing() {
-               int tab = inner.getTabBar().getSelectedTab();
-               if (tab == 0)
-                       return true;
-               return false;
-       }
-
-       public boolean isSearchResultsShowing() {
-               int tab = inner.getTabBar().getSelectedTab();
-               if (tab == 2)
-                       return true;
-               return false;
-       }
-
-       /**
-        * A native JavaScript method to reach out to the browser's window and
-        * invoke its resizeTo() method.
-        *
-        * @param x the new width
-        * @param y the new height
-        */
-       public static native void resizeTo(int x, int y) /*-{
-               $wnd.resizeTo(x,y);
-       }-*/;
-
        /**
         * Display an error message.
         *
@@ -581,33 +545,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * Retrieve the folders.
-        *
-        * @return the folders
-        
-       public Folders getFolders() {
-               return folders;
-       }*/
-
-       /**
-        * Retrieve the currentSelection.
-        *
-        * @return the currentSelection
-        */
-       public Object getCurrentSelection() {
-               return currentSelection;
-       }
-
-       /**
-        * Modify the currentSelection.
-        *
-        * @param newCurrentSelection the currentSelection to set
-        */
-       public void setCurrentSelection(Object newCurrentSelection) {
-               currentSelection = newCurrentSelection;
-       }
-
-       /**
         * Retrieve the fileList.
         *
         * @return the fileList
@@ -664,25 +601,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
        }
 
        /**
-        * Convert server date to local time according to browser timezone
-        * and format it according to localized pattern.
-        * Time is always formatted to 24hr format.
-        * NB: This assumes that server runs in UTC timezone. Otherwise
-        * we would need to adjust for server time offset as well.
-        *
-        * @param date
-        * @return String
-        */
-       public static String formatLocalDateTime(Date date) {
-               Date convertedDate = new Date(date.getTime() - date.getTimezoneOffset());
-               final DateTimeFormat dateFormatter = DateTimeFormat.getShortDateFormat();
-               final DateTimeFormat timeFormatter = DateTimeFormat.getFormat("HH:mm");
-               String datePart = dateFormatter.format(convertedDate);
-               String timePart = timeFormatter.format(convertedDate);
-               return datePart + " " + timePart;
-       }
-       
-       /**
         * History support for folder navigation
         * adds a new browser history entry
         *
@@ -696,39 +614,6 @@ public class Pithos implements EntryPoint, ResizeHandler {
                History.newItem(key);
        }
 
-       /**
-        * This method examines the token input and add a "/" at the end in case it's omitted.
-        * This happens only in Files/trash/, Files/shared/, Files/others.
-        *
-        * @param tokenInput
-        * @return the formated token with a "/" at the end or the same tokenInput parameter
-        */
-
-       private String handleSpecialFolderNames(String tokenInput){
-               List<String> pathsToCheck = Arrays.asList("Files/trash", "Files/shared", "Files/others");
-               if(pathsToCheck.contains(tokenInput))
-                       return tokenInput + "/";
-               return tokenInput;
-
-       }
-
-       /**
-        * Reject illegal resource names, like '.' or '..' or slashes '/'.
-        */
-       static boolean isValidResourceName(String name) {
-               if (".".equals(name) || "..".equals(name) || name.contains("/"))
-                       return false;
-               return true;
-       }
-
-       public void putUserToMap(String _userName, String _userFullName){
-               userFullNameMap.put(_userName, _userFullName);
-       }
-
-       public String findUserFullName(String _userName){
-               return userFullNameMap.get(_userName);
-       }
-
     public void deleteFolder(final Folder folder) {
         String path = getApiPath() + getUsername() + "/" + folder.getContainer() + "?format=json&delimiter=/&prefix=" + folder.getPrefix();
         RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, path);
index 99a420c..4a06cbb 100644 (file)
  */
 package gr.grnet.pithos.web.client;
 
-import com.google.gwt.core.client.Scheduler;
-import gr.grnet.pithos.web.client.foldertree.AccountResource;
-import gr.grnet.pithos.web.client.rest.GetRequest;
-import gr.grnet.pithos.web.client.rest.RestException;
-
-import com.google.gwt.core.client.GWT;
-import com.google.gwt.i18n.client.DateTimeFormat;
 import com.google.gwt.resources.client.ClientBundle;
 import com.google.gwt.resources.client.ImageResource;
 import com.google.gwt.user.client.ui.AbstractImagePrototype;
@@ -48,158 +41,37 @@ import com.google.gwt.user.client.ui.Composite;
 import com.google.gwt.user.client.ui.HTML;
 import com.google.gwt.user.client.ui.HasHorizontalAlignment;
 import com.google.gwt.user.client.ui.HorizontalPanel;
-import java.util.Date;
+import com.google.gwt.user.client.ui.VerticalPanel;
 
 /**
  * The panel that displays a status bar with quota information.
  */
 public class StatusPanel extends Composite {
-       public static final boolean DONE = false;
-       private HTML fileCountLabel = new HTML("");
-       private HTML fileSizeLabel = new HTML("");
-       private HTML quotaIcon = new HTML("");
-       private HTML quotaLabel = new HTML("");
-       private HTML lastLoginLabel = new HTML("");
-       private HTML currentLoginLabel = new HTML("");
-       private HTML currentlyShowingLabel = new HTML("");
 
        /**
-        * An image bundle for this widget's images.
-        */
-       public interface Images extends ClientBundle {
-
-               @Source("gr/grnet/pithos/resources/windowlist.png")
-               ImageResource totalFiles();
-
-               @Source("gr/grnet/pithos/resources/database.png")
-               ImageResource totalSize();
-
-               @Source("gr/grnet/pithos/resources/redled.png")
-               ImageResource redSize();
-
-               @Source("gr/grnet/pithos/resources/greenled.png")
-               ImageResource greenSize();
-
-               @Source("gr/grnet/pithos/resources/yellowled.png")
-               ImageResource yellowSize();
-
-               @Source("gr/grnet/pithos/resources/xclock.png")
-               ImageResource lastLogin();              
-       }
-
-       private final Images images;
-
-    private Pithos app;
-    
-       /**
         * The constructor of the status panel.
-        *
-        * @param theImages the supplied images
         */
-       public StatusPanel(Pithos _app, Images theImages) {
-        app = _app;
-               images = theImages;
+       public StatusPanel() {
                HorizontalPanel outer = new HorizontalPanel();
                outer.setWidth("100%");
-               outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
-
-               HorizontalPanel left = new HorizontalPanel();
-               left.setSpacing(8);
-               HorizontalPanel middle = new HorizontalPanel();
-               middle.setSpacing(8);
-               HorizontalPanel right = new HorizontalPanel();
-               right.setSpacing(8);
-               outer.add(left);
-               outer.add(middle);
-               outer.add(right);
-               left.add(new HTML("<b>Totals:</b> "));
-               left.add(AbstractImagePrototype.create(images.totalFiles()).createImage());
-               left.add(fileCountLabel);
-               left.add(AbstractImagePrototype.create(images.totalSize()).createImage());
-               left.add(fileSizeLabel);
-               quotaIcon.setHTML(AbstractImagePrototype.create(images.greenSize()).getHTML());
-               left.add(quotaIcon);
-               left.add(quotaLabel);
-               middle.add(AbstractImagePrototype.create(images.lastLogin()).createImage());
-               middle.add(new HTML("<b>Last login:</b> "));
-               middle.add(lastLoginLabel);
-               middle.add(new HTML("<b>\u0387 Current session login:</b> "));
-               middle.add(currentLoginLabel);
-               right.add(currentlyShowingLabel);
-               outer.setStyleName("statusbar-inner");
-               left.setStyleName("statusbar-inner");
-               middle.setStyleName("statusbar-inner");
-               right.setStyleName("statusbar-inner");
-               outer.setCellHorizontalAlignment(right, HasHorizontalAlignment.ALIGN_RIGHT);
-
+               outer.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+
+        VerticalPanel inner = new VerticalPanel();
+        inner.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
+               HorizontalPanel firstLine = new HorizontalPanel();
+               firstLine.setSpacing(8);
+        firstLine.add(new HTML("<a href='javascript:void(0)'>About</a> |"));
+        firstLine.add(new HTML("<a href='javascript:void(0)'>Help</a> |"));
+        firstLine.add(new HTML("<a href='javascript:void(0)'>Contact</a> |"));
+        firstLine.add(new HTML("<a href='javascript:void(0)'>Terms</a> |"));
+        firstLine.add(new HTML("<a href='javascript:void(0)'>Privacy</a>"));
+               inner.add(firstLine);
+
+        HorizontalPanel secondLine = new HorizontalPanel();
+        secondLine.add(new HTML("Copyright (C) 2011 Greek Research and Technology Network"));
+        inner.add(secondLine);
+        
+        outer.add(inner);
                initWidget(outer);
        }
-
-       /**
-        * Refresh the widget with the provided statistics.
-        */
-       public void displayStats(AccountResource account) {
-               if (account.getNumberOfObjects() == 1)
-                       fileCountLabel.setHTML("1 object");
-               else
-                       fileCountLabel.setHTML(account.getNumberOfObjects() + " objects");
-               fileSizeLabel.setHTML(account.getFileSizeAsString() + " used");
-               long pc = (long) ((double) account.getBytesRemaining()/(account.getBytesRemaining() + account.getBytesUsed()) + 0.5);
-               if (pc < 10) {
-                       quotaIcon.setHTML(AbstractImagePrototype.create(images.redSize()).getHTML());
-                       quotaLabel.setHTML(account.getQuotaLeftAsString() + " free");
-               } else if(pc<20) {
-                       quotaIcon.setHTML(AbstractImagePrototype.create(images.yellowSize()).getHTML());
-                       quotaLabel.setHTML(account.getQuotaLeftAsString() +" free");
-               } else {
-                       quotaIcon.setHTML(AbstractImagePrototype.create(images.greenSize()).getHTML());
-                       quotaLabel.setHTML(account.getQuotaLeftAsString() +" free");
-               }
-               final DateTimeFormat formatter = DateTimeFormat.getFormat("d/M/yyyy h:mm a");
-        Date login = account.getLastLogin();
-               lastLoginLabel.setHTML(login == null ? "" : formatter.format(login));
-
-        login = account.getCurrentLogin();
-               currentLoginLabel.setHTML(login == null ? "" : formatter.format(login));
-       }
-
-       /**
-        * Requests updated quota information from the server and refreshes
-        * the display.
-        */
-    //TODO: This should not be done here
-       public void updateStats() {
-        GetRequest<AccountResource> getAccount = new GetRequest<AccountResource>(AccountResource.class, app.getApiPath(), app.getUsername(), "") {
-            @Override
-            public void onSuccess(AccountResource result) {
-                displayStats(result);
-            }
-
-            @Override
-            public void onError(Throwable t) {
-                if(t instanceof RestException)
-                    app.displayError("Unable to fetch quota:" +
-                                ((RestException)t).getHttpStatusText());
-                else
-                    app.displayError("System error fetching quota:" +
-                                t.getMessage());
-                GWT.log("ERR", t);
-            }
-        };
-        getAccount.setHeader("X-Auth-Token", app.getToken());
-        Scheduler.get().scheduleDeferred(getAccount);
-       }
-
-       /**
-        * Displays the statistics for the current folder.
-        *
-        * @param text the statistics to display
-        */
-       public void updateCurrentlyShowing(String text) {
-               if (text == null)
-                       currentlyShowingLabel.setText("");
-               else
-                       currentlyShowingLabel.setHTML(" <b>Showing:</b> " + text);
-       }
-
 }