Search in sources :

Example 1 with OAuthConsumer

use of com.zimbra.soap.account.message.OAuthConsumer in project zm-mailbox by Zimbra.

the class GetOAuthConsumers method createConsumer.

private OAuthConsumer createConsumer(String accessToken, OAuthAccessor accessor) {
    OAuthConsumer zcsConsumer = new OAuthConsumer();
    zcsConsumer.setAccessToken(accessToken);
    zcsConsumer.setApplicationName((String) accessor.consumer.getProperty("app_name"));
    zcsConsumer.setApprovedOn((String) accessor.consumer.getProperty("approved_on"));
    zcsConsumer.setDevice((String) accessor.consumer.getProperty("device"));
    return zcsConsumer;
}
Also used : OAuthConsumer(com.zimbra.soap.account.message.OAuthConsumer)

Example 2 with OAuthConsumer

use of com.zimbra.soap.account.message.OAuthConsumer in project zm-mailbox by Zimbra.

the class GetOAuthConsumers method encodeResponse.

private void encodeResponse(Account account, GetOAuthConsumersResponse response) throws ServiceException {
    String[] accessors = account.getOAuthAccessor();
    OAuthAccessor accessor = null;
    for (String val : accessors) {
        try {
            String accessToken = val.substring(0, val.indexOf("::"));
            accessor = new OAuthAccessorSerializer().deserialize(val.substring(val.indexOf("::") + 2));
            OAuthConsumer zcsConsumer = createConsumer(accessToken, accessor);
            response.addConsumer(zcsConsumer);
        } catch (ServiceException e) {
            throw AuthProviderException.FAILURE("Error in deserializing OAuth accessor");
        }
    }
}
Also used : OAuthAccessor(net.oauth.OAuthAccessor) ServiceException(com.zimbra.common.service.ServiceException) OAuthAccessorSerializer(com.zimbra.cs.account.oauth.OAuthAccessorSerializer) OAuthConsumer(com.zimbra.soap.account.message.OAuthConsumer)

Aggregations

OAuthConsumer (com.zimbra.soap.account.message.OAuthConsumer)2 ServiceException (com.zimbra.common.service.ServiceException)1 OAuthAccessorSerializer (com.zimbra.cs.account.oauth.OAuthAccessorSerializer)1 OAuthAccessor (net.oauth.OAuthAccessor)1