Author: vkumar
Date: Wed Dec 24 08:08:26 2008
New Revision: 729328
URL: http://svn.apache.org/viewvc?rev=729328&view=rev
Log:
Fixing New Principal creation
Modified:
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet$NewUserPrincipalPanel.html
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
Modified:
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet$NewUserPrincipalPanel.html
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet%24NewUserPrincipalPanel.html?rev=729328&r1=729327&r2=729328&view=diff
==============================================================================
---
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet$NewUserPrincipalPanel.html
(original)
+++
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet$NewUserPrincipalPanel.html
Wed Dec 24 08:08:26 2008
@@ -23,23 +23,11 @@
</td>
</tr>
<tr>
- <td class="portlet-section-alternate">Default Role: </td>
- <td class="portlet-section-body" align="left">
- <select wicket:id="userRole"></select>
- </td>
- </tr>
- <tr>
<td class="portlet-section-alternate">Profiling Rule: </td>
<td class="portlet-section-body" align="left">
- <select
wicket:id="profilingRole"></select>
+ <select
wicket:id="profilingRule"></select>
</td>
</tr>
- <tr>
- <td class="portlet-section-alternate">Subsites: </td>
- <td class="portlet-section-body" align="left">
- <select wicket:id="subsites"></select>
- </td>
- </tr>
</table>
<input type="submit" value="Add User" class="portlet-form-button"
wicket:id="addUser"/>
</form>
Modified:
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
URL:
http://svn.apache.org/viewvc/portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java?rev=729328&r1=729327&r2=729328&view=diff
==============================================================================
---
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
(original)
+++
portals/jetspeed-2/applications/j2-admin/trunk/src/main/java/org/apache/jetspeed/portlets/security/JetspeedPrincipalManagementPortlet.java
Wed Dec 24 08:08:26 2008
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.ResourceBundle;
+import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.jetspeed.audit.AuditActivity;
import org.apache.jetspeed.portlets.security.users.WicketUserAdmin;
@@ -285,7 +286,7 @@
try
{
Collection rules =
getProfiler().getRulesForPrincipal(getPrincipal());
- for (Iterator it = getUserRules().iterator();
it.hasNext();)
+ for (Iterator it = getUserRules().iterator();
it.hasNext();)
{
Map ruleMap = (Map) it.next();
if (Boolean.TRUE.equals(ruleMap.get("checked")))
@@ -440,66 +441,174 @@
protected class NewUserPrincipalPanel extends Panel
{
- boolean enabled;
protected String locatorName;
protected String ruleName;
protected List fullRules;
protected List userRules;
+ String userName;
+ String password;
+ boolean checkpass;
+ String profilingRule;
+
+
- /**
- * @return the enabled
- */
- public boolean isEnabled()
- {
- return enabled;
- }
+ /**
+ * @return the profilingRule
+ */
+ public String getProfilingRule() {
+ return profilingRule;
+ }
+
+
+
+ /**
+ * @param profilingRule the profilingRule to set
+ */
+ public void setProfilingRule(String profilingRule) {
+ this.profilingRule = profilingRule;
+ }
+
+
+
+ /**
+ * @return the userName
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+
+
+ /**
+ * @param userName the userName to set
+ */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
+
+
+
+ /**
+ * @return the password
+ */
+ public String getPassword() {
+ return password;
+ }
+
+
+
+ /**
+ * @param password the password to set
+ */
+ public void setPassword(String password) {
+ this.password = password;
+ }
- protected NewUserPrincipalPanel(String id)
+
+
+ /**
+ * @return the checkpass
+ */
+ public boolean isCheckpass() {
+ return checkpass;
+ }
+
+
+
+ /**
+ * @param checkpass the checkpass to set
+ */
+ public void setCheckpass(boolean checkpass) {
+ this.checkpass = checkpass;
+ }
+
+ protected NewUserPrincipalPanel(String id)
{
super(id);
Form userForm = new Form("newUserForm");
add(userForm);
- TextField userName = new TextField("userName");
+ TextField userName = new TextField("userName",new
PropertyModel(this, "userName"));
userForm.add(userName);
- TextField password = new TextField("password");
+ TextField password = new TextField("password",new
PropertyModel(this, "password"));
userForm.add(password);
- CheckBox changePassword = new CheckBox("checkpass");
+ CheckBox changePassword = new CheckBox("checkpass",new
PropertyModel(this, "checkpass"));
userForm.add(changePassword);
- DropDownChoice userRole = new DropDownChoice("userRole",
getRoleNames(""));
- userForm.add(userRole);
- DropDownChoice profilingtRole = new
DropDownChoice("profilingRole", getProfileList());
+ DropDownChoice profilingtRole = new
DropDownChoice("profilingRule",new PropertyModel(this, "profilingRule"),
getProfileList());
userForm.add(profilingtRole);
- DropDownChoice subsites = new DropDownChoice("subsites",
getProfileList());
- userForm.add(subsites);
- Button newUser = new Button("addUser");
+ Button newUser = new Button("addUser"){
+
+ @Override
+ public void onSubmit() {
+ JetspeedPrincipal principal =
getManager().newPrincipal(getUserName(),false);
+ try{
+
getManager().addPrincipal(principal, null);
+ User user =
((UserManager)getManager()).getUser(getUserName());
+
if(!StringUtils.isEmpty(getProfilingRule())){
+
getProfiler().setRuleForPrincipal(principal,
getProfiler().getRule(getProfilingRule()), "default");
+ }
+ UserManager userManager =
(UserManager)getManager();
+ PasswordCredential credential =
userManager.getPasswordCredential(user);
+
if(!StringUtils.isEmpty(getPassword())){
+
credential.setPassword(getPassword(), false);
+ }
+
credential.setUpdateRequired(isCheckpass());
+
userManager.storePasswordCredential(credential);
+ setPrincipal(user);
+ controlPannels(true);
+ }
+ catch (SecurityException jSx)
+ {
+ jSx.printStackTrace();
+ }
+ }
+
+ };
userForm.add(newUser);
}
}
protected class NewPrincipalPanel extends Panel
{
- boolean enabled;
- protected String locatorName;
- protected String ruleName;
- protected List fullRules;
- protected List userRules;
+ protected String userName;
+
/**
- * @return the enabled
- */
- public boolean isEnabled()
- {
- return enabled;
- }
+ * @return the userName
+ */
+ public String getUserName() {
+ return userName;
+ }
+
+
+ /**
+ * @param userName the userName to set
+ */
+ public void setUserName(String userName) {
+ this.userName = userName;
+ }
- protected NewPrincipalPanel(String id)
+
+ protected NewPrincipalPanel(String id)
{
super(id);
Form userForm = new Form("newUserForm");
add(userForm);
- TextField userName = new TextField("userName");
+ TextField userName = new TextField("userName",new
PropertyModel(this, "userName"));
userForm.add(userName);
- Button newUser = new Button("addUser");
+ Button newUser = new Button("addUser"){
+ @Override
+ public void onSubmit() {
+ JetspeedPrincipal principal =
getManager().newPrincipal(getUserName(),false);
+ try{
+
getManager().addPrincipal(principal, null);
+ }
+ catch (SecurityException jSx)
+ {
+ jSx.printStackTrace();
+ }
+ }
+
+ };
userForm.add(newUser);
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]