You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2011/04/18 03:16:59 UTC
svn commit: r1094217 - in /incubator/lcf/trunk: ./
connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/
connectors/documentum/connector/src/main/java/org/apache/manifoldcf/crawler/authorities...
Author: kwright
Date: Mon Apr 18 01:16:59 2011
New Revision: 1094217
URL: http://svn.apache.org/viewvc?rev=1094217&view=rev
Log:
Fix for CONNECTORS-32. Added caching individually to the authority connectors that can benefit from it.
Modified:
incubator/lcf/trunk/ (props changed)
incubator/lcf/trunk/CHANGES.txt
incubator/lcf/trunk/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
incubator/lcf/trunk/connectors/documentum/connector/src/main/java/org/apache/manifoldcf/crawler/authorities/DCTM/AuthorityConnector.java
incubator/lcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkAuthority.java
incubator/lcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java
Propchange: incubator/lcf/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 18 01:16:59 2011
@@ -1,2 +1,3 @@
/incubator/lcf/branches/CONNECTORS-151-branch:1063444-1071206
/incubator/lcf/branches/CONNECTORS-160-branch:1071241-1071534
+/incubator/lcf/branches/CONNECTORS-32:1092556-1094216
Modified: incubator/lcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/CHANGES.txt?rev=1094217&r1=1094216&r2=1094217&view=diff
==============================================================================
--- incubator/lcf/trunk/CHANGES.txt (original)
+++ incubator/lcf/trunk/CHANGES.txt Mon Apr 18 01:16:59 2011
@@ -2,6 +2,10 @@ ManifoldCF Change Log
$Id$
======================= 0.3-dev =========================
+CONNECTORS-32: Add access token caching to the Active Directory
+authority connector, LiveLink authority connector, Meridio authority
+connector, and Documentum authority connector.
+(Shinichiro Abe, Karl Wright)
CONNECTORS-182: Install timed expiration of cached objects, which
was not hooked up to the idle cleanup architecture.
Modified: incubator/lcf/trunk/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java?rev=1094217&r1=1094216&r2=1094217&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java (original)
+++ incubator/lcf/trunk/connectors/activedirectory/connector/src/main/java/org/apache/manifoldcf/authorities/authorities/activedirectory/ActiveDirectoryAuthority.java Mon Apr 18 01:16:59 2011
@@ -45,6 +45,9 @@ public class ActiveDirectoryAuthority ex
private String userName = null;
private String password = null;
+ /** Cache manager. */
+ private ICacheManager cacheManager = null;
+
/** The initialized LDAP context (which functions as a session) */
private LdapContext ctx = null;
/** The time of last access to this ctx object */
@@ -67,18 +70,23 @@ public class ActiveDirectoryAuthority ex
{
}
- /** Return the path for the UI interface JSP elements.
- * These JSP's must be provided to allow the connector to be configured, and to
- * permit it to present document filtering specification information in the UI.
- * This method should return the name of the folder, under the <webapp>/connectors/
- * area, where the appropriate JSP's can be found. The name should NOT have a slash in it.
- *@return the folder part
+ /** Set thread context.
*/
- public String getJSPFolder()
+ public void setThreadContext(IThreadContext tc)
+ throws ManifoldCFException
{
- return "activedirectory";
+ super.setThreadContext(tc);
+ cacheManager = CacheManagerFactory.make(tc);
}
-
+
+ /** Clear thread context.
+ */
+ public void clearThreadContext()
+ {
+ super.clearThreadContext();
+ cacheManager = null;
+ }
+
/** Connect. The configuration parameters are included.
*@param configParams are the configuration parameters for this connection.
*/
@@ -152,6 +160,46 @@ public class ActiveDirectoryAuthority ex
public AuthorizationResponse getAuthorizationResponse(String userName)
throws ManifoldCFException
{
+ // Construct a cache description object
+ ICacheDescription objectDescription = new AuthorizationResponseDescription(userName,domainControllerName,this.userName,this.password);
+
+ // Enter the cache
+ ICacheHandle ch = cacheManager.enterCache(new ICacheDescription[]{objectDescription},null,null);
+ try
+ {
+ ICacheCreateHandle createHandle = cacheManager.enterCreateSection(ch);
+ try
+ {
+ // Lookup the object
+ AuthorizationResponse response = (AuthorizationResponse)cacheManager.lookupObject(createHandle,objectDescription);
+ if (response != null)
+ return response;
+ // Create the object.
+ response = getAuthorizationResponseUncached(userName);
+ // Save it in the cache
+ cacheManager.saveObject(createHandle,objectDescription,response);
+ // And return it...
+ return response;
+ }
+ finally
+ {
+ cacheManager.leaveCreateSection(createHandle);
+ }
+ }
+ finally
+ {
+ cacheManager.leaveCache(ch);
+ }
+ }
+
+ /** Obtain the access tokens for a given user name, uncached.
+ *@param userName is the user name or identifier.
+ *@return the response tokens (according to the current authority).
+ * (Should throws an exception only when a condition cannot be properly described within the authorization response object.)
+ */
+ protected AuthorizationResponse getAuthorizationResponseUncached(String userName)
+ throws ManifoldCFException
+ {
getSession();
//Create the search controls
@@ -418,7 +466,7 @@ public class ActiveDirectoryAuthority ex
}
// Protected methods
-
+
protected void getSession()
throws ManifoldCFException
{
@@ -542,6 +590,75 @@ public class ActiveDirectoryAuthority ex
return strSID.toString();
}
+ protected static long responseLifetime = 60000L;
+ protected static int LRUsize = 1000;
+ protected static StringSet emptyStringSet = new StringSet();
+
+ /** This is the cache object descriptor for cached access tokens from
+ * this connector.
+ */
+ protected static class AuthorizationResponseDescription extends org.apache.manifoldcf.core.cachemanager.BaseDescription
+ {
+ /** The user name associated with the access tokens */
+ protected String userName;
+ /** The domain controller associated with the access tokens */
+ protected String domainControllerName;
+ /** The admin user name */
+ protected String adminUserName;
+ /** The admin password */
+ protected String adminPassword;
+ /** The expiration time */
+ protected long expirationTime = -1;
+
+ /** Constructor. */
+ public AuthorizationResponseDescription(String userName, String domainControllerName,
+ String adminUserName, String adminPassword)
+ {
+ super("ActiveDirectoryAuthority",LRUsize);
+ this.userName = userName;
+ this.domainControllerName = domainControllerName;
+ this.adminUserName = adminUserName;
+ this.adminPassword = adminPassword;
+ }
+
+ /** Return the invalidation keys for this object. */
+ public StringSet getObjectKeys()
+ {
+ return emptyStringSet;
+ }
+
+ /** Get the critical section name, used for synchronizing the creation of the object */
+ public String getCriticalSectionName()
+ {
+ return getClass().getName() + "-" + userName + "-" + domainControllerName +
+ "-" + adminUserName + "-" + adminPassword;
+ }
+
+ /** Return the object expiration interval */
+ public long getObjectExpirationTime(long currentTime)
+ {
+ if (expirationTime == -1)
+ expirationTime = currentTime + responseLifetime;
+ return expirationTime;
+ }
+
+ public int hashCode()
+ {
+ return userName.hashCode() + domainControllerName.hashCode() + adminUserName.hashCode() +
+ adminPassword.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof AuthorizationResponseDescription))
+ return false;
+ AuthorizationResponseDescription ard = (AuthorizationResponseDescription)o;
+ return ard.userName.equals(userName) && ard.domainControllerName.equals(domainControllerName) &&
+ ard.adminUserName.equals(adminUserName) && ard.adminPassword.equals(adminPassword);
+ }
+
+ }
+
}
Modified: incubator/lcf/trunk/connectors/documentum/connector/src/main/java/org/apache/manifoldcf/crawler/authorities/DCTM/AuthorityConnector.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/documentum/connector/src/main/java/org/apache/manifoldcf/crawler/authorities/DCTM/AuthorityConnector.java?rev=1094217&r1=1094216&r2=1094217&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/documentum/connector/src/main/java/org/apache/manifoldcf/crawler/authorities/DCTM/AuthorityConnector.java (original)
+++ incubator/lcf/trunk/connectors/documentum/connector/src/main/java/org/apache/manifoldcf/crawler/authorities/DCTM/AuthorityConnector.java Mon Apr 18 01:16:59 2011
@@ -57,6 +57,9 @@ public class AuthorityConnector extends
protected static final AuthorizationResponse userNotFoundResponse = new AuthorizationResponse(new String[]{denyToken},AuthorizationResponse.RESPONSE_USERNOTFOUND);
protected static final AuthorizationResponse userUnauthorizedResponse = new AuthorizationResponse(new String[]{denyToken},AuthorizationResponse.RESPONSE_USERUNAUTHORIZED);
+ /** Cache manager. */
+ protected ICacheManager cacheManager = null;
+
// This is the DFC session; it may be null, or it may be set.
protected IDocumentum session = null;
protected long lastSessionFetch = -1L;
@@ -68,6 +71,23 @@ public class AuthorityConnector extends
super();
}
+ /** Set thread context.
+ */
+ public void setThreadContext(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ super.setThreadContext(tc);
+ cacheManager = CacheManagerFactory.make(tc);
+ }
+
+ /** Clear thread context.
+ */
+ public void clearThreadContext()
+ {
+ super.clearThreadContext();
+ cacheManager = null;
+ }
+
protected class GetSessionThread extends Thread
{
protected Throwable exception = null;
@@ -583,6 +603,46 @@ public class AuthorityConnector extends
if (Logging.authorityConnectors.isDebugEnabled())
Logging.authorityConnectors.debug("DCTM: Inside AuthorityConnector.getAuthorizationResponse for user '"+strUserNamePassedIn+"'");
+ // Construct a cache description object
+ ICacheDescription objectDescription = new AuthorizationResponseDescription(strUserNamePassedIn,docbaseName,userName,password,
+ domain,caseInsensitive,useSystemAcls);
+
+ // Enter the cache
+ ICacheHandle ch = cacheManager.enterCache(new ICacheDescription[]{objectDescription},null,null);
+ try
+ {
+ ICacheCreateHandle createHandle = cacheManager.enterCreateSection(ch);
+ try
+ {
+ // Lookup the object
+ AuthorizationResponse response = (AuthorizationResponse)cacheManager.lookupObject(createHandle,objectDescription);
+ if (response != null)
+ return response;
+ // Create the object.
+ response = getAuthorizationResponseUncached(strUserNamePassedIn);
+ // Save it in the cache
+ cacheManager.saveObject(createHandle,objectDescription,response);
+ // And return it...
+ return response;
+ }
+ finally
+ {
+ cacheManager.leaveCreateSection(createHandle);
+ }
+ }
+ finally
+ {
+ cacheManager.leaveCache(ch);
+ }
+ }
+
+ /** Uncached get response method. */
+ protected AuthorizationResponse getAuthorizationResponseUncached(String strUserNamePassedIn)
+ throws ManifoldCFException
+ {
+ if (Logging.authorityConnectors.isDebugEnabled())
+ Logging.authorityConnectors.debug("DCTM: Inside AuthorityConnector.getAuthorizationResponseUncached for user '"+strUserNamePassedIn+"'");
+
try
{
String strUserName;
@@ -1186,4 +1246,80 @@ public class AuthorityConnector extends
);
}
+ protected static long responseLifetime = 60000L;
+ protected static int LRUsize = 1000;
+ protected static StringSet emptyStringSet = new StringSet();
+
+ /** This is the cache object descriptor for cached access tokens from
+ * this connector.
+ */
+ protected static class AuthorizationResponseDescription extends org.apache.manifoldcf.core.cachemanager.BaseDescription
+ {
+ // The parameters upon which the cached results are based.
+ protected String userName;
+ protected String docbaseName;
+ protected String adminUserName;
+ protected String adminPassword;
+ protected String domain;
+ protected boolean caseInsensitive;
+ protected boolean useSystemACLs;
+ /** The expiration time */
+ protected long expirationTime = -1;
+
+ /** Constructor. */
+ public AuthorizationResponseDescription(String userName, String docbaseName,
+ String adminUserName, String adminPassword, String domain, boolean caseInsensitive, boolean useSystemACLs)
+ {
+ super("DocumentumDirectoryAuthority",LRUsize);
+ this.userName = userName;
+ this.docbaseName = docbaseName;
+ this.adminUserName = adminUserName;
+ this.adminPassword = adminPassword;
+ this.domain = domain;
+ this.caseInsensitive = caseInsensitive;
+ this.useSystemACLs = useSystemACLs;
+ }
+
+ /** Return the invalidation keys for this object. */
+ public StringSet getObjectKeys()
+ {
+ return emptyStringSet;
+ }
+
+ /** Get the critical section name, used for synchronizing the creation of the object */
+ public String getCriticalSectionName()
+ {
+ return getClass().getName() + "-" + userName + "-" + docbaseName +
+ "-" + adminUserName + "-" + adminPassword + "-" + ((domain==null)?"NULL":domain) + "-" +
+ (caseInsensitive?"true":"false") + "-" + (useSystemACLs?"true":"false");
+ }
+
+ /** Return the object expiration interval */
+ public long getObjectExpirationTime(long currentTime)
+ {
+ if (expirationTime == -1)
+ expirationTime = currentTime + responseLifetime;
+ return expirationTime;
+ }
+
+ public int hashCode()
+ {
+ return userName.hashCode() + docbaseName.hashCode() + adminUserName.hashCode() +
+ adminPassword.hashCode() + ((domain==null)?0:domain.hashCode()) +
+ (caseInsensitive?1:0) + (useSystemACLs?1:0);
+ }
+
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof AuthorizationResponseDescription))
+ return false;
+ AuthorizationResponseDescription ard = (AuthorizationResponseDescription)o;
+ return ard.userName.equals(userName) && ard.docbaseName.equals(docbaseName) &&
+ ard.adminUserName.equals(adminUserName) && ard.adminPassword.equals(adminPassword) &&
+ ((ard.domain==null||domain==null)?(ard.domain == domain):(ard.domain.equals(domain))) &&
+ ard.caseInsensitive == caseInsensitive && ard.useSystemACLs == useSystemACLs;
+ }
+
+ }
+
}
Modified: incubator/lcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkAuthority.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkAuthority.java?rev=1094217&r1=1094216&r2=1094217&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkAuthority.java (original)
+++ incubator/lcf/trunk/connectors/livelink/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/livelink/LivelinkAuthority.java Mon Apr 18 01:16:59 2011
@@ -68,6 +68,9 @@ public class LivelinkAuthority extends o
// So, for some kinds of errors, we just retry for a while hoping it will go away.
private static final int FAILURE_RETRY_COUNT = 5;
+ /** Cache manager. */
+ protected ICacheManager cacheManager = null;
+
// Livelink does not have "deny" permissions, and there is no such thing as a document with no tokens, so it is safe to not have a local "deny" token.
// However, people feel that a suspenders-and-belt approach is called for, so this restriction has been added.
// Livelink tokens are numbers, "SYSTEM", or "GUEST", so they can't collide with the standard form.
@@ -83,16 +86,21 @@ public class LivelinkAuthority extends o
{
}
- /** Return the path for the UI interface JSP elements.
- * These JSP's must be provided to allow the connector to be configured, and to
- * permit it to present document filtering specification information in the UI.
- * This method should return the name of the folder, under the <webapp>/connectors/
- * area, where the appropriate JSP's can be found. The name should NOT have a slash in it.
- *@return the folder part
+ /** Set thread context.
+ */
+ public void setThreadContext(IThreadContext tc)
+ throws ManifoldCFException
+ {
+ super.setThreadContext(tc);
+ cacheManager = CacheManagerFactory.make(tc);
+ }
+
+ /** Clear thread context.
*/
- public String getJSPFolder()
+ public void clearThreadContext()
{
- return "livelink";
+ super.clearThreadContext();
+ cacheManager = null;
}
/** Connect. The configuration parameters are included.
@@ -237,6 +245,43 @@ public class LivelinkAuthority extends o
public AuthorizationResponse getAuthorizationResponse(String userName)
throws ManifoldCFException
{
+ // Construct a cache description object
+ ICacheDescription objectDescription = new AuthorizationResponseDescription(userName,serverName,serverPort,
+ serverUsername,serverPassword);
+
+ // Enter the cache
+ ICacheHandle ch = cacheManager.enterCache(new ICacheDescription[]{objectDescription},null,null);
+ try
+ {
+ ICacheCreateHandle createHandle = cacheManager.enterCreateSection(ch);
+ try
+ {
+ // Lookup the object
+ AuthorizationResponse response = (AuthorizationResponse)cacheManager.lookupObject(createHandle,objectDescription);
+ if (response != null)
+ return response;
+ // Create the object.
+ response = getAuthorizationResponseUncached(userName);
+ // Save it in the cache
+ cacheManager.saveObject(createHandle,objectDescription,response);
+ // And return it...
+ return response;
+ }
+ finally
+ {
+ cacheManager.leaveCreateSection(createHandle);
+ }
+ }
+ finally
+ {
+ cacheManager.leaveCache(ch);
+ }
+ }
+
+ /** Uncached method to get access tokens for a user name. */
+ public AuthorizationResponse getAuthorizationResponseUncached(String userName)
+ throws ManifoldCFException
+ {
// First, do what's necessary to map the user name that comes in to a reasonable
// Livelink domain\\user combination.
@@ -741,6 +786,77 @@ public class LivelinkAuthority extends o
}
+ protected static long responseLifetime = 60000L;
+ protected static int LRUsize = 1000;
+ protected static StringSet emptyStringSet = new StringSet();
+
+ /** This is the cache object descriptor for cached access tokens from
+ * this connector.
+ */
+ protected static class AuthorizationResponseDescription extends org.apache.manifoldcf.core.cachemanager.BaseDescription
+ {
+ /** The user name associated with the access tokens */
+ protected String userName;
+
+ // The server connection parameters
+ protected String serverName;
+ protected int serverPort;
+ protected String serverUsername;
+ protected String serverPassword;
+
+ /** The expiration time */
+ protected long expirationTime = -1;
+
+ /** Constructor. */
+ public AuthorizationResponseDescription(String userName, String serverName, int serverPort,
+ String serverUsername, String serverPassword)
+ {
+ super("LiveLinkAuthority",LRUsize);
+ this.userName = userName;
+ this.serverName = serverName;
+ this.serverPort = serverPort;
+ this.serverUsername = serverUsername;
+ this.serverPassword = serverPassword;
+ }
+
+ /** Return the invalidation keys for this object. */
+ public StringSet getObjectKeys()
+ {
+ return emptyStringSet;
+ }
+
+ /** Get the critical section name, used for synchronizing the creation of the object */
+ public String getCriticalSectionName()
+ {
+ return getClass().getName() + "-" + userName + "-" + serverName +
+ "-" + Integer.toString(serverPort) + "-" + serverUsername + "-" + serverPassword;
+ }
+
+ /** Return the object expiration interval */
+ public long getObjectExpirationTime(long currentTime)
+ {
+ if (expirationTime == -1)
+ expirationTime = currentTime + responseLifetime;
+ return expirationTime;
+ }
+
+ public int hashCode()
+ {
+ return userName.hashCode() + serverName.hashCode() + new Integer(serverPort).hashCode() +
+ serverUsername.hashCode() + serverPassword.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof AuthorizationResponseDescription))
+ return false;
+ AuthorizationResponseDescription ard = (AuthorizationResponseDescription)o;
+ return ard.userName.equals(userName) && ard.serverName.equals(serverName) && ard.serverPort == serverPort &&
+ ard.serverUsername.equals(serverUsername) && ard.serverPassword.equals(serverPassword);
+ }
+
+ }
+
}
Modified: incubator/lcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java
URL: http://svn.apache.org/viewvc/incubator/lcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java?rev=1094217&r1=1094216&r2=1094217&view=diff
==============================================================================
--- incubator/lcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java (original)
+++ incubator/lcf/trunk/connectors/meridio/connector/src/main/java/org/apache/manifoldcf/crawler/connectors/meridio/MeridioAuthority.java Mon Apr 18 01:16:59 2011
@@ -67,7 +67,9 @@ public class MeridioAuthority extends or
private String UserName = null;
private String Password = null;
-
+ /** Cache manager. */
+ protected ICacheManager cacheManager = null;
+
final private static int MANAGE_DOCUMENT_PRIVILEGE = 17;
/** Deny access token for Meridio. All tokens begin with "U" or with "G", except the blanket "READ_ALL" that I create.
@@ -83,20 +85,22 @@ public class MeridioAuthority extends or
*/
public MeridioAuthority() {}
- /** Return the path for the UI interface JSP elements.
- * These JSP's must be provided to allow the connector to be configured, and to
- * permit it to present document filtering specification information in the UI.
- * This method should return the name of the folder, under the <webapp>/connectors/
- * area, where the appropriate JSP's can be found. The name should NOT have a slash in it.
- *@return the folder part
+ /** Set thread context.
*/
- public String getJSPFolder()
+ public void setThreadContext(IThreadContext tc)
+ throws ManifoldCFException
{
- final String jspFolder = "meridio";
- return jspFolder;
+ super.setThreadContext(tc);
+ cacheManager = CacheManagerFactory.make(tc);
+ }
+
+ /** Clear thread context.
+ */
+ public void clearThreadContext()
+ {
+ super.clearThreadContext();
+ cacheManager = null;
}
-
-
/** Connect. The configuration parameters are included.
*@param configParams are the configuration parameters for this connection.
@@ -444,6 +448,45 @@ public class MeridioAuthority extends or
public AuthorizationResponse getAuthorizationResponse(String userName)
throws ManifoldCFException
{
+ // Construct a cache description object
+ ICacheDescription objectDescription = new AuthorizationResponseDescription(userName,
+ DmwsURL.toString(),RmwsURL.toString(),MetaCartawsURL.toString(),
+ DMWSProxyHost,DMWSProxyPort,RMWSProxyHost,RMWSProxyPort,
+ MetaCartaWSProxyHost,MetaCartaWSProxyPort,this.UserName,this.Password);
+
+ // Enter the cache
+ ICacheHandle ch = cacheManager.enterCache(new ICacheDescription[]{objectDescription},null,null);
+ try
+ {
+ ICacheCreateHandle createHandle = cacheManager.enterCreateSection(ch);
+ try
+ {
+ // Lookup the object
+ AuthorizationResponse response = (AuthorizationResponse)cacheManager.lookupObject(createHandle,objectDescription);
+ if (response != null)
+ return response;
+ // Create the object.
+ response = getAuthorizationResponseUncached(userName);
+ // Save it in the cache
+ cacheManager.saveObject(createHandle,objectDescription,response);
+ // And return it...
+ return response;
+ }
+ finally
+ {
+ cacheManager.leaveCreateSection(createHandle);
+ }
+ }
+ finally
+ {
+ cacheManager.leaveCache(ch);
+ }
+ }
+
+ /** Uncached method to get an authorization response. */
+ public AuthorizationResponse getAuthorizationResponseUncached(String userName)
+ throws ManifoldCFException
+ {
if (Logging.authorityConnectors.isDebugEnabled())
Logging.authorityConnectors.debug("Meridio: Authentication user name = '" + userName + "'");
@@ -1257,4 +1300,110 @@ public class MeridioAuthority extends or
);
}
+ protected static long responseLifetime = 60000L;
+ protected static int LRUsize = 1000;
+ protected static StringSet emptyStringSet = new StringSet();
+
+ /** This is the cache object descriptor for cached access tokens from
+ * this connector.
+ */
+ protected static class AuthorizationResponseDescription extends org.apache.manifoldcf.core.cachemanager.BaseDescription
+ {
+ /** The user name associated with the access tokens */
+ protected String userName;
+
+ // The server connection parameters
+ protected String DmwsURL;
+ protected String RmwsURL;
+ protected String wsURL;
+ protected String DMWSProxyHost;
+ protected String DMWSProxyPort;
+ protected String RMWSProxyHost;
+ protected String RMWSProxyPort;
+ protected String wsProxyHost;
+ protected String wsProxyPort;
+ protected String adminUserName;
+ protected String adminPassword;
+
+ /** The expiration time */
+ protected long expirationTime = -1;
+
+ /** Constructor. */
+ public AuthorizationResponseDescription(String userName, String DmwsURL, String RmwsURL, String wsURL,
+ String DMWSProxyHost, String DMWSProxyPort, String RMWSProxyHost, String RMWSProxyPort,
+ String wsProxyHost, String wsProxyPort, String adminUserName, String adminPassword)
+ {
+ super("MeridioAuthority",LRUsize);
+ this.userName = userName;
+ this.DmwsURL = DmwsURL;
+ this.RmwsURL = RmwsURL;
+ this.wsURL = wsURL;
+ this.DMWSProxyHost = DMWSProxyHost;
+ this.DMWSProxyPort = DMWSProxyPort;
+ this.RMWSProxyHost = RMWSProxyHost;
+ this.RMWSProxyPort = RMWSProxyPort;
+ this.wsProxyHost = wsProxyHost;
+ this.wsProxyPort = wsProxyPort;
+ this.adminUserName = adminUserName;
+ this.adminPassword = adminPassword;
+ }
+
+ /** Return the invalidation keys for this object. */
+ public StringSet getObjectKeys()
+ {
+ return emptyStringSet;
+ }
+
+ /** Get the critical section name, used for synchronizing the creation of the object */
+ public String getCriticalSectionName()
+ {
+ return getClass().getName() + "-" + userName + "-" + DmwsURL +
+ "-" + RmwsURL+ "-" + wsURL + "-" +
+ ((DMWSProxyHost==null)?"":DMWSProxyHost) + "-" +
+ ((DMWSProxyPort==null)?"":DMWSProxyPort) + "-" +
+ ((RMWSProxyHost==null)?"":RMWSProxyHost) + "-" +
+ ((RMWSProxyPort==null)?"":RMWSProxyPort) + "-" +
+ ((wsProxyHost==null)?"":wsProxyHost) + "-" +
+ ((wsProxyPort==null)?"":wsProxyPort) + "-" +
+ adminUserName + "-" + adminPassword;
+ }
+
+ /** Return the object expiration interval */
+ public long getObjectExpirationTime(long currentTime)
+ {
+ if (expirationTime == -1)
+ expirationTime = currentTime + responseLifetime;
+ return expirationTime;
+ }
+
+ public int hashCode()
+ {
+ return userName.hashCode() + DmwsURL.hashCode() + RmwsURL.hashCode() + wsURL.hashCode() +
+ ((DMWSProxyHost==null)?0:DMWSProxyHost.hashCode()) +
+ ((DMWSProxyPort==null)?0:DMWSProxyPort.hashCode()) +
+ ((RMWSProxyHost==null)?0:RMWSProxyHost.hashCode()) +
+ ((RMWSProxyPort==null)?0:RMWSProxyPort.hashCode()) +
+ ((wsProxyHost==null)?0:wsProxyHost.hashCode()) +
+ ((wsProxyPort==null)?0:wsProxyPort.hashCode()) +
+ adminUserName.hashCode() + adminPassword.hashCode();
+ }
+
+ public boolean equals(Object o)
+ {
+ if (!(o instanceof AuthorizationResponseDescription))
+ return false;
+ AuthorizationResponseDescription ard = (AuthorizationResponseDescription)o;
+ return ard.userName.equals(userName) &&
+ ard.DmwsURL.equals(DmwsURL) && ard.RmwsURL.equals(RmwsURL) && ard.wsURL.equals(wsURL) &&
+ ((ard.DMWSProxyHost==null||DMWSProxyHost==null)?ard.DMWSProxyHost==DMWSProxyHost:ard.DMWSProxyHost.equals(DMWSProxyHost)) &&
+ ((ard.DMWSProxyPort==null||DMWSProxyPort==null)?ard.DMWSProxyPort==DMWSProxyPort:ard.DMWSProxyPort.equals(DMWSProxyPort)) &&
+ ((ard.RMWSProxyHost==null||RMWSProxyHost==null)?ard.RMWSProxyHost==RMWSProxyHost:ard.RMWSProxyHost.equals(RMWSProxyHost)) &&
+ ((ard.RMWSProxyPort==null||RMWSProxyPort==null)?ard.RMWSProxyPort==RMWSProxyPort:ard.RMWSProxyPort.equals(RMWSProxyPort)) &&
+ ((ard.wsProxyHost==null||wsProxyHost==null)?ard.wsProxyHost==wsProxyHost:ard.wsProxyHost.equals(wsProxyHost)) &&
+ ((ard.wsProxyPort==null||wsProxyPort==null)?ard.wsProxyPort==wsProxyPort:ard.wsProxyPort.equals(wsProxyPort)) &&
+ ard.adminUserName.equals(adminUserName) && ard.adminPassword.equals(adminPassword);
+ }
+
+ }
+
}