Commit ff06a6bf authored by toaster's avatar toaster
Browse files

added auth.management

git-svn-id: https://subversion.umiacs.umd.edu/ace/trunk@18 f1b3a171-7291-4a19-a512-95ad0ad9394a
parent 157126ac
......@@ -28,7 +28,6 @@
* Maryland Institute for Advanced Computer Study.
*/
// $Id$
package edu.umiacs.ace.monitor.users;
import edu.umiacs.ace.util.PersistUtil;
......@@ -53,109 +52,113 @@ public class DefaultAccountContextListener implements ServletContextListener {
*/
@Override
public void contextInitialized( ServletContextEvent arg0 ) {
try {
arg0.getServletContext().setAttribute("authmanagement", Boolean.valueOf(arg0.getServletContext().getInitParameter("auth.management")));
if ( Boolean.valueOf(arg0.getServletContext().getInitParameter("auth.management")) ) {
try {
// LOG.trace("Testing for account setup");
EntityManager em = PersistUtil.getEntityManager();
Query q = em.createNamedQuery("Users.listAllUsers");
if ( q.getResultList() == null || q.getResultList().size() == 0 ) {
LOG.debug("No accounts found, creating default admin");
Users u = new Users();
u.setPassword("admin");
u.setUsername("admin");
UserRoles status = new UserRoles();
status.setRolename("Status");
status.setUsername("admin");
UserRoles collMod = new UserRoles();
collMod.setRolename("Collection Modify");
collMod.setUsername("admin");
UserRoles browse = new UserRoles();
browse.setRolename("Browse");
browse.setUsername("admin");
UserRoles log = new UserRoles();
log.setRolename("Log");
log.setUsername("admin");
UserRoles audit = new UserRoles();
audit.setRolename("Audit");
audit.setUsername("admin");
UserRoles removeItem = new UserRoles();
removeItem.setRolename("Remove Item");
removeItem.setUsername("admin");
UserRoles users = new UserRoles();
users.setRolename("Users");
users.setUsername("admin");
UserRoles report = new UserRoles();
report.setRolename("Report");
report.setUsername("admin");
UserRoles dloadtoken = new UserRoles();
dloadtoken.setRolename("Download Token");
dloadtoken.setUsername("admin");
UserRoles dloaditem = new UserRoles();
dloaditem.setRolename("Download Item");
dloaditem.setUsername("admin");
UserRoles summary = new UserRoles();
summary.setRolename("Summary");
summary.setUsername("admin");
UserRoles compare = new UserRoles();
compare.setRolename("Compare");
compare.setUsername("admin");
UserRoles duplicates = new UserRoles();
duplicates.setRolename("Show Duplicates");
duplicates.setUsername("admin");
UserRoles auditSummaries = new UserRoles();
auditSummaries.setRolename("View Audit Summaries");
auditSummaries.setUsername("admin");
UserRoles actReporting = new UserRoles();
actReporting.setRolename("Modify Activity Reporting");
actReporting.setUsername("admin");
UserRoles partnerSite = new UserRoles();
partnerSite.setRolename("Modify Partner Sites");
partnerSite.setUsername("admin");
EntityTransaction et = em.getTransaction();
et.begin();
em.persist(u);
em.persist(status);
em.persist(collMod);
em.persist(browse);
em.persist(log);
em.persist(audit);
em.persist(removeItem);
em.persist(users);
em.persist(report);
em.persist(dloadtoken);
em.persist(dloaditem);
em.persist(summary);
em.persist(duplicates);
em.persist(compare);
em.persist(auditSummaries);
em.persist(actReporting);
em.persist(partnerSite);
et.commit();
EntityManager em = PersistUtil.getEntityManager();
Query q = em.createNamedQuery("Users.listAllUsers");
if ( q.getResultList() == null || q.getResultList().size() == 0 ) {
LOG.debug("No accounts found, creating default admin");
Users u = new Users();
u.setPassword("admin");
u.setUsername("admin");
UserRoles status = new UserRoles();
status.setRolename("Status");
status.setUsername("admin");
UserRoles collMod = new UserRoles();
collMod.setRolename("Collection Modify");
collMod.setUsername("admin");
UserRoles browse = new UserRoles();
browse.setRolename("Browse");
browse.setUsername("admin");
UserRoles log = new UserRoles();
log.setRolename("Log");
log.setUsername("admin");
UserRoles audit = new UserRoles();
audit.setRolename("Audit");
audit.setUsername("admin");
UserRoles removeItem = new UserRoles();
removeItem.setRolename("Remove Item");
removeItem.setUsername("admin");
UserRoles users = new UserRoles();
users.setRolename("Users");
users.setUsername("admin");
UserRoles report = new UserRoles();
report.setRolename("Report");
report.setUsername("admin");
UserRoles dloadtoken = new UserRoles();
dloadtoken.setRolename("Download Token");
dloadtoken.setUsername("admin");
UserRoles dloaditem = new UserRoles();
dloaditem.setRolename("Download Item");
dloaditem.setUsername("admin");
UserRoles summary = new UserRoles();
summary.setRolename("Summary");
summary.setUsername("admin");
UserRoles compare = new UserRoles();
compare.setRolename("Compare");
compare.setUsername("admin");
UserRoles duplicates = new UserRoles();
duplicates.setRolename("Show Duplicates");
duplicates.setUsername("admin");
UserRoles auditSummaries = new UserRoles();
auditSummaries.setRolename("View Audit Summaries");
auditSummaries.setUsername("admin");
UserRoles actReporting = new UserRoles();
actReporting.setRolename("Modify Activity Reporting");
actReporting.setUsername("admin");
UserRoles partnerSite = new UserRoles();
partnerSite.setRolename("Modify Partner Sites");
partnerSite.setUsername("admin");
EntityTransaction et = em.getTransaction();
et.begin();
em.persist(u);
em.persist(status);
em.persist(collMod);
em.persist(browse);
em.persist(log);
em.persist(audit);
em.persist(removeItem);
em.persist(users);
em.persist(report);
em.persist(dloadtoken);
em.persist(dloaditem);
em.persist(summary);
em.persist(duplicates);
em.persist(compare);
em.persist(auditSummaries);
em.persist(actReporting);
em.persist(partnerSite);
et.commit();
}
} catch ( Exception e ) {
LOG.error("Error creating default account", e);
}
} catch ( Exception e ) {
LOG.error("Error creating default account", e);
}
}
@Override
......
......@@ -28,7 +28,6 @@
* Maryland Institute for Advanced Computer Study.
*/
// $Id$
package edu.umiacs.ace.monitor.users;
import edu.umiacs.ace.util.EntityManagerServlet;
......@@ -79,7 +78,10 @@ public class UsersServlet extends EntityManagerServlet {
Users user = null;
String error = null;
boolean refresh = false;
if ( !Boolean.valueOf(getServletContext().getInitParameter("auth.management")) ) {
return;
}
String paramPass = request.getParameter(PARAM_PASSWORD);
// existing userId, lets load and update password
......
......@@ -4,7 +4,7 @@
prefix="aceam." suffix=".log" timestamp="true"/>
<!-- Configuration for authentication. This information should not need to be
changed at all. -->
changed at all unless you have your own authentication provider-->
<Realm className="org.apache.catalina.realm.DataSourceRealm"
dataSourceName="jdbc/aceamdb" debug="99" localDataSource="true"
roleNameCol="rolename" userCredCol="password" userNameCol="username"
......@@ -49,7 +49,13 @@
<!-- IMS hostname to use. Unless you deployed your own IMS, this should
probably not be changed -->
<Parameter name="ims" value="ims.umiacs.umd.edu"/>
<!-- Set this to true to disable internal user management. This should only be used
in conjunction with changes to the Authentication realm listed above.
Default: true;
-->
<Parameter name="auth.management" value="true"/>
<!-- log4j logging properties -->
<!-- change the A1.File value to a location of your logfile -->
<Parameter name="log4j.appender.A1.File" value="/tmp/aceam.log"/>
......
......@@ -5,12 +5,11 @@ The taglib directive below imports the JSTL library. If you uncomment it,
you must also add the JSTL library to the project. The Add Library... action
on Libraries node in Projects view can be used to add the JSTL 1.1 library.
--%>
<%--
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
--%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
"http://www.w3.org/TR/html4/loose.dtd">
<div class="menuheader">
<table>
......@@ -25,21 +24,25 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
<a href="EventLog?clear=1">Event Log</a>
</div>
</td>
<td align="center">
<div class="menucell">
<a href="Users">Accounts</a><BR>
<c:if test="${authmanagement}">
<a href="Users">Accounts</a><BR>
</c:if>
</div>
</td>
</tr>
</table>
</div>
<div class="header">
<img src="images/title.jpg" alt="ACE Audit Manager">
</div>
<!--
<div class="menubar">
<table>
<tr>
<td align="center">
......@@ -59,6 +62,6 @@ on Libraries node in Projects view can be used to add the JSTL 1.1 library.
</td>
</tr>
</table>
</div>
-->
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment