Appboard/2.4/admin/provisioning/custom jsp: Difference between revisions

imported>Jason.nicholls
No edit summary
imported>Jason.nicholls
No edit summary
Line 3: Line 3:
== Overview ==
== Overview ==


Another way to manage domains, users, roles, and role assignments is through the creation of a custom Java Server Page (JSP) that is run on the AppBoard server and exposed an web interface for management purposes.
Another way to manage domains, users, roles, and role assignments is through the creation of a custom Java Server Page (JSP) that is run on the AppBoard server and exposes a web interface for management purposes.
 
This document covers an example JSP implementation.


{{Warning|Creating custom JSPs that interface with AppBoard is not directly supported under the standard product maintenance contract. It is recommended this type of solution be implemented as part of a  
{{Warning|Creating custom JSPs that interface with AppBoard is not directly supported under the standard product maintenance contract. It is recommended this type of solution be implemented as part of a  
consulting engagement to ensure that it is configured and implemented correctly.  }}
consulting engagement to ensure that it is configured and implemented correctly.  }}
=== Installation and Configuration ===
Perform the following steps to install the Custom JSP for direct provisioning:
# Save the code shown in the "JSP Code" section below into a text file with the file name: selfProvisioning.jsp
# Modify the code as appropriate to meet the needs of the customer.
# Save the file in to <tt>[INSTALL_HOME]/server/webapps/enportal/pkg/system/selfProvisioning.jsp</tt>
# Invoke the self-provisioning options through the URL.  See details and examples provided below under <i>Applying Provisioning Updates</i>
# After creating the desired Users in the system, delete the <tt>selfProvisioning.jsp</tt> file from the system, so that users do not access the provisioning capabilities.
{{Warning|As long as the <tt>selfProvisioning.jsp</tt> file is placed in the system, the direct provisioning capabilities can be implemented by any User who has knowledge of the commands and access to the server in a browser.}}
=== JSP Code ===
<code>[xml,N]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="java.util.*"
import="com.edgetech.eportal.component.*"
import="com.edgetech.eportal.user.*"
import="com.edgetech.eportal.session.*"
import="com.edgetech.eportal.util.*"
import="com.edgetech.eportal.user.impl.*"
import="com.edgetech.util.logger.*"
import="com.edgetech.eportal.directory.*"
import="com.edgetech.eportal.executive.impl.PrivilegedServiceRegistry"
import="com.edgetech.eportal.executive.ServiceRegistry"
import="com.edgetech.eportal.session.impl.SessionServiceImpl"
import="com.edgetech.eportal.web.JSPUtilities"
import="com.edgetech.eportal.config.Config" %>
<jsp:useBean id="JspConfigBean" scope="application" class="com.edgetech.util.config.JspConfig" />
<%@ taglib uri="/PortalTagLibrary" prefix="portal" %>
<%
String username = request.getParameter("uid");
String password = "ChangeMe"; // Note: the initial password is set to "ChangeMe"!
String domainName = request.getParameter("domain");
String rolePath = request.getParameter("rolePath");
String errorMessage = "";
if (username != null && domainName != null && rolepath != null) {
SessionServiceImpl sessionService  = null;
AuthenticationToken systemSession = null;
try{
    sessionService = (SessionServiceImpl)PrivilegedServiceRegistry.getSessionService();
    systemSession = sessionService.createSystemSession();
UserService userService = ServiceRegistry.getUserService(systemSession);
Domain domain = UserPackageToolkit.makeDomain(domainName);
Role role = UserPackageToolkit.makeRoleFromAbsoluteString(rolePath);
String[] roleArray = rolePath.substring(1).split("/"); // Ignore the leading '/'
userService.createRole(roleArray);
String[] userArray = username.split(",");
for (int i=0; i< userArray.length; i++) {
User user = UserPackageToolkit.makeUser(domainName, userArray[i].trim());
userService.createUser(domain, userArray[i].trim(), password);
userService.assignUserToRole(user, role);
}
} catch (Exception exp) {
errorMessage = exp.getMessage();
exp.printStackTrace();
} finally {
// Terminate the system session.
sessionService.terminateSession(systemSession, SessionService.TERMCODE_LOGOUT);
}
if (errorMessage.equals("")) {
%>
<html>
<head>
<LINK href='<%=JSPUtilities.out(URLUtil.getPortalContext(), true)%>/framework/styles/editors.css' type=text/css rel=stylesheet>
<script type="text/javascript" src='<%=JSPUtilities.out(URLUtil.getPortalContext(), true)%>/framework/js/browser.js'></script>
</head>
<body>
<div align='center'>
<br/><br/><br/>
<%
out.println("User Creation successful. Please login to Portal.");
%>
<br/><br/><br/><button onClick="return cancel();" class=fixedWidth>Ok</button>
</div>
</body>
</html>
<%
return;
} else {
// re-write errorMessage here.//
}
}
%>
<html>
<head>
<title>Self Provisioning Form</title>
<LINK href='<%=JSPUtilities.out(URLUtil.getPortalContext(), true)%>/framework/styles/editors.css' type=text/css rel=stylesheet>
<script type="text/javascript" src='<%=JSPUtilities.out(URLUtil.getPortalContext(), true)%>/framework/js/browser.js'></script>
<script type="text/javascript">
var warned="";
function saveChanges(actionType)
{
    if (validateInput(document.inputForm))
    {
        document.inputForm.actionType.value = actionType;
        document.inputForm.submit();
    }
    return false;
}
function validateInput(workerForm)
{
    if ( ! isValidUsernameFieldType(workerForm.uid, "User Name", true, false))
    {
        workerForm.uid.focus();
        return false;
    }
    else if ( emptyString.test(workerForm.rolePath.value))
    {
        alert('Role cannot be empty.');
        workerForm.rolePath.focus();
        return false;
    }
    else if (emptyString.test(workerForm.domain.value))
    {
        alert('domain cannot be empty.');
        workerForm.domain.focus();
        return false;
    }
    return true;
}
</script>
</head>
<body>
<center>
<form name="inputForm" method="POST" action="">
<input type="hidden" name="actionType">
<div id="tabs" class="tabDiv">
<table border=0 cellspacing=0 cellpadding=0 width="96%">
<tr height=5><td></td></tr>
<tr height=20><td class="headerText" align='center'>Self Provisioning<hr></td></tr>
<tr height=4><td></td></tr>
</table>
</div>
<font class="propertyValue" color="red"><%=JSPUtilities.out(errorMessage)%></font>
<p>
<DIV id="generalDiv">
<table border=0 cellspacing=0 cellpadding=5 width="96%" class="box" style="border-width: 1;">
<tbody><tr>
    <td class="property" nowrap="nowrap">New User Name<br>
      <input value="" name="uid" size="200" maxlength="2000" type="text"></td>
    </tr>
  <td class="property" nowrap="nowrap">role<br>
    <input value="" name="rolePath" size="15" type="text"></td>
  </tr>
  <td class="property" nowrap="nowrap">domain<br>
    <input value="" name="domain" size="15" type="text" ></td>
  </tr> 
</tbody>
</table>
</div>
</form>
<br><div class="actionButtonDiv"><button onClick="return saveChanges('Ok');" class=fixedWidth>Continue</button>
&nbsp;&nbsp;<button onClick="return cancel();" class=fixedWidth>Cancel</button>
</center>
</body>
</html>
</code>
=== Usage ===
# <tt>uid</tt>, <tt>domain</tt>, and <tt>rolePath</tt> are required parameters in order for the provisioning code to run.
# Each new User's password is defaulted to "ChangeMe".
=== Applying Provisioning Updates ===
Perform the following steps to apply provisioning updates using the Custom JSP:
# Follow the steps above under <i>Installation and Configuration</i> to save the JSP code into the system.
# Enter a URL into the browser to invoke the self-provisioning command.  The URL will have the following format:
#* <nowiki>http://<serverhost>:<port>/enportal/pkg/system/selfProvisioning.jsp?uid=<userid01>,<userid02>,...,<userid_n>&domain=<DomainName>&rolePath=<RoleName></nowiki>
# Each user will be added to the system under the indicated Domain, and will be assigned the indicated Role.
Examples:
*<nowiki>http://localhost:8080/enportal/pkg/system/selfProvisioning.jsp?uid=jMurphy ,rJohnson ,bAckerman&domain=SafeCo&rolePath=/NOC</nowiki>
* <nowiki>http://rimagicor.com:8081/enportal/pkg/system/selfProvisioning.jsp?uid=INM18483 ,INM20170 ,INM05057 ,INM02642 ,INM05166 ,INM02642 ,INM31735 ,INM20170&domain=CustomerA&rolePath=/Users/East/Home</nowiki>
* <nowiki>http://myservername/enportal/pkg/system/selfProvisioning.jsp?uid=bill.thompson,amy.dobson,yolanda.pence&domain=North&rolePath=/SystemAdmin</nowiki>

Revision as of 15:19, 16 July 2014

Overview

Another way to manage domains, users, roles, and role assignments is through the creation of a custom Java Server Page (JSP) that is run on the AppBoard server and exposes a web interface for management purposes.

Template-warning.png
Creating custom JSPs that interface with AppBoard is not directly supported under the standard product maintenance contract. It is recommended this type of solution be implemented as part of a consulting engagement to ensure that it is configured and implemented correctly.