Package org.apache.vysper.xmpp.authorization

Examples of org.apache.vysper.xmpp.authorization.AccountCreationException


    public void addUser(String username, String password) throws AccountCreationException {
        final EntityImpl entity;
        try {
            entity = EntityImpl.parse(username);
        } catch (EntityFormatException e) {
            throw new AccountCreationException("username is expected to be in proper entity format, not " + username, e); // wrap as unchecked
        }
        // if already existent, don't create, throw error
        try {
            if (jcrStorage.getEntityNode(entity, CREDENTIALS_NAMESPACE, false) != null) {
                throw new AccountCreationException("account already exists: " + entity.getFullQualifiedName());
            }
        } catch (JcrStorageException e) {
            throw new AccountCreationException("account exists check failed for " + entity.getFullQualifiedName(), e);
        }
        // now, finally, create
        try {
            final Node credentialsNode = jcrStorage.getEntityNode(entity, CREDENTIALS_NAMESPACE, true);
            credentialsNode.setProperty("password", password);
            credentialsNode.save();
            logger.info("JCR node created: " + credentialsNode);
        } catch (Exception e) {
            // TODO remove account?
            throw new AccountCreationException("failed to create the account set credentials", e);
        }

    }
View Full Code Here


    public void addUser(String username, String password) throws AccountCreationException {
        final EntityImpl entity;
        try {
            entity = EntityImpl.parse(username);
        } catch (EntityFormatException e) {
            throw new AccountCreationException("username is expected to be in proper entity format, not " + username, e); // wrap as unchecked
        }
        // if already existent, don't create, throw error
        try {
            if (jcrStorage.getEntityNode(entity, CREDENTIALS_NAMESPACE, false) != null) {
                throw new AccountCreationException("account already exists: " + entity.getFullQualifiedName());
            }
        } catch (JcrStorageException e) {
            throw new AccountCreationException("account exists check failed for " + entity.getFullQualifiedName(), e);
        }
        // now, finally, create
        try {
            final Node credentialsNode = jcrStorage.getEntityNode(entity, CREDENTIALS_NAMESPACE, true);
            credentialsNode.setProperty("password", password);
            credentialsNode.save();
            logger.info("JCR node created: " + credentialsNode);
        } catch (Exception e) {
            // TODO remove account?
            throw new AccountCreationException("failed to create the account set credentials", e);
        }

    }
View Full Code Here

    public void addUser(Entity username, String password) throws AccountCreationException {
        // if already existent, don't create, throw error
        try {
            if (jcrStorage.getEntityNode(username, CREDENTIALS_NAMESPACE, false) != null) {
                throw new AccountCreationException("account already exists: " + username.getFullQualifiedName());
            }
        } catch (JcrStorageException e) {
            throw new AccountCreationException("account exists check failed for " + username.getFullQualifiedName(), e);
        }
        // now, finally, create
        try {
            final Node credentialsNode = jcrStorage.getEntityNode(username, CREDENTIALS_NAMESPACE, true);
            credentialsNode.setProperty("password", password);
            credentialsNode.save();
            logger.info("JCR node created: " + credentialsNode);
        } catch (Exception e) {
            // TODO remove account?
            throw new AccountCreationException("failed to create the account set credentials", e);
        }

    }
View Full Code Here

            credentialsNode.setProperty("password", password);
            credentialsNode.save();
            logger.info("JCR password changed: " + credentialsNode);
        } catch (Exception e) {
            // TODO remove account?
            throw new AccountCreationException("failed to create the account set credentials", e);
        }
    }
View Full Code Here

                if(sessionContext.getState().equals(SessionState.AUTHENTICATED)) {
                    if(accountManagement.verifyAccountExists(user)) {
                        // account exists
                        accountManagement.changePassword(user, password);
                    } else {
                        throw new AccountCreationException("Account does not exist");
                    }
                } else {
                    if(accountManagement.verifyAccountExists(user)) {
                        // account exists
                        throw new AccountCreationException("Account already exists");
                    } else {
                        accountManagement.addUser(user, password);
                    }
                }
                return StanzaBuilder.createDirectReply(stanza, true, IQStanzaType.RESULT).build();
View Full Code Here

TOP

Related Classes of org.apache.vysper.xmpp.authorization.AccountCreationException

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.