Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7a10c50
commit 40d4b17
Showing
1 changed file
with
49 additions
and
0 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
src/webapp/src/java/org/wyona/yanel/servlet/CASTicketsMap.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,49 @@ | ||
package org.wyona.yanel.servlet; | ||
|
||
import java.util.HashMap; | ||
import java.util.Iterator; | ||
|
||
import org.wyona.security.core.api.Identity; | ||
|
||
import org.apache.logging.log4j.Logger; | ||
import org.apache.logging.log4j.LogManager; | ||
|
||
/** | ||
* CAS tickets map associating the CAS tickets of a user with the realms the user might be signed in (A user can be signed in to multiple realms) | ||
*/ | ||
public class CASTicketsMap extends HashMap { | ||
|
||
private static final Logger log = LogManager.getLogger(CASTicketsMap.class); | ||
|
||
/** | ||
* | ||
*/ | ||
public String getRealmId(String casTicket) { | ||
Iterator it = keySet().iterator(); | ||
while (it.hasNext()) { | ||
String realmId = (String) it.next(); | ||
if (casTicket.equals(this.get(realmId))) { | ||
return realmId; | ||
} | ||
} | ||
log.error("No realm ID for CAS ticket '" + casTicket + "'!"); | ||
return null; | ||
} | ||
|
||
/** | ||
* @see java.lang.Object#toString() | ||
*/ | ||
public String toString() { | ||
StringBuilder buf = new StringBuilder(); | ||
Iterator iter = this.keySet().iterator(); | ||
while (iter.hasNext()) { | ||
Object realmID = iter.next(); | ||
String ticket = (String) this.get(realmID); | ||
buf.append(ticket + " (" + realmID + " realm)"); | ||
if (iter.hasNext()) { | ||
buf.append(", "); | ||
} | ||
} | ||
return buf.toString(); | ||
} | ||
} |