1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!-- Content Stylesheet for Site -->
<!-- start the processing -->
<!-- ====================================================================== -->
<!-- Main Page Section -->
<!-- ====================================================================== -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<meta name="author" value="Cameron Riley">
<meta name="email" value="criley@ekmail.com">
<title>Turbine - Turbine Services</title>
</head>
<body bgcolor="#ffffff" text="#000000" link="#525D76">
<table border="0" width="100%" cellspacing="0">
<!-- TOP IMAGE -->
<tr>
<td align="left">
<a href="http://jakarta.apache.org"><img src="http://jakarta.apache.org/images/jakarta-logo.gif" border="0"/></a>
</td>
<td align="right">
<a href="http://jakarta.apache.org/turbine/"><img src="./images/logo.gif" alt="Turbine" border="0"/></a>
</td>
</tr>
</table>
<table border="0" width="100%" cellspacing="4">
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr>
<!-- LEFT SIDE NAVIGATION -->
<td valign="top" nowrap="true">
<p><strong>Essentials</strong></p>
<ul>
<li> <a href="./index.html">Overview</a>
</li>
<li> <a href="./features.html">Features</a>
</li>
<li> <a href="./fsd.html">Specification</a>
</li>
<li> <a href="./project-map.html">Project map</a>
</li>
<li> <a href="./install.html">Installation</a>
</li>
<li> <a href="./getting-started.html">Getting Started</a>
</li>
<li> <a href="./changes.html">Changes</a>
</li>
<li> <a href="./other-docs.html">Other Documentation</a>
</li>
</ul>
<p><strong>Models</strong></p>
<ul>
<li> <a href="./pullmodel.html">Pull MVC Model</a>
</li>
<li> <a href="./model2+1.html">Model 2+1</a>
</li>
<li> <a href="./j2ee-integration.html">J2EE Integration</a>
</li>
</ul>
<p><strong>Get Involved</strong></p>
<ul>
<li> <a href="./turbine-documentation-project.html">Turbine Documentation</a>
</li>
<li> <a href="./code-standards.html">Coding Spec</a>
</li>
<li> <a href="./contributors.html">Contributors</a>
</li>
<li> <a href="./branches.html">CVS Branches</a>
</li>
<li> <a href="http://jakarta.apache.org/site/cvsindex.html">CVS Repos</a>
</li>
<li> <a href="./faq.html">FAQ</a>
</li>
<li> <a href="./license.html">License</a>
</li>
<li> <a href="http://jakarta.apache.org/site/mail.html">Mailing Lists</a>
</li>
<li> <a href="./powered.html">Powered by Turbine</a>
</li>
<li> <a href="./todo.html">Todo</a>
</li>
<li> <a href="./active-developers.html">Active Developers</a>
</li>
<li> <a href="./proposals.html">Proposals</a>
</li>
</ul>
<p><strong>Documentation</strong></p>
<ul>
<li> <a href="./action-event.html">Action Events</a>
</li>
<li> <a href="./services.html">Services</a>
</li>
<li> <a href="./security.html">Turbine and Security</a>
</li>
<li> <a href="./python.html">Turbine and Python</a>
</li>
<li> <a href="./jsp-configuration.html">Turbine and JSP</a>
</li>
<li> <a href="./velocity-site.html">Velocity Site</a>
</li>
<li> <a href="./context-howto.html">Velocity Context</a>
</li>
<li> <a href="./webmacro-site.html">Webmacro Site</a>
</li>
</ul>
<p><strong>Database</strong></p>
<ul>
<li> <a href="./peers.html">Peers</a>
</li>
<li> <a href="./advpeers.html">Advanced Peers</a>
</li>
<li> <a href="./advcriteria.html">Advanced Criteria</a>
</li>
<li> <a href="./torque.html">Torque</a>
</li>
<li> <a href="./turbine-schema.html">Core Schema</a>
</li>
<li> <a href="./db-adapters.html">DB Adapters</a>
</li>
<li> <a href="./postgres-howto.html">Postgres Howto</a>
</li>
<li> <a href="./oracle-howto.html">Oracle 8i Howto</a>
</li>
<li> <a href="./sybase-howto.html">Sybase Howto</a>
</li>
</ul>
</td>
<td align="left" valign="top">
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Turbine Security"><strong>Turbine Security</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
The Turbine Security includes a <a href="services/security-service.html">Security Service</a> as well as Actions and Screens that can be extended in the Templating Services.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Users, Groups, Roles and Permissions"><strong>Users, Groups, Roles and Permissions</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
The default Relational Database schema that Turbine uses for the database security service, and which the TDK is generated with upon initialisation, includes the data structure for the managing of permissions. The default or core schema can be viewed at;
</p>
<p>
<ul><a href="turbine-schema.html">Turbine Core Schema</a></ul>
</p>
<p>
The main tables are TURBINE_GROUP, TURBINE_USER, TURBINE_ROLE and TURBINE_PERMISSION. The Permissions are the individual actions a user is allowed to take in the system. The Role is a container for the Permissions, in other words a Role can be made of many Permissions. User is an account that is interaction with the System and the Group is a something that a User would want to do something in. In the Turbine mailing lists it has often been described in the same way as a project. In a project you have fulfill a role, however a User doesnt "belong" to a project they merely have a role in that project ( or group ). In this manner too a User can have many Roles within the one Group. For instance a User may have the Role Developer in the Group, but may also have the Role of Administrator as well. While initially confusing at first, as there are no group-user or role-user containers, it is a flexible system and strong system.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Access Control Lists"><strong>Access Control Lists</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
A User's interaction through the system is controlled by the Permissions they are able to partake in. The AccessControlLists manage this information and present it via RunData and User Interfaces to the application. The RunData interface through the getACL() method presents the AccessControlList Object.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
//get the AccessControlList Object
//from RunData
AccessControlList acl = data.getACL();
//check if the User ( from the http request )
//has permission to view the invoices
if( acl.hasPermission("viewinvoice") )
{
data.setMessage("You have permission to view the invoices.");
setTemplate(data, "Invoice.vm");
}
else
{
data.setMessage("You do not have Permission to view the Invoices");
setTemplate(data, "UnauthorizedRequest.vm");
}
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
This will check if the User has permission to view this in the Global Group which is useful for managing Anonymous Users as well as logged in Users across your application. If however you need stronger security, such as only allowing users that have logged in, and have a Role in a specific Group, the Permission will need to be matched to the Group and User. As an example, assume one of your groups is "Accounting" and the Invoice information is only to be viewed by Usersthat have a Role in Accounting as well as the Permission "viewinvoice", the above method would be re-written;
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
//get the User from RunData
User user = data.getUser();
//get the AccessControlList Object
//from RunData
AccessControlList acl = data.getACL();
//check if the User has logged in,
//has a role in the group and
//has permission to view the invoices
if( user.hasLoggedIn() &&
acl.hasPermission("viewinvoice", "Accounting") )
{
data.setMessage("You have permission to view the invoices.");
setTemplate(data, "Invoice.vm");
}
else
{
data.setMessage("You do not have Permission to view the Invoices");
setTemplate(data, "UnauthorizedRequest.vm");
}
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
If instead the Permission could be across any of the Roles the User has, the method acl.hasPermission(String permission, GroupSet groups), can be used. As always check the Javadocs for more detail.
</p>
</blockquote>
</td></tr>
</table>
<table border="0" cellspacing="0" cellpadding="2" width="100%">
<tr><td bgcolor="#525D76">
<font color="#ffffff" face="arial,helvetica,sanserif">
<a name="Templates and Logging In"><strong>Templates and Logging In</strong></a>
</font>
</td></tr>
<tr><td>
<blockquote>
<p>
Managing Anonymous Users and Logged In Users poses problems in applications for managing the Secure/Strong parts of the application and the Unsecure/Weak parts of the application. In Turbine, the Action and Screen components make managing this process quite simple. Assume the only Velocity Template allowed to be viewed without being logged in is the actual Login.vm template. As this is the only Screen that needs to be Unsecure/Weak we can manage this via the parent of Login Screen.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
package com.mycompany.modules.screens;
//parent which allows Users to view the screen
public class WeakScreen extends VelocityScreen
{
//nothing to check that the User
//can view this screen
protected void doBuildTemplate( RunData data, Context context )
throws Exception
{
//call to Super
super.doBuildTemplate(data, context);
}
}
package com.mycompany.modules.screens;
//the java component of the Login Velocity Template
public class Login extends WeakScreen
{
//nothing to check that the User
//can view this screen
protected void doBuildTemplate( RunData data, Context context )
throws Exception
{
context.put("date",new Date());
//call to Super
super.doBuildTemplate(data, context);
}
}
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
Note that there is nothing in that method which checks that the User has logged in. On the other hand, for the Secure or Strong Actions and Screens we would want a check to ensure that the User has logged in.
</p>
<div align="left">
<table cellspacing="4" cellpadding="0" border="0">
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#ffffff"><pre>
package com.mycompany.modules.screens;
//Strong screen which checks for login
public class StrongScreen extends VelocityScreen
{
//check that User has Logged in before bothering
//to add anything to the context.
protected void doBuildTemplate( RunData data )
throws Exception
{
if (data.getUser().hasLoggedIn())
{
doBuildTemplate( data, TurbineVelocity.getContext( data ) );
}
else
{
//send the User to the Login Template
data.setMessage("Please Login first!");
setTemplate(data,"Login.vm");
}
}
}
package com.mycompany.modules.screens;
//as an example use the Invoices again
public class Invoice extends StrongScreen
{
//can view this screen
protected void doBuildTemplate( RunData data, Context context )
throws Exception
{
context.put("invoice",new Invoice());
//call to Super
super.doBuildTemplate(data, context);
}
}
</pre></td>
<td bgcolor="#023264" width="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
<tr>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
<td bgcolor="#023264" width="1" height="1"><img src="/images/void.gif" width="1" height="1" vspace="0" hspace="0" border="0"/></td>
</tr>
</table>
</div>
<p>
In the latter example, before the Screen populates the Context it will check for the User being logged in by the doBuildTemplate(data) method in the parent. If the test fails, the context isnt created for the Invoice screen. Another way to manage this is to seperate the screens into two packages, com.mycompany.modules.screens.unsecure and com.mycompany.modules.screens.secure and have a Default.java Screen in each of the packages mimicing the above approaches.
</p>
</blockquote>
</td></tr>
</table>
</td>
</tr>
<!-- FOOTER -->
<tr><td colspan="2">
<hr noshade="" size="1"/>
</td></tr>
<tr><td colspan="2">
<div align="center"><font color="#525D76" size="-1"><em>
Copyright © 1999-2001, Apache Software Foundation
</em></font></div>
</td></tr>
</table>
</body>
</html>
<!-- end the processing -->
|