Download presentation
Presentation is loading. Please wait.
Published byRodney Shepherd Modified over 9 years ago
2
Application Code PDP PEP public void borrowBook (User user, Book book, Context context) throws PolicyViolationException { Request request = new Request execute(user.getRole(), "BORROW", "BOOK", context); // Subject, Action, Resource, Context String decision = executePDP (request ); if (decision.equals (“Deny”){ thorws new PolicyViolationException (“Deny”)} else if (decision.equals (“Undefined”)) thorws new PolicyViolationException (“Undefined”)} else if (decision.equals (“Permit”){ // borrow Book process if decision is Permitted … // code here to borrow book … } } public void borrowBook (User user, Book book, Context context) throws PolicyViolationException { Request request = new Request execute(user.getRole(), "BORROW", "BOOK", context); // Subject, Action, Resource, Context String decision = executePDP (request ); if (decision.equals (“Deny”){ thorws new PolicyViolationException (“Deny”)} else if (decision.equals (“Undefined”)) thorws new PolicyViolationException (“Undefined”)} else if (decision.equals (“Permit”){ // borrow Book process if decision is Permitted … // code here to borrow book … } } private void doBorrowInHolidaysWithUser() { String user = UserGetInstance(“ID”, “BORROWER”); Context context = ContextGetInstance("holidays"); Book book = new Book(); book1.setTitle("JAVA programming"); book1.setAuthor("James So"); // test borrow books in holidays try { bookService.borrowBook(user, book, context); // if we go here then failure fail("Book is borrowed by BORROWER during holidays"); } catch (Exception e) { fail(e.getMessage()); } // proceed if book is borrowed by BORROWER.... } private void doBorrowInHolidaysWithUser() { String user = UserGetInstance(“ID”, “BORROWER”); Context context = ContextGetInstance("holidays"); Book book = new Book(); book1.setTitle("JAVA programming"); book1.setAuthor("James So"); // test borrow books in holidays try { bookService.borrowBook(user, book, context); // if we go here then failure fail("Book is borrowed by BORROWER during holidays"); } catch (Exception e) { fail(e.getMessage()); } // proceed if book is borrowed by BORROWER.... } Test Case Code private void doBorrowInHolidaysWithUser() { User user = UserGetInstance(“ID”, “BORROWER”); Context context = ContextGetInstance("holidays"); Book book = new Book(); book1.setTitle("JAVA programming"); book1.setAuthor("James So"); // test borrow books in holidays try { bookService.borrowBook(user, book, context); // if we go here then failure fail("Book is borrowed by BORROWER during holidays"); } catch (Exception e) { fail(e.getMessage()); } // proceed if book is borrowed by BORROWER.... } Request: “ BORROWER ” is permitted to borrow book during holidays Request: “ BORROWER ” is permitted to borrow book during holidays Response: Permit or Deny Policy P Request Respons e
3
Methods Application Code PDP PEPs Policy P SubjectContext Test Case Code 1 2 3
4
Security Test Cases Functional Test Cases System Test Cases
5
Policy P Policy-based Software Application T Policy P' Policy Changes Test Selection Test Augmentation T' T'' T' + Different Behaviors
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.