This repository has been archived by the owner on Apr 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 91
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for revocation of access tokens. Initial support for alternat…
…ive (error) flows Use setArgsLocalized in ApplicationMessages to ensure that arguments are not localized Fix type-safety issue and make FacebookAccessTokenContext to be Serializable Use 'email' scope only if configuration scope is null Some needed fixes for Facebook flow with custom added scope Handle case when user denied dialog during Facebook OAuth interaction
- Loading branch information
Showing
16 changed files
with
410 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
108 changes: 108 additions & 0 deletions
108
...h-common/src/main/java/org/gatein/security/oauth/facebook/FacebookAccessTokenContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
/* | ||
* JBoss, a division of Red Hat | ||
* Copyright 2013, Red Hat Middleware, LLC, and individual | ||
* contributors as indicated by the @authors tag. See the | ||
* copyright.txt in the distribution for a full listing of | ||
* individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
*/ | ||
|
||
package org.gatein.security.oauth.facebook; | ||
|
||
import java.io.Serializable; | ||
import java.util.HashSet; | ||
import java.util.Iterator; | ||
import java.util.Set; | ||
|
||
/** | ||
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a> | ||
*/ | ||
public class FacebookAccessTokenContext implements Serializable { | ||
|
||
private final String accessToken; | ||
private final Set<String> scopes = new HashSet<String>(); | ||
|
||
public FacebookAccessTokenContext(String accessToken, String... scopes) { | ||
this.accessToken = accessToken; | ||
for (String scope : scopes) { | ||
this.scopes.add(scope); | ||
} | ||
} | ||
|
||
public FacebookAccessTokenContext(String accessToken, String scopesAsString) { | ||
this.accessToken = accessToken; | ||
String[] scopes = scopesAsString.split(","); | ||
for (String scope : scopes) { | ||
this.scopes.add(scope); | ||
} | ||
} | ||
|
||
public String getAccessToken() { | ||
return accessToken; | ||
} | ||
|
||
public boolean isScopeAvailable(String scope) { | ||
return scopes.contains(scope); | ||
} | ||
|
||
public String getScopesAsString() { | ||
Iterator<String> iterator = scopes.iterator(); | ||
StringBuilder result; | ||
|
||
if (iterator.hasNext()) { | ||
result = new StringBuilder(iterator.next()); | ||
} else { | ||
return ""; | ||
} | ||
|
||
while (iterator.hasNext()) { | ||
result.append("," + iterator.next()); | ||
} | ||
return result.toString(); | ||
} | ||
|
||
public boolean addScope(String scope) { | ||
return scopes.add(scope); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return new StringBuilder("FacebookAccessTokenContext [") | ||
.append("accessToken=" + accessToken) | ||
.append(", scope=" + getScopesAsString()) | ||
.append("]").toString(); | ||
} | ||
|
||
@Override | ||
public boolean equals(Object that) { | ||
if (that == this) { | ||
return true; | ||
} | ||
|
||
if (!(that instanceof FacebookAccessTokenContext)) { | ||
return false; | ||
} | ||
|
||
FacebookAccessTokenContext thatt = (FacebookAccessTokenContext)that; | ||
return this.accessToken.equals(thatt.getAccessToken()) && this.scopes.equals(thatt.scopes); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
return accessToken.hashCode() * 13 + scopes.hashCode(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.