Package com.perforce.p4java.server
Class AbstractAuthHelper
- java.lang.Object
-
- com.perforce.p4java.server.AbstractAuthHelper
-
- Direct Known Subclasses:
AuthTicketsHelper
,FingerprintsHelper
public abstract class AbstractAuthHelper extends java.lang.Object
This super class is designed to lookup auth entries from file or memory.
-
-
Field Summary
Fields Modifier and Type Field Description protected static java.lang.String
AUTH_VALUE_MAP_KEY
static long
DEFAULT_LOCK_DELAY
static int
DEFAULT_LOCK_TRY
static long
DEFAULT_LOCK_WAIT
protected static java.lang.String
SERVER_ADDRESS_MAP_KEY
protected static java.lang.String
USER_NAME_MAP_KEY
-
Constructor Summary
Constructors Constructor Description AbstractAuthHelper()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description protected static java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getFileEntries(java.io.File authFile)
Get all the auth entries found in the specified auth file.protected static java.util.List<java.util.Map<java.lang.String,java.lang.String>>
getMemoryEntries(java.util.Map<java.lang.String,java.lang.String> authMap)
Get all the auth entries found in the specified auth store in memory.protected static java.util.Map<java.lang.String,java.lang.String>
getMemoryEntry(java.lang.String userName, java.lang.String serverAddress, java.util.Map<java.lang.String,java.lang.String> authMap)
Get the auth entry in the specified auth map that matches the specified user name and server address.protected static void
saveFileEntry(java.lang.String userName, java.lang.String serverAddress, java.lang.String authValue, java.io.File authFile, int lockTry, long lockDelay, long lockWait)
Save the specified parameters as an entry into the specified auth file.protected static void
saveMemoryEntry(java.lang.String userName, java.lang.String serverAddress, java.lang.String authValue, java.util.Map<java.lang.String,java.lang.String> authMap)
Save the specified parameters as an entry into the specified auth map.
-
-
-
Field Detail
-
DEFAULT_LOCK_TRY
public static final int DEFAULT_LOCK_TRY
- See Also:
- Constant Field Values
-
DEFAULT_LOCK_DELAY
public static final long DEFAULT_LOCK_DELAY
- See Also:
- Constant Field Values
-
DEFAULT_LOCK_WAIT
public static final long DEFAULT_LOCK_WAIT
- See Also:
- Constant Field Values
-
SERVER_ADDRESS_MAP_KEY
protected static final java.lang.String SERVER_ADDRESS_MAP_KEY
- See Also:
- Constant Field Values
-
USER_NAME_MAP_KEY
protected static final java.lang.String USER_NAME_MAP_KEY
- See Also:
- Constant Field Values
-
AUTH_VALUE_MAP_KEY
protected static final java.lang.String AUTH_VALUE_MAP_KEY
- See Also:
- Constant Field Values
-
-
Method Detail
-
getMemoryEntry
protected static java.util.Map<java.lang.String,java.lang.String> getMemoryEntry(java.lang.String userName, java.lang.String serverAddress, java.util.Map<java.lang.String,java.lang.String> authMap)
Get the auth entry in the specified auth map that matches the specified user name and server address. The user name be non-null and the server address must be non-null and be of the form server:port.- Parameters:
userName
- userNameserverAddress
- serverAddressauthMap
- authMap- Returns:
- - list of auth entries found in the specified auth map
-
getMemoryEntries
protected static java.util.List<java.util.Map<java.lang.String,java.lang.String>> getMemoryEntries(java.util.Map<java.lang.String,java.lang.String> authMap)
Get all the auth entries found in the specified auth store in memory.- Parameters:
authMap
- authMap- Returns:
- - list of auth entries found in the specified auth map
-
saveMemoryEntry
protected static void saveMemoryEntry(java.lang.String userName, java.lang.String serverAddress, java.lang.String authValue, java.util.Map<java.lang.String,java.lang.String> authMap)
Save the specified parameters as an entry into the specified auth map. This method will add or replace the current entry for the user name and server address in the auth map. If the specified auth value is null then the current entry (if exits) in the specified map will be removed.- Parameters:
userName
- - non-null user nameserverAddress
- - non-null server addressauthValue
- - possibly null auth valueauthMap
- - non-null auth map
-
getFileEntries
protected static java.util.List<java.util.Map<java.lang.String,java.lang.String>> getFileEntries(java.io.File authFile) throws java.io.IOException
Get all the auth entries found in the specified auth file.- Parameters:
authFile
- authFile- Returns:
- - list of auth entries found in the specified auth file
- Throws:
java.io.IOException
- - io exception from reading auth file
-
saveFileEntry
protected static void saveFileEntry(java.lang.String userName, java.lang.String serverAddress, java.lang.String authValue, java.io.File authFile, int lockTry, long lockDelay, long lockWait) throws java.io.IOException
Save the specified parameters as an entry into the specified auth file. This method will replace the current entry for the user name and server address in the auth file. If a current entry is not found then the specified entry will be appended to the file. If the specified auth value is null then the current entry in the specified file will be removed if found.- Parameters:
userName
- - non-null user nameserverAddress
- - non-null server addressauthValue
- - possibly null auth valueauthFile
- - non-null filelockTry
- lockTrylockDelay
- lockDelaylockWait
- lockWait- Throws:
java.io.IOException
- on error
-
-