Package org.apache.vysper.xmpp.authorization

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


    public static void main(String[] args) throws Exception {

        StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();

        AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);

        accountManagement.addUser("user1@vysper.org", "password1");
        accountManagement.addUser("user2@vysper.org", "password1");

        XMPPServer server = new XMPPServer("vysper.org");
        server.addEndpoint(new TCPEndpoint());
        server.setStorageProviderRegistry(providerRegistry);
View Full Code Here


    }

    private void startServer(int port) throws Exception {
        StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();

        AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);
        accountManagement.addUser(TEST_USERNAME1, TEST_PASSWORD1);
        accountManagement.addUser(TEST_USERNAME2, TEST_PASSWORD2);

        server = new XMPPServer(SERVER_DOMAIN);

        TCPEndpoint endpoint = new TCPEndpoint();
        endpoint.setPort(port);
View Full Code Here

    }

    private void startServer(int port) throws Exception {
        StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();

        AccountManagement accountManagement = (AccountManagement) providerRegistry.retrieve(AccountManagement.class);
        accountManagement.addUser(TEST_USERNAME1, TEST_PASSWORD1);
        accountManagement.addUser(TEST_USERNAME2, TEST_PASSWORD2);

        server = new XMPPServer(SERVER_DOMAIN);

        TCPEndpoint endpoint = new TCPEndpoint();
        endpoint.setPort(port);
View Full Code Here

        this.userPasswordMap.putAll(userPasswordMap);
    }

    public void setStorageProviderRegistry(StorageProviderRegistry storageProviderRegistry)
            throws AccountCreationException, EntityFormatException {
        AccountManagement accountManagement = (AccountManagement) storageProviderRegistry
                .retrieve(AccountManagement.class);
        if (accountManagement == null)
            throw new IllegalStateException("no account manager accessible.");

        for (String user : userPasswordMap.keySet()) {
            Entity entity = EntityImpl.parse(user);
            if (!accountManagement.verifyAccountExists(entity)) {
                String password = userPasswordMap.get(user);
                if (StringUtils.isEmpty(password)) {
                    password = RandomStringUtils.randomAlphanumeric(8);
                    System.out.println(user + " user will be added with random password: '" + password + "'");
                }
                accountManagement.addUser(entity, password);
            }
        }
    }
View Full Code Here

        }
       
        XMPPServer server = new XMPPServer(localServer.getDomain());

        StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();
        final AccountManagement accountManagement = (AccountManagement) providerRegistry
        .retrieve(AccountManagement.class);

        if (!accountManagement.verifyAccountExists(localUser)) {
            accountManagement.addUser(localUser, "password1");
        }

        // S2S endpoint
        server.addEndpoint(new S2SEndpoint());
       
View Full Code Here

        ResourceRegistry resourceRegistry = new ResourceRegistry();

        EntityImpl serverEntity = new EntityImpl(null, serverDomain, null);

        AccountManagement accountManagement = (AccountManagement) storageProviderRegistry
                .retrieve(AccountManagement.class);
        OfflineStanzaReceiver offlineReceiver = (OfflineStanzaReceiver) storageProviderRegistry.retrieve(OfflineStorageProvider.class);
        DeliveringInternalInboundStanzaRelay internalStanzaRelay = new DeliveringInternalInboundStanzaRelay(serverEntity,
                resourceRegistry, accountManagement,offlineReceiver);
        DeliveringExternalInboundStanzaRelay externalStanzaRelay = new DeliveringExternalInboundStanzaRelay();
View Full Code Here

        // choose the storage you want to use
        //StorageProviderRegistry providerRegistry = new JcrStorageProviderRegistry();
        StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();

        final Entity adminJID = EntityImpl.parseUnchecked("admin@" + domain);
        final AccountManagement accountManagement = (AccountManagement) providerRegistry
                .retrieve(AccountManagement.class);

        String initialPassword = System.getProperty("vysper.admin.initial.password", "CHOOSE SECURE PASSWORD");
        if (!accountManagement.verifyAccountExists(adminJID)) {
            accountManagement.addUser(adminJID, initialPassword);
        }

        XMPPServer server = new XMPPServer(domain);
        server.addEndpoint(new TCPEndpoint());
        //server.addEndpoint(new StanzaSessionFactory());
View Full Code Here

    }

    public AdhocCommandHandler getCommandHandler(String commandNode, Entity executingUser) {
        if (executingUser == null) return null;

        final AccountManagement accountManagement = (AccountManagement)serverRuntimeContext.getStorageProvider(AccountManagement.class);
        final ResourceRegistry resourceRegistry = serverRuntimeContext.getResourceRegistry();
       
        if (!admins.contains(executingUser.getBareJID())) {
            // non-admins can only admin their own accounts
            if (commandNode.equals(COMMAND_CHANGE_USER_PASSWORD)) {
View Full Code Here

        // choose the storage you want to use
        //StorageProviderRegistry providerRegistry = new JcrStorageProviderRegistry();
        StorageProviderRegistry providerRegistry = new MemoryStorageProviderRegistry();

        final AccountManagement accountManagement = (AccountManagement) providerRegistry
                .retrieve(AccountManagement.class);

        Entity user1 = EntityImpl.parse("user1@vysper.org");
        if (!accountManagement.verifyAccountExists(user1)) {
            accountManagement.addUser(user1, "password1");
        }
        Entity user2 = EntityImpl.parse("user2@vysper.org");
        if (!accountManagement.verifyAccountExists(user2)) {
            accountManagement.addUser(user2, "password1");
        }
        Entity user3 = EntityImpl.parse("user3@vysper.org");
        if (!accountManagement.verifyAccountExists(user3)) {
            accountManagement.addUser(user3, "password1");
        }

        XMPPServer server = new XMPPServer("vysper.org");

        server.addEndpoint(new TCPEndpoint());
View Full Code Here

                XMLElement passwordElm = query.getSingleInnerElementsNamed("password", NamespaceURIs.JABBER_IQ_REGISTER);
                if(passwordElm == null ||  passwordElm.getInnerText() == null) throw new XMLSemanticError("Invalid or missing password");
                String password = passwordElm.getInnerText().getText();
                if(password.trim().length() == 0) throw new XMLSemanticError("Invalid password");
   
                AccountManagement accountManagement = (AccountManagement) serverRuntimeContext.getStorageProvider(AccountManagement.class);
                Entity user;
                if(username.contains("@")) {
                    user = EntityImpl.parse(username);
                    if(!serverRuntimeContext.getServerEnitity().getDomain().equals(user.getDomain())) {
                        throw new XMLSemanticError("Username must be in the same domain as the server");
                    }
                } else {
                    user = EntityImpl.parse(username + "@" + serverRuntimeContext.getServerEnitity());
                }
               
                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();
               
            } catch (XMLSemanticError e) {
View Full Code Here

TOP

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

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.