Package org.apache.lenya.ac

Examples of org.apache.lenya.ac.Item


     * @param accreditable The accreditable of the credential to wrap.
     * @param role The role of the credential to wrap.
     */
    public CredentialWrapper(Accreditable accreditable, Role role) {
        if (accreditable instanceof Item) {
            Item item = (Item) accreditable;
            accreditableId = item.getId();
            accreditableName = item.getName();
       
            if (item instanceof User) {
                type = USER;
            }
            else if (item instanceof Group) {
View Full Code Here


            }

            File[] addedFiles = notifier.getAddedFiles();

            for (int i = 0; i < addedFiles.length; i++) {
                Item item = loadItem(addedFiles[i]);
                add(item);
            }

            File[] removedFiles = notifier.getRemovedFiles();
            for (int i = 0; i < removedFiles.length; i++) {
                String fileName = removedFiles[i].getName();
                String id = fileName.substring(0, fileName.length() - getSuffix().length());

                Item item = (Item) items.get(id);

                if (item != null) {

                    if (item instanceof Groupable) {
                        ((Groupable) item).removeFromAllGroups();
                    }
                    if (item instanceof Group) {
                        ((Group) item).removeAllMembers();
                    }

                    remove(item);
                }
            }

            File[] changedFiles = notifier.getChangedFiles();
            for (int i = 0; i < changedFiles.length; i++) {
                Item item = loadItem(changedFiles[i]);
                update(item);
            }

        }
View Full Code Here

    protected Item loadItem(File file) throws AccessControlException {
        Configuration config = getItemConfiguration(file);

        String fileName = file.getName();
        String id = fileName.substring(0, fileName.length() - getSuffix().length());
        Item item = (Item) items.get(id);

        String klass = getItemClass(config);
        if (item == null) {
            try {
                item = (Item) Class.forName(klass).newInstance();
            } catch (Exception e) {
                String errorMsg =
                    "Exception when trying to instanciate: "
                        + klass
                        + " with exception: "
                        + e.fillInStackTrace();

                // an exception occured when trying to instanciate
                // a user.
                log.error(errorMsg);
                throw new AccessControlException(errorMsg, e);
            }
            item.setConfigurationDirectory(configurationDirectory);
        }

        try {
            item.configure(config);
        } catch (ConfigurationException e) {
            String errorMsg = "Exception when trying to configure: " + klass;
            throw new AccessControlException(errorMsg, e);
        }
        return item;
View Full Code Here

                    String paramName = operations[j] + "Credential_" + types[i];
                    if (getParameterAsString(paramName) != null) {
                        String roleId = getParameterAsString(ROLE);

                        String id = getParameterAsString(types[i]);
                        Item item = null;
                        if (types[i].equals(USER)) {
                            item = getUserManager().getUser(id);
                        } else if (types[i].equals(GROUP)) {
                            item = getGroupManager().getGroup(id);
                        } else if (types[i].equals(IPRANGE)) {
View Full Code Here

     * @param accreditable The accreditable of the credential to wrap.
     * @param role The role of the credential to wrap.
     */
    public CredentialWrapper(Accreditable accreditable, Role role) {
        if (accreditable instanceof Item) {
            Item item = (Item) accreditable;
            this.accreditableId = item.getId();
            this.accreditableName = item.getName();
       
            if (item instanceof User) {
                this.type = USER;
            }
            else if (item instanceof Group) {
View Full Code Here

            }

            File[] addedFiles = this.notifier.getAddedFiles();

            for (int i = 0; i < addedFiles.length; i++) {
                Item item = loadItem(addedFiles[i]);
                add(item);
            }

            File[] removedFiles = this.notifier.getRemovedFiles();
            for (int i = 0; i < removedFiles.length; i++) {
                String fileName = removedFiles[i].getName();
                String id = fileName.substring(0, fileName.length() - getSuffix().length());

                Item item = (Item) this.items.get(id);

                if (item != null) {

                    if (item instanceof Groupable) {
                        ((Groupable) item).removeFromAllGroups();
                    }
                    if (item instanceof Group) {
                        ((Group) item).removeAllMembers();
                    }

                    remove(item);
                }
            }

            File[] changedFiles = this.notifier.getChangedFiles();
            for (int i = 0; i < changedFiles.length; i++) {
                Item item = loadItem(changedFiles[i]);
                update(item);
            }

        }
View Full Code Here

    protected Item loadItem(File file) throws AccessControlException {
        Configuration config = getItemConfiguration(file);

        String fileName = file.getName();
        String id = fileName.substring(0, fileName.length() - getSuffix().length());
        Item item = (Item) this.items.get(id);

        String klass = ItemConfiguration.getItemClass(config);
        if (item == null) {
            try {
                item = (Item) Class.forName(klass).newInstance();
                item.enableLogging(getLogger());
            } catch (Exception e) {
                String errorMsg = "Exception when trying to instanciate: " + klass
                        + " with exception: " + e.fillInStackTrace();

                // an exception occured when trying to instanciate
                // a user.
                getLogger().error(errorMsg);
                throw new AccessControlException(errorMsg, e);
            }
            item.setConfigurationDirectory(this.configurationDirectory);
        }

        try {
            item.configure(config);
        } catch (ConfigurationException e) {
            String errorMsg = "Exception when trying to configure: " + klass;
            throw new AccessControlException(errorMsg, e);
        }
        return item;
View Full Code Here

     * @param role The role of the credential to wrap.
     * @param method
     */
    public CredentialWrapper(Accreditable accreditable, Role role, String method) {
        if (accreditable instanceof Item) {
            Item item = (Item) accreditable;
            this.accreditableId = item.getId();
            this.accreditableName = item.getName();
       
            if (item instanceof User) {
                this.type = USER;
            }
            else if (item instanceof Group) {
View Full Code Here

            }

            File[] addedFiles = this.notifier.getAddedFiles();

            for (int i = 0; i < addedFiles.length; i++) {
                Item item = loadItem(addedFiles[i]);
                add(item);
            }

            File[] removedFiles = this.notifier.getRemovedFiles();
            for (int i = 0; i < removedFiles.length; i++) {
                String fileName = removedFiles[i].getName();
                String id = fileName.substring(0, fileName.length() - getSuffix().length());

                Item item = (Item) this.items.get(id);

                if (item != null) {

                    if (item instanceof Groupable) {
                        ((Groupable) item).removeFromAllGroups();
                    }
                    if (item instanceof Group) {
                        ((Group) item).removeAllMembers();
                    }

                    remove(item);
                }
            }

            File[] changedFiles = this.notifier.getChangedFiles();
            for (int i = 0; i < changedFiles.length; i++) {
                Item item = loadItem(changedFiles[i]);
                update(item);
            }

        }
View Full Code Here

    protected Item loadItem(File file) throws AccessControlException {
        Configuration config = getItemConfiguration(file);

        String fileName = file.getName();
        String id = fileName.substring(0, fileName.length() - getSuffix().length());
        Item item = (Item) this.items.get(id);

        String klass = ItemConfiguration.getItemClass(config);
        if (item == null) {
            try {
                Class[] paramTypes = { ItemManager.class, Logger.class };
                Constructor ctor = Class.forName(klass).getConstructor(paramTypes);
                Object[] params = { this, getLogger() };
                item = (Item) ctor.newInstance(params);
            } catch (Exception e) {
                String errorMsg = "Exception when trying to instanciate: " + klass
                        + " with exception: " + e.fillInStackTrace();

                // an exception occured when trying to instanciate
                // a user.
                getLogger().error(errorMsg);
                throw new AccessControlException(errorMsg, e);
            }
        }

        try {
            item.configure(config);
        } catch (ConfigurationException e) {
            String errorMsg = "Exception when trying to configure: " + klass;
            throw new AccessControlException(errorMsg, e);
        }
        return item;
View Full Code Here

TOP

Related Classes of org.apache.lenya.ac.Item

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.