Skip to content

Commit

Permalink
The multirolemapping tests moved to maven
Browse files Browse the repository at this point in the history
Signed-off-by: David Matějček <david.matejcek@omnifish.ee>
  • Loading branch information
dmatej committed Nov 13, 2023
1 parent 788bdbf commit 95c637f
Show file tree
Hide file tree
Showing 21 changed files with 310 additions and 758 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,19 +15,17 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package com.sun.s1asdev.security.simpleMultiRoleMapping.ejb1;
package org.glassfish.main.test.app.security.multirolemapping;

import jakarta.annotation.security.RolesAllowed;
import jakarta.ejb.Local;
import jakarta.ejb.Stateless;

@Stateless
@Local({MessageLocal1.class})
public class MessageBean1 implements MessageLocal1 {

//@RolesAllowed("ejbrole")
@Override
public String getMessage() {
return "Hello from ejb";
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,19 +15,17 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package com.sun.s1asdev.security.simpleMultiRoleMapping.ejb2;
package org.glassfish.main.test.app.security.multirolemapping;

import jakarta.annotation.security.RolesAllowed;
import jakarta.ejb.Local;
import jakarta.ejb.Stateless;

@Stateless
@Local({MessageLocal2.class})
public class MessageBean2 implements MessageLocal2 {

//@RolesAllowed("ejbrole")
@Override
public String getMessage() {
return "Hello from ejb";
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,7 +15,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package com.sun.s1asdev.security.simpleMultiRoleMapping.ejb1;
package org.glassfish.main.test.app.security.multirolemapping;

import jakarta.ejb.Local;

Expand All @@ -24,5 +25,4 @@
@Local
public interface MessageLocal1 {
String getMessage();

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,7 +15,7 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package com.sun.s1asdev.security.simpleMultiRoleMapping.ejb2;
package org.glassfish.main.test.app.security.multirolemapping;

import jakarta.ejb.Local;

Expand All @@ -23,6 +24,6 @@
*/
@Local
public interface MessageLocal2 {
String getMessage();

String getMessage();
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/*
* Copyright (c) 2023 Contributors to the Eclipse Foundation.
* Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
*
* This program and the accompanying materials are made available under the
Expand All @@ -14,16 +15,21 @@
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

package com.sun.s1asdev.security.multiRoleMapping.web;
package org.glassfish.main.test.app.security.multirolemapping;

import java.io.*;
import java.net.*;
import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import jakarta.servlet.*;
import jakarta.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

public class WebTest extends HttpServlet {

private static final long serialVersionUID = 1L;

@Override
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {

Expand All @@ -32,17 +38,15 @@ protected void doGet(HttpServletRequest request,

// check roles 1 through 7
boolean found = false;
for (int i=0; i<8; i++) {
for (int i = 0; i < 8; i++) {
if (request.isUserInRole("role" + i)) {
found = true;
out.println("Hello role" + i);
}
}
if (!found) {
out.println("User '" + request.getRemoteUser() +
"' is not in expected role. Something's messed up.");
out.println("User '" + request.getRemoteUser() + "' is not in expected role. Something's messed up.");
}
out.close();
}

}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2023 Contributors to the Eclipse Foundation.
Copyright (c) 2017, 2018 Oracle and/or its affiliates. All rights reserved.
This program and the accompanying materials are made available under the
Expand All @@ -17,10 +17,13 @@
-->

<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
>
<servlet>
<servlet-name>WebTest</servlet-name>
<servlet-class>com.sun.s1asdev.security.multiRoleMapping.web.WebTest</servlet-class>
<servlet-class>org.glassfish.main.test.app.security.multirolemapping.WebTest</servlet-class>
</servlet>

<servlet-mapping>
Expand All @@ -29,99 +32,97 @@
</servlet-mapping>
<session-config>

<session-timeout>
30
</session-timeout>
<session-timeout>30</session-timeout>
</session-config>

<security-constraint>
<display-name>constraint-role1</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role1</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role1</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>constraint-role2</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role2</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role2</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>constraint-role3</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role3</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role3</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>constraint-role4</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role4</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role4</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>constraint-role5</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role5</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role5</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>constraint-role6</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role6</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role6</role-name>
</auth-constraint>
</security-constraint>
<security-constraint>
<display-name>constraint-role7</display-name>
<web-resource-collection>
<web-resource-name>WebTestServlet</web-resource-name>
<description/>
<description />
<url-pattern>/role7</url-pattern>
<http-method>GET</http-method>
</web-resource-collection>
<auth-constraint>
<description/>
<description />
<role-name>role7</role-name>
</auth-constraint>
</security-constraint>
Expand Down
Loading

0 comments on commit 95c637f

Please sign in to comment.