|
@@ -30,6 +30,7 @@ import org.springframework.security.web.authentication.preauth.PreAuthenticatedA
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.Assert;
|
|
|
|
|
|
+import java.text.MessageFormat;
|
|
|
import java.util.Collection;
|
|
|
import java.util.Date;
|
|
|
import java.util.Set;
|
|
@@ -294,6 +295,27 @@ public class CustomTokenServices implements AuthorizationServerTokenServices, Re
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public boolean revokeTokenByOpenId(String clientId, String phone,String openId) {
|
|
|
+ Collection<OAuth2AccessToken> list = tokenStore.findTokensByClientIdAndUserName(clientId, SecurityConstants.PHONE_PRINCIPAL_PREFIX + phone);
|
|
|
+
|
|
|
+ if (list == null || list.size() == 0) {
|
|
|
+ list = tokenStore.findTokensByClientIdAndUserName(clientId, MessageFormat.format("{0}:{1}:{2}", SecurityConstants.MA_PRINCIPAL_PREFIX, openId, phone));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (list != null) {
|
|
|
+ for (OAuth2AccessToken accessToken : list) {
|
|
|
+ if (accessToken != null) {
|
|
|
+ if (accessToken.getRefreshToken() != null) {
|
|
|
+ tokenStore.removeRefreshToken(accessToken.getRefreshToken());
|
|
|
+ }
|
|
|
+ tokenStore.removeAccessToken(accessToken);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public void revokeTokenByPhone(String phone) {
|
|
|
String[] clientIds = new String[] {"system", "student", "teacher","website"};
|
|
|
for (String cId : clientIds) {
|