ProfileValidators.java
2.82 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* Decompiled with CFR 0_118.
*
* Could not load the following classes:
* org.apache.felix.scr.annotations.Component
* org.apache.felix.scr.annotations.Reference
* org.apache.felix.scr.annotations.ReferenceCardinality
* org.apache.felix.scr.annotations.ReferencePolicy
* org.apache.felix.scr.annotations.Service
*/
package com.adobe.granite.auth.oauth.impl;
import com.adobe.granite.auth.oauth.ProfileValidator;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.felix.scr.annotations.Component;
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;
/*
* This class specifies class file version 49.0 but uses Java 6 signatures. Assumed Java 6.
*/
@Component(immediate=1)
@Service(value={ProfileValidators.class})
@Reference(name="profileValidator", referenceInterface=ProfileValidator.class, bind="bindProfileValidator", unbind="unbindProfileValidator", cardinality=ReferenceCardinality.OPTIONAL_MULTIPLE, policy=ReferencePolicy.DYNAMIC)
public class ProfileValidators {
private final ReadWriteLock lock = new ReentrantReadWriteLock();
private final List<ProfileValidator> profileValidators = new ArrayList<ProfileValidator>();
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
public boolean isValidProfile(String providerId, String userId, Map<String, Object> profileData) {
this.lock.readLock().lock();
try {
for (ProfileValidator profileValidator : this.profileValidators) {
if (!profileValidator.getId().equals(providerId) || profileValidator.isValidProfile(userId, profileData)) continue;
boolean bl = false;
return bl;
}
}
finally {
this.lock.readLock().unlock();
}
return true;
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
protected void bindProfileValidator(ProfileValidator profileValidator) {
this.lock.writeLock().lock();
try {
this.profileValidators.add(profileValidator);
}
finally {
this.lock.writeLock().unlock();
}
}
/*
* WARNING - Removed try catching itself - possible behaviour change.
*/
protected void unbindProfileValidator(ProfileValidator profileValidator) {
this.lock.writeLock().lock();
try {
this.profileValidators.remove(profileValidator);
}
finally {
this.lock.writeLock().unlock();
}
}
}