Search in sources :

Example 16 with OAuthConsumer

use of com.liferay.opensocial.model.OAuthConsumer in project liferay-ide by liferay.

the class LiferayOAuthStoreProvider method _getOAuthConsumer.

private OAuthConsumer _getOAuthConsumer(String keyFileName, String keyName) {
    OAuthConsumer oAuthConsumer = new OAuthConsumerImpl();
    oAuthConsumer.setConsumerKey(_DEFAULT_CONSUMER_KEY);
    oAuthConsumer.setServiceName(_DEFAULT_SERVICE_NAME);
    String consumerSecret = null;
    String path = PropsUtil.get(PropsKeys.LIFERAY_HOME).concat(_KEY_DIR);
    path = path.replaceAll(StringPool.QUOTE, StringPool.BLANK);
    keyFileName = path.concat(keyFileName);
    try {
        consumerSecret = FileUtil.read(keyFileName);
    } catch (Exception e) {
    } finally {
        if (consumerSecret == null) {
            if (!FileUtil.exists(path)) {
                FileUtil.mkdirs(path);
            }
            if (_log.isWarnEnabled()) {
                _log.warn("Unable to load OAuth key from " + keyFileName);
            }
            return null;
        }
    }
    consumerSecret = _convertFromOpenSsl(consumerSecret);
    oAuthConsumer.setConsumerSecret(consumerSecret);
    oAuthConsumer.setKeyType(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE);
    oAuthConsumer.setKeyName(keyName);
    return oAuthConsumer;
}
Also used : OAuthConsumerImpl(com.liferay.opensocial.model.impl.OAuthConsumerImpl) OAuthConsumer(com.liferay.opensocial.model.OAuthConsumer)

Example 17 with OAuthConsumer

use of com.liferay.opensocial.model.OAuthConsumer in project liferay-ide by liferay.

the class OAuthConsumerModelImpl method equals.

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }
    if (!(obj instanceof OAuthConsumer)) {
        return false;
    }
    OAuthConsumer oAuthConsumer = (OAuthConsumer) obj;
    long primaryKey = oAuthConsumer.getPrimaryKey();
    if (getPrimaryKey() == primaryKey) {
        return true;
    } else {
        return false;
    }
}
Also used : OAuthConsumer(com.liferay.opensocial.model.OAuthConsumer)

Aggregations

OAuthConsumer (com.liferay.opensocial.model.OAuthConsumer)17 NoSuchOAuthConsumerException (com.liferay.opensocial.NoSuchOAuthConsumerException)9 StringBundler (com.liferay.portal.kernel.util.StringBundler)7 Session (com.liferay.portal.kernel.dao.orm.Session)6 SystemException (com.liferay.portal.kernel.exception.SystemException)6 OAuthConsumerImpl (com.liferay.opensocial.model.impl.OAuthConsumerImpl)5 Query (com.liferay.portal.kernel.dao.orm.Query)4 QueryPos (com.liferay.portal.kernel.dao.orm.QueryPos)3 UnmodifiableList (com.liferay.portal.kernel.util.UnmodifiableList)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 FinderPath (com.liferay.portal.kernel.dao.orm.FinderPath)2 Date (java.util.Date)1 GadgetException (org.apache.shindig.gadgets.GadgetException)1