コード例 #1
0
  public OAuthConsumer addOAuthConsumer(
      long companyId,
      String gadgetKey,
      String serviceName,
      String consumerKey,
      String consumerSecret,
      String keyType)
      throws SystemException {

    if (keyType.equals(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE)) {
      consumerSecret = StringPool.BLANK;
    }

    Date now = new Date();

    long oAuthConsumerId = counterLocalService.increment();

    OAuthConsumer oAuthConsumer = oAuthConsumerPersistence.create(oAuthConsumerId);

    oAuthConsumer.setCompanyId(companyId);
    oAuthConsumer.setCreateDate(now);
    oAuthConsumer.setModifiedDate(now);
    oAuthConsumer.setGadgetKey(gadgetKey);
    oAuthConsumer.setServiceName(serviceName);
    oAuthConsumer.setConsumerKey(consumerKey);
    oAuthConsumer.setConsumerSecret(consumerSecret);
    oAuthConsumer.setKeyType(keyType);

    oAuthConsumerPersistence.update(oAuthConsumer, false);

    return oAuthConsumer;
  }
コード例 #2
0
  public OAuthConsumer updateOAuthConsumer(
      long oAuthConsumerId,
      String consumerKey,
      String consumerSecret,
      String keyType,
      String keyName,
      String callbackURL)
      throws PortalException, SystemException {

    if (keyType.equals(OAuthConsumerConstants.KEY_TYPE_RSA_PRIVATE)) {
      consumerSecret = StringPool.BLANK;
    }

    OAuthConsumer oAuthConsumer = oAuthConsumerPersistence.findByPrimaryKey(oAuthConsumerId);

    oAuthConsumer.setConsumerKey(consumerKey);
    oAuthConsumer.setConsumerSecret(consumerSecret);
    oAuthConsumer.setKeyType(keyType);

    oAuthConsumerPersistence.update(oAuthConsumer, false);

    return oAuthConsumer;
  }