public boolean authorise(Request request, Method method, Auth auth) { if (this.principal == null || auth == null) { logger.info("Invalid authorize in webdav:" + this.principal + ":" + auth); return false; } if (logger.isInfoEnabled()) logger.info( "authorise user in represource:" + this.principal + ":" + auth.getTag() + ":" + auth.getUser()); try { boolean hasAccess = AccessRightController.getController() .getIsPrincipalAuthorized(this.principal, "WebDAV.Read", true); logger.info("hasAccess:" + hasAccess); if (!hasAccess) return false; } catch (SystemException e) { e.printStackTrace(); } return true; }
public String doV3() throws Exception { try { doExecute(); String[] interceptionPointNames = new String[] {"Role.ManageUsers", "Role.ManageAccessRights", "Role.ReadForAssignment"}; AccessRightController.getController() .addUserRights(interceptionPointNames, getRoleName(), getInfoGluePrincipal()); } catch (ConstraintException e) { this.infoGluePrincipals = UserControllerProxy.getController().getAllUsers(); this.contentTypeDefinitionVOList = ContentTypeDefinitionController.getController() .getContentTypeDefinitionVOList(ContentTypeDefinitionVO.EXTRANET_ROLE_PROPERTIES); e.setResult(INPUT + "V3"); throw e; } return "successV3"; }
public String doExecute() throws Exception { AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); if (this.extraMultiParameter == null || this.extraMultiParameter.length == 0) { if (interceptionPointCategory.equalsIgnoreCase("Content")) { Integer contentId = new Integer(parameters); ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); if (!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) { Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); if (ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController() .getIsPrincipalAuthorized( this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString())) ceb.add(new AccessConstraintException("Content.contentId", "1006")); } } else if (interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) { Integer siteNodeVersionId = new Integer(parameters); SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); // If in published state we must first make it working state so it can later be published if (siteNodeVersionVO.getStateId().intValue() != SiteNodeVersionVO.WORKING_STATE) { this.oldParameters = "" + siteNodeVersionId; List events = new ArrayList(); siteNodeVersionVO = SiteNodeStateController.getController() .changeState( siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Access right changes", true, this.getInfoGluePrincipal(), siteNodeVersionVO.getSiteNodeId(), events); this.newParameters = "" + siteNodeVersionVO.getId(); this.parameters = "" + siteNodeVersionVO.getId(); siteNodeVersionId = siteNodeVersionVO.getId(); } if (!siteNodeVersionVO .getVersionModifier() .equalsIgnoreCase(this.getInfoGluePrincipal().getName())) { Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy() .getProtectedSiteNodeVersionId(siteNodeVersionId); if (protectedSiteNodeVersionId != null && !AccessRightController.getController() .getIsPrincipalAuthorized( this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", protectedSiteNodeVersionId.toString())) ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); } } ceb.throwIfNotEmpty(); } // logger.info("this.extraMultiParameters[i]:" + this.extraMultiParameter); if (this.extraMultiParameter != null && this.extraMultiParameter.length > 0) { for (int i = 0; i < this.extraMultiParameter.length; i++) { // logger.info("this.extraMultiParameters[i]:" + this.extraMultiParameter[i]); AccessRightController.getController() .update(this.extraMultiParameter[i], this.getRequest(), interceptionPointCategory); } } else { // logger.info("this.parameters:" + this.parameters); AccessRightController.getController() .update(this.parameters, this.getRequest(), interceptionPointCategory); } this.url = getResponse().encodeRedirectURL(this.returnAddress); if (newParameters != null) { this.url = this.url.replaceAll(this.oldParameters, this.newParameters); if (this.url.indexOf("ViewAccessRights") > -1) this.url = this.url + (!this.url.endsWith("&") ? "&stateChanged=true" : "stateChanged=true"); } if (this.url.indexOf("ViewAccessRights") > -1) { this.url = this.url.replaceAll("&saved=true", ""); this.url = this.url + "&saved=true"; } if (this.closeOnLoad) { this.url = this.url.replaceAll("&KeepThis=true", "&closeOnLoad=true&KeepThis=true"); } if (this.url.indexOf("ViewAccessRights") > -1) { this.url = this.url.replaceAll("&anchor=[0-9]{1,2}", ""); this.url = this.url + "&anchor=" + this.anchor; } if (this.returnAddress.indexOf("http") == 0) { getResponse().sendRedirect(url); return Action.NONE; } else return "success"; }
public String doAddGroups() throws Exception { AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer(); if (interceptionPointCategory.equalsIgnoreCase("Content")) { Integer contentId = new Integer(parameters); ContentVO contentVO = ContentControllerProxy.getController().getContentVOWithId(contentId); if (!contentVO.getCreatorName().equalsIgnoreCase(this.getInfoGluePrincipal().getName())) { Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId); if (ContentControllerProxy.getController().getIsContentProtected(contentId) && !AccessRightController.getController() .getIsPrincipalAuthorized( this.getInfoGluePrincipal(), "Content.ChangeAccessRights", protectedContentId.toString())) ceb.add(new AccessConstraintException("Content.contentId", "1006")); } } else if (interceptionPointCategory.equalsIgnoreCase("SiteNodeVersion")) { Integer siteNodeVersionId = new Integer(parameters); SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(siteNodeVersionId); // If in published state we must first make it working state so it can later be published if (siteNodeVersionVO.getStateId().intValue() != SiteNodeVersionVO.WORKING_STATE) { this.oldParameters = "" + siteNodeVersionId; List events = new ArrayList(); siteNodeVersionVO = SiteNodeStateController.getController() .changeState( siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Access right changes", true, this.getInfoGluePrincipal(), siteNodeVersionVO.getSiteNodeId(), events); this.newParameters = "" + siteNodeVersionVO.getId(); this.parameters = "" + siteNodeVersionVO.getId(); siteNodeVersionId = siteNodeVersionVO.getId(); } if (!siteNodeVersionVO .getVersionModifier() .equalsIgnoreCase(this.getInfoGluePrincipal().getName())) { Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy() .getProtectedSiteNodeVersionId(siteNodeVersionId); if (protectedSiteNodeVersionId != null && !AccessRightController.getController() .getIsPrincipalAuthorized( this.getInfoGluePrincipal(), "SiteNodeVersion.ChangeAccessRights", siteNodeVersionId.toString())) ceb.add(new AccessConstraintException("SiteNodeVersion.siteNodeId", "1006")); } } ceb.throwIfNotEmpty(); String[] groupNames = this.getRequest().getParameterValues("groupName"); AccessRightController.getController() .updateGroups(this.accessRightId, this.parameters, groupNames); this.url = getResponse().encodeRedirectURL(this.returnAddress); if (newParameters != null) { this.url = this.url.replaceAll(this.oldParameters, this.newParameters); if (this.url.indexOf("ViewAccessRights") > -1) this.url = this.url + (!this.url.endsWith("&") ? "&stateChanged=true" : "stateChanged=true"); } if (this.returnAddress.indexOf("http") == 0) { getResponse().sendRedirect(url); return Action.NONE; } else return "success"; }