Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.86 KB | None | 0 0
  1. package testcases.CWE315_Plaintext_Storage_in_Cookie;
  2.  
  3. import testcasesupport.*;
  4.  
  5. import javax.servlet.http.*;
  6.  
  7. import java.security.MessageDigest;
  8.  
  9. import java.net.PasswordAuthentication;
  10.  
  11. public class CWE315_Plaintext_Storage_in_Cookie__Servlet_01 extends AbstractTestCaseServlet
  12. {
  13.     public void func(HttpServletRequest request, HttpServletResponse response) throws Throwable
  14.     {
  15.         String data;
  16.  
  17.         PasswordAuthentication credentials = new PasswordAuthentication("user", "BP@ssw0rd".toCharArray());
  18.  
  19.         data = credentials.getUserName() + ":" + (new String(credentials.getPassword()));
  20.  
  21.         response.addCookie(new Cookie("auth", data));
  22.  
  23.     }
  24.  
  25.     public static void main(String[] args) throws ClassNotFoundException,
  26.            InstantiationException, IllegalAccessException
  27.     {
  28.         mainFromParent(args);
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement