Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/19/09 14:15:12 (15 years ago)
Author:
mbecirov
Message:

#586: Fixed copy location of permission resource files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Server.Core/3.2/Authorization/HivePermissions.cs

    r2065 r2070  
    66using HeuristicLab.Security.Contracts.BusinessObjects;
    77using System.Diagnostics;
     8using System.Xml;
     9using System.IO;
     10using System.Reflection;
    811
    912namespace HeuristicLab.Hive.Server.Core  {
    1013 
    1114  public static class HivePermissions {
    12     private const string PERMISSIONFILE = "Authorization//HivePermissionSet.xml";
    13     private const string POLICIESFILE = "Authorization//HivePermissionPolicy.xml";
     15    private const string PERMISSIONFILE = @"plugins\HivePermissionSet.xml";
     16    private const string POLICIESFILE = @"plugins\HivePermissionPolicy.xml";
    1417
    1518    public static class Jobmanagement {
     
    144147      Permission p = null;
    145148      XPathDocument doc;
     149      string assemblyName = Assembly.GetAssembly(typeof(HivePermissions)).GetName().Name;
    146150      doc = new XPathDocument(filename);
    147151      XPathNavigator nav = doc.CreateNavigator();
     
    164168      } while (nav.MoveToFollowing(XPathNodeType.Element));
    165169    }
    166 
     170    /*
     171    public static XmlDocument GetEmbeddedXml(Type type, string fileName) {
     172      Stream str = GetEmbeddedFile(type, fileName);
     173      XmlTextReader tr = new XmlTextReader(str);
     174      XmlDocument xml = new XmlDocument();
     175      xml.Load(tr);
     176      return xml;
     177    }
     178    */
     179
     180    /// <summary>
     181    /// Extracts an embedded file out of a given assembly.
     182    /// </summary>
     183    /// <param name="assemblyName">The namespace of you assembly.</param>
     184    /// <param name="fileName">The name of the file to extract.</param>
     185    /// <returns>A stream containing the file data.</returns>
     186    public static Stream GetEmbeddedFile(string assemblyName, string fileName) {
     187      try {
     188        Assembly a = Assembly.Load(assemblyName);
     189        Stream str = a.GetManifestResourceStream(assemblyName + "." + fileName);
     190
     191        if (str == null)
     192          throw new Exception("Could not locate embedded resource '" + fileName + "' in assembly '" + assemblyName + "'");
     193        return str;
     194      }
     195      catch (Exception e) {
     196        throw new Exception(assemblyName + ": " + e.Message);
     197      }
     198    }
     199
     200   
    167201    /// <summary>
    168202    /// Policy
     
    172206    private static void LoadFromXml(IList<Policy> policyList, string filename) {
    173207      PermissionCollection permissionCollection = GetPermissions();
     208      string assemblyName = Assembly.GetAssembly(typeof(HivePermissions)).GetName().Name;
    174209      XPathDocument doc = new XPathDocument(filename);
    175210      XPathNavigator nav = doc.CreateNavigator();
Note: See TracChangeset for help on using the changeset viewer.