Search in sources :

Example 1 with BridgedWorkingDirectory

use of net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory in project processdash by dtuma.

the class PermissionsManager method init.

public void init(DashboardContext ctx) throws IOException, TamperException {
    PERMISSION.checkPermission();
    // load the definitions for known permission types
    this.specs = Collections.unmodifiableMap(loadPermissionSpecs());
    // get the directory where permission-based files are stored
    workingDir = ctx.getWorkingDirectory();
    File storageDir = workingDir.getDirectory();
    // if we are using a bridged working directory, store the URL
    if (workingDir instanceof BridgedWorkingDirectory)
        bridgedUrl = workingDir.getDescription();
    // identify the current user
    identifyCurrentUser();
    // load the roles for this dashboard, and the permissions they map to
    this.rolesFile = new File(storageDir, "roles.dat");
    readRoles();
    // load the users for this dashboard, and the roles they map to
    this.usersFile = new File(storageDir, "users.dat");
    readUsers();
    updateExternalUsers();
    // evaluate the permissions associated with the current user
    assignCurrentUserPermissions();
}
Also used : BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) File(java.io.File)

Example 2 with BridgedWorkingDirectory

use of net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory in project processdash by dtuma.

the class DisplayConfig method loadConfigurationInformation.

private void loadConfigurationInformation() {
    dataDirectory = null;
    dataURL = null;
    configFile = new File(DashController.getSettingsFileName());
    WorkingDirectory workingDir = ((ProcessDashboard) getDashboardContext()).getWorkingDirectory();
    if (workingDir instanceof BridgedWorkingDirectory) {
        BridgedWorkingDirectory bwd = (BridgedWorkingDirectory) workingDir;
        dataURL = bwd.getDescription();
        dataDirectory = bwd.getTargetDirectory();
        if (dataDirectory == null)
            configFile = null;
        else
            configFile = new File(dataDirectory, configFile.getName());
    } else if (workingDir instanceof LocalWorkingDirectory) {
        LocalWorkingDirectory lwd = (LocalWorkingDirectory) workingDir;
        dataDirectory = lwd.getTargetDirectory();
    }
    DashPackage dash = TemplateLoader.getPackage(DASHBOARD_PACKAGE_ID);
    if (dash != null && StringUtils.hasValue(dash.filename)) {
        File dashJar = new File(dash.filename);
        installationDirectory = dashJar.getParentFile();
    }
    appTemplateDirectory = TemplateLoader.getApplicationTemplateDir();
    jvmInfo = System.getProperty("java.vendor") + " JRE " + System.getProperty("java.version") + "; " + System.getProperty("os.name");
}
Also used : BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) WorkingDirectory(net.sourceforge.processdash.tool.bridge.client.WorkingDirectory) LocalWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.LocalWorkingDirectory) LocalWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.LocalWorkingDirectory) ProcessDashboard(net.sourceforge.processdash.ProcessDashboard) BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) File(java.io.File) DashPackage(net.sourceforge.processdash.templates.DashPackage)

Example 3 with BridgedWorkingDirectory

use of net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory in project processdash by dtuma.

the class WBSPermissionManager method init.

/**
     * Identify the current user and determine their permissions.
     */
public static void init(WorkingDirectory workingDirectory, TeamProject proj) throws HttpException.Unauthorized {
    // determine the identity of the current user.
    String pdesUrl;
    if (workingDirectory instanceof BridgedWorkingDirectory)
        pdesUrl = workingDirectory.getDescription();
    else
        pdesUrl = ExternalLocationMapper.getInstance().getDatasetUrl();
    WhoAmI whoAmI = new WhoAmI(pdesUrl);
    currentUser = whoAmI.getUsername();
    // look at the team settings.xml file. if it was written by an old
    // version of the dashboard, it will not contain a version. In that
    // case, exit without any further analysis.
    Element settings = proj.getProjectSettings();
    if (settings == null)
        return;
    version = settings.getAttribute("version");
    if (!XMLUtils.hasValue(version))
        return;
    // the settings.xml file was written by a version of the dashboard that
    // knows how to publish permissions. Check to ensure that it has not
    // been tampered with. If it has, grant no permissions.
    File settingsFile = new File(proj.getStorageDirectory(), WBSFilenameConstants.SETTINGS_FILENAME);
    try {
        TamperDeterrent.getInstance().verifyThumbprint(settingsFile, FileType.WBS);
    } catch (Exception te) {
        System.err.println("The file " + settingsFile + " is corrupt; " + "locking down WBS permissions");
        version = "999.999";
        return;
    }
    // find the permissions granted in the settings.xml file
    Set<WBSPermission> perms = getPermissionsForUser(settings, currentUser.toLowerCase());
    perms.remove(null);
    // add the externally granted permissions of the current user
    for (String onePerm : whoAmI.getExternalPermissionGrants()) {
        if ("pdash.all".equals(onePerm))
            onePerm = ALL_PERMISSIONS;
        perms.add(new WBSPermission(onePerm));
    }
    // store these permissions for future use
    permissions = Collections.unmodifiableSet(perms);
    debugLogPermissions();
}
Also used : Element(org.w3c.dom.Element) BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) WhoAmI(net.sourceforge.processdash.tool.perm.WhoAmI) File(java.io.File) HttpException(net.sourceforge.processdash.util.HttpException)

Example 4 with BridgedWorkingDirectory

use of net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory in project processdash by dtuma.

the class ProcessDashboard method getOwnerName.

/**
     * Get the name of the person running this dashboard.  This is <b>not</b>
     * necessarily the same as the owner of the metrics data!  For example,
     * a team leader might be opening an individual's data, or anyone might
     * be opening a shared team dashboard instance.
     */
private String getOwnerName() {
    // check the preferences node for this class first.
    Preferences prefs = Preferences.userNodeForPackage(ProcessDashboard.class);
    String result = prefs.get("ownerName", null);
    if (result != null)
        return result;
    // If our preferences node didn't contain the data, try looking in
    // the preferences node for the WBS editor.  Many people will already
    // have a value stored there, so we will be able to avoid pestering
    // them for their name again.
    Preferences teamPrefs = Preferences.userRoot().node("/teamdash/wbs");
    result = teamPrefs.get("ownerName", null);
    if (result != null) {
        prefs.put("ownerName", result);
        return result;
    }
    // they are opening a dashboard instance served by a remote server.
    if (workingDirectory instanceof BridgedWorkingDirectory) {
        ResourceBundle res = ResourceBundle.getBundle("Templates.resources.ProcessDashboard");
        String title = res.getString("Enter_Name_Dialog.Title");
        String message = res.getString("Enter_Name_Dialog.Prompt");
        result = JOptionPane.showInputDialog(hideSS(), message, title, JOptionPane.PLAIN_MESSAGE);
        if (result != null) {
            prefs.put("ownerName", result);
            return result;
        }
    }
    // username and go with that.
    return System.getProperty("user.name");
}
Also used : BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) ResourceBundle(java.util.ResourceBundle) Preferences(java.util.prefs.Preferences) DirectoryPreferences(net.sourceforge.processdash.tool.bridge.client.DirectoryPreferences)

Example 5 with BridgedWorkingDirectory

use of net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory in project processdash by dtuma.

the class ProcessDashboard method configureWorkingDirectory.

private void configureWorkingDirectory(String location) {
    workingDirectory = WorkingDirectoryFactory.getInstance().get(location, WorkingDirectoryFactory.PURPOSE_DASHBOARD);
    if (JnlpRelauncher.maybeRelaunch(workingDirectory))
        System.exit(0);
    String locationDescr = workingDirectory.getDescription();
    try {
        lockMessageHandler = new LockMsgHandler();
        workingDirectory.acquireProcessLock(ACTIVATE_MESSAGE, lockMessageHandler);
    } catch (SentLockMessageException e) {
        System.exit(0);
    } catch (LockFailureException e) {
        displaySharingError(locationDescr);
        System.exit(1);
    }
    try {
        workingDirectory.prepare();
    } catch (HttpException.Unauthorized e) {
        displayStartupPermissionError("Unauthorized");
        System.exit(1);
    } catch (HttpException.Forbidden e) {
        displayStartupPermissionError("Forbidden");
        System.exit(1);
    } catch (IOException e) {
        String resKey;
        if (workingDirectory instanceof BridgedWorkingDirectory) {
            resKey = "Errors.Read_File_Error.Data_Server";
        } else {
            resKey = "Errors.Read_File_Error.Data_Directory";
        }
        displayStartupIOError(resKey, locationDescr, e);
        System.exit(1);
    }
    // Check to see if a legacy shortcut is being used to launch a dataset
    // that is now hosted on a team server.  If so, possibly configure the
    // team server URL as the "default team server."
    TeamServerSelector.maybeSetDefaultTeamServerUrl(workingDirectory);
    File cwd = workingDirectory.getDirectory();
    System.setProperty("user.dir", cwd.getAbsolutePath());
}
Also used : SentLockMessageException(net.sourceforge.processdash.util.lock.SentLockMessageException) BridgedWorkingDirectory(net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory) HttpException(net.sourceforge.processdash.util.HttpException) IOException(java.io.IOException) File(java.io.File) TeamSettingsFile(net.sourceforge.processdash.team.setup.TeamSettingsFile) LockFailureException(net.sourceforge.processdash.util.lock.LockFailureException) ReadOnlyLockFailureException(net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException)

Aggregations

BridgedWorkingDirectory (net.sourceforge.processdash.tool.bridge.client.BridgedWorkingDirectory)5 File (java.io.File)4 HttpException (net.sourceforge.processdash.util.HttpException)2 IOException (java.io.IOException)1 ResourceBundle (java.util.ResourceBundle)1 Preferences (java.util.prefs.Preferences)1 ProcessDashboard (net.sourceforge.processdash.ProcessDashboard)1 TeamSettingsFile (net.sourceforge.processdash.team.setup.TeamSettingsFile)1 DashPackage (net.sourceforge.processdash.templates.DashPackage)1 DirectoryPreferences (net.sourceforge.processdash.tool.bridge.client.DirectoryPreferences)1 LocalWorkingDirectory (net.sourceforge.processdash.tool.bridge.client.LocalWorkingDirectory)1 WorkingDirectory (net.sourceforge.processdash.tool.bridge.client.WorkingDirectory)1 WhoAmI (net.sourceforge.processdash.tool.perm.WhoAmI)1 LockFailureException (net.sourceforge.processdash.util.lock.LockFailureException)1 ReadOnlyLockFailureException (net.sourceforge.processdash.util.lock.ReadOnlyLockFailureException)1 SentLockMessageException (net.sourceforge.processdash.util.lock.SentLockMessageException)1 Element (org.w3c.dom.Element)1