Package org.encuestame.persistence.domain.application

Examples of org.encuestame.persistence.domain.application.ApplicationConnection


        if (!session.authorized()) {
            throw new IllegalStateException("OAuthSession is not yet authorized");
        }
        log.debug("Grant Access is authorized "+session.authorized());
        try {
            ApplicationConnection connection = this.applicationDao.connectApplication(
                                  session.getAuthorizingAccountId(), session.getApiKey());
            log.debug("Grant Access new connection "+connection.getConnectionId());
            sessions.remove(requestToken);
            return connection;
        } catch (Exception e) {
            throw new IllegalStateException("Unable to grant access due to session - have the App's key changed?", e);
        }
View Full Code Here


     */
    @SuppressWarnings("unchecked")
    public ApplicationConnection findAppConnection(final String accessToken) throws EnMeNoResultsFoundException{
         final DetachedCriteria criteria = DetachedCriteria.forClass(ApplicationConnection.class);
         criteria.add(Restrictions.eq("accessToken", accessToken) );
         final ApplicationConnection app = (ApplicationConnection) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
         if(app == null){
            throw new EnMeNoResultsFoundException(accessToken);
         } else {
            return app;
         }
View Full Code Here

    public ApplicationConnection searchConnectionByAppIdAndUserId(
            final UserAccount account, final Application application){
         final DetachedCriteria criteria = DetachedCriteria.forClass(ApplicationConnection.class);
         criteria.add(Restrictions.eq("account", account) );
         criteria.add(Restrictions.eq("application", application) );
         final ApplicationConnection app = (ApplicationConnection) DataAccessUtils.uniqueResult(getHibernateTemplate().findByCriteria(criteria));
        return app;
    }
View Full Code Here

     */
    public ApplicationConnection
           connectApplication(final Long accountId, final String apiKey) throws Exception{
        final Application application = getApplicationByKey(apiKey);
        final UserAccount account = getAccountDaoImp().getUserAccountById(accountId);
        final ApplicationConnection app = searchConnectionByAppIdAndUserId(account, application);
        ApplicationConnection applicationConnection = null;
        if (app != null) {
            log.debug("Removing application connection id "+app.getConnectionId());
            getHibernateTemplate().delete(app);
        }
        //create new application connection.
        applicationConnection = new ApplicationConnection();
        final String accessToken = keyGenerator.generateKey();
        final String secret = keyGenerator.generateKey();
        applicationConnection.setApiKey(apiKey);
        applicationConnection.setApplication(application);
        applicationConnection.setAccessToken(accessToken);
        applicationConnection.setSecret(secret);
        applicationConnection.setAccount(account);
        getHibernateTemplate().saveOrUpdate(applicationConnection);
        log.debug("Created New Application Connection "+applicationConnection.getConnectionId());
        return applicationConnection;
    }
View Full Code Here

TOP

Related Classes of org.encuestame.persistence.domain.application.ApplicationConnection

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.