Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Design and Architecture
  4. How to design the accessibility problem

How to design the accessibility problem

Scheduled Pinned Locked Moved Design and Architecture
helpquestionc++designtutorial
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    SSETH
    wrote on last edited by
    #1

    Hello All, Could any one suggest how can I design the following the problem in C++? How to provide access to a component of a Class to some third person. The constraints are 1. The third person should not be able to see the other details of the class! 2. the component should be accessible to only that particular third person! I have a solution to the problem. But I would like to know other approaches to solve the issue. Thanks in advance ~SSETH

    S J 2 Replies Last reply
    0
    • S SSETH

      Hello All, Could any one suggest how can I design the following the problem in C++? How to provide access to a component of a Class to some third person. The constraints are 1. The third person should not be able to see the other details of the class! 2. the component should be accessible to only that particular third person! I have a solution to the problem. But I would like to know other approaches to solve the issue. Thanks in advance ~SSETH

      S Offline
      S Offline
      Sascha Lefevre
      wrote on last edited by
      #2

      sseth21k wrote:

      I have a solution to the problem. But I would like to know other approaches to solve the issue.

      You might want to explain your existing solution so that a) people don't waste time on writing a suggestion for the same b) people might give you tips how to improve it

      If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

      S 1 Reply Last reply
      0
      • S Sascha Lefevre

        sseth21k wrote:

        I have a solution to the problem. But I would like to know other approaches to solve the issue.

        You might want to explain your existing solution so that a) people don't waste time on writing a suggestion for the same b) people might give you tips how to improve it

        If the brain were so simple we could understand it, we would be so simple we couldn't. — Lyall Watson

        S Offline
        S Offline
        SSETH
        wrote on last edited by
        #3

        class AccountInterface
        {
        public :
        virtual void CheckAccount() = 0;
        };

        class Accountant
        {
        private:
        AccountInterface * accountDept;
        public:
        Accountant():accountDept(NULL){}
        void SetCompanyAccDept(AccountInterface *accDept){accountDept = accDept;}

        void AuditCompany()
        {
        	if (accountDept)
        		accountDept->CheckAccount();
        	else
        		printf("Compnay info not set");
        }
        

        };

        class company : private AccountInterface
        {
        private:
        virtual void CheckAccount()
        {
        printf("Only Granted Accountant should have access to this");
        }
        public:
        void SetAccuntant(Accountant *accountant)
        {
        //Based on some logic grant access
        accountant->SetCompanyAccDept(this);
        }
        };

        int main (int argc, char *argv[])
        {
        company c1;
        Accountant ac1;
        c1.SetAccuntant(&ac1);
        ac1.AuditCompany();

        }

        I tried to demonstrate the idea with a company its account deptartment and an accountant. Account Details should not be public. (no Public access) The Accountant should not be able to access other details of the company ( No friend) Company is responsible for granting access permission --Private Inheritance..( is a relationship with base class but no exposed to public) Thanks, SSETH

        L 1 Reply Last reply
        0
        • S SSETH

          class AccountInterface
          {
          public :
          virtual void CheckAccount() = 0;
          };

          class Accountant
          {
          private:
          AccountInterface * accountDept;
          public:
          Accountant():accountDept(NULL){}
          void SetCompanyAccDept(AccountInterface *accDept){accountDept = accDept;}

          void AuditCompany()
          {
          	if (accountDept)
          		accountDept->CheckAccount();
          	else
          		printf("Compnay info not set");
          }
          

          };

          class company : private AccountInterface
          {
          private:
          virtual void CheckAccount()
          {
          printf("Only Granted Accountant should have access to this");
          }
          public:
          void SetAccuntant(Accountant *accountant)
          {
          //Based on some logic grant access
          accountant->SetCompanyAccDept(this);
          }
          };

          int main (int argc, char *argv[])
          {
          company c1;
          Accountant ac1;
          c1.SetAccuntant(&ac1);
          ac1.AuditCompany();

          }

          I tried to demonstrate the idea with a company its account deptartment and an accountant. Account Details should not be public. (no Public access) The Accountant should not be able to access other details of the company ( No friend) Company is responsible for granting access permission --Private Inheritance..( is a relationship with base class but no exposed to public) Thanks, SSETH

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          I'm not certain what problem you are trying to solve but that sounds far too complicated and unwieldy. The usual way to restrict things is by allocating permission levels to both users and data. That way you can grant or restrict access to individual people at run time.

          S 1 Reply Last reply
          0
          • L Lost User

            I'm not certain what problem you are trying to solve but that sounds far too complicated and unwieldy. The usual way to restrict things is by allocating permission levels to both users and data. That way you can grant or restrict access to individual people at run time.

            S Offline
            S Offline
            SSETH
            wrote on last edited by
            #5

            Thanks for respond ..I dont know if you are really getting the what exactly I am trying to target in the code.. without friend and making public accessibility I want to restrict the permission to some particular user... The way I am achieving is just one of the use case of Private Inheritance.. Could you please post here your approach(Design) in C++.. Thanks in advance..

            L 1 Reply Last reply
            0
            • S SSETH

              Thanks for respond ..I dont know if you are really getting the what exactly I am trying to target in the code.. without friend and making public accessibility I want to restrict the permission to some particular user... The way I am achieving is just one of the use case of Private Inheritance.. Could you please post here your approach(Design) in C++.. Thanks in advance..

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              SSETH wrote:

              Could you please post here your approach(Design) in C++..

              I did in my previous message. The way you control access to different features is by taking decisions at run time, as to what facilities and data a particular user has access to. Doing it your way is nigh on impossible, and would need regular changes in the code.

              1 Reply Last reply
              0
              • S SSETH

                Hello All, Could any one suggest how can I design the following the problem in C++? How to provide access to a component of a Class to some third person. The constraints are 1. The third person should not be able to see the other details of the class! 2. the component should be accessible to only that particular third person! I have a solution to the problem. But I would like to know other approaches to solve the issue. Thanks in advance ~SSETH

                J Offline
                J Offline
                jschell
                wrote on last edited by
                #7

                First off of course this is a made up problem that should never be implemented specifically in code. Parts, depending on what you mean, might be implemented in they system but not code specifically (design versus code.) But approaching it code wise.

                sseth21k wrote:

                1. The third person should not be able to see the other details of the class!

                The implementation via class A. You have an API class that returns a proxy B. The caller uses B. B internally is implemented such that A supplies all the behavior. Specifically in C++ this means that A will NOT be in an include file. Rather it should be a source file. In ractical wise you would probably put in its own package with its own include file Code wise you could tighten this even further by delivering a binary rather than source code. Then all they could see would be the Proxy.

                sseth21k wrote:

                the component should be accessible to only that particular third person!

                There is a credential class. It has specific data that identifies the caller. The API (above) is modified to take an instance of the credential class. The API checks the data to 'match' to the 'third person'. If it matches it returns the Proxy. If it doesn't match it returns null.

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups