TwitterProviderImpl.java 2.2 KB
/*
 * Decompiled with CFR 0_118.
 * 
 * Could not load the following classes:
 *  org.apache.felix.scr.annotations.Component
 *  org.apache.felix.scr.annotations.Properties
 *  org.apache.felix.scr.annotations.Property
 *  org.apache.felix.scr.annotations.Reference
 *  org.apache.felix.scr.annotations.ReferenceCardinality
 *  org.apache.felix.scr.annotations.ReferencePolicy
 *  org.apache.felix.scr.annotations.Service
 *  org.scribe.builder.api.Api
 *  org.scribe.builder.api.TwitterApi
 */
package com.adobe.granite.auth.oauth.impl;

import com.adobe.granite.auth.oauth.Provider;
import com.adobe.granite.auth.oauth.ProviderExtension;
import com.adobe.granite.auth.oauth.ProviderType;
import com.adobe.granite.auth.oauth.impl.ProviderBase;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Properties;
import org.apache.felix.scr.annotations.Property;
import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.ReferencePolicy;
import org.apache.felix.scr.annotations.Service;
import org.scribe.builder.api.Api;
import org.scribe.builder.api.TwitterApi;

@Service(value={Provider.class})
@Component(metatype=1, label="%auth.oauth.provider.twitter.name", description="%auth.oauth.provider.twitter.description")
@Properties(value={@Property(name="oauth.provider.id", value={"twitter"})})
@Reference(name="providerExtension", referenceInterface=ProviderExtension.class, bind="bindProviderExtension", unbind="unbindProviderExtension", cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
public class TwitterProviderImpl
extends ProviderBase {
    public TwitterProviderImpl() {
        super(ProviderType.OAUTH1A, (Api)new TwitterApi(), "http://api.twitter.com/1/account/verify_credentials.json");
    }

    public String mapProperty(String property) {
        if ("name".equals(property)) {
            return "profile/familyName";
        }
        if ("profile_image_url".equals(property)) {
            return "profile/avatar";
        }
        if ("lang".equals(property)) {
            return "preferences/language";
        }
        return super.mapProperty(property);
    }
}