Skip to content

Commit

Permalink
#23507 Removed usage of deprecated methods in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmatej committed Apr 6, 2022
1 parent 23ca958 commit aa384a1
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,13 +378,10 @@ private void completePreparation(final Instrumentation inst) throws

prepareURLStreamHandling();

//This is required for us to enable interrupt jaxws service
//creation calls
System.setProperty("jakarta.xml.ws.spi.Provider",
"com.sun.enterprise.webservice.spi.ProviderImpl");
//This is required for us to enable interrupt jaxws service creation calls
System.setProperty("jakarta.xml.ws.spi.Provider", "com.sun.xml.ws.spi.ProviderImpl");
//InjectionManager's injectClass will be called from getMainMethod


// Load any managed beans
ManagedBeanManager managedBeanManager = habitat.getService(ManagedBeanManager.class);
managedBeanManager.loadManagedBeans(desc.getApplication());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,7 @@ public void doFilter (ServletRequest request,
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpSession httpSession = httpRequest.getSession(true);
if (httpRequest.isUserInRole("j2ee")) {
httpSession.putValue("deployment.ejb30.ear.security",
"filterMessage=hello world: " + loginTimeout);

httpSession.setAttribute("deployment.ejb30.ear.security", "filterMessage=hello world: " + loginTimeout);
}
chain.doFilter(request, response);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public void doFilter (ServletRequest request,
}
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpSession httpSession = httpRequest.getSession(true);
httpSession.putValue("deployment.ejb30.web.jsp", "Hello World: " +
loginTimeout);
httpSession.setAttribute("deployment.ejb30.web.jsp", "Hello World: " + loginTimeout);
chain.doFilter(request, response);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@ public void doFilter (ServletRequest request,
}
HttpServletRequest httpRequest = (HttpServletRequest)request;
HttpSession httpSession = httpRequest.getSession(true);
httpSession.putValue("deployment.ejb30.war.servlet",
"Filter: Hello World: " + loginTimeout);
httpSession.setAttribute("deployment.ejb30.war.servlet", "Filter: Hello World: " + loginTimeout);
chain.doFilter(request, response);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
Expand All @@ -21,14 +22,24 @@
import jakarta.security.jacc.PolicyContextException;

public class DummyPolicyConfigurationFactory extends PolicyConfigurationFactory {
public PolicyConfiguration
getPolicyConfiguration(String contextID, boolean remove)
throws jakarta.security.jacc.PolicyContextException {

public PolicyConfiguration getPolicyConfiguration() {
return null;
}


public PolicyConfiguration getPolicyConfiguration(String contextID) {
return null;
}

public boolean inService(String contextID)
throws jakarta.security.jacc.PolicyContextException {

public PolicyConfiguration getPolicyConfiguration(String contextID, boolean remove)
throws jakarta.security.jacc.PolicyContextException {
return null;
}


public boolean inService(String contextID) throws jakarta.security.jacc.PolicyContextException {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ public AuthStatus validateRequest(MessageInfo messageInfo,
}

HttpSession session = request.getSession(false);
boolean secondPhase = (session != null &&
session.getValue("FIRST_DONE") != null);
boolean secondPhase = (session != null && session.getAttribute("FIRST_DONE") != null);
String loginName = ((secondPhase)? username + "_2" : username);
char[] pwd = new char[password.length()];
password.getChars(0, password.length(), pwd, 0);
Expand Down Expand Up @@ -117,7 +116,7 @@ public AuthStatus validateRequest(MessageInfo messageInfo,
response.setHeader("WWW-Authenticate", "Basic realm=\"default\"");
if (session == null) {
session = request.getSession(true);
session.putValue("FIRST_DONE", Boolean.TRUE);
session.setAttribute("FIRST_DONE", Boolean.TRUE);
}
response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
return AuthStatus.SEND_SUCCESS;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ public AuthStatus validateRequest(MessageInfo messageInfo,
try {
HttpSession session = request.getSession(false);
if (session != null) {
Subject savedClientSubject =
(Subject)session.getValue(SAVED_SUBJECT);
Subject savedClientSubject = (Subject) session.getAttribute(SAVED_SUBJECT);
if (savedClientSubject != null) {
System.out.println("already has saved subject");
// just copy principals for testing
Expand All @@ -96,7 +95,7 @@ public AuthStatus validateRequest(MessageInfo messageInfo,
if (session == null) {
session = request.getSession(true);
}
session.putValue(SAVED_REQUEST, new SavedRequest(request));
session.setAttribute(SAVED_REQUEST, new SavedRequest(request));
RequestDispatcher rd = request.getRequestDispatcher("login.jsp");
rd.forward(request, response);
System.out.println("Form: SEND_CONTINUE");
Expand All @@ -117,9 +116,9 @@ public AuthStatus validateRequest(MessageInfo messageInfo,
System.out.println("login success: " + username + ", " + password);
SavedRequest sreq = null;
if (session != null) {
sreq = (SavedRequest)session.getValue(SAVED_REQUEST);
sreq = (SavedRequest) session.getAttribute(SAVED_REQUEST);
// for testing only as Subject is not Serializable
session.putValue(SAVED_SUBJECT, clientSubject);
session.setAttribute(SAVED_SUBJECT, clientSubject);
}
if (sreq != null) {
StringBuffer sb = new StringBuffer(sreq.getRequestURI());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
id=<%=session.getId()%>
<% String a = request.getParameter("a");
if (a != null) {
session.putValue("a", a);
session.setAttribute("a", a);
}
out.println("a=" + session.getValue("a"));
out.println("a=" + session.getAttribute("a"));
%>

0 comments on commit aa384a1

Please sign in to comment.