while (itPrincipals.hasNext()) { I_CmsPrincipal principal = itPrincipals.next(); CmsListItem item = getList().newItem(principal.getId().toString()); item.set(LIST_COLUMN_NAME, principal.getName()); if (principal.isGroup()) { item.set(LIST_COLUMN_DISPLAY, translation.translateGroupName(principal.getName(), false)); } else { item.set(LIST_COLUMN_DISPLAY, principal.getSimpleName()); if (principal.isUser()) { if (principal.getId().equals(CmsAccessControlEntry.PRINCIPAL_ALL_OTHERS_ID) || principal.getId().equals(CmsAccessControlEntry.PRINCIPAL_OVERWRITE_ALL_ID)) { item.set(LIST_COLUMN_DESCRIPTION, ((CmsUser)principal).getDescription(getLocale())); } else { item.set(LIST_COLUMN_DESCRIPTION, ((CmsGroup)principal).getDescription(getLocale())); item.set(LIST_COLUMN_ORGUNIT, CmsOrganizationalUnit.SEPARATOR + principal.getOuFqn()); ret.add(item);
readPrincipal(dbc, principal.getId()); return; } catch (CmsDbEntryNotFoundException e) { conn = m_sqlManager.getConnection(dbc); stmt = m_sqlManager.getPreparedStatement(conn, "C_HISTORY_PRINCIPAL_CREATE"); stmt.setString(1, principal.getId().toString()); stmt.setString(2, principal.getSimpleName()); String desc = principal.getDescription(); desc = CmsStringUtil.isEmptyOrWhitespaceOnly(desc) ? "-" : desc; stmt.setString(3, desc); stmt.setString(4, CmsOrganizationalUnit.SEPARATOR + principal.getOuFqn()); if (principal instanceof CmsUser) { String email = ((CmsUser)principal).getEmail();
/** * Lists the access control entries belonging to the given principal.<p> * * @param resourceName the name of the resource * @param principalName the name of the principal * @throws Exception if something goes wrong */ public void lsacc(String resourceName, String principalName) throws Exception { I_CmsPrincipal principal = m_cms.lookupPrincipal(principalName); List<CmsAccessControlEntry> acList = m_cms.getAccessControlEntries(resourceName); for (int i = 0; i < acList.size(); i++) { CmsAccessControlEntry ace = acList.get(i); I_CmsPrincipal acePrincipal = m_cms.lookupPrincipal(ace.getPrincipal()); if (principal.equals(acePrincipal)) { String pName = (acePrincipal != null) ? acePrincipal.getName() : ace.getPrincipal().toString(); m_shell.getOut().println(pName + ": " + ace.getPermissions().getPermissionString() + " " + ace); } } }
/** * Returns the set of users that are responsible for a specific resource.<p> * * @param dbc the current database context * @param resource the resource to get the responsible users from * * @return the set of users that are responsible for a specific resource * * @throws CmsException if something goes wrong */ public Set<CmsUser> readResponsibleUsers(CmsDbContext dbc, CmsResource resource) throws CmsException { Set<CmsUser> result = new HashSet<CmsUser>(); Iterator<I_CmsPrincipal> principals = readResponsiblePrincipals(dbc, resource).iterator(); while (principals.hasNext()) { I_CmsPrincipal principal = principals.next(); if (principal.isGroup()) { try { result.addAll(getUsersOfGroup(dbc, principal.getName(), true, false, false)); } catch (CmsException e) { if (LOG.isInfoEnabled()) { LOG.info(e); } } } else { result.add((CmsUser)principal); } } return result; }
/** * Displays the access control list of a given resource.<p> * * @param resourceName the name of the resource * * @throws Exception if something goes wrong * * @see CmsObject#getAccessControlList(String) */ public void getAcl(String resourceName) throws Exception { CmsAccessControlList acList = m_cms.getAccessControlList(resourceName); Iterator principals = acList.getPrincipals().iterator(); while (principals.hasNext()) { I_CmsPrincipal p = m_cms.lookupPrincipal((CmsUUID)principals.next()); System.out.println(p.getName() + ": " + acList.getPermissions(p.getId()).getPermissionString()); } }
/** * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(I_CmsPrincipal obj) { if ((this == obj) || equals(obj)) { return 0; } return getName().compareTo(obj.getName()); }
/** * Contains the visibility handler configuration for a content field path.<p> */ protected static class VisibilityConfiguration { /** The handler instance. */ private I_CmsXmlContentVisibilityHandler m_handler; /** The handler configuration parameters. */ private String m_params; /** * Constructor.<p> * * @param handler the handler instance * @param params the handler configuration parameteres */ protected VisibilityConfiguration(I_CmsXmlContentVisibilityHandler handler, String params) { m_handler = handler; m_params = params; } /** * Returns the visibility handler instance.<p> * * @return the handler instance */ public I_CmsXmlContentVisibilityHandler getHandler() {
String id = (principal != null) ? principal.getName() : entry.getPrincipal().toString(); String name; String ou = null; int flags = 0; if ((principal != null) && principal.isGroup()) { name = key(org.opencms.security.Messages.GUI_ORGUNIT_DISPLAY_NAME_2, new Object[] { ((CmsGroup)principal).getDescription(getLocale()), principal.getSimpleName()}); ou = CmsOrganizationalUnit.getParentFqn(id); flags = CmsAccessControlEntry.ACCESS_FLAGS_GROUP; } else if ((principal != null) && principal.isUser()) { name = ((CmsUser)principal).getFullName(); ou = CmsOrganizationalUnit.getParentFqn(id);
I_CmsPrincipal principal = (I_CmsPrincipal)entry.getKey(); if (principal instanceof CmsHistoryPrincipal) { if (principal.isGroup()) { name = ((CmsHistoryPrincipal)principal).getDescription() + " (" + principal.getSimpleName() + ")"; image = "commons/group.png"; name = ((CmsGroup)principal).getDescription(getLocale()) + " (" + principal.getSimpleName() + ")"; image = "commons/group.png"; image = "commons/user.png"; ou = principal.getOuFqn(); } else {
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof I_CmsPrincipal) { if (m_id != null) { return m_id.equals(((I_CmsPrincipal)obj).getId()); } } return false; }
if (principal != null) { CmsPrincipalBean prinBean = new CmsPrincipalBean( principal.getName(), principal.getDescription(), principal.isGroup()); if (!resource.getRootPath().equals(res.getRootPath())) { if (resource.getRootPath().startsWith(storedSiteRoot)) {
name = ((CmsGroup)principal).getDescription(getLocale()) + " (" + principal.getSimpleName() + ")"; image = "commons/group.png"; image = "commons/user.png"; ou = principal.getOuFqn(); } else {
/** * Sets the access flags to identify the given principal type.<p> * * @param principal the principal to set the flags for */ public void setFlagsForPrincipal(I_CmsPrincipal principal) { setFlags( principal.isGroup() ? CmsAccessControlEntry.ACCESS_FLAGS_GROUP : CmsAccessControlEntry.ACCESS_FLAGS_USER); }
/** * Filters out all users with flags greater than <code>{@link I_CmsPrincipal#FLAG_CORE_LIMIT}</code>.<p> * * The given parameter list is directly modified, so the returned list is the same object as the input list.<p> * * @param users a list of <code>{@link CmsUser}</code> objects * * @return the filtered principal list */ public static List<CmsUser> filterCoreUsers(List<CmsUser> users) { Iterator<CmsUser> it = users.iterator(); while (it.hasNext()) { I_CmsPrincipal p = it.next(); if (p.getFlags() > I_CmsPrincipal.FLAG_CORE_LIMIT) { it.remove(); } } return users; }
/** * @see java.lang.Comparable#compareTo(java.lang.Object) */ public int compareTo(Object obj) { if ((this == obj) || this.equals(obj)) { return 0; } I_CmsPrincipal that = (I_CmsPrincipal)obj; return this.getName().compareTo(that.getName()); }
/** * @see java.lang.Object#equals(java.lang.Object) */ @Override public boolean equals(Object obj) { if (obj == this) { return true; } if (obj instanceof I_CmsPrincipal) { if (m_id != null) { return m_id.equals(((I_CmsPrincipal)obj).getId()); } } return false; }
/** * Displays the access control list of a given resource.<p> * * @param resourceName the name of the resource * * @throws Exception if something goes wrong * * @see CmsObject#getAccessControlList(String) */ public void getAcl(String resourceName) throws Exception { CmsAccessControlList acList = m_cms.getAccessControlList(resourceName); Iterator<CmsUUID> principals = acList.getPrincipals().iterator(); while (principals.hasNext()) { I_CmsPrincipal p = m_cms.lookupPrincipal(principals.next()); m_shell.getOut().println(p.getName() + ": " + acList.getPermissions(p.getId()).getPermissionString()); } }