2. Invoke InterMediateBean.excludeTest(), this in-turn invokes
- * TargetBean.excludeTest(). 3. Put the TargetBean's excludeTest() method in
- * the exclude-list or DenyAll 4. Verify that jakarta.ejb.EJBAccessException is
- * generated.
- */
-
- public void excludeTest() throws Exception {
- logMsg("Starting excludeTest ");
- try {
- ejbref.initLogging(props);
- if (!ejbref.excludeTest(props)) {
- logErr("excludeTest returned false");
- throw new Exception("excludeTest failed");
- }
- logMsg("excludeTest passed");
- } catch (Exception e) {
- throw new Exception("excludeTest failed:", e);
- }
- }
-
- public void logMsg(String msg) {
- logger = Helper.getLogger();
- logger.log(Level.INFO, msg);
- }
-
- /*
- * public void cleanup() throws Exception { logMsg("cleanup ok"); }
- */
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/InterMediate.java b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/InterMediate.java
deleted file mode 100644
index 510ebc98ad..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/InterMediate.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2007, 2018 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.ejb.mr;
-
-public interface InterMediate {
- public void initLogging(java.util.Properties p);
-
- public boolean IsCallerB1(String caller);
-
- public boolean IsCallerB2(String caller, java.util.Properties p);
-
- public boolean InRole(String role, java.util.Properties p);
-
- public boolean EjbNotAuthz(java.util.Properties p);
-
- public boolean EjbIsAuthz(java.util.Properties p);
-
- public boolean EjbSecRoleRef(String role, java.util.Properties p);
-
- public boolean uncheckedTest(java.util.Properties p);
-
- public boolean excludeTest(java.util.Properties p);
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/InterMediateBean.java b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/InterMediateBean.java
deleted file mode 100644
index e696895b89..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/InterMediateBean.java
+++ /dev/null
@@ -1,215 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.ejb.mr;
-
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import com.sun.ts.tests.ejb30.common.helper.Helper;
-
-import jakarta.annotation.Resource;
-import jakarta.annotation.security.DeclareRoles;
-import jakarta.annotation.security.RolesAllowed;
-import jakarta.annotation.security.RunAs;
-import jakarta.ejb.EJB;
-import jakarta.ejb.EJBAccessException;
-import jakarta.ejb.EJBs;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateless;
-import jakarta.ejb.TransactionAttribute;
-import jakarta.ejb.TransactionAttributeType;
-import jakarta.ejb.TransactionManagement;
-import jakarta.ejb.TransactionManagementType;
-
-@Stateless(name = "InterMediateBean")
-// @Remote({InterMediate.class})
-
-// Set EJB References
-@EJBs({
- @EJB(name = "TargetBean", beanName = "TargetBean", beanInterface = Target.class) })
-@TransactionManagement(TransactionManagementType.CONTAINER)
-@DeclareRoles({ "Administrator", "Employee", "Manager" })
-@RunAs("Manager")
-@RolesAllowed({ "Administrator", "Employee", "Manager" })
-public class InterMediateBean implements InterMediate {
- // Lookup TargetBean and save the reference in ejb1
- @EJB(beanName = "TargetBean")
- private Target ejb1 = null;
-
- private Logger logger = Helper.getLogger();
-
- private SessionContext sctx = null;
-
- private static final String UserNameProp = "user";
-
- private static final String UserPasswordProp = "password";
-
- private String username = "";
-
- private String password = "";
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public void initLogging(java.util.Properties p) {
- logger = Helper.getLogger();
- }
-
- @Resource
- public void setSessionContext(SessionContext sc) {
- sctx = sc;
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean IsCallerB1(String caller) {
- String name = sctx.getCallerPrincipal().getName();
- logMsg("IsCallerB1: " + name);
-
- if (name.indexOf(caller) < 0)
- return false;
- else
- return true;
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean IsCallerB2(String caller, java.util.Properties p) {
- try {
- // ejb1.initLogging(p);
- logMsg("Running IsCallerB2 :" + caller);
- boolean result = ejb1.IsCaller(caller);
- return result;
- } catch (Exception e) {
- logMsg("Caught Unexpected exception e.getMessage()");
- return false;
- }
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean InRole(String role, java.util.Properties p) {
- try {
- // ejb1.initLogging(p);
- logMsg("Running InRole : " + role);
- boolean result = ejb1.EjbSecRoleRef(role);
- return result;
- } catch (Exception e) {
- logMsg("Caught Unexpected exception e.getMessage()");
- return false;
- }
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean EjbNotAuthz(java.util.Properties p) {
- try {
- // ejb1.initLogging(p);
- ejb1.EjbNotAuthz();
- logMsg(
- "Method call did not generate an expected jakarta.ejb.EJBAccessException");
- return false;
- } catch (EJBAccessException e) {
- logMsg("Caught jakarta.ejb.EJBAccessException as expected");
- cleanup(ejb1);
- return true;
- } catch (Exception e) {
- logMsg("Caught Unexpected exception e.getMessage()");
- cleanup(ejb1);
- return false;
- }
- }
-
- private void cleanup(Target ejbref) {
-
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean EjbIsAuthz(java.util.Properties p) {
- logMsg("In InterMediateBean.EjbIsAuthz method");
- try {
- // ejb1.initLogging(p);
- boolean result = ejb1.EjbIsAuthz();
-
- if (!result)
- return false;
-
- } catch (Exception e) {
- logMsg("Caught Unexpected exception e.getMessage()");
- return false;
- }
- return true;
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean EjbSecRoleRef(String role, java.util.Properties p) {
- logMsg("In InterMediateBean.EjbSecRoleRef method");
- try {
- // ejb1.initLogging(p);
- boolean result = ejb1.EjbSecRoleRef(role);
-
- if (!result)
- return false;
- return true;
- } catch (Exception e) {
- logMsg("Caught Unexpected exception e.getMessage()");
- return false;
- }
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean uncheckedTest(java.util.Properties p) {
- logMsg("In InterMediateBean.uncheckedTest method");
- try {
- // ejb1.initLogging(p);
- boolean result = ejb1.uncheckedTest();
- return result;
- } catch (Exception e) {
- logMsg("InterMediateBean.unchecktedTest failed with exception: "
- + e.getMessage());
- return false;
- }
- }
-
- @RolesAllowed({ "Administrator", "Employee", "Manager" })
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public boolean excludeTest(java.util.Properties p) {
- logMsg("In InterMediateBean.excludeTest method");
-
- try {
- // ejb1.initLogging(p);
- boolean result = ejb1.excludeTest();
- return false;
- } catch (EJBAccessException ex) {
- logMsg("InterMediateBean : Got expected EJBAccessException");
- return true;
-
- } catch (Exception e) {
- logMsg("InterMediateBean.excludeTest failed with exception: "
- + e.getMessage());
- return false;
- }
- }
-
- @TransactionAttribute(TransactionAttributeType.NEVER)
- public void logMsg(String msg) {
- logger.log(Level.INFO, msg);
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/Target.java b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/Target.java
deleted file mode 100644
index 056f1371e4..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/Target.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.ejb.mr;
-
-public interface Target {
- public void initLogging(java.util.Properties p);
-
- public boolean IsCaller(String caller);
-
- public boolean EjbNotAuthz();
-
- public boolean EjbIsAuthz();
-
- public boolean EjbSecRoleRef(String role);
-
- public boolean uncheckedTest();
-
- public boolean excludeTest();
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/TargetBean.java b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/TargetBean.java
deleted file mode 100644
index 1e59179d8a..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/TargetBean.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.ejb.mr;
-
-import java.util.logging.Logger;
-
-import com.sun.ts.tests.ejb30.common.helper.Helper;
-
-import jakarta.annotation.Resource;
-import jakarta.annotation.security.DeclareRoles;
-import jakarta.annotation.security.DenyAll;
-import jakarta.annotation.security.PermitAll;
-import jakarta.annotation.security.RolesAllowed;
-import jakarta.ejb.SessionContext;
-import jakarta.ejb.Stateless;
-import jakarta.ejb.TransactionAttribute;
-import jakarta.ejb.TransactionAttributeType;
-
-@Stateless(name = "TargetBean")
-// @Remote({Target.class})
-@DeclareRoles({ "Administrator", "Manager", "Employee" })
-
-public class TargetBean implements Target {
-
- private SessionContext sctx;
-
- private Logger logger = Helper.getLogger();
-
- @RolesAllowed({ "Administrator", "Manager", "Employee" })
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public void initLogging(java.util.Properties p) {
- }
-
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public boolean IsCaller(String caller) {
- if (sctx.getCallerPrincipal().getName().indexOf(caller) < 0)
- return false;
- else
- return true;
- }
-
- @RolesAllowed({ "Administrator" })
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public boolean EjbNotAuthz() {
- return true;
- }
-
- @RolesAllowed({ "Administrator", "Manager", "Employee" })
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public boolean EjbIsAuthz() {
- return true;
- }
-
- @RolesAllowed({ "Manager", "Employee" })
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public boolean EjbSecRoleRef(String role) {
- return sctx.isCallerInRole(role);
- }
-
- @PermitAll
- public boolean uncheckedTest() {
- return true;
- }
-
- @DenyAll
- @TransactionAttribute(TransactionAttributeType.REQUIRED)
- public boolean excludeTest() {
- return true;
- }
-
- @Resource
- public void setSessionContext(SessionContext sc) {
- sctx = sc;
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/build.xml
deleted file mode 100644
index caf7b77f0e..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/build.xml
+++ /dev/null
@@ -1,31 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/jacc_ejb_mr_ejblitesecuredjsp_vehicle_web.war.sun-ejb-jar.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/jacc_ejb_mr_ejblitesecuredjsp_vehicle_web.war.sun-ejb-jar.xml
deleted file mode 100644
index 75dda5c983..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/jacc_ejb_mr_ejblitesecuredjsp_vehicle_web.war.sun-ejb-jar.xml
+++ /dev/null
@@ -1,89 +0,0 @@
-
-
-
-
-
-
- Administrator
- j2ee
-
-
- Manager
- javajoe
-
-
- Employee
- javajoe
- j2ee
-
-
- 0
-
- InterMediateBean
- jacc_ejb_mr_InterMediateBean
- false
-
- javajoe
-
-
-
- supported
- supported
- supported
- supported
-
-
- username_password
- default
- true
-
-
- supported
-
-
- false
- -1
-
-
-
- TargetBean
- jacc_ejb_mr_TargetBean
- false
-
-
- supported
- supported
- supported
- supported
-
-
- username_password
- default
- false
-
-
- supported
-
-
- false
- -1
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/jacc_ejb_mr_ejblitesecuredjsp_vehicle_web.war.sun-web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/jacc_ejb_mr_ejblitesecuredjsp_vehicle_web.war.sun-web.xml
deleted file mode 100644
index c9344e8fa2..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/ejb/mr/jacc_ejb_mr_ejblitesecuredjsp_vehicle_web.war.sun-web.xml
+++ /dev/null
@@ -1,38 +0,0 @@
-
-
-
-
-
- jacc_ejb_mr_ejblitesecuredjsp_vehicle_web
-
- Administrator
- j2ee
-
-
- Manager
- javajoe
-
-
- Employee
- javajoe
- j2ee
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSLogRecord.java b/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSLogRecord.java
deleted file mode 100644
index 15a5b81cdc..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSLogRecord.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/**
- * $Id$
- *
- * @author Raja Perumal
- * 07/12/02
- */
-
-package com.sun.ts.tests.jacc.provider;
-
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-
-/**
- * TSLogRecord is the custom LogRecord which has one additional logging field
- * ContextId, in addition to the regular Logging fields. The Log fields of
- * TSLogRecord are 1) sequence number 2) context Id (The logging context) 3)
- * message 4) class name (The class which logs the log message) 5) method name (
- * The method which logs the log message)
- **/
-public class TSLogRecord extends LogRecord {
-
- /**
- * @serial The logging context Id
- */
- private String contextId;
-
- /**
- * Construct a LogRecord with the given level, message and context values.
- *
- * @param level
- * a logging level value
- * @param contextId
- * the logging contextId
- * @param msg
- * the raw non-localized logging message
- *
- */
- TSLogRecord(Level level, String message, String contextId) {
- // set the rest of the fields using parent constructor
- super(level, message);
- this.contextId = contextId;
-
- }
-
- /**
- * Construct a LogRecord with the given level and message
- *
- * @param level
- * a logging level value
- * @param msg
- * the raw non-localized logging message
- *
- */
- TSLogRecord(Level level, String message) {
- super(level, message);
- // Add jacc_ctx for default contextId
- this.contextId = "jacc_ctx";
- }
-
- /**
- * Get the contextId
- *
- * @ return contextId
- */
- public String getContextId() {
- return contextId;
- }
-
- /**
- * Set the contextId
- *
- * @param contextId
- * the logging context Id
- */
- public void setContextId(String cId) {
- contextId = cId;
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSLogger.java b/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSLogger.java
deleted file mode 100644
index b5c747444e..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSLogger.java
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/**
- * $Id$
- *
- * @author Raja Perumal
- * 07/13/02
- */
-
-package com.sun.ts.tests.jacc.provider;
-
-import java.util.logging.FileHandler;
-import java.util.logging.Filter;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogManager;
-import java.util.logging.Logger;
-
-/**
- * TSLogger is the custom Logger which extends java.util.Logger
- *
- **/
-public class TSLogger extends Logger {
-
- /**
- * @serial The logging context Id
- */
- private String contextId;
-
- private int levelValue = Level.INFO.intValue();
-
- private int offValue = Level.OFF.intValue();
-
- private Filter filter;
-
- private String name;
-
- // Note : The logger instance should not be
- // stored in this instance variable,
- // it should be kept at the log Manager using
- //
- // LogManager.addLogger(TSlogger);
- //
- // and it can be retrieved using
- //
- // LogManager.getLogger(name);
- //
- // Since Logger and TSLogger are of different types
- // we cannot use the above logic and hence we have
- // no choice except to store it here.
- //
- private static TSLogger tsLogger = null;
-
- protected TSLogger(String name) {
- super(name, null);
- this.name = name;
- levelValue = Level.INFO.intValue();
- }
-
- /**
- * Find or create a logger for a named subsystem. If a logger has already been
- * created with the given name it is returned. Otherwise a new logger is
- * created.
- *
- * If a new logger is created its log level will be configured based on the
- * LogManager configuration and it will configured to also send logging output
- * to its parent's handlers. It will be registered in the LogManager global
- * namespace.
- *
- * @param name
- * A name for the logger. This should be a dot-separated name and
- * should normally be based on the package name or class name of the
- * subsystem, such as java.net or javax.swing
- * @return a suitable Logger
- */
- public static synchronized TSLogger getTSLogger(String name) {
- TSLogger result = null;
-
- LogManager manager = LogManager.getLogManager();
-
- // TSLogger result = manager.getLogger(name);
- // if (result == null){
- // result = new TSLogger(name);
- // manager.addLogger(result);
- // result = manager.getLogger(name);
- // }
-
- if (tsLogger != null) {
- if (tsLogger.getName().equals(name))
- result = tsLogger;
- } else {
- result = new TSLogger(name);
- manager.addLogger(result);
- }
-
- return result;
- }
-
- /**
- * Log a message, with no arguments.
- *
- * If the logger is currently enabled for the given message level then the
- * given message is forwarded to all the registered output Handler objects.
- *
- *
- * @param level
- * One of the message level identifiers, e.g. SEVERE
- * @param msg
- * The string message (or a key in the message catalog)
- */
- public void log(Level level, String msg) {
- // assign default context (jacc_ctx) to all messages ???
- log(level, msg, "jacc_ctx");
- }
-
- /**
- * Log a message, with no arguments.
- *
- * If the logger is currently enabled for the given message level then the
- * given message is forwarded to all the registered output Handler objects.
- *
- *
- * @param level
- * One of the message level identifiers, e.g. SEVERE
- * @param msg
- * The string message (or a key in the message catalog)
- * @param contextId
- * the logging context Id
- */
- public void log(Level level, String msg, String contextId) {
- if (level.intValue() < levelValue || levelValue == offValue) {
- return;
- }
- TSLogRecord lr = new TSLogRecord(level, msg, contextId);
- String rbn = null;
-
- Logger target = this;
- while (target != null) {
- rbn = target.getResourceBundleName();
- if (rbn != null) {
- break;
- }
- target = target.getParent();
- }
-
- if (rbn != null) {
- lr.setResourceBundleName(rbn);
- // lr.setResourceBundle("null");
- }
-
- log(lr);
-
- }
-
- /**
- * Log a TSLogRecord.
- *
- * @param record
- * the TSLogRecord to be published
- */
- public void log(TSLogRecord record) {
- if (record.getLevel().intValue() < levelValue || levelValue == offValue) {
- return;
- }
- synchronized (this) {
- if (filter != null && !filter.isLoggable(record)) {
- return;
- }
- }
-
- // Post the LogRecord to all our Handlers, and then to
- // our parents' handlers, all the way up the tree.
-
- TSLogger logger = this;
- while (logger != null) {
- Handler targets[] = logger.getHandlers();
-
- if (targets != null) {
- for (int i = 0; i < targets.length; i++) {
- // targets[i].publish(record);
-
- // Publish record only if the
- // handler is of type FileHandler
- // Do not publish to all parent handler
- // Parent handler may not be able to
- // Format the TSLogRecord, because
- // TSLogRecord is the custom record.
- if (targets[i] instanceof FileHandler)
- targets[i].publish(record);
- }
- }
-
- if (!logger.getUseParentHandlers()) {
- break;
- }
-
- // logger = (TSLogger)logger.getParent();
- logger = null;
- }
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicy.java b/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicy.java
deleted file mode 100644
index ef72dbfe7e..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicy.java
+++ /dev/null
@@ -1,634 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/**
- * $Id$
- *
- * @author Raja Perumal
- * 08/14/02
- */
-
-package com.sun.ts.tests.jacc.provider;
-
-import java.io.File;
-import java.security.CodeSource;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.ProtectionDomain;
-import java.util.StringTokenizer;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-
-import com.sun.ts.lib.util.sec.security.provider.PolicyFile;
-
-import jakarta.security.jacc.EJBMethodPermission;
-import jakarta.security.jacc.EJBRoleRefPermission;
-import jakarta.security.jacc.PolicyConfiguration;
-import jakarta.security.jacc.PolicyConfigurationFactory;
-import jakarta.security.jacc.PolicyContext;
-import jakarta.security.jacc.WebResourcePermission;
-import jakarta.security.jacc.WebRoleRefPermission;
-import jakarta.security.jacc.WebUserDataPermission;
-
-/**
- * This is a delegating Policy Implementation class which delegates the
- * permission evaluation to vendor's policy implentation defined by
- * "vendor.jakarta.security.jacc.policy.provider"
- *
- * In case the vendor doesn't provide Policy implementation default jdk policy
- * will be used.
- *
- * Note: Since J2EE 1.3 appservers are not required to support JSR115, the 1.3
- * policy implementation defined by "jakarta.security.auth.policy.provider" will
- * not used for testing in this TCK
- */
-public final class TSPolicy extends java.security.Policy {
- private java.security.Policy policy = null;
-
- public static final String VENDOR_POLICY_PROVIDER = "vendor.jakarta.security.jacc.policy.provider";
-
- private static ClassLoader classLoader = null;
-
- public static boolean POLICY_INSTALLED = false;
-
- public static TSLogger logger = null;
-
- boolean firstInvocationForJACCPermissions = true;
-
- boolean multipleSetPolicyAllowed = false;
-
- String[] tokenArray = new String[2];
-
- String methodInterfaceName = null;
-
- String methodName = null;
-
- // This constructor will be used by vendor AppServer
- public TSPolicy() {
- initializeTSLogger();
- if (!POLICY_INSTALLED)
- loadPolicy();
-
- // invoke equals and hashCode method on all JACC Permissions.
- if (firstInvocationForJACCPermissions) {
- jaccPermissionsEquals();
- jaccPermissionsHashCode();
- firstInvocationForJACCPermissions = false;
- }
- }
-
- /**
- * Evaluates the global policy and returns a PermissionCollection object
- * specifying the set of permissions allowed for code from the specified code
- * source.
- *
- * @param codesource
- * the CodeSource associated with the caller. This encapsulates the
- * original location of the code (where the code came from) and the
- * public key(s) of its signer.
- *
- * @return the set of permissions allowed for code from codesource
- * according to the policy.The returned set of permissions must be a
- * new mutable instance and it must support heterogeneous Permission
- * types.
- *
- */
- public PermissionCollection getPermissions(CodeSource codesource) {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicy", "getPermissions");
- }
- // print permission collection as logger info ?
- return policy.getPermissions(codesource);
- }
-
- /**
- * Evaluates the global policy and returns a PermissionCollection object
- * specifying the set of permissions allowed given the characteristics of the
- * protection domain.
- *
- * @param domain
- * the ProtectionDomain associated with the caller.
- *
- * @return the set of permissions allowed for the domain according to
- * the policy.The returned set of permissions must be a new mutable
- * instance and it must support heterogeneous Permission types.
- *
- * @see java.security.ProtectionDomain
- * @see java.security.SecureClassLoader
- * @since 1.4
- */
- public PermissionCollection getPermissions(ProtectionDomain domain) {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicy", "getPermissions");
- }
- // print permission collection as logger info ?
- return policy.getPermissions(domain);
- }
-
- /**
- * Evaluates the global policy for the permissions granted to the
- * ProtectionDomain and tests whether the permission is granted.
- *
- * @param domain
- * the ProtectionDomain to test
- * @param permission
- * the Permission object to be tested for implication.
- *
- * @return true if "permission" is a proper subset of a permission granted to
- * this ProtectionDomain.
- *
- * @see java.security.ProtectionDomain
- * @since 1.4
- */
- public boolean implies(ProtectionDomain domain, Permission permission) {
- // invoke policyContextKey1() only if
- // permission instanceof WebResourcePermission and
- // permission.getName().equals(/secured.jsp) // for secured.jsp
- if ((permission instanceof WebResourcePermission)
- && (permission.getName().equals("/secured.jsp"))) {
- logger.log(Level.INFO, "Calling policyContextKey1()");
- policyContextKey1();
- }
-
- if (permission instanceof EJBMethodPermission) {
-
- // Get method interface name (such as "Remote", "Home", etc..)
- // and method name from permissions.getActions() string.
- tokenArray = getTokensFromString(permission.getActions());
-
- // Get method interface name and methodName from tokenArray
- methodName = tokenArray[0];
- methodInterfaceName = tokenArray[1];
-
- // inovke policyContextKey2() and policyContextKey3() only if
- // permission.getName().equals("jacc_providerContracts_JACCEntity") and
- // methodInterfaceName.equals("Remote) and
- // methodName.equals("getArg1")
- if ((permission.getName().equals("jacc_providerContracts_JACCEntity"))
- && methodName.equals("getArg1")
- && methodInterfaceName.equals("Remote"))
-
- {
- logger.log(Level.INFO, "Calling policyContextKey2()");
- // policyContextKey2();
- logger.log(Level.INFO, "Calling policyContextKey3()");
- policyContextKey3();
- }
- }
-
- // If there is a PolicyContext.getContextID, verify new getPolicyConfiguration() methods work
- String contextId = PolicyContext.getContextID();
- if(contextId != null) {
- try {
- // Should be non-null PolicyConfiguration
- PolicyConfigurationFactory pcf = PolicyConfigurationFactory.getPolicyConfigurationFactory();
- PolicyConfiguration pc = pcf.getPolicyConfiguration();
- if(pc != null) {
- logger.log(Level.INFO, "PolicyConfigurationFactory.getPolicyConfiguration() : PASSED");
- } else {
- logger.log(Level.INFO, "PolicyConfigurationFactory.getPolicyConfiguration() : FAILED");
- }
- // Should be non-null PolicyConfiguration and match no-arg getPolicyConfiguration()
- PolicyConfiguration pc2 = pcf.getPolicyConfiguration(contextId);
- if(pc2 == null || !pc.equals(pc2)) {
- logger.log(Level.INFO, "PolicyConfigurationFactory.getPolicyConfiguration(String) : FAILED");
- } else {
- logger.log(Level.INFO, "PolicyConfigurationFactory.getPolicyConfiguration(String) : PASSED");
- }
-
- } catch (Exception e) {
- logger.log(Level.INFO, "PolicyConfigurationFactory.getPolicyConfiguration() : FAILED");
- }
- }
-
- return policy.implies(domain, permission);
- }
-
- /**
- * Refreshes/reloads the policy configuration. The behavior of this method
- * depends on the implementation. For example, calling refresh
on
- * a file-based policy will cause the file to be re-read.
- *
- */
- public void refresh() {
- policy.refresh();
- if (logger != null)
- logger.log(Level.INFO, "TSPolicy.refresh() invoked");
- }
-
- /**
- * Loads vendor's policy implementation or JDK's default policy Note:
- * LoadPolicy does not set the policy using setPolicy(policy), since setPolicy
- * method will be called by the underlying provider, this task is delegated to
- * the underlying provider.
- */
- private void loadPolicy() {
- String javaPolicy = System.getProperty(VENDOR_POLICY_PROVIDER);
- if (javaPolicy == null) {
- logger.log(Level.FINE, "Loading Default Policy");
- policy = (java.security.Policy) new PolicyFile();
- policy.refresh();
- POLICY_INSTALLED = true;
- logger.log(Level.INFO, "Default policy loaded");
- } else {
- try {
- logger.log(Level.FINE, "Loading Policy = " + javaPolicy);
- // Object obj = Class.forName(javaPolicy).newInstance();
- classLoader = TSPolicy.class.getClassLoader();
- Class clazz = classLoader.loadClass(javaPolicy);
- Object obj = (Object) clazz.newInstance();
-
- if (obj instanceof java.security.Policy) {
- policy = (java.security.Policy) obj;
- logger.log(Level.INFO, "vendor's policy loaded!");
- POLICY_INSTALLED = true;
- } else {
- logger.log(Level.SEVERE,
- "vendor's policy is not of type java.security.Policy");
- throw new RuntimeException(
- javaPolicy + "is not a type of java.security.Policy");
- }
- } catch (ClassNotFoundException cnfe) {
- // problem with property value or classpath
- logger.log(Level.SEVERE, "vendor's Policy instantiation error", cnfe);
- throw new RuntimeException(cnfe);
- } catch (IllegalAccessException iae) {
- // problem with policy class definition
- logger.log(Level.SEVERE, "vendor's Policy instantiation error", iae);
- throw new RuntimeException(iae);
- } catch (InstantiationException ie) {
- // problem with policy instantiation
- logger.log(Level.SEVERE, "vendor's Policy instantiation error", ie);
- throw new RuntimeException(ie);
- }
- }
- }
-
- private static void initializeTSLogger() {
- String logFileLocation = null;
- if (logger != null)
- return;
- else {
- try {
- logFileLocation = System.getProperty("log.file.location");
- if (logFileLocation != null) {
- logger = TSLogger.getTSLogger("jacc");
- boolean appendMode = true;
-
- // clean the content of JACCLog.txt if it exists
- File file = new File(logFileLocation + "/JACCLog.txt");
- if (file.exists()) {
- // delete the file, if it exists
- file.delete();
- }
-
- // create a new file
- System.out.println(
- "XXXX: in initializeTSLogger() - about to create JACCLog.txt");
- FileHandler fileHandler = new FileHandler(
- logFileLocation + "/JACCLog.txt", appendMode);
- fileHandler.setFormatter(new TSXMLFormatter());
- logger.addHandler(fileHandler);
- setTSLogger(logger);
- } else {
- // use default logging mechanism
- logger = TSLogger.getTSLogger("jacc");
- setTSLogger(logger);
- logger.log(Level.SEVERE,
- "log.file.location not set: Using default logger");
- }
- } catch (Exception e) {
- throw new RuntimeException("TSLogger Initialization failed", e);
- }
- }
- }
-
- public static TSLogger getTSLogger() {
- return logger;
- }
-
- public static void setTSLogger(TSLogger lgr) {
- logger = lgr;
- }
-
- /**
- * testName: policyContextKey1
- *
- * @assertion_ids: JACC:SPEC:99; JACC:JAVADOC:30
- *
- * @test_Strategy: 1) call
- * PolicyContext.getContext("jakarta.servlet.http.HttpServletRequest")
- * 2) verify the return value is an instance of
- * HttpServletRequest
- *
- */
- private void policyContextKey1() {
- try {
- // Get HttpServletRequest object
- jakarta.servlet.http.HttpServletRequest ctx = PolicyContext
- .getContext("jakarta.servlet.http.HttpServletRequest");
- logger.log(Level.INFO, "PolicyContext.getContext() " + "test passed for"
- + "jakarta.servlet.http.HttpServletRequest");
- logger.log(Level.INFO, "PolicyContextKey1: PASSED");
- } catch (ClassCastException e) {
- logger.log(Level.INFO,
- "PolicyContext.getContext()" + "returned incorrect value for key "
- + "jakarta.servlet.http.HttpServletRequest");
- logger.log(Level.SEVERE, "PolicyContextKey1: FAILED");
- } catch (Exception e) {
- logger.log(Level.SEVERE, "PolicyContextKey1: FAILED");
- }
- }
-
- /**
- * testName: policyContextKey3
- *
- * @assertion_ids: JACC:SPEC:97; JACC:JAVADOC:30
- *
- * @test_Strategy: 1) call
- * PolicyContext.getContext("javax.security.auth.Subject.container)
- * 2) verify the return value is an instance of
- * javax.security.auth.Subject
- *
- */
- private void policyContextKey3() {
- try {
- // Get Subject
- javax.security.auth.Subject subject = PolicyContext
- .getContext("javax.security.auth.Subject.container");
- logger.log(Level.INFO, "PolicyContext.getContext() " + "test passed for"
- + "javax.security.auth.Subject.container");
- logger.log(Level.INFO, "PolicyContextKey3: PASSED");
- } catch (ClassCastException e) {
- logger.log(Level.INFO,
- "PolicyContext.getContext()" + "returned incorrect value for key "
- + "javax.security.auth.Subject.container");
- logger.log(Level.INFO, "PolicyContextKey3: FAILED");
- } catch (Exception e) {
- logger.log(Level.SEVERE, "PolicyContextKey3: FAILED");
- }
- }
-
- /**
- * Gets the method interface name and method Name from the given permission's
- * action string
- */
- public String[] getTokensFromString(String actions) {
- String[] array = new String[2];
- StringTokenizer strtoken;
-
- // Get first token and the remaining string
- strtoken = new StringTokenizer(actions, ",");
- if (actions.indexOf(",") > 0) {
- // get methodName
- array[0] = strtoken.nextToken();
-
- if (strtoken.hasMoreTokens()) {
- // get methodInterfaceName
- array[1] = strtoken.nextToken();
- }
- }
- return array;
- }
-
- /**
- * testName: jaccPermissionsEquals
- *
- * assertion_ids: JACC:JAVADOC:4; JACC:JAVADOC:9; JACC:JAVADOC:43;
- * JACC:JAVADOC:47; JACC:JAVADOC:53
- *
- * test_Strategy: 1) verify EJBMethodPermission.equals() or 2) verify
- * EJBRoleRefPermission.equals() or 3) verify WebResourcePermission.equals()
- * or 4) verify WebRoleRefPermission.equals() or 5) verify
- * WebUserDataPermission.equals()
- *
- */
- private void jaccPermissionsEquals() {
- try {
- logger.log(Level.FINE, "Checking EJBMethodPermission.equals()");
-
- EJBMethodPermission emp = new EJBMethodPermission("DummyEJB",
- "dummyMethod,Home,String");
-
- // call equals method onto itself
- boolean result = emp.equals(emp);
-
- if (result) {
- logger.log(Level.INFO, "EJBMethodPermission.equals() : PASSED");
- } else {
- logger.log(Level.INFO, "EJBMethodPermission.equals() : FAILED");
- logger.log(Level.INFO, "Calling EJBMethodPermission.equals()"
- + " onto itself returned false");
- }
-
- } catch (Exception e) {
- logger.log(Level.SEVERE, "EJBMethodPermission.equals() : FAILED");
- }
-
- try {
- EJBRoleRefPermission errp = new EJBRoleRefPermission("DummyEJB",
- "dummyRole");
- // call equals method onto itself
- boolean result = errp.equals(errp);
- if (result) {
- logger.log(Level.INFO, "EJBRoleRefPermission.equals() : PASSED");
- } else {
- logger.log(Level.INFO, "EJBRoleRefPermission.equals() : FAILED");
- logger.log(Level.INFO, "Calling EJBRoleRefPermission.equals()"
- + " onto itself returned false");
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "EJBRoleRefPermission.equals() : FAILED");
- }
-
- try {
- WebResourcePermission wrp = new WebResourcePermission("/dummyEntry",
- "POST");
-
- // call equals method onto itself
- boolean result = wrp.equals(wrp);
- if (result) {
- logger.log(Level.INFO, "WebResourcePermission.equals() : PASSED");
- } else {
- logger.log(Level.INFO, "WebResourcePermission.equals() : FAILED");
- logger.log(Level.INFO, "Calling WebResourcePermission.equals()"
- + " onto itself returned false");
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "WebResourcePermission.equals() : FAILED");
- }
-
- try {
- WebRoleRefPermission wrrp = new WebRoleRefPermission("dummyReosource",
- "dummyRole");
-
- // call equals method onto itself
- boolean result = wrrp.equals(wrrp);
- if (result) {
- logger.log(Level.INFO, "WebRoleRefPermission.equals() : PASSED");
- } else {
- logger.log(Level.INFO, "WebRoleRefPermission.equals() : FAILED");
- logger.log(Level.INFO, "Calling WebRoleRefPermission.equals()"
- + " onto itself returned false");
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "WebRoleRefPermission.equals() : FAILED");
- }
-
- try {
- WebUserDataPermission wudp = new WebUserDataPermission(
- "/dummyResource.jsp", "GET,POST:CONFIDENTIAL");
-
- // call equals method onto itself
- boolean result = wudp.equals(wudp);
- if (result) {
- logger.log(Level.INFO, "WebUserDataPermission.equals() : PASSED");
- } else {
- logger.log(Level.INFO, "WebUserDataPermission.equals() : FAILED");
- logger.log(Level.INFO, "Calling WebUserDataPermission.equals()"
- + " onto itself returned false");
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "WebUserDataPermission.equals() : FAILED");
- }
-
- }
-
- /**
- * testName: jaccPermissionsHashCode
- *
- * assertion_ids: JACC:JAVADOC:6; JACC:JAVADOC:11; JACC:JAVADOC:42;
- * JACC:JAVADOC:49; JACC:JAVADOC:55
- *
- * test_Strategy: 1) verify EJBMethodPermission.hashCode(); or 2) verify
- * EJBRoleRefPermission.hashCode(); or 3) verify
- * WebResourcePermission.hashCode() or 4) verify
- * WebRoleRefPermission.hashCode() or 5) verify
- * WebUserDataPermission.hashCode()
- */
-
- private void jaccPermissionsHashCode() {
- try {
- EJBMethodPermission emp = new EJBMethodPermission("DummyEJB",
- "dummyMethod,Home,String");
-
- // Get EJBMethodPermission's hashcode
- int hashCode1 = emp.hashCode();
-
- // Get EJBMethodPermission's hashcode again
- int hashCode2 = emp.hashCode();
-
- if (hashCode1 == hashCode2) {
- logger.log(Level.INFO, "EJBMethodPermission.hashCode() : PASSED");
- } else {
- logger.log(Level.INFO, "EJBMethodPermission.hashCode() : FAILED");
- logger.log(Level.INFO, "EJBMethodPermission.hashCode()"
- + " returned different values within the same application.");
-
- }
-
- } catch (Exception e) {
- logger.log(Level.SEVERE, "EJBMethodPermission.hashCode() : FAILED");
- }
-
- try {
- EJBRoleRefPermission errp = new EJBRoleRefPermission("DummyEJB",
- "dummyRole");
-
- // Get EJBRoleRefPermission's hashcode
- int hashCode3 = errp.hashCode();
-
- // Get EJBRoleRefPermission's hashcode again
- int hashCode4 = errp.hashCode();
-
- if (hashCode3 == hashCode4) {
- logger.log(Level.INFO, "EJBRoleRefPermission.hashCode() : PASSED");
- } else {
- logger.log(Level.INFO, "EJBRoleRefPermission.hashCode() : FAILED");
- logger.log(Level.INFO, "EJBRoleRefPermission.hashCode()"
- + " returned different values within the same application.");
- }
-
- } catch (Exception e) {
- logger.log(Level.SEVERE, "EJBRoleRefPermission.hashCode() : FAILED");
- }
-
- try {
- WebResourcePermission wrp = new WebResourcePermission("/dummyEntry",
- "POST");
-
- // Get WebResourcePermission's hashcode
- int hashCode5 = wrp.hashCode();
-
- // Get WebResourcePermission's hashcode again
- int hashCode6 = wrp.hashCode();
-
- if (hashCode5 == hashCode6) {
- logger.log(Level.INFO, "WebResourcePermission.hashCode() : PASSED");
- } else {
- logger.log(Level.INFO, "WebResourcePermission.hashCode() : FAILED");
- logger.log(Level.INFO, "WebResourcePermission.hashCode()"
- + " returned different values within the same application.");
- }
-
- } catch (Exception e) {
- logger.log(Level.SEVERE, "WebResourcePermission.hashCode() : FAILED");
- }
-
- try {
- WebRoleRefPermission wrrp = new WebRoleRefPermission("dummyReosource",
- "dummyRole");
-
- // Get WebRoleRefPermission's hashcode
- int hashCode7 = wrrp.hashCode();
-
- // Get WebRoleRefPermission's hashcode again
- int hashCode8 = wrrp.hashCode();
-
- if (hashCode7 == hashCode8) {
- logger.log(Level.INFO, "WebRoleRefPermission.hashCode() : PASSED");
- } else {
- logger.log(Level.INFO, "WebRoleRefPermission.hashCode() : FAILED");
- logger.log(Level.INFO, "WebRoleRefPermission.hashCode()"
- + " returned different values within the same application.");
- }
-
- } catch (Exception e) {
- logger.log(Level.SEVERE, "WebRoleRefPermission.hashCode() : FAILED");
- }
-
- try {
- WebUserDataPermission wudp = new WebUserDataPermission(
- "/dummyResource.jsp", "GET,POST:CONFIDENTIAL");
-
- // Get WebUserDataPermission's hashcode
- int hashCode9 = wudp.hashCode();
-
- // Get WebUserDataPermission's hashcode again
- int hashCode10 = wudp.hashCode();
-
- if (hashCode9 == hashCode10) {
- logger.log(Level.INFO, "WebUserDataPermission.hashCode() : PASSED");
- } else {
- logger.log(Level.INFO, "WebUserDataPermission.hashCode() : FAILED");
- logger.log(Level.INFO, "WebUserDataPermission.hashCode()"
- + " returned different values within the same application.");
- }
- } catch (Exception e) {
- logger.log(Level.SEVERE, "WebUserDataPermission.hashCode() : FAILED");
- }
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicyConfigurationFactoryImpl.java b/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicyConfigurationFactoryImpl.java
deleted file mode 100644
index 796d5da2f0..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicyConfigurationFactoryImpl.java
+++ /dev/null
@@ -1,262 +0,0 @@
-/*
- * Copyright (c) 2007, 2022 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/**
- * $Id$
- *
- * @author Raja Perumal
- * 08/01/02
- */
-
-package com.sun.ts.tests.jacc.provider;
-
-import java.util.logging.Level;
-
-import jakarta.security.jacc.PolicyConfiguration;
-import jakarta.security.jacc.PolicyConfigurationFactory;
-import jakarta.security.jacc.PolicyContext;
-import jakarta.security.jacc.PolicyContextException;
-
-/**
- * JACC PolicyConfigurationFactory This is a delegating
- * PolicyConfigurationFactory which delegates the policy configurations to
- * vendor implementation of PolicyConfigurationFactory class.
- *
- */
-public class TSPolicyConfigurationFactoryImpl
- extends PolicyConfigurationFactory {
- private static TSLogger lgr = null;
-
- private static String FACTORY_NAME = "vendor.jakarta.security.jacc.PolicyConfigurationFactory.provider";
-
- private static PolicyConfigurationFactory pcFactory;
-
- private static TSPolicyConfigurationImpl policyConfiguration = null;
-
- private static ClassLoader classLoader = null;
-
- public TSPolicyConfigurationFactoryImpl() throws PolicyContextException {
- try {
-
- pcFactory = TSPolicyConfigurationFactoryImpl
- .getPolicyConfigurationFactory();
- } catch (PolicyContextException pce) {
- if (lgr != null)
- lgr.severe("Failed to get PolicyConfigurationFactory");
- throw new PolicyContextException(pce);
- }
- }
-
- /**
- * This method is used to obtain an instance of the provider specific class
- * that implements the PolicyConfiguration interface that corresponds to the
- * identified policy context within the provider. The methods of the
- * PolicyConfiguration interface are used to define the policy statements of
- * the identified policy context.
- *
- * If at the time of the call, the identified policy context does not exist in
- * the provider, then the policy context will be created in the provider and
- * the Object that implements the context's PolicyConfiguration Interface will
- * be returned. If the state of the identified context is "deleted" or
- * "inService" it will be transitioned to the "open" state as a result of the
- * call. The states in the lifecycle of a policy context are defined by the
- * PolicyConfiguration interface.
- *
- * For a given value of policy context identifier, this method must always
- * return the same instance of PolicyConfiguration and there must be at most
- * one actual instance of a PolicyConfiguration with a given policy context
- * identifier (during a process context).
- *
- * To preserve the invariant that there be at most one PolicyConfiguration
- * object for a given policy context, it may be necessary for this method to
- * be thread safe.
- *
- *
- * @param contextId
- * A String identifying the policy context whose PolicyConfiguration
- * interface is to be returned. The value passed to this parameter
- * must not be null.
- *
- * @param remove
- * A boolean value that establishes whether or not the policy
- * statements of an existing policy context are to be removed before
- * its PolicyConfiguration object is returned. If the value passed to
- * this parameter is true, the policy statements of an existing
- * policy context will be removed. If the value is false, they will
- * not be removed.
- *
- * @return an Object that implements the PolicyConfiguration Interface matched
- * to the Policy provider and corresponding to the identified policy
- * context.
- *
- * @throws java.lang.SecurityException
- * when called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the getPolicyConfiguration method
- * signature. The exception thrown by the implementation class will
- * be encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
-
- public PolicyConfiguration getPolicyConfiguration(String contextId,
- boolean remove) throws PolicyContextException {
- PolicyConfiguration polConf = null;
- // check if we can invoke method
- if (lgr.isLoggable(Level.FINER)) {
- lgr.entering("PolicyConfigurationFactoryImpl", "getPolicyConfiguration");
- }
- polConf = new TSPolicyConfigurationImpl(contextId, remove, lgr);
- lgr.log(Level.INFO,
- "PolicyConfigurationFactory.getPolicyConfiguration() invoked");
- lgr.log(Level.FINER,
- "Getting PolicyConfiguration object with id = " + contextId);
- policyConfiguration = (TSPolicyConfigurationImpl) polConf;
-
- return polConf;
- }
-
- /**
- * This static method uses a system property to find and instantiate (via a
- * public constructor) a provider specific factory implementation class. The
- * name of the provider specific factory implementation class is obtained from
- * the value of the system property,
- *
- *
- * vendor.jakarta.security.jacc.PolicyConfigurationFactory.provider
- *
- *
- *
- * @return the singleton instance of the provider specific
- * PolicyConfigurationFactory implementation class.
- *
- * @throws SecurityException
- * when called by an AccessControlContext that has not been granted
- * the "getPolicy" SecurityPermission.
- *
- * @throws PolicyContextException
- * when the class named by the system property could not be found
- * including because the value of the system property has not been
- * set.
- */
-
- public static PolicyConfigurationFactory getPolicyConfigurationFactory()
- throws PolicyContextException {
- // Get TSLogger
- getTSLogger();
- if (pcFactory != null)
- return pcFactory;
- String classname = System.getProperty(FACTORY_NAME);
- if (classname == null) {
- lgr.severe("factory.name.notset");
- throw new PolicyContextException(
- "PolicyConfigurationFactory name not set!");
- }
- try {
- // Class clazz = Class.forName(classname);
- classLoader = TSPolicyConfigurationFactoryImpl.class.getClassLoader();
- Class clazz = classLoader.loadClass(classname);
- pcFactory = (PolicyConfigurationFactory) clazz.newInstance();
-
- if (pcFactory != null) {
- lgr.log(Level.INFO, "PolicyConfigurationFactory instantiated");
- }
- } catch (Exception e) {
- lgr.log(Level.SEVERE, "factory.instantiation.error", e);
- throw new PolicyContextException(e);
- }
- return pcFactory;
- }
-
- /**
- * This method determines if the identified policy context exists with state
- * "inService" in the Policy provider associated with the factory.
- *
- *
- * @param contextId
- * A string identifying a policy context
- *
- * @return true if the identified policy context exists within the provider
- * and its state is "inService", false otherwise.
- *
- * @throws java.lang.SecurityException
- * when called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the inService method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public boolean inService(String contextId) throws PolicyContextException {
- // check if we can invoke method
- if (lgr.isLoggable(Level.FINER)) {
- lgr.entering("PolicyConfigurationFactoryImpl", "inService");
- }
- lgr.log(Level.INFO, "PolicyConfigurationFactory.inService() invoked");
- lgr.log(Level.FINER,
- "PolicyConfiguration.inService() invoked for context id = "
- + contextId);
-
- // check if we can invoke method
- if (lgr.isLoggable(Level.FINER)) {
- lgr.entering("PolicyConfigurationFactoryImpl", "getPolicyConfiguration");
- }
-
- return pcFactory.inService(contextId);
- }
-
- public PolicyConfiguration getPolicyConfiguration(String contextID){
- if (lgr.isLoggable(Level.FINER)) {
- lgr.entering("PolicyConfigurationFactoryImpl", "getPolicyConfiguration(String)");
- }
- PolicyConfiguration polConf = pcFactory.getPolicyConfiguration(contextID);
- lgr.log(Level.INFO,
- "PolicyConfigurationFactory.getPolicyConfiguration(String) invoked");
- return polConf;
- }
-
- public PolicyConfiguration getPolicyConfiguration(){
- String contextId = PolicyContext.getContextID();
- PolicyConfiguration polConf = null;
- // check if we can invoke method
- if (lgr.isLoggable(Level.FINER)) {
- lgr.entering("PolicyConfigurationFactoryImpl", "getPolicyConfiguration()");
- }
- polConf = pcFactory.getPolicyConfiguration(contextId);
- lgr.log(Level.INFO,
- "PolicyConfigurationFactory.getPolicyConfiguration(String) invoked");
- lgr.log(Level.FINER,
- "Getting PolicyConfiguration object with id = " + contextId);
- policyConfiguration = (TSPolicyConfigurationImpl) polConf;
-
- return polConf;
- }
-
- private static void getTSLogger() {
- if (lgr != null)
- return;
- else {
- // TSLogger already intialized by TSPolicy,
- // get the instance of TSLogger from TSPolicy
- TSPolicy tsPolicy = (TSPolicy) java.security.Policy.getPolicy();
- lgr = tsPolicy.getTSLogger();
- }
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicyConfigurationImpl.java b/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicyConfigurationImpl.java
deleted file mode 100644
index 7384a76fb5..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSPolicyConfigurationImpl.java
+++ /dev/null
@@ -1,1004 +0,0 @@
-/*
- * Copyright (c) 2007, 2022 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- *
- * @author Raja Perumal
- */
-
-package com.sun.ts.tests.jacc.provider;
-
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Map;
-import java.util.Vector;
-import java.util.logging.Level;
-
-import jakarta.security.jacc.EJBMethodPermission;
-import jakarta.security.jacc.EJBRoleRefPermission;
-import jakarta.security.jacc.PolicyConfiguration;
-import jakarta.security.jacc.PolicyConfigurationFactory;
-import jakarta.security.jacc.PolicyContextException;
-import jakarta.security.jacc.WebResourcePermission;
-import jakarta.security.jacc.WebRoleRefPermission;
-import jakarta.security.jacc.WebUserDataPermission;
-
-/**
- * Jacc PolicyConfiguration delegates the policy configuration tasks to vendor's
- * PolicyConfiguration implementation class.
- *
- */
-public class TSPolicyConfigurationImpl implements PolicyConfiguration {
- private PolicyConfiguration policyConfiguration = null;
-
- private PolicyConfigurationFactory pcf = null;
-
- private static TSLogger logger = null;
-
- private String applicationContext = null;
-
- private String appTime = null;
-
- private Vector applicationLinkTable = new Vector();
-
- public TSPolicyConfigurationImpl(String contextId, boolean remove,
- TSLogger lgr) throws PolicyContextException {
- Date date = new Date();
- appTime = "" + date.getTime();
- logger = lgr;
-
- // Add timeStamp to the contextId,
- applicationContext = contextId;
-
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "TSPolicyConfigurationImpl");
- }
-
- // set vendor's PolicyConfigurationFactory
- pcf = TSPolicyConfigurationFactoryImpl.getPolicyConfigurationFactory();
-
- // **** This covers two assertions JACC:SPEC:33 and JACC:SPEC:56 ****
- // set vendor's PolicyConfiguration
- policyConfiguration = pcf.getPolicyConfiguration(contextId, remove);
-
- // This(appId record) will be used as an identifier
- // for isolating the logs associated with each test run.
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO,
- "appId :: " + stuffData(applicationContext) + " , " + appTime);
- }
-
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "TSPolicyConfigurationImpl");
- }
- }
-
- /**
- * This method returns this object's policy context identifier.
- *
- * @return this object's policy context identifier.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the getContextID method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public String getContextID() throws PolicyContextException {
-
- boolean bWasInservice = policyConfiguration.inService();
-
- String contextId = policyConfiguration.getContextID();
-
- // if the state was inService for our getContextID call, then it must remain
- // in that state as its next transitional state (per javadoc table)
- if (bWasInservice) {
- assertIsInserviceState("getContextID");
- } else {
- // state was not inService so make sure it is still NOT in the
- // inService state after calling policyConfiguration.getContextID()
- assertStateNotInservice("getContextID");
- }
-
- if (logger.isLoggable(Level.FINER)) {
- logger.log(Level.FINER, "contextId =" + contextId);
- }
- return contextId;
- }
-
- /**
- * Used to add permissions to a named role in this PolicyConfiguration. If the
- * named Role does not exist in the PolicyConfiguration, it is created as a
- * result of the call to this function.
- *
- * It is the job of the Policy provider to ensure that all the permissions
- * added to a role are granted to principals "mapped to the role".
- *
- *
- * @param roleName
- * the name of the Role to which the permissions are to be added.
- *
- * @param permissions
- * the collection of permissions to be added to the role. The
- * collection may be either a homogenous or heterogenous collection.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the addToRole method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public void addToRole(String roleName, PermissionCollection permissions)
- throws PolicyContextException {
- String permissionType = null;
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "addToRole");
- }
- if (roleName == null || permissions == null)
- return;
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.addToRole(roleName, permissions);
- assertStateNotInservice("addToRole");
-
- if (logger.isLoggable(Level.INFO)) {
- StringBuffer sbuf = new StringBuffer("");
- int bufLength = 0;
- for (Enumeration en = permissions.elements(); en.hasMoreElements();) {
- sbuf.append("addToRole :: ");
- sbuf.append(applicationContext + " , ");
- sbuf.append(appTime + " , ");
- Permission p = (Permission) en.nextElement();
-
- // Get the permission type,
- // valid permission types are
- // 1) WebResourcePermission
- // 2) WebUserDataPermission
- // 3) WebRoleRefPermission
- // 4) EJBMethodPermission
- // 5) EJBRoleRefPermission
- permissionType = getPermissionType(p);
- sbuf.append(permissionType + " , ");
- sbuf.append(p.getName() + " , ");
- sbuf.append(p.getActions());
- logger.log(Level.INFO, sbuf.toString());
- // Re-initialize string buffer.
- bufLength = sbuf.length();
- sbuf.delete(0, bufLength);
-
- if (permissionType.equals("WebResourcePermission")
- || permissionType.equals("WebRoleRefPermission")
- || permissionType.equals("EJBMethodPermission")
- || permissionType.equals("EJBRoleRefPermission")) {
- // logged so we can check roleNames and resourcePerms
- logger.log(Level.INFO, "MSG_TAG :: " + permissionType + " :: "
- + roleName + " :: " + applicationContext + " :: " + p.getName());
- } else {
- // logger.log(Level.INFO, "MSG_TAG :: nothing logged for " +
- // permissionType + " :: " + roleName + " :: " + applicationContext +
- // " :: " + p.getName());
- }
-
- }
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "addToRole");
- }
- }
-
- /**
- * Used to add a single permission to a named role in this
- * PolicyConfiguration. If the named Role does not exist in the
- * PolicyConfiguration, it is created as a result of the call to this
- * function.
- *
- * It is the job of the Policy provider to ensure that all the permissions
- * added to a role are granted to principals "mapped to the role".
- *
- *
- * @param roleName
- * the name of the Role to which the permission is to be added.
- *
- * @param permission
- * the permission to be added to the role.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the addToRole method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public void addToRole(String roleName, Permission permission)
- throws PolicyContextException {
- String permissionType = null;
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "addToRole");
- }
- if (roleName == null || permission == null)
- return;
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
-
- policyConfiguration.addToRole(roleName, permission);
- assertStateNotInservice("addToRole");
-
- // Get the permission type,
- // valid permission types are
- // 1) WebResourcePermission
- // 2) WebUserDataPermission
- // 3) WebRoleRefPermission
- // 4) EJBMethodPermission
- // 5) EJBRoleRefPermission
- permissionType = getPermissionType(permission);
- if (logger.isLoggable(Level.INFO)) {
- String sbuf = new String("addToRole :: " + applicationContext + " , "
- + appTime + " , " + permissionType + " , " + permission.getName()
- + " , " + permission.getActions());
- logger.log(Level.INFO, sbuf);
- }
-
- if (permissionType.equals("WebResourcePermission")
- || permissionType.equals("WebRoleRefPermission")
- || permissionType.equals("EJBMethodPermission")
- || permissionType.equals("EJBRoleRefPermission")) {
- // logged so we can check roleNames and resourcePerms
- logger.log(Level.INFO, "MSG_TAG :: " + permissionType + " :: " + roleName
- + " :: " + applicationContext + " :: " + permission.getName());
- } else {
- // logger.log(Level.INFO, "MSG_TAG :: nothing logged for " +
- // permissionType + " :: " + roleName + " :: " + applicationContext + " ::
- // " + permission.getName());
- }
-
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "addToRole");
- }
- }
-
- /**
- * Used to add unchecked policy statements to this PolicyConfiguration.
- *
- *
- * @param permissions
- * the collection of permissions to be added as unchecked policy
- * statements. The collection may be either a homogenous or
- * heterogenous collection.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the addToUncheckedPolicy method signature.
- * The exception thrown by the implementation class will be
- * encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
- public void addToUncheckedPolicy(PermissionCollection permissions)
- throws PolicyContextException {
- String permissionType = null;
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "addToUncheckedPolicy");
- }
- if (permissions == null)
- return;
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.addToUncheckedPolicy(permissions);
- assertStateNotInservice("addToUncheckedPolicy");
-
- if (logger.isLoggable(Level.INFO)) {
- StringBuffer sbuf = new StringBuffer("");
- int bufLength = 0;
-
- for (Enumeration en = permissions.elements(); en.hasMoreElements();) {
- sbuf.append("unchecked :: ");
- sbuf.append(applicationContext + " , ");
- sbuf.append(appTime + " , ");
-
- Permission p = (Permission) en.nextElement();
- // Get the permission type,
- // valid permission types are
- // 1) WebResourcePermission
- // 2) WebUserDataPermission
- // 3) WebRoleRefPermission
- // 4) EJBMethodPermission
- // 5) EJBRoleRefPermission
- permissionType = getPermissionType(p);
-
- sbuf.append(permissionType + " , ");
- sbuf.append(p.getName() + " , ");
- sbuf.append(p.getActions());
-
- logger.log(Level.INFO, sbuf.toString());
- // Re-initialize string buffer
- bufLength = sbuf.length();
- sbuf.delete(0, bufLength);
- }
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "addToUncheckedPolicy");
- }
- }
-
- /**
- * Used to add a single unchecked policy statement to this
- * PolicyConfiguration.
- *
- *
- * @param permission
- * the permission to be added to the unchecked policy statements.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the addToUncheckedPolicy method signature.
- * The exception thrown by the implementation class will be
- * encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
- public void addToUncheckedPolicy(Permission permission)
- throws PolicyContextException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "addToUncheckedPolicy");
- }
-
- if (permission == null)
- return;
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.addToUncheckedPolicy(permission);
- assertStateNotInservice("addToUncheckedPolicy");
-
- // Get the permission type,
- // valid permission types are
- // 1) WebResourcePermission
- // 2) WebUserDataPermission
- // 3) WebRoleRefPermission
- // 4) EJBMethodPermission
- // 5) EJBRoleRefPermission
- String permissionType = getPermissionType(permission);
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO,
- "unchecked :: " + applicationContext + " , " + appTime + " , "
- + permissionType + " , " + permission.getName() + " , "
- + permission.getActions());
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "addToUncheckedPolicy");
- }
- }
-
- /**
- * Used to add excluded policy statements to this PolicyConfiguration.
- *
- *
- * @param permissions
- * the collection of permissions to be added to the excluded policy
- * statements. The collection may be either a homogenous or
- * heterogenous collection.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the addToExcludedPolicy method signature.
- * The exception thrown by the implementation class will be
- * encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
- public void addToExcludedPolicy(PermissionCollection permissions)
- throws PolicyContextException {
- String permissionType = null;
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "addToExcludedPolicy");
- }
- if (permissions == null)
- return;
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.addToExcludedPolicy(permissions);
- assertStateNotInservice("addToExcludedPolicy");
-
- if (logger.isLoggable(Level.INFO)) {
- StringBuffer sbuf = new StringBuffer("");
- int bufLength = 0;
- for (Enumeration en = permissions.elements(); en.hasMoreElements();) {
- sbuf.append("excluded :: ");
- sbuf.append(applicationContext + " , ");
- sbuf.append(appTime + " , ");
- Permission p = (Permission) en.nextElement();
-
- // Get the permission type,
- // valid permission types are
- // 1) WebResourcePermission
- // 2) WebUserDataPermission
- // 3) WebRoleRefPermission
- // 4) EJBMethodPermission
- // 5) EJBRoleRefPermission
- permissionType = getPermissionType(p);
- sbuf.append(permissionType + " , ");
- sbuf.append(p.getName() + " , ");
- sbuf.append(p.getActions());
- logger.log(Level.INFO, sbuf.toString());
- // Re-initialize string buffer.
- bufLength = sbuf.length();
- sbuf.delete(0, bufLength);
- }
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "addToExcludedPolicy");
- }
- }
-
- /**
- * Used to add a single excluded policy statement to this PolicyConfiguration.
- *
- *
- * @param permission
- * the permission to be added to the excluded policy statements.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the addToExcludedPolicy method signature.
- * The exception thrown by the implementation class will be
- * encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
- public void addToExcludedPolicy(Permission permission)
- throws PolicyContextException {
- String permissionType = null;
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "addToExcludedPolicy");
- }
- if (permission == null)
- return;
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.addToExcludedPolicy(permission);
- assertStateNotInservice("addToExcludedPolicy");
-
- // Get the permission type,
- // valid permission types are
- // 1) WebResourcePermission
- // 2) WebUserDataPermission
- // 3) WebRoleRefPermission
- // 4) EJBMethodPermission
- // 5) EJBRoleRefPermission
- permissionType = getPermissionType(permission);
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO,
- "excluded :: " + applicationContext + " , " + appTime + " , "
- + permissionType + " , " + permission.getName() + " , "
- + permission.getActions());
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "addToExcludedPolicy");
- }
- }
-
- /**
- * Used to remove a role and all its permissions from this
- * PolicyConfiguration.
- *
- *
- * @param roleName
- * the name of the Role to remove from this PolicyConfiguration.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the removeRole method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public void removeRole(String roleName) throws PolicyContextException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "removeRole");
- }
- if (roleName == null)
- return;
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.removeRole(roleName);
- assertStateNotInservice("removeRole");
-
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "Removed Role :: " + roleName);
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "removeRole");
- }
- }
-
- /**
- * Used to remove any unchecked policy statements from this
- * PolicyConfiguration.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the removeUncheckedPolicy method signature.
- * The exception thrown by the implementation class will be
- * encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
- public void removeUncheckedPolicy() throws PolicyContextException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "removeUncheckedPolicy");
- }
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.removeUncheckedPolicy();
- assertStateNotInservice("removeUncheckedPolicy");
-
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "Removed all unchecked policy statements");
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "removeUncheckedPolicy");
- }
- }
-
- /**
- * Used to remove any excluded policy statements from this
- * PolicyConfiguration.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the removeExcludedPolicy method signature.
- * The exception thrown by the implementation class will be
- * encapsulated (during construction) in the thrown
- * PolicyContextException.
- */
- public void removeExcludedPolicy() throws PolicyContextException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "removeExcludedPolicy");
- }
-
- policyConfiguration = pcf.getPolicyConfiguration(applicationContext, false);
- policyConfiguration.removeExcludedPolicy();
- assertStateNotInservice("removeExcludedPolicy");
-
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "Removed all excluded policy statements");
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "removeExcludedPolicy");
- }
- }
-
- /**
- * This method is used to set to "inService" the state of the policy context
- * whose interface is this PolicyConfiguration Object. Only those policy
- * contexts whose state is "inService" will be included in the policy contexts
- * processed by the Policy.refresh method. A policy context whose state is
- * "inService" may be returned to the "open" state by calling the
- * getPolicyConfiguration method of the PolicyConfiguration factory with the
- * policy context identifier of the policy context.
- *
- * When the state of a policy context is "inService", calling any method other
- * than commit, delete, getContextID, or inService on its PolicyConfiguration
- * Object will cause an UnsupportedOperationException to be thrown.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" when this method is
- * called.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the commit method signature. The exception
- * thrown by the implementation class will be encapsulated (during
- * construction) in the thrown PolicyContextException.
- */
- public void commit() throws PolicyContextException {
- // Date date= new Date();
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "commit");
- }
-
- boolean bWasInservice = policyConfiguration.inService();
- policyConfiguration.commit();
-
- assertIsInserviceState("commit");
-
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "PolicyConfiguration.commit() called");
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "commit");
- }
- }
-
- /**
- * Creates a relationship between this configuration and another such that
- * they share the same principal-to-role mappings. PolicyConfigurations are
- * linked to apply a common principal-to-role mapping to multiple seperately
- * manageable PolicyConfigurations, as is required when an application is
- * composed of multiple modules.
- *
- * Note that the policy statements which comprise a role, or comprise the
- * excluded or unchecked policy collections in a PolicyConfiguration are
- * unaffected by the configuration being linked to another.
- *
- *
- * @param link
- * a reference to a different PolicyConfiguration than this
- * PolicyConfiguration.
- *
- * The relationship formed by this method is symetric, transitive and
- * idempotent. If the argument PolicyConfiguration does not have a
- * different Policy context identifier than this PolicyConfiguration
- * no relationship is formed, and an exception, as described below,
- * is thrown.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws java.lang.UnsupportedOperationException
- * if the state of the policy context whose interface is this
- * PolicyConfiguration Object is "deleted" or "inService" when this
- * method is called.
- *
- * @throws java.lang.IllegalArgumentException
- * if called with an argument PolicyConfiguration whose Policy
- * context is equivalent to that of this PolicyConfiguration.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the linkConfiguration method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public void linkConfiguration(PolicyConfiguration link)
- throws PolicyContextException {
- String contextId = null;
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "linkConfiguration");
- }
-
- if (link != null) {
- contextId = link.getContextID();
-
- // Check if the application name already exists
- if (applicationLinkTable != null) {
-
- // Now add the contextId that is being linked to applicationLinkTable
- if (!applicationLinkTable.contains(contextId)) {
- applicationLinkTable.add(contextId);
- }
-
- // Now add this.applicationContextId to applicationLinkTable
- if (!applicationLinkTable.contains(applicationContext)) {
- applicationLinkTable.add(applicationContext);
- }
- }
-
- if (logger.isLoggable(Level.INFO)) {
- StringBuffer sbuf = new StringBuffer("");
- int bufLength = 0;
- sbuf.append("link :: ");
- for (Enumeration appEnum = applicationLinkTable.elements(); appEnum
- .hasMoreElements();) {
- String stuffedAppName = stuffData((String) appEnum.nextElement());
- sbuf.append(stuffedAppName);
- if (appEnum.hasMoreElements())
- sbuf.append(",");
- }
- sbuf.append(" : ");
- sbuf.append(appTime);
-
- // Log all the linked application names
- logger.log(Level.INFO, sbuf.toString());
- }
- }
-
- // policyConfiguration.linkConfiguration(link);
- // Note:
- // The Passed varibale "link" may be an instance of
- // delegating Provider's PolicyConfiguration, so before
- // linking it with Vendor's PolicyConfiguration, first
- // get the vendor's equivalent PolicyConfiguration from "link"
-
- // get contextId from link
- String vendorContextId = link.getContextID();
-
- // get vendor's Policy configuration from "link"
- // Note: pcf is vendor's PolicyConfigurationFactory
- PolicyConfiguration vendorPC = pcf.getPolicyConfiguration(vendorContextId,
- false);
-
- // Now link the vendor's PolicyConfiguration
-
- boolean bWasInservice = policyConfiguration.inService();
- policyConfiguration.linkConfiguration(vendorPC);
-
- assertStateNotInservice("linkConfiguration");
-
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "linkConfiguration");
- }
- }
-
- /**
- * Causes all policy statements to be deleted from this PolicyConfiguration
- * and sets its internal state such that calling any method, other than
- * delete, getContextID, or inService on the PolicyConfiguration will be
- * rejected and cause an UnsupportedOperationException to be thrown.
- *
- * This operation has no affect on any linked PolicyConfigurations other than
- * removing any links involving the deleted PolicyConfiguration.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the delete method signature. The exception
- * thrown by the implementation class will be encapsulated (during
- * construction) in the thrown PolicyContextException.
- */
- public void delete() throws PolicyContextException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "delete");
- }
-
- policyConfiguration.delete();
- assertStateNotInservice("delete");
-
- if (logger.isLoggable(Level.INFO)) {
- logger.log(Level.INFO, "Deleted all policy statements");
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "delete");
- }
- }
-
- /**
- * This method is used to determine if the policy context whose interface is
- * this PolicyConfiguration Object is in the "inService" state.
- *
- * @return true if the state of the associated policy context is "inService";
- * false otherwise.
- *
- * @throws java.lang.SecurityException
- * if called by an AccessControlContext that has not been granted
- * the "setPolicy" SecurityPermission.
- *
- * @throws jakarta.security.jacc.PolicyContextException
- * if the implementation throws a checked exception that has not
- * been accounted for by the inService method signature. The
- * exception thrown by the implementation class will be encapsulated
- * (during construction) in the thrown PolicyContextException.
- */
- public boolean inService() throws PolicyContextException {
- if (logger.isLoggable(Level.FINER)) {
- logger.entering("TSPolicyConfigurationImpl", "inService");
- }
-
- boolean bWasInservice = policyConfiguration.inService();
-
- boolean ret = policyConfiguration.inService();
-
- // if the state was inService befor our policyConfiguration.inService()
- // call, then it must remain in that state as its next transitional
- // state (per javadoc table)
- if (bWasInservice) {
- assertIsInserviceState("inService");
- } else {
- // state was not inService so must've been OPEN or DELETED but
- // either way, the next state must remain the same so we know
- // we should NOT trasition to different state
- assertStateNotInservice("inService");
- }
-
- if (logger.isLoggable(Level.FINE)) {
- logger.log(Level.FINE, "PolicyConfiguration.inService() called");
- }
- if (logger.isLoggable(Level.FINER)) {
- logger.exiting("TSPolicyConfigurationImpl", "inService");
- }
- return ret;
- }
-
- public String getPermissionType(Permission permission) {
- if (permission instanceof WebResourcePermission)
- return "WebResourcePermission";
- else if (permission instanceof WebUserDataPermission)
- return "WebUserDataPermission";
- else if (permission instanceof WebRoleRefPermission)
- return "WebRoleRefPermission";
- else if (permission instanceof EJBMethodPermission)
- return "EJBMethodPermission";
- else if (permission instanceof EJBRoleRefPermission)
- return "EJBRoleRefPermission";
- else
- return null;
- }
-
- // This method process the input string and stuffs the character twice if
- // the processed character is not an alphabet
- public static String stuffData(String inputStr) {
-
- char[] outStr = new char[2048];
- char[] str = inputStr.toCharArray();
- for (int i = 0, j = 0; i < str.length; i++) {
- int a = (new Character(str[i])).getNumericValue(str[i]);
-
- // Don't stuff extra character if the character is an alphabet
- //
- // Numeric values for alphabets falls in 10 to 35, this includes
- // both upper and lower cases
- if ((a > 9) && (a < 36)) {
- outStr[j++] = str[i];
-
- } else { // stuff the character
- outStr[j++] = str[i];
- outStr[j++] = str[i];
- }
- }
- return ((new String(outStr)).trim());
- }
-
- public PermissionCollection getExcludedPermissions(){
- return policyConfiguration.getExcludedPermissions();
- }
-
- public PermissionCollection getUncheckedPermissions(){
- return policyConfiguration.getUncheckedPermissions();
- }
-
- public Map getPerRolePermissions(){
- return policyConfiguration.getPerRolePermissions();
- }
-
- private void assertIsInserviceState(String callingMethod) {
-
- try {
- if (!policyConfiguration.inService()) {
- String msg1 = "ERROR - our policy config should be in the INSERVICE state.";
- String msg2 = "In the wrong state after having called: "
- + callingMethod;
- debugOut(msg1);
- debugOut(msg2);
- logger.log(Level.SEVERE, msg1);
- }
- } catch (SecurityException ex) {
- String err = "ERROR - got securityException calling policyConfiguration.inService().";
- err += " You likely need to have 'setPolicy' grant set";
- debugOut(err);
- debugOut(ex.toString());
- } catch (Exception ex) {
- debugOut("ERROR - Exception calling policyConfiguration.inService(): "
- + ex.toString());
- ex.printStackTrace();
- }
- }
-
- private void assertStateNotInservice(String callingMethod) {
-
- try {
- if (policyConfiguration.inService()) {
- String msg1 = "ERROR - our policy config should not be in the INSERVICE state.";
- String msg2 = "In the wrong state after having called: "
- + callingMethod;
- debugOut(msg1);
- debugOut(msg2);
- logger.log(Level.SEVERE, msg1);
- }
- } catch (SecurityException ex) {
- String err = "ERROR - got securityException calling policyConfiguration.inService().";
- err += " You likely need to have 'setPolicy' grant set";
- debugOut(err);
- debugOut(ex.toString());
- } catch (Exception ex) {
- debugOut("ERROR - Exception calling policyConfiguration.inService(): "
- + ex.toString());
- ex.printStackTrace();
- }
- }
-
- private void debugOut(String str) {
- System.out.println(str);
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSXMLFormatter.java b/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSXMLFormatter.java
deleted file mode 100644
index 5f73b052db..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/provider/TSXMLFormatter.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/**
- * $Id$
- *
- * @author Raja Perumal
- * 07/13/02
- */
-
-package com.sun.ts.tests.jacc.provider;
-
-import java.util.ResourceBundle;
-import java.util.logging.Handler;
-import java.util.logging.Level;
-import java.util.logging.LogRecord;
-import java.util.logging.XMLFormatter;
-
-/**
- * TSXMLFormatter formats TSLogRecord in XML format.
- *
- */
-public class TSXMLFormatter extends XMLFormatter {
-
- private String contextId;
-
- /**
- * Override parent class format method
- *
- * @param lrecord
- * the LogRecord to be formatted.
- * @return a formatted log record
- */
- public String format(LogRecord lrecord) {
-
- String message = lrecord.getMessage();
- Level level = lrecord.getLevel();
- TSLogRecord record = new TSLogRecord(level, message);
-
- return format(record);
- }
-
- /**
- * Format the given message to XML.
- *
- * @param record
- * the log record to be formatted.
- * @return a formatted log record
- */
- public String format(TSLogRecord record) {
-
- // TSLogRecord record = (TSLogRecord)lrecord;
- StringBuffer sb = new StringBuffer(500);
- sb.append("\n");
-
- sb.append(" ");
- sb.append(record.getSequenceNumber());
- sb.append("\n");
-
- sb.append(" ");
- sb.append(record.getContextId());
- sb.append("\n");
-
- sb.append(" ");
- escape(sb, record.getLevel().toString());
- sb.append("\n");
-
- if (record.getSourceClassName() != null) {
- sb.append(" ");
- escape(sb, record.getSourceClassName());
- sb.append("\n");
- }
-
- if (record.getSourceMethodName() != null) {
- sb.append(" ");
- escape(sb, record.getSourceMethodName());
- sb.append("\n");
-
- }
-
- sb.append(" ");
- sb.append(record.getThreadID());
- sb.append("\n");
-
- if (record.getMessage() != null) {
- // Format the message string and its accompanying parameters.
- String message = formatMessage(record);
- sb.append(" ");
- escape(sb, message);
- sb.append("");
- sb.append("\n");
- }
-
- // If the message is being localized, output the key, resource
- // bundle name, and params.
- ResourceBundle bundle = record.getResourceBundle();
- try {
- if (bundle != null && bundle.getString(record.getMessage()) != null) {
- sb.append(" ");
- escape(sb, record.getMessage());
- sb.append("\n");
-
- sb.append(" ");
- escape(sb, record.getResourceBundleName());
- sb.append("\n");
-
- Object parameters[] = record.getParameters();
- for (int i = 0; i < parameters.length; i++) {
- sb.append(" ");
- try {
- escape(sb, parameters[i].toString());
- } catch (Exception ex) {
- sb.append("???");
- }
- sb.append("\n");
- }
- }
- } catch (Exception ex) {
- // The message is not in the catalog. Drop through.
- }
-
- if (record.getThrown() != null) {
- // Report on the state of the throwable.
- Throwable th = record.getThrown();
- sb.append(" \n");
- sb.append(" ");
- escape(sb, th.toString());
- sb.append("\n");
-
- StackTraceElement trace[] = th.getStackTrace();
- for (int i = 0; i < trace.length; i++) {
- StackTraceElement frame = trace[i];
- sb.append(" \n");
- sb.append(" ");
- escape(sb, frame.getClassName());
- sb.append("\n");
-
- sb.append(" ");
- escape(sb, frame.getMethodName());
- sb.append("\n");
-
- // Check for a line number.
- if (frame.getLineNumber() >= 0) {
- sb.append(" ");
- sb.append(frame.getLineNumber());
- sb.append("\n");
- }
- sb.append(" \n");
- }
- sb.append(" \n");
- }
-
- sb.append("\n");
- return sb.toString();
- }
-
- // Append to the given StringBuffer an escaped version of the
- // given text string where XML special characters have been escaped.
- // For a null string we appebd ""
- private void escape(StringBuffer sb, String text) {
- if (text == null) {
- text = "";
- }
-
- for (int i = 0; i < text.length(); i++) {
- char ch = text.charAt(i);
- if (ch == '<') {
- sb.append("<");
- } else if (ch == '>') {
- sb.append(">");
- } else if (ch == '&') {
- sb.append("&");
- } else {
- sb.append(ch);
- }
- }
- }
-
- /**
- * Return the header string for a set of XML formatted records.
- *
- * @param h
- * The target handler.
- * @return header string
- */
- public String getHead(Handler h) {
- StringBuffer sb = new StringBuffer();
- sb.append("\n");
- // sb.append("\n");
- sb.append("\n");
- return sb.toString();
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/AccessToAll.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/util/AccessToAll.jsp
deleted file mode 100644
index 032bded073..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/AccessToAll.jsp
+++ /dev/null
@@ -1,58 +0,0 @@
-<%--
-
- Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-
-
-<%@ page language="java" %>
-
-
- JSP with WildCard Auth Constraint
-
- JSP with WildCard Auth Constraint
-
- <%
-
- out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
- out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
- if (request.isUserInRole("ADM")){
- out.println("USR_IN_ROLE_ADM");
- }else
- out.println("USR_NOT_IN_ROLE_ADM");
-
- if (request.isUserInRole("MGR")){
- out.println("USR_IN_ROLE_MGR");
- }else
- out.println("USR_NOT_IN_ROLE_MGR");
-
- if (request.isUserInRole("EMP")){
- out.println("USR_IN_ROLE_EMP");
- }else
- out.println("USR_NOT_IN_ROLE_EMP");
-
- if (request.isUserInRole("VP")){
- out.println("USR_IN_ROLE_VP");
- }else
- out.println("USR_NOT_IN_ROLE_VP");
-
- %>
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/FetchLogClient.java b/jacc/src/main/java/com/sun/ts/tests/jacc/util/FetchLogClient.java
deleted file mode 100644
index 485d00c51b..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/FetchLogClient.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * @(#)FetchLogClient.java 1.4 03/05/16
- */
-
-package com.sun.ts.tests.jacc.util;
-
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.logging.FileHandler;
-import java.util.logging.Level;
-
-import com.sun.javatest.Status;
-import com.sun.ts.lib.harness.EETest;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.jacc.provider.TSLogger;
-import com.sun.ts.tests.jacc.provider.TSXMLFormatter;
-
-public class FetchLogClient extends EETest {
- private Properties props = null;
-
- private TSURL tsURL = new TSURL();
-
- private String webServerHost = "unknown";
-
- private int webServerPort = 8000;
-
- private String SERVLET = "/jaccRoot/FetchLogs";
-
- private String logFileLocation = null;
-
- public static void main(String args[]) {
- FetchLogClient theTests = new FetchLogClient();
- Status s = theTests.run(args, System.out, System.err);
- s.exit();
- }
-
- /**
- * @class.setup_props: log.file.location; webServerHost; webServerPort;
- *
- *
- */
- public void setup(String[] args, Properties p) throws Exception {
- props = p;
- boolean pass = true;
- try {
- logFileLocation = p.getProperty("log.file.location");
- if (logFileLocation == null)
- pass = false;
-
- webServerHost = p.getProperty("webServerHost");
- if (webServerHost == null)
- pass = false;
- else if (webServerHost.equals(""))
- pass = false;
-
- try {
- webServerPort = Integer.parseInt(p.getProperty("webServerPort"));
- } catch (Exception e) {
- TestUtil.printStackTrace(e);
-
- pass = false;
- }
-
- TestUtil.logMsg("webServerHost = " + webServerHost);
- TestUtil.logMsg("webServerPort = " + webServerPort);
- TestUtil.logMsg("log.file.location = " + logFileLocation);
-
- if (!pass) {
- TestUtil
- .logErr("Please specify web server host & port" + "in ts.jte file");
- throw new Exception("Setup Failed: WebServer host/port not set");
- }
- TestUtil.logMsg("Setup ok");
- } catch (Exception e) {
- throw new Exception("Setup Failed:", e);
- }
-
- }
-
- public void cleanup() throws Exception {
- }
-
- /**
- * testName: fetchLogClientTest
- *
- * @assertion: This is a sample test used for fetching log messages created by
- * TSlogger.
- */
- public void fetchLogClientTest() throws Exception {
-
- long seqNum = 0L;
- String contextId = null;
- Collection recordCollection = null;
- Properties props = null;
- URL url = null;
-
- try {
-
- // Create a tsLogger
- TSLogger tsLogger = TSLogger.getTSLogger("jacc");
- FileHandler tsFileHandler = new FileHandler(
- logFileLocation + "/jacc_log.txt");
- tsFileHandler.setFormatter(new TSXMLFormatter());
- tsLogger.addHandler(tsFileHandler);
-
- // create some log messages
- tsLogger.log(Level.INFO, "message-1", "jacc_ctx");
- tsLogger.log(Level.INFO, "message-2", "jacc_ctx");
- tsLogger.log(Level.INFO, "PolicyConfigurationFactory instantiated",
- "jacc_ctx");
- tsLogger.log(Level.INFO, "message-4", "new_ctx");
- tsLogger.log(Level.INFO, "message-5", "new_ctx");
-
- tsFileHandler.close();
-
- url = tsURL.getURL("http", webServerHost, webServerPort, SERVLET);
-
- props = new Properties();
- props.put("LogFilePath", logFileLocation + "/jacc_log.txt");
- props.put("LogQueryString", "findLogsByContextId");
- props.put("LogQueryParams", "jacc_ctx");
-
- HttpURLConnection conn = (HttpURLConnection) url.openConnection();
- conn.setDoOutput(true);
- conn.setDoInput(true);
- conn.setUseCaches(false);
- conn.setRequestProperty("Content-Type",
- "java-internal/" + props.getClass().getName());
-
- ObjectOutputStream oos = new ObjectOutputStream(conn.getOutputStream());
- oos.writeObject(props);
- oos.flush();
- oos.close();
-
- InputStream is = conn.getInputStream();
- ObjectInputStream ois = new ObjectInputStream(is);
-
- String header = (String) ois.readObject();
-
- // read the header information,
- //
- // if the header is equal to "RecordCollection header"
- // then the remaining data is a recordCollection object
- // else report log file processing failure.
- //
- if (header.equals("RecordCollection header")) {
- recordCollection = (Collection) ois.readObject();
-
- printCollection(recordCollection);
-
- } else {
- TestUtil.logErr("Log File processing failed");
- TestUtil.logErr("Log file does not exists in the server"
- + " or you don't have read permission for log file");
- TestUtil.logErr("Check permissions for log file ");
- TestUtil.logErr("See User guide for Configuring log file permissions");
- }
-
- ois.close();
-
- } catch (Exception e) {
- TestUtil.logErr(e.getMessage());
- TestUtil.printStackTrace(e);
- }
-
- }
-
- public void printCollection(Collection recordCollection) {
- RecordEntry recordEntry = null;
- Iterator iterator = recordCollection.iterator();
-
- while (iterator.hasNext()) {
- recordEntry = (RecordEntry) iterator.next();
- printRecordEntry(recordEntry);
- }
- }
-
- public void printRecordEntry(RecordEntry rec) {
- TestUtil.logMsg("*******Log Content*******");
- TestUtil.logMsg("seqence no =" + rec.getSequenceNumber());
- TestUtil.logMsg("ContextId =" + rec.getContextId());
- TestUtil.logMsg("Message =" + rec.getMessage());
- if (rec.getClassName() != null)
- TestUtil.logMsg("Class name =" + rec.getClassName());
- if (rec.getMethodName() != null)
- TestUtil.logMsg("Method name =" + rec.getMethodName());
- if (rec.getLevel() != null)
- TestUtil.logMsg("Level =" + rec.getLevel());
- if (rec.getThrown() != null)
- TestUtil.logMsg("Thrown =" + rec.getThrown());
- TestUtil.logMsg("");
-
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/FetchLogs.java b/jacc/src/main/java/com/sun/ts/tests/jacc/util/FetchLogs.java
deleted file mode 100644
index ba4450535e..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/FetchLogs.java
+++ /dev/null
@@ -1,747 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * @(#)FetchLogs.java 1.10 04/02/27
- */
-
-package com.sun.ts.tests.jacc.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.SequenceInputStream;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.servlet.ServletConfig;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.http.HttpServlet;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-
-/**
- *
- * @deprecated This class should not be used anymore and is here for historical
- * purposes.
- *
- * FetchLogs servlet is used for collecting logs from the server.
- *
- * FetchLogs servlet gets the logfile location from its input
- * parameters and locates the log file in the server, parses it and
- * extracts a subset of logs based on various parameters such as
- * "contextId" or "sequenceNumber" and builds Collection of logs of
- * type (RecordEntry) and returns the Collection
- *
- */
-public class FetchLogs extends HttpServlet {
- Collection recordCollection = new Vector();
-
- Collection appIdRecordCollection = new Vector();
-
- Collection linkRecordCollection = new Vector();
-
- Collection appSpecificRecordCollection = new Vector();
-
- public void init(ServletConfig config) throws ServletException {
- super.init(config);
- }
-
- public void doPost(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- doGet(request, response);
- }
-
- public void doGet(HttpServletRequest request, HttpServletResponse response)
- throws ServletException, IOException {
- Properties props = new Properties();
- File logfile = null;
-
- try {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder documentBuilder = documentBuilderFactory
- .newDocumentBuilder();
-
- OutputStream outStream = response.getOutputStream();
- ObjectOutputStream ostream = new ObjectOutputStream(outStream);
- String logFileLocation = request.getParameter("LogFilePath");
-
- if (logFileLocation != null)
- logfile = new File(logFileLocation);
-
- if ((logfile == null) || (!logfile.exists())) {
- String header = "Log file does not exists";
- ostream.writeObject(header);
-
- TestUtil.logErr("Log File : " + logFileLocation + " does not exists");
- TestUtil.logErr("Check permissions for log file ");
- TestUtil.logErr("See User guide for Configuring log file permissions");
- } else {
- // The generated log file jacc_log.txt is an ever growing
- // log file, since it is an ever growing log file,
- // there will not be any end tag at the end of the
- // log file.
- //
- // This will cause the SAXParser to throw fatal error message
- // "XML Document structures must start and end with the
- // same entity"
- //
- // In order to avoid this error message the FileInputStream
- // should have the end tag , this can be achieved by
- // creating a SequenceInputStream which includes a
- // FileInputStream and a ByteArrayInputStream, where the
- // ByteArrayInputStream contains the bytes for
- //
- String endLogTag = "";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- endLogTag.getBytes());
- SequenceInputStream sis = new SequenceInputStream(
- new FileInputStream(logFileLocation), bais);
-
- Document document = documentBuilder.parse(sis);
- Element rootElement = document.getDocumentElement();
- NodeList nodes = rootElement.getChildNodes();
-
- String queryString = request.getParameter("LogQueryString");
- String queryParams = request.getParameter("LogQueryParams");
- // TestUtil.logMsg("LogFilePath =" + logFileLocation);
- // TestUtil.logMsg("LogQueryString =" + queryString);
- // TestUtil.logMsg("LogQueryParams =" + queryParams);
-
- // Add a header to inform the client that the following
- // data is a recordCollection Object.
- ostream.writeObject(new String("RecordCollection header"));
-
- // Get appId records(appId records are records which identifies
- // the records with application name and time stamp ).
- //
- // for extracting appId records, process each record and
- // search whether the record starts with "appId" string.
- //
- // if the log records starts with "appId"
- // i.e if (log records starts with "appId") then
- // add the records to appIdRecordCollection
- // else if (log records starts with "link") then
- // add the records to linkRecordCollection
- // else
- // add the records to recordCollection
- //
- // Note: In the process of locating appId records
- // the remaining records are also processed and
- // stored as "linkRecordCollection" and
- // "recordCollection" based on the content of the records
- if (queryString.equals("getAppSpecificRecordCollection")) {
- // This call populates both appIdRecordCollection and
- // the rest of record collection
- appIdRecordCollection = getAppIdRecordCollection("appId", nodes);
- // printCollection(appIdRecordCollection);
-
- // write recordCollection
- ostream.writeObject(recordCollection);
- // printCollection(recordCollection);
-
- // Parse through all appId records and
- // find the current application name
- String applicationName = getCurrentApplicationName();
-
- // Parse all link records and find all the
- // applications that are linked to the current application
- Vector linkedApplicationNames = getLinkedApplicationNames();
-
- // Using the application names, isolate the
- // application specific logs from the rest of the logs
- Collection newAppSpecificRecordCollection = getAppSpecificRecordCollection(
- applicationName, linkedApplicationNames);
- // printCollection(newAppSpecificRecordCollection);
-
- // write applicaiton specific record Collection
- ostream.writeObject(newAppSpecificRecordCollection);
- } else {
- recordCollection = processLogs(queryString, queryParams, nodes);
- // write recordCollection
- ostream.writeObject(recordCollection);
- }
- // printCollection(appIdRecordCollection);
- // write appIdRecordCollection
- // ostream.writeObject(appIdRecordCollection);
- }
- ostream.flush();
- ostream.close();
- } catch (ParserConfigurationException pce) {
- TestUtil.logErr("PaserConfigurationException :" + pce.getMessage());
- TestUtil.printStackTrace(pce);
- throw new ServletException(pce.getMessage(), pce);
- } catch (SAXException se) {
- TestUtil.logErr("SAXException :" + se.getMessage());
- TestUtil.printStackTrace(se);
- throw new ServletException(se.getMessage(), se);
- } catch (IOException ioe) {
- TestUtil.logErr("IOException :" + ioe.getMessage());
- TestUtil.printStackTrace(ioe);
- ioe.printStackTrace();
- throw new ServletException("log file not found :" + ioe.getMessage(),
- ioe);
- } catch (SecurityException se) {
- TestUtil.logErr("SecurityException :" + se.getMessage());
- TestUtil.printStackTrace(se);
- se.printStackTrace();
- throw new ServletException(se.getMessage(), se);
- } catch (Exception e) {
- TestUtil.logErr("Exception :" + e.getMessage());
- TestUtil.printStackTrace(e);
- throw new ServletException(e.getMessage(), e);
- }
- }
-
- public Collection processLogs(String queryString, String queryParams,
- NodeList nodes) throws Exception {
- Collection recordCollection = null;
- if (queryString.equals("findLogsByContextId")) {
- recordCollection = findLogsByContextId(queryParams, nodes);
- } else if (queryString.equals("findLogsBySequenceNumber")) {
- recordCollection = findLogsBySequenceNumber(queryParams, nodes);
- } else if (queryString.equals("findLogsBySubStringMatch")) {
- recordCollection = findLogsBySubStringMatch(queryParams, nodes);
- } else if (queryString.equals("findLogsByPrefix")) {
- recordCollection = findLogsByPrefix(queryParams, nodes);
- } else if (queryString.equals("pullAllLogRecords")) {
- recordCollection = pullAllLogRecords(queryParams, nodes);
- } else {
- TestUtil.logErr("InCorrect query string :+queryString");
- throw new Exception("InCorrect query string :" + queryString);
- }
- return recordCollection;
- }
-
- /**
- * Locates the logs based on the given contextId
- */
- public Collection findLogsByContextId(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
-
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("contextId")) {
- nodeValue = getText(childNode);
- if (nodeValue.equals(queryParams)) {
- // create a new record entry and
- // add it to the collection
- RecordEntry recordEntry = new RecordEntry(recordNode);
- recordCollection.add(recordEntry);
- }
- }
- }
- }
- return recordCollection;
- }
-
- /**
- * Fetches all JACC specific server side logs from jacc_log.txt
- */
- public Collection pullAllLogRecords(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- // create a new record entry and
- // add it to the collection
- RecordEntry recordEntry = new RecordEntry(recordNode);
- recordCollection.add(recordEntry);
- }
- }
- return recordCollection;
- }
-
- /**
- * Locates the logs based on SubStringMatch
- */
- public Collection findLogsBySubStringMatch(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("message")) {
- nodeValue = getText(childNode);
- if (nodeValue.indexOf(queryParams) > 0) {
- // create a new record entry and
- // add it to the collection
- RecordEntry recordEntry = new RecordEntry(recordNode);
- recordCollection.add(recordEntry);
- }
- }
- }
- }
- return recordCollection;
- }
-
- /**
- * Locates the logs based on the given prefix string
- */
- public Collection findLogsByPrefix(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("message")) {
- nodeValue = getText(childNode);
- if (nodeValue.startsWith(queryParams)) {
- // create a new record entry that matches the
- // query criteria
- RecordEntry matchingRecordEntry = new RecordEntry(recordNode);
- recordCollection.add(matchingRecordEntry);
- }
- }
- }
- }
- return recordCollection;
- }
-
- /**
- * This method retrieves the appId records.
- *
- * i.e if (log records starts with "appId") then add the records to
- * appIdRecordCollection else add the records to recordCollection
- *
- * Note: In the process of locating appId records the remaining records are
- * also isolated and stored in a collection called "recordCollection"
- */
- public Collection getAppIdRecordCollection(String queryParams, NodeList nodes)
- throws Exception {
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("message")) {
- nodeValue = getText(childNode);
- if (nodeValue.startsWith(queryParams)) {
- // create a new record entry that matches the
- // query criteria i.e "appId"
- RecordEntry matchingRecordEntry = new RecordEntry(recordNode);
- this.appIdRecordCollection.add(matchingRecordEntry);
- } else if (nodeValue.startsWith("link")) {
- // create a new record entry for link records
- RecordEntry linkRecordEntry = new RecordEntry(recordNode);
- this.linkRecordCollection.add(linkRecordEntry);
- } else {
- // create a new record entry that do not
- // match the query criteria
- RecordEntry nonMatchingRecordEntry = new RecordEntry(recordNode);
- this.recordCollection.add(nonMatchingRecordEntry);
- }
- }
- }
- }
- return appIdRecordCollection;
- }
-
- /**
- * Locates logs based on the given sequenceNumber
- */
- public Collection findLogsBySequenceNumber(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
- int sequenceNumber = (new Integer(queryParams)).intValue();
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("sequence")) {
- nodeValue = getText(childNode);
- int nodeValueInInt = (new Integer(nodeValue)).intValue();
- if (nodeValueInInt == sequenceNumber) {
- // create a new record entry and
- // add it to the collection
- RecordEntry recordEntry = new RecordEntry(recordNode);
- recordCollection.add(recordEntry);
- }
- }
- }
- }
- return recordCollection;
- }
-
- public String getText(Node textNode) {
- String result = "";
- NodeList nodes = textNode.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- if (node.getNodeType() == Node.TEXT_NODE) {
- result = node.getNodeValue();
- break;
- }
- }
- return result;
- }
-
- public void printCollection(Collection recordCollection) {
- RecordEntry recordEntry = null;
- Iterator iterator = recordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (RecordEntry) iterator.next();
- printRecordEntry(recordEntry);
- }
- }
-
- public void printRecordEntry(RecordEntry rec) {
- System.out.println("*******Log Content*******");
- System.out.println("seqence no =" + rec.getSequenceNumber());
- System.out.println("ContextId =" + rec.getContextId());
- System.out.println("Message =" + rec.getMessage());
- if (rec.getClassName() != null)
- System.out.println("Class name =" + rec.getClassName());
- if (rec.getMethodName() != null)
- System.out.println("Method name =" + rec.getMethodName());
- if (rec.getLevel() != null)
- System.out.println("Level =" + rec.getLevel());
- if (rec.getThrown() != null)
- System.out.println("Thrown =" + rec.getThrown());
- System.out.println();
-
- }
-
- // This method returns the current application name by analysing
- // all the appId log records.
- //
- // The appId log record contains the Application name and the timeStamp
- // For example, let us examine the following 3 appId log records.
- //
- // appId :: MyApp , 1058312446598
- // appId :: App , 1058312463706
- // appId :: adminapp , 1058312480593
- //
- // In the above 3 appId records
- // a) the first field "appId :: " identifies this as a appId record
- // b) the second field indicates the application name
- // c) the third field refers to the timestamp at which the record was
- // created.
- //
- // By comparing the timestamps we can locate the latest of all appId records
- // and return the application name associated with it.
- public String getCurrentApplicationName() {
- RecordEntry recordEntry = null;
- String temp = null;
- String timeStampString = null;
- String appName = null;
- String prevAppName = null;
- long prevRecordTimeStamp = 0;
- long recordTimeStamp = 0;
- String[] tokenArray = new String[2];
-
- if (appIdRecordCollection == null) {
- TestUtil.logMsg("Record collection empty : No appId records found");
- return null;
- }
-
- Iterator iterator = appIdRecordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (RecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // Remove the string "appId :: " from the message
- temp = message.substring(9, message.length());
-
- // Get appName and timeStampString
- tokenArray = temp.split(" , ");
- appName = tokenArray[0];
- timeStampString = tokenArray[1];
-
- // now unstuff application name
- appName = unStuffData(appName);
-
- // TestUtil.logMsg("appName ="+appName);
- // TestUtil.logMsg("timeStampString ="+timeStampString);
-
- // Get long value from the string
- recordTimeStamp = (new Long(timeStampString)).longValue();
- if (recordTimeStamp < prevRecordTimeStamp) {
- recordTimeStamp = prevRecordTimeStamp;
- appName = prevAppName;
- }
- }
- return appName;
- }
-
- // This method returns the linked application names by analysing
- // all the link log records.
- //
- // The link log record contains the list of Application names
- // and the timeStamp.
- // For example, let us examine the following 2 link log records.
- //
- // link :: MyApp,SecondApp : 1058312446598
- // link :: App,SecondApp,ThirdApp : 1058312463706
- //
- // In the above 3 link records
- // a) the first field "link :: " identifies this as a link record
- // b) the second field indicates the application names that are
- // linked to.
- // Note: Linked application names are idenified using
- // the comma separator.
- // c) the last field indicates the timestamp at which the record was
- // created.
- //
- // By comparing the timestamps we can locate the latest link records
- // and return the application names linked to it.
- public Vector getLinkedApplicationNames() {
- RecordEntry recordEntry = null;
- String temp = null;
- String timeStampString = null;
- String appNames = null;
- String prevAppName = null;
- long prevRecordTimeStamp = 0;
- long recordTimeStamp = 0;
- String[] tokenArray = new String[2];
- Vector applicationNames = new Vector();
-
- if (linkRecordCollection == null) {
- TestUtil.logMsg("Record collection empty : No link records found");
- return null;
- }
-
- Iterator iterator = linkRecordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (RecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // Remove the string "link :: " from the message
- temp = message.substring(8, message.length());
-
- // Get appName and timeStampString
- tokenArray = temp.split(" : ");
- appNames = tokenArray[0];
- timeStampString = tokenArray[1];
-
- // now unstuff application name
- appNames = unStuffData(appNames);
-
- // Get long value from the string
- recordTimeStamp = (new Long(timeStampString)).longValue();
- if (recordTimeStamp < prevRecordTimeStamp) {
- recordTimeStamp = prevRecordTimeStamp;
- appNames = prevAppName;
- }
- }
-
- StringTokenizer strtoken;
-
- if (appNames != null) {
- // create a vector with applicationNames
- strtoken = new StringTokenizer(appNames, ",");
- if (appNames.indexOf(",") > 0) {
- // if the appNames string contains multiple applications
- // add all of them to the vector applicationNames
- while (strtoken.hasMoreTokens()) {
- applicationNames.add(strtoken.nextToken());
- }
- } else if (appNames != null) {
- // if the appNames string contains only one application
- // add it to the vector applicationNames
- applicationNames.add(appNames);
- }
- } else {
- // else return null
- return null;
- }
-
- return applicationNames;
- }
-
- /*
- * This method reads all non-appId records from the record collection and
- * isolates current appSpecific records from the rest using the given
- * applicationName and the linkedApplicationNames.
- */
- public Collection getAppSpecificRecordCollection(String applicationName,
- Vector linkedApplicationNames) {
- RecordEntry recordEntry = null;
-
- if (recordCollection == null) {
- TestUtil.logMsg("Record collection empty : No records found");
- return null;
- }
- Iterator iterator = this.recordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (RecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // if recordEntry contains the specified applicationName
- // Add the record to appSpecificRecordCollection
- if (message.indexOf(applicationName) > 0) {
- appSpecificRecordCollection.add(recordEntry);
- }
- }
-
- if (linkedApplicationNames != null) {
- // retrieve all the records associated with
- // linked applications.
- for (Enumeration appEnum = linkedApplicationNames.elements(); appEnum
- .hasMoreElements();) {
- applicationName = (String) appEnum.nextElement();
-
- iterator = this.recordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (RecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // if recordEntry contains the specified applicationName
- // Add the record to appSpecificRecordCollection
- if (message.indexOf(applicationName) > 0) {
- appSpecificRecordCollection.add(recordEntry);
- }
- }
-
- }
- }
- return appSpecificRecordCollection;
- }
-
- // This method tokenize the given string and
- // return first token and the remaining
- // string a string array based on the given delimeter
- public static String[] getTokens(String str, String delimeter) {
- String[] array = new String[2];
- StringTokenizer strtoken;
-
- // Get first token and the remaining string
- strtoken = new StringTokenizer(str, delimeter);
- if (str.indexOf(delimeter) > 0) {
- array[0] = strtoken.nextToken();
- array[1] = str.substring(array[0].length() + 3, str.length());
- }
- // TestUtil.logMsg("Input String ="+str);
- // TestUtil.logMsg("array[0] ="+array[0]);
- // TestUtil.logMsg("array[1] ="+array[1]);
- return array;
- }
-
- // This will remove the stuffed characters in the input string
- // Note: The non-alphabets in the input string was already stuffed by
- // the same character, this method unstuff those characters
- public static String unStuffData(String inputStr) {
- char[] outStr = new char[2048];
- char[] str = inputStr.toCharArray();
- for (int i = 0, j = 0; i < str.length;) {
-
- int a = (new Character(str[i])).getNumericValue(str[i]);
-
- // Don't stuff extra character if the character is an alphabet
- //
- // Numeric values for alphabets falls in 10 to 35, this includes
- // both upper and lower cases
- if ((a > 9) && (a < 36)) {
- outStr[j++] = str[i++];
- } else { // unstuff the character
- outStr[j++] = str[i++]; // just skip the next character
- // Remove only the stuffed characters not data separators
- if ((i + 1) < str.length) {
- if (str[i + 1] == str[i]) {
- // just skip the next character
- i++;
- }
- }
- i++;
- }
- }
-
- return ((new String(outStr)).trim());
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/LogFileProcessor.java b/jacc/src/main/java/com/sun/ts/tests/jacc/util/LogFileProcessor.java
deleted file mode 100644
index 35866e67ff..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/LogFileProcessor.java
+++ /dev/null
@@ -1,1447 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.SequenceInputStream;
-import java.security.Permission;
-import java.security.PermissionCollection;
-import java.security.Permissions;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.StringTokenizer;
-import java.util.Vector;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-import com.sun.ts.lib.util.TestUtil;
-
-import jakarta.security.jacc.EJBMethodPermission;
-import jakarta.security.jacc.EJBRoleRefPermission;
-import jakarta.security.jacc.WebResourcePermission;
-import jakarta.security.jacc.WebRoleRefPermission;
-import jakarta.security.jacc.WebUserDataPermission;
-
-/**
- *
- * @author Raja Perumal
- */
-/**
- * LogFileProcessor does the following operations
- *
- * 1) Fetches log records from JACCLog.txt
- *
- * 2) Checks for the existance of search string in the log for example to verify
- * whether server log contains a string "Java EE rocks" use the following code
- *
- * LogFileProcessor logProcessor = new LogFileProcessor(properties); boolean
- * contains = logProcessor.verifyLogContains("Java EE rocks");
- *
- * where "properties" contains the following key value pair 1) log.file.location
- *
- * 3) Prints the collection of log records.
- *
- */
-public class LogFileProcessor {
-
- private String logFileLocation = null;
-
- private Collection recordCollection = new Vector();
-
- private Collection appIdRecordCollection = new Vector();
-
- private Collection linkRecordCollection = new Vector();
-
- private Collection appSpecificRecordCollection = new Vector();
-
- private Permissions appSpecificUnCheckedPermissions = new Permissions();
-
- private Permissions appSpecificExcludedPermissions = new Permissions();
-
- private Permissions appSpecificAddToRolePermissions = new Permissions();
-
- public LogFileProcessor() {
- }
-
- public LogFileProcessor(Properties props) {
- setup(props);
- }
-
- /**
- * setup method
- */
- public void setup(Properties p) {
- boolean pass = true;
- try {
- if (p != null) {
- TestUtil
- .logMsg("setting logFileLocation based on passed in Properties");
- logFileLocation = p.getProperty("log.file.location");
- } else {
- TestUtil.logMsg(
- "setting logFileLocation based on passed in System.getProperty()");
- logFileLocation = System.getProperty("log.file.location");
- }
- if (logFileLocation == null) {
- pass = false;
- }
- TestUtil.logMsg("log.file.location = " + logFileLocation);
-
- if (!pass) {
- TestUtil.logErr("Setup Failed ");
- TestUtil.logErr("Please verify the following in ts.jte");
- TestUtil.logErr("log.file.location");
- }
- TestUtil.logMsg("Setup ok");
-
- } catch (Exception e) {
- TestUtil.logErr("Setup Failed ");
- TestUtil.logErr("Please verify the following in ts.jte");
- TestUtil.logErr("log.file.location");
- }
-
- }
-
- public Permissions getAppSpecificUnCheckedPermissions() {
- return appSpecificUnCheckedPermissions;
- }
-
- public Permissions getAppSpecificExcludedPermissions() {
- return appSpecificExcludedPermissions;
- }
-
- public Permissions getAppSpecificAddToRolePermissions() {
- return appSpecificAddToRolePermissions;
- }
-
- /*
- * This is convenience method for pulling out a list of permissions from
- * records that are identified with passed in that match all of the following:
- * - permission category (e.g. "excluded", "unchecked", "addToRole") -
- * permission type ("WebResourcePermission", etc) - with an appcontext that
- * contains the passed in appContext value. If you want a complete matching
- * appContext, then pass the whole thing in.
- */
- public Permissions getAppSpecificPermissions(String permCat, String permType,
- String appContext) {
- Permissions permsToReturn = new Permissions();
- LogRecordEntry recordEntry = null;
- Permission p = null;
-
- if (appSpecificRecordCollection == null) {
- return null;
- }
-
- Iterator iterator = appSpecificRecordCollection.iterator();
-
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- p = getPermissionFromRecordEntry(recordEntry, permCat, permType,
- appContext);
- if (p != null) {
- permsToReturn.add(p);
- }
- }
-
- // printPermissionCollection(permsToReturn);
- return permsToReturn;
- }
-
- public void fetchLogs(String accessMethod) {
- fetchLogs(accessMethod, null);
- }
-
- /**
- * FetchLogs pull logs from the server.
- *
- */
- public void fetchLogs(String accessMethod, String appName) {
-
- File logfile = null;
-
- try {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder documentBuilder = documentBuilderFactory
- .newDocumentBuilder();
-
- logFileLocation += "/JACCLog.txt";
-
- if (logFileLocation != null) {
- logfile = new File(logFileLocation);
- }
- if ((logfile == null) || (!logfile.exists())) {
- // String header = "Log file does not exists";
- // ostream.writeObject(header);
-
- System.out
- .println("Log File : " + logFileLocation + " does not exists");
- System.out.println("Check permissions for log file ");
- System.out
- .println("See User guide for Configuring log file permissions");
- } else {
- // LogRecords will be added to JACCLog.txt as long as the server is
- // up and running. Since TSSLog.txt is continuously updated with
- // more record there will not be any end tag at the end of the
- // log file.
- //
- // This will cause the SAXParser to throw fatal error message
- // "XML Document structures must start and end with the
- // same entity"
- //
- // In order to avoid this error message the FileInputStream
- // should have the end tag , this can be achieved by
- // creating a SequenceInputStream which includes a
- // FileInputStream and a ByteArrayInputStream, where the
- // ByteArrayInputStream contains the bytes for
- //
- String endLogTag = "";
- ByteArrayInputStream bais = new ByteArrayInputStream(
- endLogTag.getBytes());
- SequenceInputStream sis = new SequenceInputStream(
- new FileInputStream(logFileLocation), bais);
-
- Document document = documentBuilder.parse(sis);
- Element rootElement = document.getDocumentElement();
- NodeList nodes = rootElement.getChildNodes();
-
- String queryString = "pullAllRecords";
- String queryParams = "fullLog";
-
- StringTokenizer strtoken = new StringTokenizer(accessMethod, "|");
-
- if (accessMethod.indexOf("|") > 0) {
- queryString = strtoken.nextToken();
- queryParams = strtoken.nextToken();
- }
-
- if (queryString.equals("pullAllRecords")) {
- recordCollection = pullAllLogRecords(queryParams, nodes);
- // printCollection(recordCollection);
- } else if (queryString.equals("getAppSpecificRecordCollection")) {
-
- // Get appId records(appId records are records which identifies
- // the records with application name and time stamp ).
- //
- // for extracting appId records, process each record and
- // search whether the record starts with "appId" string.
- //
- // if the log records starts with "appId"
- // i.e if (log records starts with "appId") then
- // add the records to appIdRecordCollection
- // else if (log records starts with "link") then
- // add the records to linkRecordCollection
- // else
- // add the records to recordCollection
- //
- // Note: In the process of locating appId records
- // the remaining records are also processed and
- // stored as "linkRecordCollection" and
- // "recordCollection" based on the content of the records
-
- // This call populates both appIdRecordCollection and
- // the rest of record collection
- appIdRecordCollection = getAppIdRecordCollection("appId", nodes);
- // printCollection(appIdRecordCollection);
- // printCollection(recordCollection);
-
- // Parse through all appId records and
- // find the current application name
- String applicationName = null;
- if (appName == null) {
- applicationName = getCurrentApplicationName();
- } else {
- applicationName = getCurrentApplicationName(appName);
- }
-
- // Parse all link records and find all the
- // applications that are linked to the current application
- Vector linkedApplicationNames = getLinkedApplicationNames();
-
- // Using the application names, isolate the
- // application specific logs from the rest of the logs
- Collection newAppSpecificRecordCollection = getAppSpecificRecordCollection(
- applicationName, linkedApplicationNames);
- // printCollection(newAppSpecificRecordCollection);
-
- }
-
- // From the record collection read all the records
- // and construct list of Permissions such as
- //
- // 1) appSpecificUnCheckedPermissions
- // 2) appSpecificExcludedPermissions
- // 3) appSpecificAddToRolePermissions
- //
- // Where "appSpecificUnCheckedPermissions" contains all the
- // application specific unchecked permission collection.
- //
- // "appSpecificExcludedPermissions" contains all the
- // application specific excluded permission collection.
- //
- // "appSpecificAddToRolePermissions" contains all the
- // application specific add to role permission collection.
- //
- getPermissionCollection();
- }
-
- } catch (Exception e) {
- TestUtil.logErr(e.getMessage());
- TestUtil.printStackTrace(e);
- e.printStackTrace();
- }
-
- }
-
- public PermissionCollection getPermissionCollection() {
- PermissionCollection pColl = new Permissions();
- LogRecordEntry recordEntry = null;
- Permission p = null;
-
- if (appSpecificRecordCollection == null) {
- return null;
- }
- Iterator iterator = appSpecificRecordCollection.iterator();
-
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- p = getPermissionFromRecordEntry(recordEntry);
- if (p != null) {
- pColl.add(p);
- }
- }
- // printPermissionCollection(pColl);
- return pColl;
- }
-
- // Parse record entry and extract permissions from the following
- // type of log records "unchecked", "excluded" and "addToRole"
- //
- // unchecked :: appName , 1058323788497 , EJBMethodPermission , MEJBBean ,
- // getMBeanCount,Remote
- // addToRole :: appName3 , 1058323977373 , WebResourcePermission ,
- // /secured.jsp , GET,POST
- // excluded :: appName2 , 1058323977373 , WebUserDataPermission ,
- // /excluded.jsp , GET,POST
- //
- // In the above records
- //
- // 1) First field identifies the category of record
- // 2) second field identifies the application name
- // 3) thrid field identifies the timestamp in which
- // the record was created.
- // 4) fourth field identifies the Permission type such as
- // a) WebResourcePermission b) WebRoleRefPermission
- // c) WebUserDataPermission d) EJBMehodPermission
- // e) EJBRoleRefPermission
- // 5) fifth field identifies the permission name
- // 6) sixth field identifies the permission action.
- //
- public Permission getPermissionFromRecordEntry(LogRecordEntry recordEntry) {
-
- String permissionCategory = null;
- String applicationContext = null;
- String temp = null;
- String message = null;
- String permissionType = null;
- String permissionName = null;
- String permissionAction = null;
- String permissionNameAndAction = null;
- String applicationTimeStamp = null;
- String[] tokenArray = new String[2];
- StringTokenizer permCategoryToken = null;
- StringTokenizer strtok = null;
- boolean isUnChecked = false;
- boolean isExcluded = false;
- boolean isAddToRole = false;
-
- Permission p = null;
-
- if (recordEntry != null) {
- message = recordEntry.getMessage();
- // Get permission category
- // i.e "unchecked, excluded or addTorole"
- permCategoryToken = new StringTokenizer(message, " :: ");
- if (message.indexOf(" :: ") > 0) {
- permissionCategory = permCategoryToken.nextToken();
- temp = message.substring(permissionCategory.length() + 4,
- message.length());
- }
- // TestUtil.logMsg("PermissionCategory ="+permissionCategory);
-
- if (permissionCategory != null) {
- if (permissionCategory.equals("unchecked")) {
- isUnChecked = true;
- } else if (permissionCategory.equals("excluded")) {
- isExcluded = true;
- } else if (permissionCategory.equals("addToRole")) {
- isAddToRole = true;
- }
- }
-
- // i.e Proceed only if the permission Category is one of the following
- // a) unchecked
- // b) excluded
- // c) addToRole
- // else return null
- if (isUnChecked || isExcluded || isAddToRole) {
- // Get ApplicationContext
- tokenArray = getTokens(temp, " , ");
- applicationContext = tokenArray[0];
- temp = tokenArray[1];
- TestUtil.logTrace("Application Context =" + applicationContext);
-
- // Get Application time stamp
- tokenArray = getTokens(temp, " , ");
- applicationTimeStamp = tokenArray[0];
- temp = tokenArray[1];
- TestUtil.logTrace("Application Time stamp =" + applicationTimeStamp);
-
- // Get permission Type
- tokenArray = getTokens(temp, " , ");
- permissionType = tokenArray[0];
- permissionNameAndAction = tokenArray[1];
- TestUtil.logTrace("PermissionType =" + permissionType);
-
- // extract permission name and action
- tokenArray = getTokens(permissionNameAndAction, " , ");
- permissionName = tokenArray[0];
- permissionAction = tokenArray[1];
- TestUtil.logTrace("permissionName = " + permissionName);
- TestUtil.logTrace("permissionAction = " + permissionAction);
-
- // Change string "null" to just null
- // i.e "null" --> null
- if (permissionAction.equals("null")) {
- permissionAction = null; // Construct permissions based on their
- // permission type
- }
- if (permissionType.equals("WebResourcePermission")) {
- p = new WebResourcePermission(permissionName, permissionAction);
- } else if (permissionType.equals("WebRoleRefPermission")) {
- p = new WebRoleRefPermission(permissionName, permissionAction);
- } else if (permissionType.equals("WebUserDataPermission")) {
- p = new WebUserDataPermission(permissionName, permissionAction);
- } else if (permissionType.equals("EJBMethodPermission")) {
- p = new EJBMethodPermission(permissionName, permissionAction);
- } else if (permissionType.equals("EJBRoleRefPermission")) {
- p = new EJBRoleRefPermission(permissionName, permissionAction); // Add
- // permissions
- // to
- // their
- // corresponding
- // permission
- // collection
- // based on their permission category type
- }
- if (isUnChecked) {
- appSpecificUnCheckedPermissions.add(p);
- } else if (isExcluded) {
- appSpecificExcludedPermissions.add(p);
- } else if (isAddToRole) {
- appSpecificAddToRolePermissions.add(p);
-
- }
- }
- }
-
- return p;
- }
-
- public Permission getPermissionFromRecordEntry(LogRecordEntry recordEntry,
- String permCat, String permType, String appContext) {
- String permissionCategory = null;
- String applicationContext = null;
- String temp = null;
- String message = null;
- String permissionType = null;
- String permissionName = null;
- String permissionAction = null;
- String permissionNameAndAction = null;
- String applicationTimeStamp = null;
- String[] tokenArray = new String[2];
- StringTokenizer permCategoryToken = null;
-
- Permission p = null;
-
- if (recordEntry != null) {
- message = recordEntry.getMessage();
- // Get permission category
- // i.e "unchecked, excluded or addToRole"
- permCategoryToken = new StringTokenizer(message, " :: ");
- if (message.indexOf(" :: ") > 0) {
- permissionCategory = permCategoryToken.nextToken();
- temp = message.substring(permissionCategory.length() + 4,
- message.length());
- }
-
- if ((permissionCategory == null)
- || (!permissionCategory.equals(permCat))) {
- TestUtil.logTrace(permissionCategory + " != " + permCat);
- return null;
- }
- TestUtil.logTrace(permissionCategory + " == " + permCat);
-
- // Get ApplicationContext
- tokenArray = getTokens(temp, " , ");
- applicationContext = tokenArray[0];
- temp = tokenArray[1];
- if (!applicationContext.contains(appContext)) {
- TestUtil.logTrace(applicationContext + " != " + appContext);
- return null;
- }
- TestUtil.logTrace("applicationContext =" + applicationContext);
-
- // Get Application time stamp
- tokenArray = getTokens(temp, " , ");
- applicationTimeStamp = tokenArray[0];
- temp = tokenArray[1];
- TestUtil.logTrace("Application Time stamp =" + applicationTimeStamp);
-
- // Get permission Type
- tokenArray = getTokens(temp, " , ");
- permissionType = tokenArray[0];
- permissionNameAndAction = tokenArray[1];
- TestUtil.logTrace("PermissionType =" + permissionType);
-
- // extract permission name and action
- tokenArray = getTokens(permissionNameAndAction, " , ");
- permissionName = tokenArray[0];
- permissionAction = tokenArray[1];
- TestUtil.logTrace("permissionName = " + permissionName);
- TestUtil.logTrace("permissionAction = " + permissionAction);
-
- if (permissionAction.equals("null")) {
- permissionAction = null; // Construct permissions based on their
- // permission type
- }
-
- if (!permissionType.equals(permType)) {
- return null;
- }
-
- if (permissionType.equals("WebResourcePermission")) {
- p = new WebResourcePermission(permissionName, permissionAction);
- } else if (permissionType.equals("WebRoleRefPermission")) {
- p = new WebRoleRefPermission(permissionName, permissionAction);
- } else if (permissionType.equals("WebUserDataPermission")) {
- p = new WebUserDataPermission(permissionName, permissionAction);
- } else if (permissionType.equals("EJBMethodPermission")) {
- p = new EJBMethodPermission(permissionName, permissionAction);
- } else if (permissionType.equals("EJBRoleRefPermission")) {
- p = new EJBRoleRefPermission(permissionName, permissionAction);
- }
- }
-
- return p;
- }
-
- public Permissions getSpecificPermissions(Permissions suppliedPermCollection,
- String permissionType) {
- Permission p = null;
- Permissions expectedPermissionCollection = new Permissions();
-
- if (permissionType.equals("WebResourcePermission")) {
- for (Enumeration en = suppliedPermCollection.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
- if (p instanceof WebResourcePermission) {
- expectedPermissionCollection.add(p);
- }
- }
- } else if (permissionType.equals("WebUserDataPermission")) {
- for (Enumeration en = suppliedPermCollection.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
-
- if (p instanceof WebUserDataPermission) {
- expectedPermissionCollection.add(p);
- }
- }
- } else if (permissionType.equals("WebRoleRefPermission")) {
- for (Enumeration en = suppliedPermCollection.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
- if (p instanceof WebRoleRefPermission) {
- expectedPermissionCollection.add(p);
- }
- }
- } else if (permissionType.equals("EJBMethodPermission")) {
- for (Enumeration en = suppliedPermCollection.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
- if (p instanceof EJBMethodPermission) {
- expectedPermissionCollection.add(p);
- }
- }
- } else if (permissionType.equals("EJBRoleRefPermission")) {
- for (Enumeration en = suppliedPermCollection.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
- if (p instanceof EJBRoleRefPermission) {
- expectedPermissionCollection.add(p);
- }
- }
- }
- return expectedPermissionCollection;
- }
-
- /**
- * Fetches all JSR196 SPI logs from JACCLog.txt
- */
- public static Collection pullAllLogRecords(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- Node recordNode;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
-
- if (recordNode.getNodeName().equals("record")) {
- LogRecordEntry recordEntry = new LogRecordEntry(recordNode);
- recordCollection.add(recordEntry);
-
- }
- }
- return recordCollection;
- }
-
- public void setAppIdRecordCollection(Collection recordCollection) {
- this.appIdRecordCollection = recordCollection;
- }
-
- public Collection getAppIdRecordCollection() {
- return this.appIdRecordCollection;
- }
-
- public void setRecordCollection(Collection recordCollection) {
- this.recordCollection = recordCollection;
- }
-
- public Collection getRecordCollection() {
- return this.recordCollection;
- }
-
- public void setAppSpecificRecordCollection(Collection recordCollection) {
- this.appSpecificRecordCollection = recordCollection;
- }
-
- public Collection getAppSpecificRecordCollection() {
- return this.appSpecificRecordCollection;
- }
-
- /**
- * Checks for the existance of search string in the log. For example to verify
- * whether server log contains a string "Java EE rocks" use the following code
- *
- * LogFileProcessor logProcessor = new LogFileProcessor(properties); boolean
- * contains = logProcessor.verifyLogContains("Java EE rocks");
- *
- * where "properties" contains the key value pair for 1) log.file.location
- */
- public boolean verifyLogContains(String args[]) {
- LogRecordEntry recordEntry = null;
- TestUtil.logMsg("Searching log records for record :" + args[0]);
- if (recordCollection == null) {
- TestUtil.logMsg("Record collection empty : No log records found");
- return false;
- } else {
- TestUtil.logMsg(
- "Record collection has: " + recordCollection.size() + " records.");
- }
-
- int numberOfArgs = args.length;
- int numberOfMatches = 0;
-
- boolean argsMatchIndex[] = new boolean[args.length];
- for (int i = 0; i < args.length; i++) {
- // initialize all argsMatchIndex to "false" (i.e no match)
- argsMatchIndex[i] = false;
-
- // From the given string array(args) if there is a record match
- // for the search string, then the corresponding argsMatchIndex[i]
- // will be set to true(to indicate a match)
- // i.e argsMatchIndex[i] = true;
- //
- // For example if the string array contains
- // String args[]={"JK", "EMERSON", "J.B.Shaw};
- //
- // And if the string "JK" and "J.B.Shaw" are found in the records
- // then the argsMatchIndex will be set as shown below
- // argsMatchIndex[] ={true, false, true};
- //
- }
-
- Iterator iterator = recordCollection.iterator();
- while (iterator.hasNext()) {
- // loop thru all message tag/entries in the log file
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
- // loop through all arguments to search for a match
- for (int i = 0; i < numberOfArgs; i++) {
-
- // Search only unique record matches ignore repeat occurances
- if (argsMatchIndex[i] != true) {
- // see if one of the search argument matches with
- // the logfile message entry and if so return true
- if ((message != null) && message.equals(args[i])) {
- TestUtil.logMsg("Matching Record :");
- TestUtil.logMsg(recordEntry.getMessage());
-
- // Increment match count
- numberOfMatches++;
-
- // Mark the matches in argsMatchIndex
- argsMatchIndex[i] = true;
-
- continue;
- }
- }
-
- }
-
- // Return true if, we found matches for all strings
- // in the given string array
- if (numberOfMatches == numberOfArgs) {
- return true;
- }
- }
-
- // Print unmatched Strings(i.e no matches were found for these strings)
- TestUtil.logMsg(
- "No Matching log Record(s) found for the following String(s) :");
- for (int i = 0; i < numberOfArgs; i++) {
- if (argsMatchIndex[i] == false) {
- TestUtil.logMsg(args[i]);
- }
- }
-
- return false;
- }
-
- /**
- * Checks for the existance of one of the search string(from a given String
- * array.
- *
- * For example to verify whether server log contains one of the following
- * String String[] arr ={"aaa", "bbb", "ccc"};
- *
- * LogFileProcessor logProcessor = new LogFileProcessor(properties); boolean
- * contains = logProcessor.verifyLogContainsOneOf(arr);
- *
- * This method will return true if the log file contains one of the specified
- * String (say "aaa" )
- *
- * where "properties" contains the key value pair for 1) log.file.location
- */
- public boolean verifyLogContainsOneOf(String args[]) {
- LogRecordEntry recordEntry = null;
- boolean result = false;
-
- TestUtil
- .logMsg("Searching log records for the presence of one of the String"
- + " from a given string array");
- if (recordCollection == null) {
- TestUtil.logMsg("Record collection empty : No log records found");
- return false;
- } else {
- TestUtil.logMsg(
- "Record collection has: " + recordCollection.size() + " records.");
- }
-
- int numberOfArgs = args.length;
-
- Iterator iterator = recordCollection.iterator();
- searchLabel: while (iterator.hasNext()) {
- // loop thru all message tag/entries in the log file
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
- // loop through all arguments to search for a match
- for (int i = 0; i < numberOfArgs; i++) {
-
- // see if one of the search argument matches with
- // the logfile message entry and if so return true
- if ((message != null) && message.equals(args[i])) {
- TestUtil.logMsg("Matching Record :");
- TestUtil.logMsg(recordEntry.getMessage());
- result = true;
-
- // If a match is found no need to search further
- break searchLabel;
- }
- }
-
- }
-
- if (!result) {
- // Print unmatched Strings(i.e no matches were found for these strings)
- TestUtil.logMsg(
- "No Matching log Record(s) found for the following String(s) :");
- for (int i = 0; i < numberOfArgs; i++) {
- TestUtil.logMsg(args[i]);
- }
- }
-
- return result;
- }
-
- /**
- * This method looks for the presence of the given substring (from the array
- * of strings "args") in the serverlog, which starts with the given
- * "srchStrPrefix" search-string-prefix.
- *
- *
- * For example to verify whether server log contains one of the following
- * Strings in a server log with appContextId as the message prefix we can
- * issue the following command
- *
- * String[] arr ={"aaa", "bbb", "ccc"}; String srchStrPrefix ="appContextId";
- *
- * LogFileProcessor logProcessor = new LogFileProcessor(properties); boolean
- * contains = logProcessor.verifyLogContainsOneOf(arr);
- *
- * "appContextId= xxxx aaa yyyyyyyyyyyyyyyyy" "appContextId= yyyy bbb
- * xxxxxxxxxxxxxxxxx"
- *
- * This method will return true if the log file contains one of the specified
- * String (say "aaa" ) in the message log with "appContextId" as its message
- * prefix.
- *
- * where "properties" contains the key value pair for 1) log.file.location
- */
- public boolean verifyLogContainsOneOfSubString(String args[],
- String srchStrPrefix) {
- LogRecordEntry recordEntry = null;
- boolean result = false;
-
- TestUtil
- .logMsg("Searching log records for the presence of one of the String"
- + " from a given string array");
- if (recordCollection == null) {
- TestUtil.logMsg("Record collection empty : No log records found");
- return false;
- } else {
- TestUtil.logMsg(
- "Record collection has: " + recordCollection.size() + " records.");
- }
-
- int numberOfArgs = args.length;
-
- Iterator iterator = recordCollection.iterator();
- searchLabel: while (iterator.hasNext()) {
- // loop thru all message tag/entries in the log file
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
- // loop through all arguments to search for a match
- for (int i = 0; i < numberOfArgs; i++) {
-
- // see if one of the search argument matches with
- // the logfile message entry and if so return true
- if ((message != null) && (message.startsWith(srchStrPrefix, 0))
- && (message.indexOf(args[i]) > 0)) {
- TestUtil.logMsg("Matching Record :");
- TestUtil.logMsg(recordEntry.getMessage());
- result = true;
-
- // If a match is found no need to search further
- break searchLabel;
- }
- }
-
- }
-
- if (!result) {
- // Print unmatched Strings(i.e no matches were found for these strings)
- TestUtil.logMsg(
- "No Matching log Record(s) found for the following String(s) :");
- for (int i = 0; i < numberOfArgs; i++) {
- TestUtil.logMsg(args[i]);
- }
- }
-
- return result;
- }
-
- /**
- * verifyLogImplies() takes the individual expectedPermissions and and checks
- * whether the generatedPermissions.implies() is true.
- */
- public boolean verifyLogImplies(Permissions expectedPermissions,
- Permissions generatedPermissions) {
- boolean verified = false;
- Permission p;
-
- for (Enumeration en = expectedPermissions.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
-
- verified = generatedPermissions.implies(p);
- if (!verified) {
- TestUtil.logErr(
- "The following permission doesn't match with server generated Permissions");
- TestUtil.logErr("permissionName = " + p.getName());
- TestUtil.logErr("permissionAction = " + p.getActions());
-
- TestUtil.logErr("\n\n");
- TestUtil.logErr("Print Expected Permissions :");
- printPermissions(expectedPermissions);
- TestUtil.logErr("\n\n");
- TestUtil.logErr("Print Generated Permissions :");
- printPermissions(generatedPermissions);
- return false;
- }
- }
-
- // following code compares each generatedPermission with
- // expectedPermissionCollection and lists the extra permissions
- for (Enumeration en = generatedPermissions.elements(); en
- .hasMoreElements();) {
- p = (Permission) en.nextElement();
- verified = expectedPermissions.implies(p);
- if (!verified) {
- TestUtil.logMsg(
- "The following server generated permission doesn't match with the expected Permissions");
- TestUtil.logMsg("permissionName = " + p.getName());
- TestUtil.logMsg("permissionAction = " + p.getActions());
- }
- }
-
- return true;
- }
-
- public void printCollection(Collection recordCollection) {
- LogRecordEntry recordEntry = null;
- Iterator iterator = recordCollection.iterator();
-
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- printRecordEntry(recordEntry);
- }
- }
-
- // Print heterogeneous collection of permissions
- public void printPermissions(Permissions perms) {
- int count = 0;
- for (Enumeration en = perms.elements(); en.hasMoreElements();) {
- count++;
- Permission p = (Permission) en.nextElement();
- TestUtil.logMsg("-------------");
- TestUtil.logMsg(count + ") permissionType = " + p.getClass().getName());
- TestUtil.logMsg(count + ") permissionName = " + p.getName());
- TestUtil.logMsg(count + ") permissionAction = " + p.getActions());
- }
-
- }
-
- public void printPermissionCollection(PermissionCollection permCollection) {
- String permissionType = null;
- int count = 0;
-
- for (Enumeration en = permCollection.elements(); en.hasMoreElements();) {
- count++;
-
- Permission p = (Permission) en.nextElement();
- if (p instanceof WebResourcePermission) {
- permissionType = "WebResourcePermission";
- } else if (p instanceof WebUserDataPermission) {
- permissionType = "WebUserDataPermission";
- } else if (p instanceof WebRoleRefPermission) {
- permissionType = "WebRoleRefPermission";
- } else if (p instanceof EJBMethodPermission) {
- permissionType = "EJBMethodPermission";
- } else if (p instanceof EJBRoleRefPermission) {
- permissionType = "EJBRoleRefPermission";
- }
- TestUtil.logMsg("-------------");
- TestUtil.logMsg(count + ") permissionType = " + permissionType);
- TestUtil.logMsg(count + ") permissionName = " + p.getName());
- TestUtil.logMsg(count + ") permissionAction = " + p.getActions());
- }
- }
-
- public void printRecordEntry(LogRecordEntry rec) {
- TestUtil.logMsg("*******Log Content*******");
-
- TestUtil.logMsg("Milli Seconds =" + rec.getMilliSeconds());
- TestUtil.logMsg("Seqence no =" + rec.getSequenceNumber());
- TestUtil.logMsg("Message =" + rec.getMessage());
- if (rec.getClassName() != null) {
- TestUtil.logMsg("Class name =" + rec.getClassName());
- }
- if (rec.getMethodName() != null) {
- TestUtil.logMsg("Method name =" + rec.getMethodName());
- }
- if (rec.getLevel() != null) {
- TestUtil.logMsg("Level =" + rec.getLevel());
- }
- if (rec.getThrown() != null) {
- TestUtil.logMsg("Thrown =" + rec.getThrown());
- }
- TestUtil.logMsg("");
- }
-
- public String extractQueryToken(String str, String ContextId) {
- StringTokenizer strtok;
- String DELIMETER = "|";
- String qstring = null;
- String qparams = null;
-
- strtok = new StringTokenizer(ContextId, DELIMETER);
- if (ContextId.indexOf(DELIMETER) > 0) {
- qstring = strtok.nextToken();
- if (strtok.hasMoreTokens()) {
- qparams = strtok.nextToken();
- }
- }
-
- // return query string or query params based on the content
- // of the string str
- if (str.equals("LogQueryString")) {
- return qstring;
- } else {
- return qparams;
- }
- }
-
- // This method tokenize the given string and
- // return first token and the remaining
- // string a string array based on the given delimeter
- public static String[] getTokens(String str, String delimeter) {
- String[] array = new String[2];
- StringTokenizer strtoken;
-
- // Get first token and the remaining string
- strtoken = new StringTokenizer(str, delimeter);
- if (str.indexOf(delimeter) > 0) {
- array[0] = strtoken.nextToken();
- array[1] = str.substring(array[0].length() + 3, str.length());
- } else {
- // With JSR115 Maintenance review change the permission name
- // for WebRoleRefPermission can be an empty string.
- // this results in permissionName=""
- // i.e the input string will have a value such as
- // str=" , "
- array[0] = "";
- array[1] = strtoken.nextToken();
- }
-
- // TestUtil.logMsg("Input String ="+str);
- // TestUtil.logMsg("array[0] ="+array[0]);
- // TestUtil.logMsg("array[1] ="+array[1]);
- return array;
- }
-
- //
- // Locates the logs based on the given prefix string
- //
- // For example to locate all commit records i.e records such as
- //
- // commit :: MyApp1058312446320 , recordTimeStamp=1058312446598
- //
- // Use the following method to pull all the commit records
- //
- // fingLogsByPrefix("commit", nodes);
- public Collection findLogsByPrefix(String queryParams, NodeList nodes)
- throws Exception {
- Collection recordCollection = new Vector();
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
-
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
-
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("message")) {
- nodeValue = getText(childNode);
- if (nodeValue.startsWith(queryParams)) {
- // create a new record entry and
- // add it to the collection
- LogRecordEntry recordEntry = new LogRecordEntry(recordNode);
-
- recordCollection.add(recordEntry);
- }
- }
- }
- }
- return recordCollection;
- }
-
- public String getText(Node textNode) {
- String result = "";
- NodeList nodes = textNode.getChildNodes();
-
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
-
- if (node.getNodeType() == Node.TEXT_NODE) {
- result = node.getNodeValue();
- break;
- }
- }
- return result;
- }
-
- /**
- * This method retrieves the appId records.
- *
- * i.e if (log records starts with "appId") then add the records to
- * appIdRecordCollection else add the records to recordCollection
- *
- * Note: In the process of locating appId records the remaining records are
- * also isolated and stored in a collection called "recordCollection"
- */
- public Collection getAppIdRecordCollection(String queryParams, NodeList nodes)
- throws Exception {
- String nodeName;
- String nodeValue;
- Node childNode;
- Node recordNode;
- NodeList recordNodeChildren;
-
- for (int i = 0; i < nodes.getLength(); i++) {
- // Take the first record
- recordNode = nodes.item(i);
- // get all the child nodes for the first record
- recordNodeChildren = recordNode.getChildNodes();
- for (int j = 0; j < recordNodeChildren.getLength(); j++) {
- childNode = recordNodeChildren.item(j);
- nodeName = childNode.getNodeName();
- if (nodeName.equals("message")) {
- nodeValue = getText(childNode);
- if (nodeValue.startsWith(queryParams)) {
- // create a new record entry that matches the
- // query criteria i.e "appId"
- LogRecordEntry matchingRecordEntry = new LogRecordEntry(recordNode);
- this.appIdRecordCollection.add(matchingRecordEntry);
- } else if (nodeValue.startsWith("link")) {
- // create a new record entry for link records
- LogRecordEntry linkRecordEntry = new LogRecordEntry(recordNode);
- this.linkRecordCollection.add(linkRecordEntry);
- } else {
- // create a new record entry that do not
- // match the query criteria
- LogRecordEntry nonMatchingRecordEntry = new LogRecordEntry(
- recordNode);
- this.recordCollection.add(nonMatchingRecordEntry);
- }
- }
- }
- }
- return appIdRecordCollection;
- }
-
- public String getCurrentApplicationName() {
- return getCurrentAppName(null);
- }
-
- public String getCurrentApplicationName(String appName) {
- return getCurrentAppName(appName);
- }
-
- // This method returns the current application name by analysing
- // all the appId log records.
- //
- // The appId log record contains the Application name and the timeStamp
- // For example, let us examine the following 3 appId log records.
- //
- // appId :: MyApp , 1058312446598
- // appId :: App , 1058312463706
- // appId :: adminapp , 1058312480593
- //
- // In the above 3 appId records
- // a) the first field "appId :: " identifies this as a appId record
- // b) the second field indicates the application name
- // c) the third field refers to the timestamp at which the record was
- // created.
- //
- // By comparing the timestamps we can locate the latest of all appId records
- // and return the application name associated with it.
- private String getCurrentAppName(String matchAppName) {
- LogRecordEntry recordEntry = null;
- String temp = null;
- String timeStampString = null;
- String appName = null;
- String prevAppName = null;
- long prevRecordTimeStamp = 0;
- long recordTimeStamp = 0;
- String[] tokenArray = new String[2];
-
- if ((appIdRecordCollection == null) || (appIdRecordCollection.isEmpty())) {
- TestUtil.logMsg("Record collection empty : No appId records found");
- return null;
- }
-
- Iterator iterator = appIdRecordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // Remove the string "appId :: " from the message
- temp = message.substring(9, message.length());
-
- // Get appName and timeStampString
- tokenArray = temp.split(" , ");
- appName = tokenArray[0];
- timeStampString = tokenArray[1];
-
- // now unstuff application name
- appName = unStuffData(appName);
-
- TestUtil.logMsg("appName =" + appName);
- TestUtil.logMsg("timeStampString =" + timeStampString);
-
- // Get long value from the string
- if (matchAppName == null) {
- // warning: what this does is look for the newest record
- // and use that as the appname. If multiple apps
- // are deployed at same time - this could return
- // a record that belongs to a different app.
- recordTimeStamp = (new Long(timeStampString)).longValue();
- if (recordTimeStamp < prevRecordTimeStamp) {
- recordTimeStamp = prevRecordTimeStamp;
- appName = prevAppName;
- }
- } else {
- // we want an appname that matches/contains the passed in appName
- if (appName.contains(matchAppName)) {
- break;
- }
- }
- }
- return appName;
- }
-
- // This method returns the linked application names by analysing
- // all the link log records.
- //
- // The link log record contains the list of Application names
- // and the timeStamp.
- // For example, let us examine the following 2 link log records.
- //
- // link :: MyApp,SecondApp : 1058312446598
- // link :: App,SecondApp,ThirdApp : 1058312463706
- //
- // In the above 3 link records
- // a) the first field "link :: " identifies this as a link record
- // b) the second field indicates the application names that are
- // linked to.
- // Note: Linked application names are idenified using
- // the comma separator.
- // c) the last field indicates the timestamp at which the record was
- // created.
- //
- // By comparing the timestamps we can locate the latest link records
- // and return the application names linked to it.
- public Vector getLinkedApplicationNames() {
- LogRecordEntry recordEntry = null;
- String temp = null;
- String timeStampString = null;
- String appNames = null;
- String prevAppName = null;
- long prevRecordTimeStamp = 0;
- long recordTimeStamp = 0;
- String[] tokenArray = new String[2];
- Vector applicationNames = new Vector();
-
- if (linkRecordCollection == null) {
- TestUtil.logMsg("Record collection empty : No link records found");
- return null;
- }
- Iterator iterator = linkRecordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // Remove the string "link :: " from the message
- temp = message.substring(8, message.length());
-
- // Get appName and timeStampString
- tokenArray = temp.split(" : ");
- appNames = tokenArray[0];
- timeStampString = tokenArray[1];
-
- // now unstuff application name
- appNames = unStuffData(appNames);
-
- // Get long value from the string
- recordTimeStamp = (new Long(timeStampString)).longValue();
- if (recordTimeStamp < prevRecordTimeStamp) {
- recordTimeStamp = prevRecordTimeStamp;
- appNames = prevAppName;
- }
- }
-
- StringTokenizer strtoken;
-
- if (appNames != null) {
- // create a vector with applicationNames
- strtoken = new StringTokenizer(appNames, ",");
- if (appNames.indexOf(",") > 0) {
- // if the appNames string contains multiple applications
- // add all of them to the vector applicationNames
- while (strtoken.hasMoreTokens()) {
- applicationNames.add(strtoken.nextToken());
- }
- } else if (appNames != null) {
- // if the appNames string contains only one application
- // add it to the vector applicationNames
- applicationNames.add(appNames);
- }
- } else {
- // else return null
- return null;
- }
-
- return applicationNames;
- }
-
- /*
- * This returns the collection of records that have a message field that
- * contains the keyword "MSG_TAG". This is a generic flag used to put a phrase
- * or info into a records message field so that we can easily search on those
- * MSG_TAG fields later on.
- */
- public Collection getMsgTagRecordCollection() {
- LogRecordEntry recordEntry = null;
- Collection msgTagRecordCollection = new Vector();
-
- TestUtil.logTrace("getMsgTagRecordCollection(): Record collection size : "
- + recordCollection.size());
- if (recordCollection == null) {
- TestUtil.logTrace("Record collection empty : No records found");
- return null;
- }
- Iterator iterator = this.recordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- if (message.indexOf("MSG_TAG") > -1) {
- TestUtil.logTrace("getMsgTagRecordCollection(): message = " + message);
- msgTagRecordCollection.add(recordEntry);
- }
- }
- TestUtil
- .logTrace("getMsgTagRecordCollection(): returning collection size of: "
- + msgTagRecordCollection.size());
- return msgTagRecordCollection;
- }
-
- /*
- * This method reads all non-appId records from the record collection and
- * isolates current appSpecific records from the rest using the given
- * applicationName and the linkedApplicationNames.
- */
- public Collection getAppSpecificRecordCollection(String applicationName,
- Vector linkedApplicationNames) {
- LogRecordEntry recordEntry = null;
-
- if (recordCollection == null) {
- TestUtil.logMsg("Record collection empty : No records found");
- return null;
- }
- Iterator iterator = this.recordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // if recordEntry contains the specified applicationName
- // Add the record to appSpecificRecordCollection
- if (message.indexOf(applicationName) > 0) {
- appSpecificRecordCollection.add(recordEntry);
- }
- }
-
- if (linkedApplicationNames != null) {
- // retrieve all the records associated with
- // linked applications.
- for (Enumeration appEnum = linkedApplicationNames.elements(); appEnum
- .hasMoreElements();) {
- applicationName = (String) appEnum.nextElement();
-
- iterator = this.recordCollection.iterator();
- while (iterator.hasNext()) {
- recordEntry = (LogRecordEntry) iterator.next();
- String message = recordEntry.getMessage();
-
- // if recordEntry contains the specified applicationName
- // Add the record to appSpecificRecordCollection
- if (message.indexOf(applicationName) > 0) {
- appSpecificRecordCollection.add(recordEntry);
- }
- }
-
- }
- }
- return appSpecificRecordCollection;
- }
-
- // This will remove the stuffed characters in the input string
- // Note: The non-alphabets in the input string was already stuffed by
- // the same character, this method unstuff those characters
- public static String unStuffData(String inputStr) {
- char[] outStr = new char[2048];
- char[] str = inputStr.toCharArray();
-
- TestUtil.logMsg("unStuffData called with: " + inputStr);
-
- for (int i = 0, j = 0; i < str.length;) {
-
- int a = Character.getNumericValue(str[i]);
-
- // Don't stuff extra character if the character is an alphabet
- //
- // Numeric values for alphabets falls in 10 to 35, this includes
- // both upper and lower cases
- if ((a > 9) && (a < 36)) {
- outStr[j++] = str[i++];
- } else { // unstuff the character
- outStr[j] = str[i]; // just skip the next character
- // Remove only the stuffed characters not data separators
- if (((i + 1) < str.length) && (str[i + 1] == str[i])) {
- // just skip the next character
- i++;
- }
- i++;
- j++;
- }
- }
-
- TestUtil.logMsg("unStuffData returning: " + (new String(outStr)).trim());
- return ((new String(outStr)).trim());
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/LogRecordEntry.java b/jacc/src/main/java/com/sun/ts/tests/jacc/util/LogRecordEntry.java
deleted file mode 100644
index 6a47f3628b..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/LogRecordEntry.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.util;
-
-import java.io.Serializable;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class LogRecordEntry implements Serializable {
-
- private long milliSeconds;
-
- private long sequenceNumber;
-
- private String level;
-
- private String className;
-
- private String methodName;
-
- private String message;
-
- private String thrown;
-
- public LogRecordEntry(Node recordNode) throws Exception {
- if (!recordNode.getNodeName().equals("record")) {
- throw new Exception("Unexpected tag :" + recordNode.getNodeName());
- }
- NodeList nodes = recordNode.getChildNodes();
-
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- String childNode = node.getNodeName();
-
- if (childNode.equals("millis")) {
- milliSeconds = (new Long(getText(node))).longValue();
-
- } else if (childNode.equals("sequence")) {
- sequenceNumber = (new Long(getText(node))).longValue();
-
- } else if (childNode.equals("level")) {
- level = getText(node);
-
- } else if (childNode.equals("class")) {
- className = getText(node);
-
- } else if (childNode.equals("method")) {
- methodName = getText(node);
-
- } else if (childNode.equals("message")) {
- message = getText(node);
-
- } else if (childNode.equals("exception")) {
- thrown = getText(node);
-
- }
-
- }
- }
-
- public long getMilliSeconds() {
- return this.milliSeconds;
- }
-
- public void setMilliSeconds(long milliSec) {
- milliSeconds = milliSec;
- }
-
- public long getSequenceNumber() {
- return this.sequenceNumber;
- }
-
- public void setSequenceNumber(long seqNum) {
- sequenceNumber = seqNum;
- }
-
- public String getMessage() {
- return this.message;
- }
-
- public void setMessage(String msg) {
- message = msg;
- }
-
- public String getLevel() {
- return this.level;
- }
-
- public void setLevel(String lvl) {
- level = lvl;
- }
-
- public String getClassName() {
- return this.className;
- }
-
- public void setClassName(String cName) {
- className = cName;
- }
-
- public String getMethodName() {
- return this.methodName;
- }
-
- public void setMethodName(String mName) {
- methodName = mName;
- }
-
- public String getThrown() {
- return this.thrown;
- }
-
- public void setThrown(String thrwn) {
- thrown = thrwn;
- }
-
- public String getText(Node textNode) {
- String result = "";
- NodeList nodes = textNode.getChildNodes();
-
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
-
- if (node.getNodeType() == Node.TEXT_NODE) {
- result = node.getNodeValue();
- break;
- }
- }
- return result;
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/RecordEntry.java b/jacc/src/main/java/com/sun/ts/tests/jacc/util/RecordEntry.java
deleted file mode 100644
index bb93b84735..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/RecordEntry.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-/*
- * $Id$
- */
-
-package com.sun.ts.tests.jacc.util;
-
-import java.io.Serializable;
-
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class RecordEntry implements Serializable {
-
- private long sequenceNumber;
-
- private String contextId;
-
- private String message;
-
- private String className;
-
- private String methodName;
-
- private String level;
-
- private String thrown;
-
- public RecordEntry(Node recordNode) throws Exception {
- if (!recordNode.getNodeName().equals("record")) {
- throw new Exception("Unexpected tag :" + recordNode.getNodeName());
- }
- NodeList nodes = recordNode.getChildNodes();
-
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
- String childNode = node.getNodeName();
-
- if (childNode.equals("sequence")) {
- sequenceNumber = (new Long(getText(node))).longValue();
- } else if (childNode.equals("contextId")) {
- contextId = getText(node);
- } else if (childNode.equals("logger")) {// logger = getText(node);
- } else if (childNode.equals("level")) {
- level = getText(node);
- } else if (childNode.equals("class")) {
- className = getText(node);
- } else if (childNode.equals("method")) {
- methodName = getText(node);
- } else if (childNode.equals("thread")) {// thread =
- // (new Integer(getText(node))).getInt();
- } else if (childNode.equals("message")) {
- message = getText(node);
- } else if (childNode.equals("exception")) {
- thrown = getText(node);
- }
-
- }
- }
-
- public long getSequenceNumber() {
- return this.sequenceNumber;
- }
-
- public void setSequenceNumber(long seqNum) {
- sequenceNumber = seqNum;
- }
-
- public String getContextId() {
- return this.contextId;
- }
-
- public void setContextId(String cId) {
- contextId = cId;
- }
-
- public String getMessage() {
- return this.message;
- }
-
- public void setMessage(String msg) {
- message = msg;
- }
-
- public String getLevel() {
- return this.level;
- }
-
- public void setLevel(String lvl) {
- level = lvl;
- }
-
- public String getClassName() {
- return this.className;
- }
-
- public void setClassName(String cName) {
- className = cName;
- }
-
- public String getMethodName() {
- return this.methodName;
- }
-
- public void setMethodName(String mName) {
- methodName = mName;
- }
-
- public String getThrown() {
- return this.thrown;
- }
-
- public void setThrown(String thrwn) {
- thrown = thrwn;
- }
-
- public String getText(Node textNode) {
- String result = "";
- NodeList nodes = textNode.getChildNodes();
-
- for (int i = 0; i < nodes.getLength(); i++) {
- Node node = nodes.item(i);
-
- if (node.getNodeType() == Node.TEXT_NODE) {
- result = node.getNodeValue();
- break;
- }
- }
- return result;
- }
-
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/anyauthuser.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/util/anyauthuser.jsp
deleted file mode 100644
index ab0c42612a..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/anyauthuser.jsp
+++ /dev/null
@@ -1,41 +0,0 @@
-<%--
-
- Copyright (c) 2013, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-
-<%@ page language="java" %>
-
-
- JSP with Any Authenticated User Auth Constraint
-
- JSP with Double-WildCard Auth Constraint
-
- <%
-
- out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
- out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
- if (request.isUserInRole("**")){
- out.println("USR_IN_ROLE_STARSTAR");
- } else {
- out.println("USR_NOT_IN_ROLE_STARSTAR");
- }
-
- %>
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/util/build.xml
deleted file mode 100644
index f3b3141eab..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/build.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/excluded.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/util/excluded.jsp
deleted file mode 100644
index 06aba36726..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/excluded.jsp
+++ /dev/null
@@ -1,40 +0,0 @@
-<%--
-
- Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-
-
-<%@ page language="java" %>
-
-
-JSP used for verifying excluded policy statement
-
-JSP used for excluded policy statement
-
-<%
-
-out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
-out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
-%>
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/jacc_util.ear.sun-application.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/util/jacc_util.ear.sun-application.xml
deleted file mode 100644
index 0a62bd5599..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/jacc_util.ear.sun-application.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
- jacc_util_web.war
- jacc_util_web
-
- 0
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/jacc_util_web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/util/jacc_util_web.xml
deleted file mode 100644
index f4d38ca6ea..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/jacc_util_web.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
- jacc_util
-
- FetchLogs
- com.sun.ts.tests.jacc.util.FetchLogs
-
-
- FetchLogs
- /FetchLogs
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/secured.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/util/secured.jsp
deleted file mode 100644
index cd4e79bacd..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/secured.jsp
+++ /dev/null
@@ -1,48 +0,0 @@
-<%--
-
- Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-
-
-<%@ page language="java" %>
-
-
-JSP with Security Constraint
-
-JSP with Security Constraint
-
-<%
-
-out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
-out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
-// Surround these with !'s so they are easier to search for.
-// (i.e. we can search for !true! or !false!)
-out.println("isUserInRole(\"ADM\"): !" + request.isUserInRole("ADM") + "!
");
-out.println("isUserInRole(\"MGR\"): !" + request.isUserInRole("MGR") + "!
");
-out.println("isUserInRole(\"VP\"): !" + request.isUserInRole("VP") + "!
");
-out.println("isUserInRole(\"EMP\"): !" + request.isUserInRole("EMP") + "!
");
-out.println("isUserInRole(\"Administrator\"): !" + request.isUserInRole("Administrator") + "!
");
-
-%>
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/sslprotected.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/util/sslprotected.jsp
deleted file mode 100644
index 74efe762ed..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/sslprotected.jsp
+++ /dev/null
@@ -1,40 +0,0 @@
-<%--
-
- Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-
-
-<%@ page language="java" %>
-
-
-SSL Proteected
-
-SSL protected JSP
-
-<%
-
-out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
-out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
-%>
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/util/unchecked.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/util/unchecked.jsp
deleted file mode 100644
index 46537b64e4..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/util/unchecked.jsp
+++ /dev/null
@@ -1,40 +0,0 @@
-<%--
-
- Copyright (c) 2006, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-
-
-<%@ page language="java" %>
-
-
-JSP used for verifying unchecked permission
-
-JSP used for unchecked permission
-
-<%
-
-out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
-out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
-%>
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/build.xml
deleted file mode 100644
index d35d8755fe..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/build.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/Client.java b/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/Client.java
deleted file mode 100644
index 4ace07f494..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/Client.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.web.containerContracts;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Properties;
-
-import com.sun.javatest.Status;
-import com.sun.ts.lib.harness.ServiceEETest;
-import com.sun.ts.lib.porting.TSHttpsURLConnection;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.BASE64Encoder;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.jacc.util.LogFileProcessor;
-
-public class Client extends ServiceEETest {
-
- private Properties props = null;
-
- private String hostname = null;
-
- private int portnum = 0;
-
- private String pageBase = "/jacc_web_containerContracts_web";
-
- private String securedPage = "/secured.jsp";
-
- private String sslProtectedPage = "/sslprotected.jsp";
-
- private String authusername = "";
-
- private String authpassword = "";
-
- private String username = "";
-
- private String password = "";
-
- private int securedPortNum = 0;
-
- private TSNamingContext nctx = null;
-
- private LogFileProcessor logProcessor = null;
-
- public static void main(String args[]) {
- Client theTests = new Client();
- Status s = theTests.run(args, System.out, System.err);
- s.exit();
- }
-
- /**
- * @class.setup_props: log.file.location; webServerHost; webServerPort;
- * authuser; authpassword; user; password;
- * securedWebServicePort; platform.mode;
- * porting.ts.HttpsURLConnection.class.1;
- *
- */
- public void setup(String[] args, Properties p) throws Exception {
- props = p;
-
- try {
- hostname = p.getProperty("webServerHost");
- portnum = Integer.parseInt(p.getProperty("webServerPort"));
- securedPortNum = Integer.parseInt(p.getProperty("securedWebServicePort"));
- authusername = p.getProperty("authuser");
- authpassword = p.getProperty("authpassword");
- username = p.getProperty("user");
- password = p.getProperty("password");
-
- nctx = new TSNamingContext();
-
- // create LogFileProcessor
- logProcessor = new LogFileProcessor(props);
- // logProcessor = new LogFileProcessor();
-
- // Retrieve logs
- logProcessor.fetchLogs("pullAllLogRecords|fullLog");
-
- } catch (Exception e) {
- logErr("Error: got exception: ", e);
- }
-
- }
-
- public void cleanup() throws Exception { //
- }
-
- /**
- * @testName: IsUserInRole
- *
- * @assertion_ids: JACC:SPEC:65; JACC:SPEC:32; JACC:SPEC:75
- *
- * @test_Strategy: 1. Register TS provider with the AppServer.
- *
- * (Note: TSProvider is the delegating policy provider
- * supplied with compatibility test suite. See User guide for
- * Registering TS Provider with your AppServer ).
- *
- * 2. Deploy a jsp secured.jsp which is accessible by a role
- * Administrator.
- *
- * 3. Assign javajoe to role Administrator and access the jsp
- *
- * 4. verify the rolename by calling isUserInRole() inside
- * secured.jsp
- *
- */
- public void IsUserInRole() throws Exception {
-
- TSURL ctsurl = new TSURL();
-
- String url = ctsurl.getURLString("http", hostname, portnum,
- pageBase + securedPage);
- try {
- URL newURL = new URL(url);
-
- // Encode authData
- String authData = authusername + ":" + authpassword;
- TestUtil.logMsg("authData : " + authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
- TestUtil.logMsg("encoded authData : " + encodedAuthData);
-
- // open URLConnection
- URLConnection urlConn = newURL.openConnection();
-
- TestUtil.logMsg("HttpURLconnection established to :" + newURL.toString());
-
- // set request property
- urlConn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- InputStream content = (InputStream) urlConn.getInputStream();
- BufferedReader in = new BufferedReader(new InputStreamReader(content));
-
- String output = "";
- String line;
- while ((line = in.readLine()) != null) {
- output = output + line;
- TestUtil.logMsg(line);
- }
-
- TestUtil.logMsg("Data received" + output);
-
- // check for the occurance of the authusername
- // in the output this ensures that the authorized user is
- // able to access the resource secured.jsp
- String stringToSearch = authusername;
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception("PermissionToRole: getRemoteUser(): "
- + "- did not find \"" + stringToSearch + "\" in log.");
- } else {
- TestUtil.logMsg("User javajoe accessed secured.jsp");
- }
- } catch (Exception e) {
- TestUtil.logErr(e.getMessage(), e);
- TestUtil.printStackTrace(e);
- throw new Exception("IsUserInRole : FAILED", e);
- }
- }
-
- /**
- * @testName: WebUserDataPermission
- *
- * @assertion_ids: JACC:SPEC:71; JACC:SPEC:117; JACC:SPEC:104; JACC:SPEC:113
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy a jsp called (sslprotected.jsp) with a security
- * constraint that has a user-data-constraint
- * CONFIDENTIAL
- *
- * 3. Send https request to sslprotected.jsp, access the
- * content of sslprotected.jsp
- *
- * JSPName URL ---------------------------------
- * sslprotecd.jsp /sslprotected.jsp
- *
- */
- public void WebUserDataPermission() throws Exception {
-
- boolean verified = false;
-
- TSURL ctsurl = new TSURL();
-
- String url = ctsurl.getURLString("https", hostname, securedPortNum,
- pageBase + sslProtectedPage);
- try {
- URL newURL = new URL(url);
-
- // Encode authData
- String authData = authusername + ":" + authpassword;
- TestUtil.logMsg("authData : " + authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
- TestUtil.logMsg("encoded authData : " + encodedAuthData);
-
- // open HttpsURLConnection
- TSHttpsURLConnection httpsURLConn = new TSHttpsURLConnection();
-
- if (httpsURLConn != null) {
- TestUtil.logMsg("WebUserDataPermission(): hostname = " + hostname);
- TestUtil.logMsg(
- "WebUserDataPermission(): securedPortNum = " + securedPortNum);
- TestUtil.logMsg("WebUserDataPermission(): pageBase = " + pageBase);
- TestUtil.logMsg(
- "WebUserDataPermission(): sslProtectedPage = " + sslProtectedPage);
- TestUtil.logMsg(
- "WebUserDataPermission(): url.toString() = " + url.toString());
- TestUtil.logMsg("WebUserDataPermission(): newURL.toString() = "
- + newURL.toString());
-
- TestUtil
- .logMsg("Opening https url connection to: " + newURL.toString());
- httpsURLConn.init(newURL);
- httpsURLConn.setDoInput(true);
- httpsURLConn.setDoOutput(true);
- httpsURLConn.setUseCaches(false);
-
- } else {
- throw new Exception("Error opening httsURLConnection"); // set request
- // property
- }
- httpsURLConn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- InputStream content = (InputStream) httpsURLConn.getInputStream();
-
- BufferedReader in = new BufferedReader(new InputStreamReader(content));
-
- String output = "";
- String line;
- while ((line = in.readLine()) != null) {
- output = output + line;
- TestUtil.logMsg(line);
- }
-
- // check for the occurance of the authusername
- // in the output this ensures that the authorized user is
- // able to access the resource secured.jsp
- String stringToSearch = authusername;
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception("PermissionToRole: getRemoteUser(): "
- + "- did not find \"" + stringToSearch + "\" in log.");
- } else {
- TestUtil.logMsg("User javajoe accessed sslprotected.jsp");
- }
- } catch (Exception e) {
- throw new Exception("WebUserDataPermission : FAILED", e);
- }
- }
-
- /**
- * @testName: WebResourcePermission
- *
- * @assertion_ids: JACC:SPEC:73; JACC:SPEC:117; JACC:SPEC:76
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy a jsp called (secured.jsp) configure it to be
- * accessible only by Role Administrator
- *
- * 3. Access secured.jsp with a user(j2ee) who is not in role
- * Administrator
- *
- * 4. expect proper Http error message.
- *
- * JSPName URL --------------------------------- secured.jsp
- * /secured.jsp
- *
- */
- public void WebResourcePermission() throws Exception {
-
- TSURL ctsurl = new TSURL();
-
- String url = ctsurl.getURLString("http", hostname, portnum,
- pageBase + securedPage);
- try {
- URL newURL = new URL(url);
-
- // Encode authData
- String authData = username + ":" + password;
- TestUtil.logMsg("authData : " + authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
- TestUtil.logMsg("encoded authData : " + encodedAuthData);
-
- // open URLConnection
- URLConnection urlConn = newURL.openConnection();
-
- // set request property with user j2ee
- // who is not in the Role Administrator
- urlConn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- InputStream content = (InputStream) urlConn.getInputStream();
-
- BufferedReader in = new BufferedReader(new InputStreamReader(content));
-
- String output = "";
- String line;
- while ((line = in.readLine()) != null) {
- output = output + line;
- TestUtil.logMsg(line);
- }
-
- // Control shouldn't reach this point
- throw new Exception("WebResourcePermission test failed :"
- + "User j2ee allowed to access secured.jsp");
-
- } catch (IOException e) {
- TestUtil.printStackTrace(e);
-
- TestUtil.logMsg("Got expected IOException : "
- + "user j2ee not allowed to access secured.jsp ");
- TestUtil.logMsg("WebResourcePermission test passed");
- }
-
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/build.xml
deleted file mode 100644
index 7445538cb5..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/build.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/jacc_web_containerContracts_web.war.sun-web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/jacc_web_containerContracts_web.war.sun-web.xml
deleted file mode 100644
index e37851191d..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/jacc_web_containerContracts_web.war.sun-web.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
-
-
- jacc_web_containerContracts_web
-
- Administrator
- javajoe
-
-
- Employee
- j2ee
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/jacc_web_containerContracts_web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/jacc_web_containerContracts_web.xml
deleted file mode 100644
index a639171604..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/containerContracts/jacc_web_containerContracts_web.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-
-
-
-
- jacc_web_containerContracts
-
- sslprotected
- sslprotected
- /sslprotected.jsp
- 0
-
- ADM
- Administrator
-
-
-
- secured
- secured
- /secured.jsp
- 0
-
- ADM
- Administrator
-
-
-
- sslprotected
- /sslprotected.jsp
-
-
- secured
- /secured.jsp
-
-
- 54
-
-
-
- MySecureBit3
- /secured.jsp
- POST
- GET
-
-
- Administrator
-
-
- NONE
-
-
-
-
- MySecureBit6
- /sslprotected.jsp
- POST
- GET
-
-
- Administrator
-
-
- CONFIDENTIAL
-
-
-
- BASIC
- default
-
-
- Administrator
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/Client.java b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/Client.java
deleted file mode 100644
index 490cdf2bb0..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/Client.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.web.principal2role;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Properties;
-
-import com.sun.javatest.Status;
-import com.sun.ts.lib.harness.ServiceEETest;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.BASE64Encoder;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-
-//import sun.misc.BASE64Encoder;
-public class Client extends ServiceEETest {
- // Shared test variables:
- private Properties props = null;
-
- private String pageSec = null;
-
- private String pageSec1 = null;
-
- private String ctxroot = "/jacc_web_principal2role_first_module_web";
-
- private String ctxroot1 = "/jacc_web_principal2role_second_module_web";
-
- // two different web resources
- private String pageJspSec = ctxroot + "/first_resource.jsp";
-
- private String pageJspSec1 = ctxroot1 + "/second_resource.jsp";
-
- private String hostname = null;
-
- private int portnum = 0;
-
- private String unauthusername = null;
-
- private String unauthpassword = null;
-
- private String username = null;
-
- private String password = null;
-
- private TSNamingContext nctx = null;
-
- public static void main(String[] args) {
-
- Client theTests = new Client();
- Status s = theTests.run(args, System.out, System.err);
- s.exit();
- }
-
- /*
- * @class.setup_props: webServerHost; webServerPort; user; password; authuser;
- * authpassword;
- *
- */
- public void setup(String[] args, Properties p) throws Exception {
-
- try {
- hostname = p.getProperty("webServerHost");
- portnum = Integer.parseInt(p.getProperty("webServerPort"));
-
- // j2ee is an authorized user
- username = p.getProperty("user");
- password = p.getProperty("password");
-
- // javajoe is an unauthorized user
- unauthusername = p.getProperty("authuser");
- unauthpassword = p.getProperty("authpassword");
-
- pageSec = pageJspSec;
- pageSec1 = pageJspSec1;
-
- nctx = new TSNamingContext();
-
- } catch (Exception e) {
- logErr("Error in setup: ", e);
- }
- }
-
- /*
- * @testName: PrincipalToRoleMapping
- *
- * @assertion_ids: JACC:SPEC:29; JACC:SPEC:124
- *
- * @test_Strategy: 1) Create a application ear file with two web modules
- * containing one webresource each. 2) In web module one
- * (jacc_principal2role_first_module_web.war) allow role-name Administrator to
- * access the resource(first_resource.jsp) 3) In web module two
- * (jacc_principal2role_second_module_web.war) allow role-name Administrator
- * to access the resource(second_resource.jsp) 4) Set the following
- * principal-to-role mapping for the application
- * Administrator j2ee
- *
- * Manager javajoe
- * 5) Verify the same principal-to-role mapping is
- * applied to both web modules by performing step6 and 7 6) Verify this by
- * accessing webresource one(first_resource.jsp) from module one using
- * authorized user(j2ee), make sure user j2ee is allowed access. Try accessing
- * webresource one (first_resource.jsp) using unauthorized user(javajoe), make
- * sure user javajoe is not allowed access this resource. 7) Repeat the step 6
- * for webresource two(second_resource.jsp)
- *
- */
- public void PrincipalToRoleMapping() throws Exception {
-
- TSURL ctsurl = new TSURL();
-
- String firstURLstr = ctsurl.getURLString("http", hostname, portnum,
- pageSec);
- String secondURLstr = ctsurl.getURLString("http", hostname, portnum,
- pageSec1);
-
- try {
- URL firstURL = new URL(firstURLstr);
- URL secondURL = new URL(secondURLstr);
-
- // Checking accessibility for a valid user to firstURL
- TestUtil.logMsg("Verifying access rights");
- TestUtil.logMsg("***********************");
- TestUtil.logMsg("Authorized user " + username + " invoking " + firstURL);
- if (isAccessible(firstURL, username, password)) {
- TestUtil.logMsg("Access allowed");
- } else {
- throw new Exception("Authorized user acesss denied");
- }
-
- // Checking accessibility for an unauthorized user to firstURL
- TestUtil.logMsg(
- "Unauthorized user " + unauthusername + " invoking " + firstURL);
- if (!isAccessible(firstURL, unauthusername, unauthpassword)) {
- TestUtil.logMsg("Access denied");
- } else {
- throw new Exception("Unauthorized user access allowed");
- }
-
- // Checking accessibility for a valid user to SecondURL
- TestUtil.logMsg("Authorized user " + username + " invoking " + secondURL);
- if (isAccessible(secondURL, username, password)) {
- TestUtil.logMsg("Access allowed");
- } else {
- throw new Exception("Authorized user acesss denied");
- }
-
- // Checking accessibility for an unauthorized user to secondURL
- TestUtil.logMsg(
- "Unauthorized user " + unauthusername + " invoking " + secondURL);
- if (!isAccessible(secondURL, unauthusername, unauthpassword)) {
- TestUtil.logMsg("Access denied");
- } else {
- throw new Exception("Unauthorized user access allowed");
- }
-
- TestUtil.logMsg(
- "Same PrincipalToRoleMapping applied for both " + "web modules");
-
- } catch (Exception e) {
- TestUtil.logMsg("Test PrincipalToRoleMapping failed");
- e.printStackTrace();
- throw new Exception("Test PrincipalToRoleMapping failed");
- }
- }
-
- public void cleanup() throws Exception {
- //
- }
-
- public boolean isAccessible(URL url, String user, String pwd) {
-
- try {
- // Encode authData
- String authData = user + ":" + pwd;
- // TestUtil.logMsg("authData : "+authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
- String encodedAuthData = encoder.encode(authData.getBytes());
- // TestUtil.logMsg("encoded authData : "+ encodedAuthData);
-
- // open URLConnection
- URLConnection urlConn = url.openConnection();
-
- // set request property
- urlConn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- InputStream content = (InputStream) urlConn.getInputStream();
-
- BufferedReader in = new BufferedReader(new InputStreamReader(content));
-
- String output = "";
- String line;
- // TestUtil.logMsg("Output from "+url);
- while ((line = in.readLine()) != null) {
- output = output + line;
- // TestUtil.logMsg(line);
- }
-
- // check for the occurance of the user
- // in the output this ensures that the authorized user is
- // able to access the given url
- String stringToSearch = user;
- if (output.indexOf(stringToSearch) == -1) {
- return false;
- }
- return true;
- } catch (Exception e) {
- // e.printStackTrace();
- return false;
- }
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/build.xml
deleted file mode 100644
index 2ad9ecad46..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/build.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/first_resource.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/first_resource.jsp
deleted file mode 100644
index e6cde809fc..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/first_resource.jsp
+++ /dev/null
@@ -1,42 +0,0 @@
-<%--
-
- Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-<%@ page language="java" %>
-
-
- JSP with Security Constraint
-
- JSP with Security Constraint
- <%
-
- out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
- out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
- // Surround these with !'s so they are easier to search for.
- // (i.e. we can search for !true! or !false!)
- out.println("isUserInRole(\"ADM\"): !" + request.isUserInRole("ADM") + "!
");
- out.println("isUserInRole(\"MGR\"): !" + request.isUserInRole("MGR") + "!
");
- out.println("isUserInRole(\"VP\"): !" + request.isUserInRole("VP") + "!
");
- out.println("isUserInRole(\"EMP\"): !" + request.isUserInRole("EMP") + "!
");
- out.println("isUserInRole(\"Administrator\"): !" + request.isUserInRole("Administrator") + "!
");
-
- %>
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_first_module_web.war.sun-web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_first_module_web.war.sun-web.xml
deleted file mode 100644
index 302ec4f89b..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_first_module_web.war.sun-web.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- jacc_web_principal2role_first_module_web
-
- Administrator
- j2ee
-
-
- Manager
- javajoe
-
-
- Employee
- javajoe
- j2ee
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_first_module_web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_first_module_web.xml
deleted file mode 100644
index 3a7df55b50..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_first_module_web.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
- jacc_principal2role_first_module
-
- first_resource
- /first_resource.jsp
- 0
-
-
- first_resource
- /first_resource.jsp
-
-
- 5
-
-
-
- MySecureBit0
- /first_resource.jsp
- GET
- POST
-
-
- Administrator
-
-
- NONE
-
-
-
- BASIC
- default
-
-
- the administrator role
- Administrator
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_second_module_web.war.sun-web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_second_module_web.war.sun-web.xml
deleted file mode 100644
index 7e70b94d91..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_second_module_web.war.sun-web.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- jacc_web_principal2role_second_module_web
-
- Administrator
- j2ee
-
-
- Manager
- javajoe
-
-
- Employee
- javajoe
- j2ee
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_second_module_web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_second_module_web.xml
deleted file mode 100644
index 78d50ffdce..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/jacc_web_principal2role_second_module_web.xml
+++ /dev/null
@@ -1,56 +0,0 @@
-
-
-
-
- jacc_web_principal2role_second_module
-
- second_resource
- /second_resource.jsp
- 0
-
-
- second_resource
- /second_resource.jsp
-
-
- 5
-
-
-
- MySecureBit0
- /second_resource.jsp
- GET
- POST
-
-
- Administrator
-
-
- NONE
-
-
-
- BASIC
- default
-
-
- the administrator role
- Administrator
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/second_resource.jsp b/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/second_resource.jsp
deleted file mode 100644
index e6cde809fc..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/principal2role/second_resource.jsp
+++ /dev/null
@@ -1,42 +0,0 @@
-<%--
-
- Copyright (c) 2008, 2018 Oracle and/or its affiliates. All rights reserved.
-
- This program and the accompanying materials are made available under the
- terms of the Eclipse Public License v. 2.0, which is available at
- http://www.eclipse.org/legal/epl-2.0.
-
- This Source Code may also be made available under the following Secondary
- Licenses when the conditions for such availability set forth in the
- Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- version 2 with the GNU Classpath Exception, which is available at
- https://www.gnu.org/software/classpath/license.html.
-
- SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
-
---%>
-
-<%@ page language="java" %>
-
-
- JSP with Security Constraint
-
- JSP with Security Constraint
- <%
-
- out.println("The user principal is: " + request.getUserPrincipal().getName() + "
");
- out.println("getRemoteUser(): " + request.getRemoteUser() + "
" );
-
- // Surround these with !'s so they are easier to search for.
- // (i.e. we can search for !true! or !false!)
- out.println("isUserInRole(\"ADM\"): !" + request.isUserInRole("ADM") + "!
");
- out.println("isUserInRole(\"MGR\"): !" + request.isUserInRole("MGR") + "!
");
- out.println("isUserInRole(\"VP\"): !" + request.isUserInRole("VP") + "!
");
- out.println("isUserInRole(\"EMP\"): !" + request.isUserInRole("EMP") + "!
");
- out.println("isUserInRole(\"Administrator\"): !" + request.isUserInRole("Administrator") + "!
");
-
- %>
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/Client.java b/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/Client.java
deleted file mode 100644
index bd3ba516c5..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/Client.java
+++ /dev/null
@@ -1,501 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.web.providerContracts;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.Properties;
-
-import com.sun.javatest.Status;
-import com.sun.ts.lib.harness.ServiceEETest;
-import com.sun.ts.lib.porting.TSURL;
-import com.sun.ts.lib.util.BASE64Encoder;
-import com.sun.ts.lib.util.TSNamingContext;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.jacc.util.LogFileProcessor;
-import com.sun.ts.tests.jacc.util.LogRecordEntry;
-
-//import sun.misc.*;
-public class Client extends ServiceEETest {
-
- private Properties props = null;
-
- private String contextId = "jacc_ctx";
-
- private String hostname = null;
-
- private int portnum = 0;
-
- private String pageBase = "/jacc_web_providerContracts_web";
-
- private String securedPage = "/secured.jsp";
-
- private String accessToAllPage = "/AccessToAll.jsp";
-
- private String anyAuthUserPage = "/anyauthuser.jsp";
-
- private String authusername = "";
-
- private String authpassword = "";
-
- private TSNamingContext nctx = null;
-
- LogFileProcessor logProcessor = null;
-
- public static void main(String args[]) {
- Client theTests = new Client();
- Status s = theTests.run(args, System.out, System.err);
- s.exit();
- }
-
- /**
- * @class.setup_props: log.file.location; webServerHost; webServerPort;
- * authuser; authpassword;
- *
- */
- public void setup(String[] args, Properties p) throws Exception {
- props = p;
- boolean pass = true;
-
- try {
- hostname = p.getProperty("webServerHost");
- portnum = Integer.parseInt(p.getProperty("webServerPort"));
- authusername = p.getProperty("authuser");
- authpassword = p.getProperty("authpassword");
-
- nctx = new TSNamingContext();
-
- // create LogProcessor
- logProcessor = new LogFileProcessor(props);
-
- // Retrieve logs that matches with contextId
- logProcessor.fetchLogs(contextId);
-
- } catch (Exception e) {
- logErr("Error: got exception: ", e);
- }
-
- }
-
- public void cleanup() throws Exception {
- //
- }
-
- /**
- * @testName: WildCardAuthConstraint
- *
- * @assertion_ids: JACC:SPEC:35; JACC:SPEC:10; JACC:JAVADOC:19;
- * JACC:JAVADOC:25; JACC:JAVADOC:26; JACC:JAVADOC:27;
- * JACC:JAVADOC:30; JACC:JAVADOC:31; JACC:SPEC:129;
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy a jsp AccessToAll.jsp which contains a wildcard
- * auth constraint (i.e "*" as shown below) in its security
- * constraint. *
- *
- *
- * 3. Access the jsp /AccessToAll.jsp from the client.
- *
- * 4. Make sure the login user javajoe is able to access the
- * jsp /AccessToAll.jsp
- *
- * 4. Make sure the login user is mapped to all roles defined
- * in the application (i.e. ADM, EMP and MGR) i.e a)
- * isUserInRole("ADM") should return true and b)
- * isUserInRole("MGR") should return true and c)
- * isUserInRole("EMP") should return true
- *
- * 5. Make sure the login user is not in the role that is not
- * defined in the application. i.e isUserInRole("VP") should
- * return false
- */
- public void WildCardAuthConstraint() throws Exception {
-
- TSURL ctsurl = new TSURL();
-
- String url = ctsurl.getURLString("http", hostname, portnum,
- pageBase + accessToAllPage);
- try {
- URL newURL = new URL(url);
-
- // Encode authData
- String authData = authusername + ":" + authpassword;
- TestUtil.logMsg("authData : " + authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
- TestUtil.logMsg("encoded authData : " + encodedAuthData);
-
- // open URLConnection
- URLConnection urlConn = newURL.openConnection();
-
- // set request property
- urlConn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- InputStream content = (InputStream) urlConn.getInputStream();
-
- String cookies = null;
-
- for (int i = 0;; i++) {
- String header = urlConn.getHeaderField(i);
- // TestUtil.logMsg("Header "+i+"= "+header);
-
- if (header == null) {
- break;
- }
- if ((header.indexOf("JSESSIONIDSSO") != -1)
- || (header.indexOf("JSESSIONID") != -1)) {
- cookies = addCookies(header, cookies);
- }
- }
-
- TestUtil.logMsg("cookies received = " + cookies);
-
- BufferedReader in = new BufferedReader(new InputStreamReader(content));
-
- String output = "";
- String line;
- while ((line = in.readLine()) != null) {
- output = output + line;
- TestUtil.logMsg(line);
- }
-
- // check for the occurance of the authusername
- // in the output this ensures that the authorized user is
- // able to access the resource AccessToAll.jsp
- String stringToSearch = authusername;
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception("AccessToAll.jsp: getRemoteUser(): "
- + "- did not find \"" + stringToSearch + "\" in log.");
- } else {
- TestUtil.logMsg("User javajoe accessed AccessToAll.jsp"); // look for
- // String
- // "USR_IN_ROLE_ADM"
- }
- stringToSearch = "USR_IN_ROLE_ADM";
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception(
- "AccessToAll.jsp: getRemoteUser(): " + "- not mapped to role ADM");
- } else {
- TestUtil.logMsg("User in Role ADM"); // look for String
- // "USR_IN_ROLE_MGR"
- }
- stringToSearch = "USR_IN_ROLE_MGR";
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception(
- "AccessToAll.jsp: getRemoteUser(): " + "- not mapped to role MGR");
- } else {
- TestUtil.logMsg("User in Role MGR"); // look for String
- // "USR_IN_ROLE_EMP"
- }
- stringToSearch = "USR_IN_ROLE_EMP";
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception(
- "AccessToAll.jsp: getRemoteUser(): " + "- not mapped to role EMP");
- } else {
- TestUtil.logMsg("User in Role EMP"); // look for String
- // "USR_NOT_IN_ROLE_VP"
- }
- stringToSearch = "USR_NOT_IN_ROLE_VP";
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception(
- "AccessToAll.jsp: getRemoteUser(): " + "- mapped to role VP");
- } else {
- TestUtil.logMsg("User not in Role VP");
- }
-
- // to test assertion JACC:SPEC:129
- stringToSearch = "USR_IN_ROLE_STARSTAR";
- if (output.indexOf(stringToSearch) == -1) {
- // should get here since we did not create any role-ref or role named
- // "**".
- TestUtil.logMsg("User is correctly not in any Role named '**'");
- } else {
- throw new Exception(
- "anyauthuser.jsp: getRemoteUser() - incorrectly mapped to role named '**'");
- }
-
- } catch (Exception e) {
- throw new Exception("Test WildCardAuthConstraint : FAILED", e);
- }
-
- }
-
- /**
- * @testName: PermissionsToRole
- *
- * @assertion_ids: JACC:SPEC:65; JACC:SPEC:10; JACC:JAVADOC:19;
- * JACC:JAVADOC:25; JACC:JAVADOC:26; JACC:JAVADOC:27;
- * JACC:JAVADOC:30; JACC:JAVADOC:31
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy a jsp secured.jsp which is accessible by a role
- * Administrator.
- *
- * 3. Assign javajoe to role Administrator and access the jsp
- *
- * 4. If javajoe can access secured.jsp this implies all users
- * mapped to Administrator can access secured.jsp
- *
- * Note: Invoking PermissionsToRole assumes that the
- * TSProvider was alreaded loaded and this triggers indirectly
- * invoking other JAVADOC APIs
- */
- public void PermissionsToRole() throws Exception {
-
- TSURL ctsurl = new TSURL();
-
- String url = ctsurl.getURLString("http", hostname, portnum,
- pageBase + securedPage);
- try {
- URL newURL = new URL(url);
-
- // Encode authData
- String authData = authusername + ":" + authpassword;
- TestUtil.logMsg("authData : " + authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
- TestUtil.logMsg("encoded authData : " + encodedAuthData);
-
- // open URLConnection
- URLConnection urlConn = newURL.openConnection();
-
- // set request property
- urlConn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
-
- InputStream content = (InputStream) urlConn.getInputStream();
-
- String cookies = null;
-
- for (int i = 0;; i++) {
- String header = urlConn.getHeaderField(i);
- // TestUtil.logMsg("Header "+i+"= "+header);
-
- if (header == null) {
- break;
- }
- if ((header.indexOf("JSESSIONIDSSO") != -1)
- || (header.indexOf("JSESSIONID") != -1)) {
- cookies = addCookies(header, cookies);
- }
- }
-
- TestUtil.logMsg("cookies received = " + cookies);
-
- BufferedReader in = new BufferedReader(new InputStreamReader(content));
-
- String output = "";
- String line;
- while ((line = in.readLine()) != null) {
- output = output + line;
- // TestUtil.logMsg (line);
- }
-
- // check for the occurance of the authusername
- // in the output this ensures that the authorized user is
- // able to access the resource secured.jsp
- String stringToSearch = authusername;
- if (output.indexOf(stringToSearch) == -1) {
- throw new Exception("PermissionToRole: getRemoteUser(): "
- + "- did not find \"" + stringToSearch + "\" in log.");
- } else {
- TestUtil.logMsg("User javajoe accessed secured.jsp");
- }
- } catch (Exception e) {
- throw new Exception("Test PermissionToRole : FAILED", e);
- }
-
- }
-
- /**
- * @testName: anyAuthUserWebResPermAddedToRole
- *
- * @assertion_ids: JACC:SPEC:128;
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. deploy contents of this test dir (this test is most
- * concnerned with deployment of anyauthuser.jsp which
- * specifies role "**" in the auth-constraint element. This
- * should cause a WebResourcePermission to be added to the
- * "**" role.)
- *
- * 3. attempt to access the deployed anyauthuser.jsp
- *
- * 4. At this point, there should be an entry in the
- * JACCLog.txt file that begins with "MSG_TAG" and it shold
- * contain a message about the WebResourcePermission being
- * added for role "**" with page anyauthuser being referenced.
- * We will parse the entries of the JACCLog.txt and search for
- * our string info that indicates proper message info was
- * dumped for the servlet that had an auth-constraint = "**".
- *
- */
- public void anyAuthUserWebResPermAddedToRole() throws Exception {
-
- boolean bSuccess = false;
-
- try {
-
- // lets invoke our doc to make sure deploymenbt did occur and that
- // translation of the DD security elements did occur. If they did
- // not properly occur, we should not be able to invoke the servlet
- // and that means the rest of our tests is going to fail.
- String servletPath = pageBase + anyAuthUserPage;
- invokeServlet(servletPath, "POST");
-
- //
- // ok, now validate the log file had content we expected to see
- // this is done in the following steps:
- //
-
- // 1. get all log messages needed to test assertion 128 (they all
- // shoudl start with "MSG_TAG". the ones containing info about
- // WebResourcePermission are specific to assertion JACC:SPEC:128
- String searchStr = "MSG_TAG :: WebResourcePermission :: **";
- Collection col = logProcessor.getMsgTagRecordCollection();
- TestUtil.logMsg("col.size() = " + col.size());
-
- // 2. find one of these log messages that matches our "anyauthuser"
- // servlet
- // and was that resulted from this appContext/pageBase
- Iterator iterator = col.iterator();
-
- while (iterator.hasNext()) {
- LogRecordEntry recordEntry = (LogRecordEntry) iterator.next();
- String msg = recordEntry.getMessage();
- if ((msg != null) && msg.startsWith(searchStr)
- && (msg.indexOf("anyauthuser") > 0)) {
- // SUCCESS: we found a matching record entry which means
- // a WebResourcePermission was added to Role "**" for our
- // "anyauthuser" servlet that specifies "**" in its auth-constraint
- bSuccess = true;
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new Exception("Test anyAuthUserWebResPermAddedToRole : FAILED", ex);
- }
-
- if (bSuccess) {
- TestUtil.logMsg("Test anyAuthUserWebResPermAddedToRole Passed.");
- } else {
- throw new Exception("Test anyAuthUserWebResPermAddedToRole : FAILED");
- }
- }
-
- /*
- * Convenience method that will establish a url connections and perform a
- * get/post request. A username and password will be passed in the request
- * header and they will be encoded using the BASE64Encoder class.
- */
- private int invokeServlet(String sContext, String requestMethod) {
- int code = 200;
-
- TSURL ctsurl = new TSURL();
- if (!sContext.startsWith("/")) {
- sContext = "/" + sContext;
- }
-
- String url = ctsurl.getURLString("http", hostname, portnum, sContext);
- try {
- URL newURL = new URL(url);
-
- // Encode authData
- // hint: make sure username and password are valid for your
- // (J2EE) security realm otherwise you recieve http 401 error.
- String authData = authusername + ":" + authpassword;
- TestUtil.logMsg("authData : " + authData);
-
- BASE64Encoder encoder = new BASE64Encoder();
-
- String encodedAuthData = encoder.encode(authData.getBytes());
- TestUtil.logMsg("encoded authData : " + encodedAuthData);
-
- // open URLConnection
- HttpURLConnection conn = (HttpURLConnection) newURL.openConnection();
-
- // set request property
- conn.setDoOutput(true);
- conn.setDoInput(true);
- conn.setRequestProperty("Authorization",
- "Basic " + encodedAuthData.trim());
- conn.setRequestMethod(requestMethod); // POST or GET etc
- conn.connect();
-
- TestUtil.logMsg("called HttpURLConnection.connect() for url: " + url);
- code = conn.getResponseCode();
- TestUtil.logMsg("Got response code of: " + code);
- String str = conn.getResponseMessage();
- TestUtil.logMsg("Got response string of: " + str);
-
- /*
- * // DEBUG AID InputStream content = (InputStream)conn.getInputStream();
- * BufferedReader in = new BufferedReader(new InputStreamReader(content));
- * try { String line; while ((line = in.readLine()) != null) {
- * TestUtil.logMsg(line); } } finally { in.close(); }
- */
- } catch (Exception e) {
- TestUtil.logMsg(
- "Abnormal return status encountered while invoking " + sContext);
- TestUtil.logMsg("Exception Message was: " + e.getMessage());
- e.printStackTrace();
- }
-
- return code;
- } // invokeServlet()
-
- public String addCookies(String cookieHeader, String cookies) {
-
- String cookie;
-
- if (cookieHeader == null) {
- return null;
- }
-
- int j = cookieHeader.indexOf(";");
-
- if (j != -1) {
- String cValue = cookieHeader.substring(0, j);
- cookie = cValue.trim();
- } else {
- cookie = cookieHeader.trim(); // append cookie with existing cookies
- }
- if (cookies == null) {
- cookies = cookie;
- } else {
- cookies += ";" + cookie;
- }
- return cookies;
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/build.xml
deleted file mode 100644
index a3b1c764f2..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/build.xml
+++ /dev/null
@@ -1,30 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/jacc_web_providerContracts_web.war.sun-web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/jacc_web_providerContracts_web.war.sun-web.xml
deleted file mode 100644
index 65a3610eac..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/jacc_web_providerContracts_web.war.sun-web.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-
-
-
-
-
- jacc_web_providerContracts_web
-
- Administrator
- javajoe
- j2ee
-
-
- Manager
- javajoe
-
-
- Employee
- javajoe
- j2ee
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/jacc_web_providerContracts_web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/jacc_web_providerContracts_web.xml
deleted file mode 100644
index eb34ec2989..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/providerContracts/jacc_web_providerContracts_web.xml
+++ /dev/null
@@ -1,127 +0,0 @@
-
-
-
-
- jacc_web_providerContracts
-
- AccessToAll
- AccessToAll
- /AccessToAll.jsp
- 0
-
- ADM
- Administrator
-
-
- EMP
- Employee
-
-
- MGR
- Manager
-
-
-
- secured
- secured
- /secured.jsp
- 0
-
- ADM
- Administrator
-
-
-
- anyauthuser
- anyauthuser
- /anyauthuser.jsp
- 0
-
-
- AccessToAll
- /AccessToAll.jsp
-
-
- secured
- /secured.jsp
-
-
- anyauthuser
- /anyauthuser.jsp
-
-
- 54
-
-
-
- MySecureBit3
- /secured.jsp
- POST
- GET
-
-
- Administrator
-
-
- NONE
-
-
-
-
- MySecureBit4
- /AccessToAll.jsp
- POST
- GET
-
-
- *
-
-
- NONE
-
-
-
-
- MySecureBit7
- /anyauthuser.jsp
- POST
- GET
-
-
- **
-
-
- NONE
-
-
-
- BASIC
- default
-
-
- Administrator
-
-
- Employee
-
-
- Manager
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/Client.java b/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/Client.java
deleted file mode 100644
index cbf4b5a31b..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/Client.java
+++ /dev/null
@@ -1,961 +0,0 @@
-/*
- * Copyright (c) 2007, 2020 Oracle and/or its affiliates. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v. 2.0, which is available at
- * http://www.eclipse.org/legal/epl-2.0.
- *
- * This Source Code may also be made available under the following Secondary
- * Licenses when the conditions for such availability set forth in the
- * Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
- * version 2 with the GNU Classpath Exception, which is available at
- * https://www.gnu.org/software/classpath/license.html.
- *
- * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
- */
-
-package com.sun.ts.tests.jacc.web.toolsContracts;
-
-import java.security.Permissions;
-import java.util.Properties;
-
-import com.sun.javatest.Status;
-import com.sun.ts.lib.harness.ServiceEETest;
-import com.sun.ts.lib.util.TestUtil;
-import com.sun.ts.tests.jacc.util.LogFileProcessor;
-
-import jakarta.security.jacc.WebResourcePermission;
-import jakarta.security.jacc.WebRoleRefPermission;
-import jakarta.security.jacc.WebUserDataPermission;
-
-// CAUTION: *** The expected permissions constructed for various permissions
-// such as WebResourcePermission, WebRoleRefPermission,
-// WebUserDataPermission are based on the application
-// jacc_toolsContracts. If the application is modified for
-// any reason then the expected permissions should also be
-// modified accordingly. ***
-//
-public class Client extends ServiceEETest {
-
- private Properties props = null;
-
- private String contextId = "jacc_ctx";
-
- LogFileProcessor logProcessor = null;
-
- private String applicationContext;
-
- private boolean initialized = false;
-
- private Permissions unCheckedPermissions = new Permissions();
-
- private Permissions excludedPermissions = new Permissions();
-
- private Permissions addToRolePermissions = new Permissions();
-
- public static void main(String args[]) {
- Client theTests = new Client();
- Status s = theTests.run(args, System.out, System.err);
- s.exit();
- }
-
- /**
- * @class.setup_props: log.file.location; webServerHost; webServerPort;
- *
- *
- */
- public void setup(String[] args, Properties p) throws Exception {
- props = p;
- if (!initialized) {
- // create LogFileProcessor
- logProcessor = new LogFileProcessor(props);
-
- // retrieve logs based on application Name
- logProcessor.fetchLogs("getAppSpecificRecordCollection|appId",
- "toolsContracts");
-
- // retrieve unchecked permissions as a permission collection
- unCheckedPermissions = logProcessor.getAppSpecificUnCheckedPermissions();
-
- // retrieve excluded permissions as a permission collection
- excludedPermissions = logProcessor.getAppSpecificExcludedPermissions();
-
- // retrieve addToRole permissions as a permission collection
- addToRolePermissions = logProcessor.getAppSpecificAddToRolePermissions();
-
- initialized = true;
- }
- }
-
- public void cleanup() throws Exception {
-
- }
-
- /**
- * @testName: WebResourcePermission
- *
- * @assertion_ids: JACC:SPEC:36; JACC:SPEC:72; JACC:SPEC:27; JACC:SPEC:28;
- * JACC:SPEC:52; JACC:SPEC:128;
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy the application.
- *
- * 3. During deployment, appserver generates permissions for
- * the J2EE components based on the given deployment
- * descriptor
- *
- * 4. Retrieve server side logs and verify the generated
- * permissions matches the expected permission collection
- *
- */
- public void WebResourcePermission() throws Exception {
- boolean verified = false;
- Permissions expectedUnCheckedPermissions = new Permissions();
- Permissions expectedExcludedPermissions = new Permissions();
- Permissions expectedAddToRolePermissions = new Permissions();
-
- // ----------UNCHECKED----------//
- // 1) retrieve server generated unchecked policy statements
- // 2) construct expected unchecked policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "unchecked" WebResourcePermissions
- Permissions uncheckedWebResourcePermissions = logProcessor
- .getSpecificPermissions(unCheckedPermissions, "WebResourcePermission");
-
- TestUtil.logMsg("Server generated unchecked WebResourcePermissions");
- logProcessor.printPermissionCollection(uncheckedWebResourcePermissions);
-
- // Construct the expected unchecked WebResourcePermission
- expectedUnCheckedPermissions
- .add(new WebResourcePermission("/unchecked.jsp", (String) null));
- expectedUnCheckedPermissions
- .add(new WebResourcePermission("/sslprotected.jsp", "!GET,POST"));
- expectedUnCheckedPermissions.add(new WebResourcePermission(
- "/:/secured.jsp:/unchecked.jsp:/excluded.jsp:/sslprotected.jsp:/anyauthuser.jsp",
- (String) null));
- expectedUnCheckedPermissions
- .add(new WebResourcePermission("/excluded.jsp", "!GET,POST"));
- expectedUnCheckedPermissions
- .add(new WebResourcePermission("/secured.jsp", "!GET,POST"));
- expectedUnCheckedPermissions
- .add(new WebResourcePermission("/anyauthuser.jsp", "!GET,POST"));
-
- TestUtil.logMsg("verifying unchecked policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedUnCheckedPermissions,
- uncheckedWebResourcePermissions);
-
- if (!verified) {
- throw new Exception("WebResourcePermission failed: "
- + "unchecked policy statements verification failed");
- } else {
- TestUtil.logMsg("unchecked policy statements verification successful");
- }
-
- // ---------EXCLUDED----------//
- // 1) retrieve server generated excluded policy statements
- // 2) construct expected excluded policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "excluded" WebResourcePermissions
- Permissions excludedWebResourcePermissions = logProcessor
- .getSpecificPermissions(excludedPermissions, "WebResourcePermission");
-
- TestUtil.logMsg("Server generated excluded WebResourcePermissions");
- logProcessor.printPermissionCollection(excludedWebResourcePermissions);
-
- // Construct the expected excluded WebResourcePermission
- expectedExcludedPermissions
- .add(new WebResourcePermission("/excluded.jsp", "GET,POST"));
-
- TestUtil.logMsg("verifying excluded policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedExcludedPermissions,
- excludedWebResourcePermissions);
-
- if (!verified) {
- throw new Exception("WebResourcePermission failed: "
- + "excluded policy statements verification failed");
- } else {
- TestUtil.logMsg("excluded policy statements verification successful");
- }
-
- // ---------ADDTOROLE----------//
- // 1) retrieve server generated addToRole policy statements
- // 2) construct expected addToRole policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "addToRole" WebResourcePermissions
- Permissions addToRoleWebResourcePermissions = logProcessor
- .getSpecificPermissions(addToRolePermissions, "WebResourcePermission");
-
- TestUtil.logMsg("Server generated addToRole WebResourcePermissions");
- logProcessor.printPermissionCollection(addToRoleWebResourcePermissions);
-
- // Construct the expected excluded WebResourcePermission
- expectedAddToRolePermissions
- .add(new WebResourcePermission("/secured.jsp", "GET,POST"));
- expectedAddToRolePermissions
- .add(new WebResourcePermission("/sslprotected.jsp", "GET,POST"));
- expectedAddToRolePermissions
- .add(new WebResourcePermission("/anyauthuser.jsp", "GET,POST"));
-
- TestUtil.logMsg("verifying addToRole policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedAddToRolePermissions,
- addToRoleWebResourcePermissions);
-
- if (!verified) {
- throw new Exception("WebResourcePermission failed: "
- + "addToRole policy statements verification failed");
- } else {
- TestUtil.logMsg("addToRole policy statements verification successful");
- }
- }
-
- /**
- * @testName: WebRoleRefPermission
- *
- * @assertion_ids: JACC:SPEC:36; JACC:SPEC:112; JACC:SPEC:38; JACC:SPEC:43;
- * JACC:SPEC:44; JACC:JAVADOC:50; JACC:SPEC:27; JACC:SPEC:28;
- * JACC:SPEC:45; JACC:SPEC:52; JACC:SPEC:75; JACC:SPEC:128;
- * JACC:SPEC:131
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ). 2.
- * Deploy the application.
- *
- * 3. During deployment, appserver generates permissions for
- * the J2EE components based on the given deployment
- * descriptor
- *
- * 4. Retrieve server side logs and verify the generated
- * permissions matches the expected permission collection
- */
- public void WebRoleRefPermission() throws Exception {
- boolean verified = false;
- Permissions expectedAddToRolePermissions = new Permissions();
-
- // ---------ADDTOROLE----------//
- // 1) retrieve server generated addToRole policy statements
- // 2) construct expected addToRole policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "addToRole" WebRoleRefPermissions
- Permissions addToRoleWebRoleRefPermissions = logProcessor
- .getSpecificPermissions(addToRolePermissions, "WebRoleRefPermission");
-
- TestUtil.logMsg("Server generated addToRole WebRoleRefPermissions");
- logProcessor.printPermissionCollection(addToRoleWebRoleRefPermissions);
-
- // Construct the expected excluded WebRoleRefPermission
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("secured", "ADM"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("secured", "Administrator"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("secured", "Manager"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("secured", "Employee"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("sslprotected", "MGR"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("sslprotected", "ADM"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("sslprotected", "Administrator"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("sslprotected", "Manager"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("sslprotected", "Employee"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("unchecked", "Manager"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("unchecked", "Administrator"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("unchecked", "Employee"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("excluded", "Manager"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("excluded", "Administrator"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("excluded", "Employee"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("anyauthuser", "Employee"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("anyauthuser", "Manager"));
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("anyauthuser", "Administrator"));
-
- // JSR115 Maintenance Review changes
- expectedAddToRolePermissions
- .add(new WebRoleRefPermission("", "Administrator"));
- expectedAddToRolePermissions.add(new WebRoleRefPermission("", "Manager"));
- expectedAddToRolePermissions.add(new WebRoleRefPermission("", "Employee"));
-
- TestUtil.logMsg("verifying addToRole policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedAddToRolePermissions,
- addToRoleWebRoleRefPermissions);
-
- if (!verified) {
- throw new Exception("WebRoleRefPermission failed: "
- + "addToRole policy statements verification failed");
- } else {
- TestUtil.logMsg("addToRole policy statements verification successful");
- }
- }
-
- /**
- * @testName: AnyAuthUserWebRoleRef
- *
- * @assertion_ids: JACC:SPEC:130; JACC:SPEC:131;
- *
- * @test_Strategy: This is testing that: If the any authenticated user
- * role-name, **, does not appear in a security-role-ref
- * within the servlet, a WebRoleRefPermission must also be
- * added for it. The name of each such WebRoleRefPermission
- * must be the servlet-name of the corresponding servlet
- * element. steps: 1. We have any-authenticated-user
- * referenced in a security-constraint in our DD (for
- * anyauthuser.jsp) We have a total of 5 servlets defined in
- * our DD also.
- *
- * 2. Deploy the application.
- *
- * 3. During deployment, appserver generates permissions for
- * the J2EE components based on the given deployment
- * descriptor
- *
- * 4. Retrieve server side logs and verify the generated
- * permissions matches the expected permission collection
- */
- public void AnyAuthUserWebRoleRef() throws Exception {
- boolean verified = false;
- Permissions expectedAddToRolePerms = new Permissions();
-
- // retrieve server generated addToRole policy statements
- Permissions addToRoleWebRoleRefPermissions = logProcessor
- .getSpecificPermissions(addToRolePermissions, "WebRoleRefPermission");
-
- // for debug aid, print out server generated addToRole policy statements
- TestUtil.logMsg("Server generated addToRole WebRoleRefPermissions");
- logProcessor.printPermissionCollection(addToRoleWebRoleRefPermissions);
-
- // according to jacc 1.5 spec (chapter 3, section 3.1.3.3), it states that
- // "a WebRoleRefPermission must also be added for it" (meaning **) and that
- // "The name of each such WebRoleRefPermission must be the servlet-name
- // of the corresponding servlet element."
- // This means for each servlet definition in our web.xml, there will need to
- // exist a WebRoleRefPermission with that servlet name for the ** role.
- //
- expectedAddToRolePerms.add(new WebRoleRefPermission("excluded", "**"));
- expectedAddToRolePerms.add(new WebRoleRefPermission("unchecked", "**"));
- expectedAddToRolePerms.add(new WebRoleRefPermission("sslprotected", "**"));
- expectedAddToRolePerms.add(new WebRoleRefPermission("secured", "**"));
- expectedAddToRolePerms.add(new WebRoleRefPermission("anyauthuser", "**"));
-
- TestUtil.logMsg("verifying addToRole policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedAddToRolePerms,
- addToRoleWebRoleRefPermissions);
-
- if (!verified) {
- throw new Exception("AnyAuthUserWebRoleRef failed: "
- + "addToRole policy statements for any-authenticated-user (**) failed");
- } else {
- TestUtil.logMsg("addToRole policy statements verification successful");
- }
-
- }
-
- /**
- * @testName: WebResourcePermissionExcludedPolicy
- *
- * @assertion_ids: JACC:SPEC:37; JACC:SPEC:114; JACC:SPEC:111; JACC:SPEC:27;
- * JACC:SPEC:28; JACC:SPEC:34; JACC:SPEC:52
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy the application.
- *
- * 3. During deployment, appserver generates permissions for
- * the J2EE components based on the given deployment
- * descriptor
- *
- * 4. Retrieve server side logs and verify the generated
- * permissions matches the expected permission collection
- *
- */
- public void WebResourcePermissionExcludedPolicy() throws Exception {
- boolean verified = false;
- Permissions expectedExcludedPermissions = new Permissions();
-
- // ---------EXCLUDED----------//
- // 1) retrieve server generated excluded policy statements
- // 2) construct expected excluded policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "excluded" WebResourcePermissions
- Permissions excludedWebResourcePermissions = logProcessor
- .getSpecificPermissions(excludedPermissions, "WebResourcePermission");
-
- TestUtil.logMsg("Server generated excluded WebResourcePermissions");
- logProcessor.printPermissionCollection(excludedWebResourcePermissions);
-
- // Construct the expected excluded WebResourcePermission
- expectedExcludedPermissions
- .add(new WebResourcePermission("/excluded.jsp", "GET,POST"));
-
- TestUtil.logMsg("verifying excluded policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedExcludedPermissions,
- excludedWebResourcePermissions);
-
- if (!verified) {
- throw new Exception("WebResourcePermissionExcludedPolicy failed: "
- + "excluded policy statements verification failed");
- } else {
- TestUtil.logMsg("excluded policy statements verification successful");
- }
- }
-
- /**
- * @testName: WebResourcePermissionUnCheckedPolicy
- *
- * @assertion_ids: JACC:SPEC:36; JACC:SPEC:39; JACC:SPEC:27; JACC:SPEC:28;
- * JACC:SPEC:52; JACC:JAVADOC:17
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy the application.
- *
- * 3. During deployment, appserver generates permissions for
- * the J2EE components based on the given deployment
- * descriptor
- *
- * 4. Retrieve server side logs and verify the generated
- * unchecked permissions matches the expected permission
- * collection
- */
- public void WebResourcePermissionUnCheckedPolicy() throws Exception {
- Permissions expectedPermissions = new Permissions();
- boolean verified = false;
-
- // Get "unchecked" WebResourcePermissions
- Permissions uncheckedWebResourcePermissions = logProcessor
- .getSpecificPermissions(unCheckedPermissions, "WebResourcePermission");
-
- TestUtil.logMsg("Server generated unchecked WebResourcePermissions");
- logProcessor.printPermissionCollection(uncheckedWebResourcePermissions);
-
- // Construct the expected unchecked WebResourcePermission
- expectedPermissions
- .add(new WebResourcePermission("/unchecked.jsp", (String) null));
- expectedPermissions
- .add(new WebResourcePermission("/sslprotected.jsp", "!GET,POST"));
- expectedPermissions.add(new WebResourcePermission(
- "/:/secured.jsp:/unchecked.jsp:/excluded.jsp:/sslprotected.jsp:/anyauthuser.jsp",
- (String) null));
- expectedPermissions
- .add(new WebResourcePermission("/excluded.jsp", "!GET,POST"));
- expectedPermissions
- .add(new WebResourcePermission("/secured.jsp", "!GET,POST"));
- expectedPermissions
- .add(new WebResourcePermission("/anyauthuser.jsp", "!GET,POST"));
-
- verified = logProcessor.verifyLogImplies(expectedPermissions,
- uncheckedWebResourcePermissions);
-
- if (!verified) {
- throw new Exception("WebResourcePermissionUnCheckedPolicy failed");
- } else {
- TestUtil.logMsg("WebResourcePermission constructed"
- + " correctly with unchecked policy statements");
- }
- }
-
- /**
- * @testName: WebUserDataPermission
- *
- * @assertion_ids: JACC:SPEC:41; JACC:SPEC:42; JACC:JAVADOC:54;
- * JACC:JAVADOC:56; JACC:JAVADOC:58; JACC:SPEC:27;
- * JACC:SPEC:28; JACC:SPEC:34; JACC:SPEC:52
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Deploy the application.
- *
- * 3. During deployment, appserver generates permissions for
- * the J2EE components based on the given deployment
- * descriptor
- *
- * 4. Retrieve server side logs and verify the generated
- * unchecked permissions matches the expected permission
- * collection
- *
- *
- */
- public void WebUserDataPermission() throws Exception {
- boolean verified = false;
- Permissions expectedUnCheckedPermissions = new Permissions();
- Permissions expectedExcludedPermissions = new Permissions();
-
- // ----------UNCHECKED----------//
- // 1) retrieve server generated unchecked policy statements
- // 2) construct expected unchecked policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "unchecked" WebUserDataPermissions
- Permissions uncheckedWebUserDataPermissions = logProcessor
- .getSpecificPermissions(unCheckedPermissions, "WebUserDataPermission");
-
- TestUtil.logMsg("Server generated unchecked WebUserDataPermissions");
- logProcessor.printPermissionCollection(uncheckedWebUserDataPermissions);
-
- // Construct the expected unchecked WebUserDataPermission
- expectedUnCheckedPermissions.add(new WebUserDataPermission(
- "/sslprotected.jsp", "GET,POST:CONFIDENTIAL"));
- expectedUnCheckedPermissions
- .add(new WebUserDataPermission("/excluded.jsp", "!GET,POST"));
- expectedUnCheckedPermissions
- .add(new WebUserDataPermission("/sslprotected.jsp", "!GET,POST"));
- expectedUnCheckedPermissions
- .add(new WebUserDataPermission("/secured.jsp", (String) null));
- expectedUnCheckedPermissions
- .add(new WebUserDataPermission("/anyauthuser.jsp", "!GET,POST"));
- expectedUnCheckedPermissions.add(new WebUserDataPermission(
- "/:/unchecked.jsp:/secured.jsp:/sslprotected.jsp:/excluded.jsp:/anyauthuser.jsp",
- (String) null));
- expectedUnCheckedPermissions
- .add(new WebUserDataPermission("/unchecked.jsp", (String) null));
-
- TestUtil.logMsg("verifying unchecked policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedUnCheckedPermissions,
- uncheckedWebUserDataPermissions);
-
- if (!verified) {
- throw new Exception("WebUserDataPermission failed: "
- + "unchecked policy statements verification failed");
- } else {
- TestUtil.logMsg("unchecked policy statements verification successful");
- }
-
- // ---------EXCLUDED----------//
- // 1) retrieve server generated excluded policy statements
- // 2) construct expected excluded policy statements
- // 3) verify expected policy statements with generated policy statements
-
- // Get "excluded" WebUserDataPermission
- Permissions excludedWebUserDataPermissions = logProcessor
- .getSpecificPermissions(excludedPermissions, "WebUserDataPermission");
-
- TestUtil.logMsg("Server generated excluded WebUserDataPermission");
- logProcessor.printPermissionCollection(excludedWebUserDataPermissions);
-
- // Construct the expected excluded WebUserDataPermission
- expectedExcludedPermissions
- .add(new WebUserDataPermission("/excluded.jsp", "GET,POST"));
-
- TestUtil.logMsg("verifying excluded policy statments:");
-
- verified = logProcessor.verifyLogImplies(expectedExcludedPermissions,
- excludedWebUserDataPermissions);
-
- if (!verified) {
- throw new Exception("WebUserDataPermission failed: "
- + "excluded policy statements verification failed");
- } else {
- TestUtil.logMsg("excluded policy statements verification successful");
- }
- }
-
- /**
- * @testName: WebResourcePermissionEquals
- *
- * @assertion_ids: JACC:JAVADOC:40
- *
- * @test_Strategy: 1. When we deploy the applications defined in
- * toolsContracts, the equals() and hashcode() method will be
- * called on all JACC Permission classes. ( i.e
- * EJBMethodPermission, EJBRoleRefPermission,
- * WebResourcePermission, WebRoleRefPermission,
- * WebUserDataPermission)
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify the result of WebResourcePermission.equals()
- *
- *
- */
- public void WebResourcePermissionEquals() throws Exception {
- boolean verified = false;
-
- String tempArgs[] = { "WebResourcePermission.equals() : PASSED" };
-
- // verify the log contains the required string.
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("WebResourcePermissionEquals : FAILED");
- } else {
- TestUtil.logMsg("WebResourcePermissionEquals : PASSED");
- }
- }
-
- /**
- * @testName: WebRoleRefPermissionEquals
- *
- * @assertion_ids: JACC:JAVADOC:47
- *
- * @test_Strategy: 1. When we deploy the applications defined in
- * toolsContracts, the equals() and hashcode() method will be
- * called on all JACC Permission classes. ( i.e
- * EJBMethodPermission, EJBRoleRefPermission,
- * WebResourcePermission, WebRoleRefPermission,
- * WebUserDataPermission)
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify the result of WebRoleRefPermission.equals()
- *
- *
- */
- public void WebRoleRefPermissionEquals() throws Exception {
- boolean verified = false;
-
- String tempArgs[] = { "WebRoleRefPermission.equals() : PASSED" };
-
- // verify the log contains the required string.
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("WebRoleRefPermissionEquals : FAILED");
- } else {
- TestUtil.logMsg("WebRoleRefPermissionEquals : PASSED");
- }
- }
-
- /**
- * @testName: WebUserDataPermissionEquals
- *
- * @assertion_ids: JACC:JAVADOC:53
- *
- * @test_Strategy: 1. When we deploy the applications defined in
- * toolsContracts, the equals() and hashcode() method will be
- * called on all JACC Permission classes. ( i.e
- * EJBMethodPermission, EJBRoleRefPermission,
- * WebResourcePermission, WebRoleRefPermission,
- * WebUserDataPermission)
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify the result of WebUserDataPermission.equals()
- *
- *
- */
- public void WebUserDataPermissionEquals() throws Exception {
- boolean verified = false;
-
- String tempArgs[] = { "WebUserDataPermission.equals() : PASSED" };
-
- // verify the log contains the required string.
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("WebUserDataPermissionEquals : FAILED");
- } else {
- TestUtil.logMsg("WebUserDataPermissionEquals : PASSED");
- }
- }
-
- /**
- * @testName: WebResourcePermissionHashCode
- *
- * @assertion_ids: JACC:JAVADOC:42
- *
- * @test_Strategy: 1. When we deploy the applications defined in
- * toolsContracts, the equals() and hashcode() method will be
- * called on all JACC Permission classes. ( i.e
- * EJBMethodPermission, EJBRoleRefPermission,
- * WebResourcePermission, WebRoleRefPermission,
- * WebUserDataPermission)
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify the result of WebResourcePermission.hashCode()
- *
- *
- */
- public void WebResourcePermissionHashCode() throws Exception {
- boolean verified = false;
-
- String tempArgs[] = { "WebResourcePermission.hashCode() : PASSED" };
-
- // verify the log contains the required string.
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("WebResourcePermissionHashCode : FAILED");
- } else {
- TestUtil.logMsg("WebResourcePermissionHashCode : PASSED");
- }
- }
-
- /**
- * @testName: WebRoleRefPermissionHashCode
- *
- * @assertion_ids: JACC:JAVADOC:49
- *
- * @test_Strategy: 1. When we deploy the applications defined in
- * toolsContracts, the equals() and hashcode() method will be
- * called on all JACC Permission classes. ( i.e
- * EJBMethodPermission, EJBRoleRefPermission,
- * WebResourcePermission, WebRoleRefPermission,
- * WebUserDataPermission)
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify the result of WebRoleRefPermission.hashCode()
- *
- *
- */
- public void WebRoleRefPermissionHashCode() throws Exception {
- boolean verified = false;
-
- String tempArgs[] = { "WebRoleRefPermission.hashCode() : PASSED" };
-
- // verify the log contains the required string.
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("WebRoleRefPermissionHashCode : FAILED");
- } else {
- TestUtil.logMsg("WebRoleRefPermissionHashCode : PASSED");
- }
- }
-
- /**
- * @testName: WebUserDataPermissionHashCode
- *
- * @assertion_ids: JACC:JAVADOC:55
- *
- * @test_Strategy: 1. When we deploy the applications defined in
- * toolsContracts, the equals() and hashcode() method will be
- * called on all JACC Permission classes. ( i.e
- * EJBMethodPermission, EJBRoleRefPermission,
- * WebResourcePermission, WebRoleRefPermission,
- * WebUserDataPermission)
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify the result of WebUserDataPermission.hashCode()
- *
- *
- */
- public void WebUserDataPermissionHashCode() throws Exception {
- boolean verified = false;
-
- String tempArgs[] = { "WebUserDataPermission.hashCode() : PASSED" };
-
- // verify the log contains the required string.
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("WebUserDataPermissionHashCode : FAILED");
- } else {
- TestUtil.logMsg("WebUserDataPermissionHashCode : PASSED");
- }
- }
-
- /**
- * @testName: PolicyConfigurationFactory
- *
- * @assertion_ids: JACC:SPEC:25; JACC:SPEC:15; JACC:SPEC:63
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Use FetchLog servlet to read the server side log to
- * verify PolicyConfigurationFactory is called and
- * instantiated in the server.
- *
- * Description The getPolicyConfigurationFactory method must
- * be used in the containers to which the application or
- * module are being deployed to find or instantiate
- * PolicyConfigurationFactory objects.
- *
- */
- public void PolicyConfigurationFactory() throws Exception {
- boolean verified = false;
- String args[] = { "PolicyConfigurationFactory instantiated" };
-
- // verify whether the log contains required messages.
- verified = logProcessor.verifyLogContains(args);
-
- if (!verified) {
- throw new Exception("PolicyConfigurationFactory failed : "
- + "PolicyconfigurationFactory not instantiated");
- } else {
- TestUtil.logMsg("PolicyConfigurationFactory() instantiated");
- }
- }
-
- /**
- * @testName: GetPolicyConfiguration
- *
- * @assertion_ids: JACC:SPEC:26; JACC:JAVADOC:28; JACC:JAVADOC:29
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Use FetchLog servlet to read the server side log to
- * verify PolicyConfigurationFactory is called and
- * instantiated in the server.
- *
- * Description The getPolicyconfiguration method of the
- * factory must be used to find or instantiate
- * PolicyConfiguration objects corresponding to the
- * application or modules being deployed.
- *
- */
- public void GetPolicyConfiguration() throws Exception {
- boolean verified = false;
- String args[] = {
- "PolicyConfigurationFactory.getPolicyConfiguration() invoked" };
-
- // verify whether the log contains required messages.
- verified = logProcessor.verifyLogContains(args);
- if (!verified) {
- throw new Exception("GetPolicyConfiguration failed : "
- + "getPolicyconfiguration() was not invoked");
- } else {
- TestUtil.logMsg(
- "PolicyConfigurationFactory.getPolicyConfiguration() invoked");
- }
- }
-
- /**
- * @testName: validateNoInvalidStates
- *
- * @assertion_ids: JACC:SPEC:60;
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Use FetchLog servlet to read the server side log to
- * verify PolicyConfigurationFactory is called and
- * instantiated in the server.
- *
- * Description This method looks for occurances of error
- * message within JACCLog.txt where those error messags would
- * only appear in JACCLog.txt if there was a
- * policyConfiguration lifecycle state that was in the wrong
- * state at the wrong time. This can ONLY test the state for
- * being in the 'inService' state or not. So testing is done
- * to make sure the PolicyConfigration state is correct wrt
- * policyConfiguration.inService() for each of the methods
- * defined in the PolicyConfiguration javadoc table. Again,
- * this is not a complete validation of all states, but is
- * only able to validate if the state is inService or not at
- * each of the method calls based on the javadoc table.
- * Occurance of an ERROR message below would be a flag for a
- * method being in an incorrect state.
- */
- public void validateNoInvalidStates() throws Exception {
- boolean verified = false;
- String args1[] = {
- "ERROR - our policy config should not be in the INSERVICE state." };
- String args2[] = {
- "ERROR - our policy config should be in the INSERVICE state." };
-
- // verify that the log contains no errors related to the inService state
- verified = logProcessor.verifyLogContains(args1);
- if (verified) {
- // if here, then there was an error message where we were errorneously
- // caught in the inService state when we should not have been
- throw new Exception(
- "validateNoInvalidStates failed : detected error message of: "
- + args1[0]);
- } else {
- TestUtil.logMsg("validateNoInvalidStates() passed.");
- }
-
- verified = logProcessor.verifyLogContains(args2);
- if (verified) {
- // if here, then there was an error message where we were NOT
- // in the inService state but we should have been
- throw new Exception(
- "validateNoInvalidStates failed : detected error message of: "
- + args2[0]);
- } else {
- TestUtil.logMsg("validateNoInvalidStates() passed.");
- }
-
- }
-
- /**
- * @testName: PolicyRefresh
- *
- * @assertion_ids: JACC:SPEC:54; JACC:SPEC:5; JACC:SPEC:23
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Use FetchLog servlet to read the server side log and
- * verify that TSPolicy.refresh() method is called
- *
- * (Note: This assertion implicitly tests JACC:SPEC:5,
- * JACC:SPEC:23 i.e loading provider specified interfaces by
- * the containers)
- *
- */
- public void PolicyRefresh() throws Exception {
- boolean verified = false;
- String tempArgs[] = { "TSPolicy.refresh() invoked" };
-
- // verify the log contains TSPolicy.refresh().
- verified = logProcessor.verifyLogContains(tempArgs);
-
- if (!verified) {
- throw new Exception("PolicyRefresh() failed");
- } else {
- TestUtil.logMsg("TSPolicy.refresh() invoked");
- }
- }
-
- /**
- * @testName: Policy
- *
- * @assertion_ids: JACC:SPEC:53; JACC:SPEC:56; JACC:SPEC:67; JACC:SPEC:68;
- * JACC:SPEC:105; JACC:SPEC:14; JACC:SPEC:22
- *
- * @test_Strategy: 1. Register TS provider with the AppServer. (See User guide
- * for Registering TS Provider with your AppServer ).
- *
- * 2. Use FetchLog servlet, and verify the server side log
- * contains the following string "TSPolicy.refresh() invoked"
- *
- * 3. The occurance of the above string indicates the server
- * used the system property
- * jakarta.security.jacc.policy.provider to instantiate and
- * replace the policy object used by the JRE
- */
- public void Policy() throws Exception {
-
- boolean verified = false;
-
- String args[] = { "TSPolicy.refresh() invoked" };
-
- // verify whether the log contains required string.
- verified = logProcessor.verifyLogContains(args);
-
- if (!verified) {
- throw new Exception("TestName: Policy failed : "
- + "Policy replacement algorithm not used");
- } else {
- TestUtil.logMsg("System Policy loaded based on system properties");
- }
-
- }
-}
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/build.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/build.xml
deleted file mode 100644
index 83e2d46e4f..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/build.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/jacc_web_toolsContracts_web.war.sun-web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/jacc_web_toolsContracts_web.war.sun-web.xml
deleted file mode 100644
index 2e8161d5c7..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/jacc_web_toolsContracts_web.war.sun-web.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-
-
-
-
-
- jacc_web_toolsContracts_web
-
- Administrator
- j2ee
-
-
- Manager
- javajoe
-
-
- Employee
- javajoe
- j2ee
-
-
diff --git a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/jacc_web_toolsContracts_web.xml b/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/jacc_web_toolsContracts_web.xml
deleted file mode 100644
index 1707a5480e..0000000000
--- a/jacc/src/main/java/com/sun/ts/tests/jacc/web/toolsContracts/jacc_web_toolsContracts_web.xml
+++ /dev/null
@@ -1,165 +0,0 @@
-
-
-
-
- jacc_web_toolsContracts
-
- excluded
- excluded
- /excluded.jsp
- 0
-
-
- unchecked
- unchecked
- /unchecked.jsp
- 0
-
-
- sslprotected
- sslprotected
- /sslprotected.jsp
- 0
-
- ADM
- Administrator
-
-
- MGR
- Manager
-
-
-
- secured
- secured
- /secured.jsp
- 0
-
- ADM
- Administrator
-
-
-
- anyauthuser
- anyauthuser
- /anyauthuser.jsp
- 0
-
-
- excluded
- /excluded.jsp
-
-
- unchecked
- /unchecked.jsp
-
-
- sslprotected
- /sslprotected.jsp
-
-
- secured
- /secured.jsp
-
-
- anyauthuser
- /anyauthuser.jsp
-
-
- 54
-
-
-
- MySecureBit5
- /excluded.jsp
- POST
- GET
-
-
-
- NONE
-
-
-
-
- MySecureBit6
- /sslprotected.jsp
- POST
- GET
-
-
- Administrator
-
-
- CONFIDENTIAL
-
-
-
-
- MySecureBit3
- /secured.jsp
- POST
- GET
-
-
- Administrator
-
-
- NONE
-
-
-
-
- MySecureBit4
- /unchecked.jsp
- POST
- GET
-
-
- NONE
-
-
-
-
- MySecureBit5
- /anyauthuser.jsp
- GET
- POST
-
-
- **
-
-
- NONE
-
-
-
- BASIC
- default
-
-
- Administrator
-
-
- Manager
-
-
- Employee
-
-
diff --git a/pom.xml b/pom.xml
index 2291cc512b..36c3bb8200 100644
--- a/pom.xml
+++ b/pom.xml
@@ -47,9 +47,6 @@
ejb32
el
integration
-
-
- jacc
javaee
javamail
jaxrs
@@ -227,18 +224,6 @@
${project.version}
-
- ${project.groupId}
- jacc
- ${project.version}
-
-
-
- ${project.groupId}
- jaspic
- ${project.version}
-
-
${project.groupId}
javaee
@@ -353,12 +338,6 @@
${project.version}
-
- ${project.groupId}
- securityapi
- ${project.version}
-
-
${project.groupId}
servlet
diff --git a/release/tools/build.xml b/release/tools/build.xml
index 0de7b9a5d7..265c6a0f9a 100644
--- a/release/tools/build.xml
+++ b/release/tools/build.xml
@@ -85,10 +85,8 @@
-
-
@@ -443,18 +441,6 @@