Fix a possible ConcurrentModificationException in CredentialsManager.
This commit is contained in:
parent
17e931572e
commit
768db27837
@ -46,6 +46,8 @@ public class CredentialsManager
|
|||||||
* that one of them returned.
|
* that one of them returned.
|
||||||
*/
|
*/
|
||||||
public byte[] getLocalKey(String username)
|
public byte[] getLocalKey(String username)
|
||||||
|
{
|
||||||
|
synchronized(authorities)
|
||||||
{
|
{
|
||||||
for (CredentialsAuthority auth : authorities)
|
for (CredentialsAuthority auth : authorities)
|
||||||
{
|
{
|
||||||
@ -56,7 +58,7 @@ public class CredentialsManager
|
|||||||
return passwd;
|
return passwd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +77,8 @@ public class CredentialsManager
|
|||||||
* that one of them returned.
|
* that one of them returned.
|
||||||
*/
|
*/
|
||||||
public byte[] getRemoteKey(String username, String media)
|
public byte[] getRemoteKey(String username, String media)
|
||||||
|
{
|
||||||
|
synchronized(authorities)
|
||||||
{
|
{
|
||||||
for (CredentialsAuthority auth : authorities)
|
for (CredentialsAuthority auth : authorities)
|
||||||
{
|
{
|
||||||
@ -86,7 +90,7 @@ public class CredentialsManager
|
|||||||
return passwd;
|
return passwd;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -102,13 +106,15 @@ public class CredentialsManager
|
|||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean checkLocalUserName(String username)
|
public boolean checkLocalUserName(String username)
|
||||||
|
{
|
||||||
|
synchronized(authorities)
|
||||||
{
|
{
|
||||||
for (CredentialsAuthority auth : authorities)
|
for (CredentialsAuthority auth : authorities)
|
||||||
{
|
{
|
||||||
if( auth.checkLocalUserName(username))
|
if( auth.checkLocalUserName(username))
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,10 +125,13 @@ public class CredentialsManager
|
|||||||
* @param authority the {@link CredentialsAuthority} to add to this manager.
|
* @param authority the {@link CredentialsAuthority} to add to this manager.
|
||||||
*/
|
*/
|
||||||
public void registerAuthority(CredentialsAuthority authority)
|
public void registerAuthority(CredentialsAuthority authority)
|
||||||
|
{
|
||||||
|
synchronized(authorities)
|
||||||
{
|
{
|
||||||
if(!authorities.contains(authority))
|
if(!authorities.contains(authority))
|
||||||
authorities.add(authority);
|
authorities.add(authority);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes <tt>authority</tt> from the list of {@link CredentialsAuthority}s
|
* Removes <tt>authority</tt> from the list of {@link CredentialsAuthority}s
|
||||||
@ -132,7 +141,10 @@ public class CredentialsManager
|
|||||||
* manager.
|
* manager.
|
||||||
*/
|
*/
|
||||||
public void unregisterAuthority(CredentialsAuthority authority)
|
public void unregisterAuthority(CredentialsAuthority authority)
|
||||||
|
{
|
||||||
|
synchronized(authorities)
|
||||||
{
|
{
|
||||||
authorities.remove(authority);
|
authorities.remove(authority);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user