FacebookProviderImpl.java
2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
* 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.FacebookApi
*/
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.FacebookApi;
@Service(value={Provider.class})
@Component(metatype=1, label="%auth.oauth.provider.facebook.name", description="%auth.oauth.provider.facebook.description")
@Properties(value={@Property(name="oauth.provider.id", value={"facebook"})})
@Reference(name="providerExtension", referenceInterface=ProviderExtension.class, bind="bindProviderExtension", unbind="unbindProviderExtension", cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
public class FacebookProviderImpl
extends ProviderBase {
public FacebookProviderImpl() {
super(ProviderType.OAUTH2, (Api)new FacebookApi(), "https://graph.facebook.com/me");
}
public String mapProperty(String property) {
if ("first_name".equals(property)) {
return "profile/givenName";
}
if ("last_name".equals(property)) {
return "profile/familyName";
}
if ("locale".equals(property)) {
return "preferences/language";
}
return super.mapProperty(property);
}
public Object mapValue(String key, String value) {
if ("profile/avatar".equals(key)) {
return "http://graph.facebook.com/" + value + "/picture";
}
return super.mapValue(key, value);
}
}