Package org.exist.security

Examples of org.exist.security.Permission


    @Override
    public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {

        if(isCalledAs("permissions-to-string")) {
            final int mode = ((IntegerValue)args[0].itemAt(0)).getInt();
            final Permission perm = PermissionFactory.getPermission(mode);
            return new StringValue(perm.toString());
        } else {
            final String permissionsString = args[0].itemAt(0).getStringValue();
            try {
                final Permission perm = UnixStylePermissionAider.fromString(permissionsString);
                return new IntegerValue(perm.getMode());
            } catch(final SyntaxException se) {
                throw new XPathException(this, se);
            }
        }
    }
View Full Code Here


   * @see org.exist.xquery.BasicFunction#eval(org.exist.xquery.value.Sequence[], org.exist.xquery.value.Sequence)
   */
  public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence)
    throws XPathException {
    try {
      final Permission perm = getPermissions(collection, args);
      return new IntegerValue(perm.getMode(), Type.INT);
        } catch (final XMLDBException xe) {
            logger.error("Unable to retrieve resource permissions");
            throw new XPathException(this, "Unable to retrieve resource permissions", xe);
        }
  }
View Full Code Here

   * @throws XPathException
   */
  protected Permission getPermissions(Collection collection, Sequence[] args)
        throws XMLDBException, XPathException {
    final UserManagementService ums = (UserManagementService) collection.getService("UserManagementService", "1.0");
    Permission perm;
    if(getSignature().getArgumentCount() == 2) {
        final Resource res = collection.getResource(args[1].getStringValue());
        if (res != null) {
            perm = ums.getPermissions(res);
        } else {
View Full Code Here

        final int mode = Integer.parseInt(octal, 8);
        return new StringValue(AbstractUnixStylePermission.modeToSimpleSymbolicMode(mode));
    }
   
    private Permission getPermissions(final XmldbURI pathUri) throws XPathException, PermissionDeniedException {
        final Permission permissions;
        final Collection col = context.getBroker().getCollection(pathUri);
        if(col != null) {
            permissions = col.getPermissionsNoLock();
        } else {
            final DocumentImpl doc = context.getBroker().getResource(pathUri, Permission.READ);
View Full Code Here

        CollectionManagementService mgr = (CollectionManagementService)
          root.getService("CollectionManagementService", "1.0");
                UserManagementService umgr = (UserManagementService)
                    root.getService("UserManagementService", "1.0");
        collection = mgr.createCollection(COLLECTION);
                Permission perms = umgr.getPermissions(collection);
                perms.setMode(0744);
                umgr.setPermissions(collection, perms);
      }
    } catch (Exception e) {
      throw new IrcException("Failed to initialize the database: " + e.getMessage());
    }
View Full Code Here

    public String[] getResources() throws XMLDBException {
        return listResources();
    }

    private Permission getPermission(final String owner, final String group, final int mode, final List<ACEAider> aces) throws PermissionDeniedException {
        final Permission perm = PermissionAiderFactory.getPermission(owner, group, mode);
        if(perm instanceof ACLPermission && aces != null && !aces.isEmpty()) {
            final ACLPermission aclPermission = (ACLPermission)perm;
            for(final ACEAider ace : aces) {
                aclPermission.addACE(ace.getAccessType(), ace.getTarget(), ace.getWho(), ace.getMode());
            }
View Full Code Here

        final Object[] acl = (Object[])hash.get("acl");
        List aces = null;
        if(acl != null) {
            aces = Arrays.asList(acl);
        }
        final Permission perm;
        try {
            perm = getPermission(owner, group, mode, (List<ACEAider>)aces);
        } catch(final PermissionDeniedException pde) {
            throw new XMLDBException(ErrorCodes.PERMISSION_DENIED, "Unable to retrieve permissions for resource '" + name + "': " + pde.getMessage(), pde);
        }
View Full Code Here

   */
  public Sequence evalWithCollection(Collection collection, Sequence[] args, Sequence contextSequence)
    throws XPathException {

    try {
      final Permission perm = getPermissions(collection, args);
      if("get-owner".equals(getSignature().getName().getLocalName())) {
        return new StringValue(perm.getOwner().getName());
            } else {
        return new StringValue(perm.getGroup().getName());
            }


        } catch (final XMLDBException xe) {
            logger.error("Unable to retrieve resource permissions");
View Full Code Here

     * @param collection The collection
     * @return TRUE if the conditions are met, else FALSE
     */
    private boolean isPermissionsOK(Collection collection) {

        Permission perms = collection.getPermissions();

        return (perms.getOwner().getName().equals(SecurityManager.SYSTEM)
                && perms.getGroup().getName().equals(SecurityManager.DBA_GROUP)
                && perms.getMode() == Permission.DEFAULT_SYSTEM_SECURITY_COLLECTION_PERM);

    }
View Full Code Here

     * @param collection The document
     * @return TRUE if the conditions are met, else FALSE
     */
    private boolean isPermissionsOK(DocumentImpl document) {

        Permission perms = document.getPermissions();

        return (perms.getOwner().hasDbaRole()
                && perms.getGroup().getName().equals(SecurityManager.DBA_GROUP)
                && perms.getMode() == Permission.DEFAULT_SYSTEM_SECURITY_COLLECTION_PERM
                && document.getMetadata().getMimeType().equals(REQUIRED_MIMETYPE));

    }
View Full Code Here

TOP

Related Classes of org.exist.security.Permission

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.