Examples of GDataAccount


Examples of org.apache.lucene.gdata.data.GDataAccount

    }

    public void testSaveUser() throws StorageException, IOException {

        GDataAccount user = new GDataAccount();
        user.setName(username);
        user.setPassword(password);
        StorageAccountWrapper wrapper = new StorageAccountWrapper(user);
        this.modifier.createAccount(wrapper);
        IndexSearcher searcher = new IndexSearcher(this.dir);
        Query q = new TermQuery(new Term(StorageAccountWrapper.FIELD_ACCOUNTNAME,
                username));
        Hits h = searcher.search(q);
        assertEquals("length == 1", 1, h.length());
        GDataAccount storedUser = StorageAccountWrapper.buildEntity(h.doc(0));
        assertTrue(storedUser.equals(user));
        searcher.close();
    }
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

        searcher.close();
    }

    public void testUpdateUser() throws StorageException, IOException {
        testSaveUser();
        GDataAccount user = new GDataAccount();
        user.setName(username);
        user.setPassword("newPass");
        StorageAccountWrapper wrapper = new StorageAccountWrapper(user);
        this.modifier.updateAccount(wrapper);
        IndexSearcher searcher = new IndexSearcher(this.dir);
        Query q = new TermQuery(new Term(StorageAccountWrapper.FIELD_ACCOUNTNAME,
                username));
        Hits h = searcher.search(q);
        assertEquals("length == 1", 1, h.length());
        GDataAccount storedUser = StorageAccountWrapper.buildEntity(h.doc(0));
        assertTrue(storedUser.equals(user));

        assertFalse(storedUser.getPassword().equals(password));
        searcher.close();
    }
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

                .lookup(AuthenticationController.class,
                        ComponentType.AUTHENTICATIONCONTROLLER);
        ServiceFactory factory = GDataServerRegistry.getRegistry().lookup(
                ServiceFactory.class, ComponentType.SERVICEFACTORY);
        AdminService adminService = factory.getAdminService();
        GDataAccount account;
        try {
            account = adminService.getFeedOwningAccount(request.getFeedId());
            String token = getTokenFromRequest(request.getHttpServletRequest());
            if (LOG.isDebugEnabled())
                LOG.debug("Got Token: " + token + "; for requesting account: "
                        + account);
            if (account != null && token != null)
                return controller.authenticateToken(token, clientIp,
                        AccountRole.ENTRYAMINISTRATOR, account.getName());

        } catch (ServiceException e) {
            LOG.error("can get GDataAccount for feedID -- "
                    + request.getFeedId(), e);
            throw new AuthenticatorException(" Service exception occured", e);
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

    /*
     * Test method for 'org.apache.lucene.gdata.server.authentication.AuthenticationController.authenticatAccount(HttpServletRequest)'
     */
    public void testAuthenticatAccount() throws IllegalBlockSizeException, BadPaddingException, AuthenticationException, IOException {
        GDataAccount account = new GDataAccount();
        account.setName(accountName);
        account.setPassword("testme");
        account.setRole(AccountRole.ENTRYAMINISTRATOR);
       
        String token = this.controller.authenticatAccount(account,this.clientIp);
        String notSame = this.controller.calculateAuthToken("192.168.0",Integer.toString(account.getRolesAsInt()),this.accountName);
        assertNotSame(notSame,token);
        String authString = "192.168.0#"+this.accountName +"#"+account.getRolesAsInt()+"#";
        assertTrue(this.controller.deCryptAuthToken(token).startsWith(authString));
        assertTrue(this.controller.deCryptAuthToken(notSame).startsWith(authString));
    }
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

    /*
     * Test method for 'org.apache.lucene.gdata.server.authentication.AuthenticationController.authenticateToken(String)'
     */
    public void testAuthenticateToken() throws IllegalBlockSizeException, BadPaddingException, UnsupportedEncodingException, AuthenticationException {
        GDataAccount account = new GDataAccount();
        account.setName("simon");
        account.setPassword("testme");
        account.setRole(AccountRole.ENTRYAMINISTRATOR);
        String token = this.controller.calculateAuthToken("192.168.0",Integer.toString(account.getRolesAsInt()),this.accountName);
       
        assertTrue(this.controller.authenticateToken(token,this.clientIp,AccountRole.ENTRYAMINISTRATOR,this.accountName));
        assertTrue(this.controller.authenticateToken(token,this.clientIp,AccountRole.USER,this.accountName));
        assertFalse(this.controller.authenticateToken(token,this.clientIp,AccountRole.USERADMINISTRATOR,"someOtherAccount"));
        try{
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

        if (account.getName() == null)
            throw new StorageException("can not update account -- name is null");
        if (account.getPassword() == null)
            throw new StorageException(
                    "can not update account -- password is null");
        GDataAccount persitentAccount = getAccount(account.getName());
        refreshPersistentObject(persitentAccount);
        try {
            this.container.set(account);
            this.container.delete(persitentAccount);
            this.container.commit();
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

     */
    public void deleteAccount(String accountname) throws StorageException {
        if (accountname == null)
            throw new StorageException(
                    "can not delete account -- account name is null");
        GDataAccount account = this.getAccount(accountname);
        refreshPersistentObject(account);
        if (LOG.isInfoEnabled())
            LOG.info("delete account -- account name: " + accountname);
        try {
            this.container.delete(account);
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

        query.descend("feed").descend("id").constrain(feed.getId()).equal();
        ObjectSet set = query.execute();
        if (set.hasNext())
            throw new StorageException("feed with feedID " + feed.getId()
                    + " is already stored");
        GDataAccount account = getAccount(accountname);
        refreshPersistentObject(account);
        feed.setAccount(account);
        /*
         * service config not required in db4o storage.
         * Entries/Feeds don't have to be build from xml
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

            throw new StorageException("Can not update feed -- id is null");
        if(feed.getServiceType() == null)
            throw new StorageException("Can not update feed -- service type is null");
        if(accountname == null)
            throw new StorageException("Account name is null");
        GDataAccount account = getAccount(accountname);
        Query query = this.container.query();
        query.constrain(ServerBaseFeed.class);
        query.descend("feed").descend("id").constrain(feed.getId());
        ObjectSet<ServerBaseFeed> set=  query.execute();
        if (set.size() > 1)
View Full Code Here

Examples of org.apache.lucene.gdata.data.GDataAccount

   
    public String getAccountNameForFeedId(String feedId)
            throws StorageException {
        if(feedId == null)
            throw new StorageException("feed id is null");
        GDataAccount account = getServerBaseFeed(feedId).getAccount();
        if(account == null)
            throw new IllegalStateException("No account stored with feed -- feedID: "+feedId);
       
        return account.getName();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.