/// <summary> /// Method for convenient testing of local connectors. /// </summary> public APIConfiguration CreateTestConfiguration(SafeType <Connector> clazz, Configuration config) { LocalConnectorInfoImpl info = new LocalConnectorInfoImpl(); info.ConnectorConfigurationClass = SafeType <Configuration> .Get(config); info.ConnectorClass = (clazz); info.ConnectorDisplayNameKey = ("DUMMY_DISPLAY_NAME"); info.ConnectorKey = ( new ConnectorKey(clazz.RawType.Name + ".bundle", "1.0", clazz.RawType.Name)); info.Messages = (this.CreateDummyMessages()); APIConfigurationImpl rv = new APIConfigurationImpl(); rv.IsConnectorPoolingSupported = ( IsConnectorPoolingSupported(clazz)); ConfigurationPropertiesImpl properties = CSharpClassProperties.CreateConfigurationProperties(config); rv.ConfigurationProperties = (properties); rv.ConnectorInfo = (info); rv.SupportedOperations = ( FrameworkUtil.GetDefaultSupportedOperations(clazz)); info.DefaultAPIConfiguration = ( rv); return(rv); }
/// <summary> /// Get the singleton instance of the <see cref="ConnectorServer" />. /// </summary> public static ConnectorServer NewInstance() { SafeType <ConnectorServer> type = SafeType <ConnectorServer> .ForRawType(Type.GetType(IMPL_NAME, true)); return(type.CreateInstance()); }
MergeIntoBean(ConfigurationPropertiesImpl properties, Configuration config) { SafeType <Configuration> configType = SafeType <Configuration> .Get(config); IDictionary <string, PropertyInfo> descriptors = GetFilteredProperties(configType); foreach (ConfigurationPropertyImpl property in properties.Properties) { String name = property.Name; PropertyInfo desc = CollectionUtil.GetValue(descriptors, name, null); if (desc == null) { String FMT = "Class ''{0}'' does not have a property ''{1}''."; String MSG = String.Format(FMT, configType.RawType.Name, name); throw new ArgumentException(MSG); } object val = property.Value; //some value types such as arrays //are mutable. make sure the config object //has its own copy val = SerializerUtil.CloneObject(val); desc.SetValue(config, val, null); } }
public ConnectorClassAttribute(String connectorDisplayNameKey, Type connectorConfigurationClass) { _connectorDisplayNameKey = connectorDisplayNameKey; _connectorCategoryKey = string.Empty; _connectorConfigurationClass = SafeType <Configuration> .ForRawType(connectorConfigurationClass); }
static LocalConnectorFacadeImpl() { AddImplementation(SafeType <APIOperation> .Get <CreateApiOp>(), SafeType <APIOperation> .Get <CreateImpl>()); AddImplementation(SafeType <APIOperation> .Get <DeleteApiOp>(), SafeType <APIOperation> .Get <DeleteImpl>()); AddImplementation(SafeType <APIOperation> .Get <SchemaApiOp>(), SafeType <APIOperation> .Get <SchemaImpl>()); AddImplementation(SafeType <APIOperation> .Get <SearchApiOp>(), SafeType <APIOperation> .Get <SearchImpl>()); AddImplementation(SafeType <APIOperation> .Get <UpdateApiOp>(), SafeType <APIOperation> .Get <UpdateImpl>()); AddImplementation(SafeType <APIOperation> .Get <AuthenticationApiOp>(), SafeType <APIOperation> .Get <AuthenticationImpl>()); AddImplementation(SafeType <APIOperation> .Get <ResolveUsernameApiOp>(), SafeType <APIOperation> .Get <ResolveUsernameImpl>()); AddImplementation(SafeType <APIOperation> .Get <TestApiOp>(), SafeType <APIOperation> .Get <TestImpl>()); AddImplementation(SafeType <APIOperation> .Get <ScriptOnConnectorApiOp>(), SafeType <APIOperation> .Get <ScriptOnConnectorImpl>()); AddImplementation(SafeType <APIOperation> .Get <ScriptOnResourceApiOp>(), SafeType <APIOperation> .Get <ScriptOnResourceImpl>()); AddImplementation(SafeType <APIOperation> .Get <SyncApiOp>(), SafeType <APIOperation> .Get <SyncImpl>()); }
protected EventSubscription <TEvent> CreateSubscription <TEvent>( IEventSource source, IEventListener listener, SafeType <TEvent> eventType, Action <TEvent> action) where TEvent : IEvent { var subscription = this.HasSubscription_(source, listener, eventType, action); if (subscription != null) { return(subscription); } subscription = new EventSubscription <TEvent>(source, listener, eventType, action); var contract = (source as EventSource) !.owner_.FormClosedWith(subscription, (listener as EventListener) ! .owner_); subscription.Contract = contract; return(subscription); }
public void Sync(ObjectClass objClass, SyncToken token, SyncResultsHandler handler, OperationOptions options) { ((SyncApiOp)this.GetOperationCheckSupported(SafeType <APIOperation> .Get <SyncApiOp>())) .Sync(objClass, token, handler, options); }
public void TestSchema() { OperationOptionInfo opInfo = new OperationOptionInfo("name", typeof(int?)); ObjectClassInfoBuilder bld = new ObjectClassInfoBuilder(); bld.ObjectType = ObjectClass.ACCOUNT_NAME; ObjectClassInfo info = bld.Build(); ICollection <ObjectClassInfo> temp = CollectionUtil.NewSet(info); IDictionary <SafeType <APIOperation>, ICollection <ObjectClassInfo> > map = new Dictionary <SafeType <APIOperation>, ICollection <ObjectClassInfo> >(); map[SafeType <APIOperation> .Get <CreateApiOp>()] = temp; ICollection <OperationOptionInfo> temp2 = CollectionUtil.NewSet(opInfo); IDictionary <SafeType <APIOperation>, ICollection <OperationOptionInfo> > map2 = new Dictionary <SafeType <APIOperation>, ICollection <OperationOptionInfo> >(); map2[SafeType <APIOperation> .Get <CreateApiOp>()] = temp2; Schema v1 = new Schema(CollectionUtil.NewSet(info), CollectionUtil.NewSet(opInfo), map, map2); Schema v2 = (Schema)CloneObject(v1); Assert.AreEqual(v1, v2); Assert.AreEqual(info, v2.ObjectClassInfo.First()); Assert.AreEqual(1, v2.SupportedObjectClassesByOperation.Count); Assert.AreEqual(1, v2.SupportedOptionsByOperation.Count); Assert.AreEqual(1, v2.OperationOptionInfo.Count); }
public Object RunScriptOnResource(ScriptContext request, OperationOptions options) { return(((ScriptOnResourceApiOp)this .GetOperationCheckSupported(SafeType <APIOperation> .Get <ScriptOnResourceApiOp>())) .RunScriptOnResource(request, options)); }
public void TestOperationRequest() { ConfigurationPropertiesImpl configProperties = new ConfigurationPropertiesImpl(); configProperties.Properties = (new List <ConfigurationPropertyImpl>()); APIConfigurationImpl apiImpl = new APIConfigurationImpl(); apiImpl.ConfigurationProperties = (configProperties); IList <object> args = new List <object>(); args.Add("my arg"); OperationRequest v1 = new OperationRequest(new ConnectorKey("my bundle", "my version", "my connector"), apiImpl, SafeType <APIOperation> .Get <CreateApiOp>(), "mymethodName", args); OperationRequest v2 = (OperationRequest)CloneObject(v1); Assert.AreEqual("my bundle", v2.ConnectorKey.BundleName); Assert.AreEqual("my version", v2.ConnectorKey.BundleVersion); Assert.AreEqual("my connector", v2.ConnectorKey.ConnectorName); Assert.IsNotNull(v2.Configuration); Assert.AreEqual(SafeType <APIOperation> .Get <CreateApiOp>(), v2.Operation); Assert.AreEqual("mymethodName", v2.OperationMethodName); Assert.IsTrue( CollectionUtil.Equals( args, v2.Arguments)); }
GetFilteredProperties(SafeType <Configuration> config) { IDictionary <string, PropertyInfo> rv = new Dictionary <string, PropertyInfo>(); PropertyInfo[] descriptors = config.RawType.GetProperties(); foreach (PropertyInfo descriptor in descriptors) { String propName = descriptor.Name; if (!descriptor.CanWrite) { //if there's no setter, ignore it continue; } if ("ConnectorMessages".Equals(propName)) { continue; } if (!descriptor.CanRead) { const String FMT = "Found setter ''{0}'' but not the corresponding getter."; String MSG = String.Format(FMT, propName); throw new ArgumentException(MSG); } rv[propName] = descriptor; } return(rv); }
public Strategyinput_Types() : base(new Type[1] { typeof(SafeType) }, new object[] { (SafeType)typeof(CombatControlledObject) }, typeof(SafeType)) { name = "Type"; inputtype = typeof(CombatControlledObject); }
public RemoteOperationInvocationHandler(RemoteConnectorInfoImpl connectorInfo, String connectorFacadeKey, SafeType <APIOperation> operation) { _connectorInfo = connectorInfo; _connectorFacadeKey = connectorFacadeKey; _operation = operation; }
/// <summary> /// Return an instance of an API operation. /// </summary> /// <returns> /// <code>null</code> if the operation is not support otherwise /// return an instance of the operation.</returns> /// <seealso cref="Org.IdentityConnectors.Framework.Api.ConnectorFacade.GetOperation(SafeType{APIOperation})" /> public APIOperation GetOperation(SafeType <APIOperation> api) { if (!SupportedOperations.Contains(api)) { return(null); } return(GetOperationImplementation(api)); }
public void TestTimeout() { ConnectorInfoManager manager = GetConnectorInfoManager(); ConnectorInfo info1 = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstConnector"); Assert.IsNotNull(info1); APIConfiguration config = info1.CreateDefaultAPIConfiguration(); config.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(CreateApiOp)), 5000); config.SetTimeout(SafeType <APIOperation> .ForRawType(typeof(SearchApiOp)), 5000); ConfigurationProperties props = config.ConfigurationProperties; ConfigurationProperty property = props.GetProperty("numResults"); // 1000 is several times the remote size between pauses property.Value = 2; OperationOptionsBuilder opBuilder = new OperationOptionsBuilder(); opBuilder.SetOption("delay", 10000); ConnectorFacade facade1 = ConnectorFacadeFactory.GetInstance().NewInstance(config); ICollection <ConnectorAttribute> attrs = CollectionUtil.NewReadOnlySet <ConnectorAttribute>(); try { facade1.Create(ObjectClass.ACCOUNT, attrs, opBuilder.Build()).GetUidValue(); Assert.Fail("expected timeout"); } catch (OperationTimeoutException) { // expected } //catch (RemoteWrappedException e) //{ // Assert.IsTrue(e.Is(typeof(OperationTimeoutException))); //} try { facade1.Search(ObjectClass.ACCOUNT, null, new ResultsHandler() { Handle = obj => { return(true); } }, opBuilder.Build()); Assert.Fail("expected timeout"); } catch (OperationTimeoutException) { // expected } //catch (RemoteWrappedException e) //{ // Assert.IsTrue(e.Is(typeof(OperationTimeoutException))); //} }
public Uid RemoveAttributeValues( ObjectClass objclass, Uid uid, ICollection <ConnectorAttribute> attrs, OperationOptions options) { return(((UpdateApiOp)this.GetOperationCheckSupported(SafeType <APIOperation> .Get <UpdateApiOp>())) .RemoveAttributeValues(objclass, uid, attrs, options)); }
public Schema Schema() { SchemaBuilder schemaBuilder = new SchemaBuilder(SafeType <Connector> .Get(this)); ICollection <ConnectorAttributeInfo> connectorAttributeInfos = new List <ConnectorAttributeInfo>(); connectorAttributeInfos.Add(ConnectorAttributeInfoBuilder.Build("User Logon Name")); schemaBuilder.DefineObjectClass(ObjectClass.ACCOUNT_NAME, connectorAttributeInfos); return(schemaBuilder.Build()); }
CreateBean(ConfigurationPropertiesImpl properties, SafeType <Configuration> configType) { Configuration rv = configType.CreateInstance(); rv.ConnectorMessages = properties.Parent.ConnectorInfo.Messages; MergeIntoBean(properties, rv); return(rv); }
private static string GetRandomString(int length, SafeType safe) { // randomize generator System.Random r = new Random(1); // Negative numbers indicate a random string length of 10-20 is desired. if (length < 0) { length = 10 + r.Next(11); } char[] chars = new char[length]; for (int i = 0; i < length; i++) { switch (safe) { case SafeType.String: switch (r.Next(3)) { case 0: // Get a random char between ascii 65 and 90 (upper case alphabets). chars[i] = (char)(65 + r.Next(26)); break; case 1: // Get a random char between ascii 97 and 122 (lower case alphabets). chars[i] = (char)(97 + r.Next(26)); break; case 2: // Get a random number 0 - 9 chars[i] = (char)('0' + r.Next(10)); break; } break; case SafeType.File: // 10% use SafeFileChars if (r.Next(10) == 0) { // Get a random char from SafeFileChars chars[i] = SafeFileChars[r.Next(SafeFileChars.Length)]; } else { goto case 0; // value - SafeType.String } break; case SafeType.None: // Get a random char from ascii 32 - 126 chars[i] = (char)(32 + r.Next(95)); break; } } return(new string(chars)); }
private APIOperation GetOperationCheckSupported(SafeType <APIOperation> api) { // check if this operation is supported. if (!SupportedOperations.Contains(api)) { String MSG = "Operation ''{0}'' not supported."; String str = String.Format(MSG, api); throw new InvalidOperationException(str); } return(GetOperationImplementation(api)); }
public RelayStream(EventRelay parent, SafeType <TEvent> eventType) { this.parent_ = parent; this.convertSourceToThisEmit_ = this.parent_.CompileEmit <TEvent>(); this.eventType_ = eventType; foreach (var source in this.parent_.relaySources_) { this.AddSource(source); } }
protected APIOperation CreateLoggingProxy(SafeType <APIOperation> api, APIOperation target) { APIOperation ret = target; if (LOGGINGPROXY_ENABLED) { LoggingProxy logging = new LoggingProxy(api, target); ret = NewAPIOperationProxy(api, logging); } return(ret); }
protected Schema ExecuteSchema(String scriptName) { var scb = new SchemaBuilder(SafeType <Connector> .Get(this)); var arguments = new Dictionary <String, Object> { { SchemaBldr, scb } }; ExecuteScript(GetScript(scriptName), CreateBinding(arguments, OperationType.SCHEMA, null, null, null, null)); return(scb.Build()); }
public EventSubscription( IEventSource source, IEventListener listener, SafeType <TEvent> eventType, Action <TEvent> handler) { this.Source = source; this.Listener = listener; this.EventType = new SafeType <IEvent>(eventType.Value); this.Handler = handler; }
public static ICollection <SafeType <APIOperation> > GetUnconditionallySupportedOperations() { HashSet <SafeType <APIOperation> > ret; ret = new HashSet <SafeType <APIOperation> >(); //add validate api op always ret.Add(SafeType <APIOperation> .Get <ValidateApiOp>()); //add ScriptOnConnectorApiOp always ret.Add(SafeType <APIOperation> .Get <ScriptOnConnectorApiOp>()); return(ret); }
protected override APIOperation GetOperationImplementation(SafeType <APIOperation> api) { InvocationHandler handler = new RemoteOperationInvocationHandler( GetAPIConfiguration(), api); APIOperation proxy = NewAPIOperationProxy(api, handler); // add logging.. proxy = CreateLoggingProxy(api, proxy); return(proxy); }
public static ICollection <SafeType <APIOperation> > AllAPIOperations() { ICollection <SafeType <APIOperation> > set = new HashSet <SafeType <APIOperation> >(); CollectionUtil.AddAll(set, SPI_TO_API.Values); // add Get because it doesn't have a corresponding SPI. set.Add(SafeType <APIOperation> .Get <GetApiOp>()); set.Add(SafeType <APIOperation> .Get <ValidateApiOp>()); return(CollectionUtil.AsReadOnlySet(set)); }
/// <summary> /// Returns the instance of this factory. /// </summary> /// <returns>The instance of this factory</returns> private static TestHelpersSpi GetSpi() { lock (LOCK) { if (_instance == null) { SafeType <TestHelpersSpi> type = FrameworkInternalBridge.LoadType <TestHelpersSpi>(IMPL_NAME); _instance = type.CreateInstance(); } return(_instance); } }
/// <summary> /// Get the singleton instance of the <see cref="ConnectorFacadeFactory" />. /// </summary> public static ConnectorFacadeFactory GetInstance() { lock (LOCK) { if (_instance == null) { SafeType <ConnectorFacadeFactory> t = FrameworkInternalBridge.LoadType <ConnectorFacadeFactory>(IMPL_NAME); _instance = t.CreateInstance(); } } return(_instance); }
public void TestAPIConfiguration() { ConnectorInfoManager manager = GetConnectorInfoManager(); ConnectorInfo info = FindConnectorInfo(manager, "1.0.0.0", "org.identityconnectors.testconnector.TstConnector"); Assert.IsNotNull(info); APIConfiguration api = info.CreateDefaultAPIConfiguration(); ConfigurationProperties props = api.ConfigurationProperties; ConfigurationProperty property = props.GetProperty("tstField"); Assert.IsNotNull(property); ICollection <SafeType <APIOperation> > operations = property.Operations; Assert.AreEqual(1, operations.Count); Assert.IsTrue(operations.Contains(SafeType <APIOperation> .Get <SyncApiOp>())); Thread.CurrentThread.CurrentUICulture = new CultureInfo("en"); Assert.AreEqual("Help for test field.", property.GetHelpMessage(null)); Assert.AreEqual("Display for test field.", property.GetDisplayName(null)); Assert.AreEqual("Group for test field.", property.GetGroup(null)); Assert.AreEqual("Test Framework Value", info.Messages.Format("TEST_FRAMEWORK_KEY", "empty")); CultureInfo eslocale = new CultureInfo("es"); Thread.CurrentThread.CurrentUICulture = eslocale; Assert.AreEqual("tstField.help_es", property.GetHelpMessage(null)); Assert.AreEqual("tstField.display_es", property.GetDisplayName(null)); CultureInfo esESlocale = new CultureInfo("es-ES"); Thread.CurrentThread.CurrentUICulture = esESlocale; Assert.AreEqual("tstField.help_es-ES", property.GetHelpMessage(null)); Assert.AreEqual("tstField.display_es-ES", property.GetDisplayName(null)); CultureInfo esARlocale = new CultureInfo("es-AR"); Thread.CurrentThread.CurrentUICulture = esARlocale; Assert.AreEqual("tstField.help_es", property.GetHelpMessage(null)); Assert.AreEqual("tstField.display_es", property.GetDisplayName(null)); ConnectorFacadeFactory facf = ConnectorFacadeFactory.GetInstance(); ConnectorFacade facade = facf.NewInstance(api); // call the various create/update/delete commands.. facade.Schema(); }
protected override APIOperation GetOperationImplementation(SafeType<APIOperation> api) { // add remote proxy InvocationHandler handler = new RemoteOperationInvocationHandler( (RemoteConnectorInfoImpl)GetAPIConfiguration().ConnectorInfo, remoteConnectorFacadeKey, api); APIOperation proxy = NewAPIOperationProxy(api, handler); // now wrap the proxy in the appropriate timeout proxy proxy = CreateTimeoutProxy(api, proxy); // add logging proxy proxy = CreateLoggingProxy(api, proxy); return proxy; }
private static string GetRandomString(int length, SafeType safe) { // randomize generator System.Random r = new Random (1); // Negative numbers indicate a random string length of 10-20 is desired. if (length < 0) length = 10 + r.Next(11); char[] chars = new char[length]; for (int i = 0; i < length; i++) { switch (safe) { case SafeType.String: switch (r.Next(3)) { case 0: // Get a random char between ascii 65 and 90 (upper case alphabets). chars[i] = (char)(65 + r.Next(26)); break; case 1: // Get a random char between ascii 97 and 122 (lower case alphabets). chars[i] = (char)(97 + r.Next(26)); break; case 2: // Get a random number 0 - 9 chars[i] = (char)('0' + r.Next(10)); break; } break; case SafeType.File: // 10% use SafeFileChars if (r.Next(10) == 0) { // Get a random char from SafeFileChars chars[i] = SafeFileChars[r.Next(SafeFileChars.Length)]; } else { goto case 0; // value - SafeType.String } break; case SafeType.None: // Get a random char from ascii 32 - 126 chars[i] = (char)(32 + r.Next(95)); break; } } return new string(chars); }
public LoggingProxy(SafeType<APIOperation> api, object target) { _op = api; _target = target; _guid = Guid.NewGuid(); }
public ConnectorClassAttribute(String connectorDisplayNameKey, String connectorCategoryKey, Type connectorConfigurationClass) { _connectorDisplayNameKey = connectorDisplayNameKey; _connectorCategoryKey = connectorCategoryKey; _connectorConfigurationClass = SafeType<Configuration>.ForRawType(connectorConfigurationClass); }
private void TestCallPattern(TestOperationPattern pattern, SafeType<Connector> clazz) { Configuration config = new MockConfiguration(false); ConnectorFacadeFactory factory = ConnectorFacadeFactory.GetInstance(); // **test only** APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, config); ConnectorFacade facade; facade = factory.NewInstance(impl); // make the call on the connector facade.. pattern.MakeCall(facade); // check the call structure.. IList<MockConnector.Call> calls = MockConnector.GetCallPattern(); // check the call pattern.. Assert.AreEqual("Init", calls[0].MethodName); calls.RemoveAt(0); pattern.CheckCalls(calls); Assert.AreEqual("Dispose", calls[0].MethodName); calls.RemoveAt(0); Assert.IsTrue(calls.Count == 0); }
private bool OperationOptionOperation(SafeType<APIOperation> op) { if (typeof(AuthenticationApiOp) == op.RawType || typeof(CreateApiOp) == op.RawType || typeof(DeleteApiOp) == op.RawType || typeof(GetApiOp) == op.RawType || typeof(ResolveUsernameApiOp) == op.RawType || typeof(ScriptOnConnectorApiOp) == op.RawType || typeof(ScriptOnResourceApiOp) == op.RawType || typeof(SearchApiOp) == op.RawType || typeof(SyncApiOp) == op.RawType || typeof(UpdateApiOp) == op.RawType) { return true; } return false; }
/// <summary> /// </summary> public SchemaBuilder(SafeType<Connector> connectorClass) { Assertions.NullCheck(connectorClass, "connectorClass"); _defaultSupportedOperations = FrameworkUtil.GetDefaultSupportedOperations(connectorClass); }
public void SetTimeout(SafeType<APIOperation> operation, int timeout) { _timeoutMap[operation] = timeout; }
public LoggingProxy(SafeType<APIOperation> api, object target) { _op = api; _target = target; }
/// <summary> /// Creates a new <see cref="APIOperation" /> proxy given a handler. /// </summary> protected APIOperation NewAPIOperationProxy(SafeType<APIOperation> api, InvocationHandler handler) { return (APIOperation)Proxy.NewProxyInstance(api.RawType, handler); }
protected APIOperation CreateLoggingProxy(SafeType<APIOperation> api, APIOperation target) { APIOperation ret = target; if (LOGGINGPROXY_ENABLED) { LoggingProxy logging = new LoggingProxy(api, target); ret = NewAPIOperationProxy(api, logging); } return ret; }
/// <summary> /// Return an instance of an API operation. /// </summary> /// <returns> /// <code>null</code> if the operation is not support otherwise /// return an instance of the operation.</returns> /// <seealso cref="Org.IdentityConnectors.Framework.Api.ConnectorFacade.GetOperation(SafeType{APIOperation})" /> public APIOperation GetOperation(SafeType<APIOperation> api) { if (!SupportedOperations.Contains(api)) { return null; } return GetOperationImplementation(api); }
public ConnectorFacade CreateConnectorFacade(SafeType<Connector> clazz) { if (null == _facade) { PropertyBag propertyBag = TestHelpers.GetProperties(clazz.RawType); string assemblyFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); string testModulePath = Path.GetFullPath(Path.Combine(assemblyFolder, "..\\..\\..\\Samples\\Tests\\TestModule.psm1")); string objectChacheModulePath = typeof(ObjectCacheLibrary).Assembly.Location; var importModules = new string[] { testModulePath, objectChacheModulePath }; APIConfiguration impl = TestHelpers.CreateTestConfiguration(clazz, propertyBag, "configuration"); impl.ConfigurationProperties.SetPropertyValue("PsModulesToImport", importModules); // impl.ProducerBufferSize = 0; impl.ResultsHandlerConfiguration.EnableAttributesToGetSearchResultsHandler = false; impl.ResultsHandlerConfiguration.EnableCaseInsensitiveFilter = false; impl.ResultsHandlerConfiguration.EnableFilteredResultsHandler = false; impl.ResultsHandlerConfiguration.EnableNormalizingResultsHandler = false; //We timeout after 10s impl.SetTimeout(SafeType<APIOperation>.ForRawType(typeof(CreateApiOp)), 10000); impl.SetTimeout(SafeType<APIOperation>.ForRawType(typeof(UpdateApiOp)), 10000); impl.SetTimeout(SafeType<APIOperation>.ForRawType(typeof(DeleteApiOp)), 10000); _facade = ConnectorFacadeFactory.GetInstance().NewInstance(impl); } return _facade; }
protected override APIOperation GetOperationImplementation(SafeType<APIOperation> api) { if (api.RawType == typeof(IConnectorEventSubscriptionApiOp) || api.RawType == typeof(ISyncEventSubscriptionApiOp)) { //Not supported remotely with legacy communication protocol return null; } // add remote proxy InvocationHandler handler = new RemoteOperationInvocationHandler( (RemoteConnectorInfoImpl)GetAPIConfiguration().ConnectorInfo, remoteConnectorFacadeKey, api); APIOperation proxy = NewAPIOperationProxy(api, handler); // now wrap the proxy in the appropriate timeout proxy proxy = CreateTimeoutProxy(api, proxy); // add logging proxy proxy = CreateLoggingProxy(api, proxy); return proxy; }
protected override APIOperation GetOperationImplementation(SafeType<APIOperation> api) { InvocationHandler handler = new RemoteOperationInvocationHandler( GetAPIConfiguration(), api); APIOperation proxy = NewAPIOperationProxy(api, handler); // add logging.. proxy = CreateLoggingProxy(api, proxy); return proxy; }
public RemoteOperationInvocationHandler(APIConfigurationImpl configuration, SafeType<APIOperation> operation) { _configuration = configuration; _operation = operation; }
/// <summary> /// Return an instance of an API operation. /// </summary> /// <returns> /// <code>null</code> if the operation is not support otherwise /// return an instance of the operation.</returns> /// <seealso cref="Org.IdentityConnectors.Framework.Api.ConnectorFacade.GetOperation(SafeType{APIOperation})" /> public APIOperation GetOperation(SafeType<APIOperation> api) { if (!_configuration.IsSupportedOperation(api)) { return null; } return GetOperationImplementation(api); }
/// <summary> /// Creates the timeout proxy for the given operation. /// </summary> /// <param name="api"> /// The operation </param> /// <param name="target"> /// The underlying object </param> /// <returns> The proxy </returns> protected internal APIOperation CreateTimeoutProxy(SafeType<APIOperation> api, APIOperation target) { int timeout = GetAPIConfiguration().GetTimeout(api); int bufferSize = GetAPIConfiguration().ProducerBufferSize; DelegatingTimeoutProxy handler = new DelegatingTimeoutProxy(target, timeout, bufferSize); return NewAPIOperationProxy(api, handler); }
public int GetTimeout(SafeType<APIOperation> operation) { return Math.Max(CollectionUtil.GetValue(_timeoutMap, operation, APIConstants.NO_TIMEOUT), APIConstants.NO_TIMEOUT); }
/// <summary> /// Gets the implementation of the given operation /// </summary> /// <param name="api">The operation to implement.</param> /// <returns>The implementation</returns> protected abstract APIOperation GetOperationImplementation(SafeType<APIOperation> api);
private bool ObjectClassOperation(SafeType<APIOperation> op) { if (typeof(AuthenticationApiOp) == op.RawType || typeof(CreateApiOp) == op.RawType || typeof(DeleteApiOp) == op.RawType || typeof(GetApiOp) == op.RawType || typeof(ResolveUsernameApiOp) == op.RawType || typeof(SearchApiOp) == op.RawType || typeof(SyncApiOp) == op.RawType || typeof(UpdateApiOp) == op.RawType) { return true; } return false; }
private APIOperation GetOperationCheckSupported(SafeType<APIOperation> api) { // check if this operation is supported. if (!SupportedOperations.Contains(api)) { String str = String.Format(Msg, api); throw new InvalidOperationException(str); } return GetOperationImplementation(api); }
/// <summary> /// Returns the supported options for the given operation. /// </summary> /// <param name="apiop">The operation.</param> /// <returns>the supported options for the given operation.</returns> public ICollection<OperationOptionInfo> GetSupportedOptionsByOperation(SafeType<APIOperation> apiop) { ICollection<OperationOptionInfo> rv = CollectionUtil.GetValue(_supportedOptionsByOperation, apiop, null); if (rv == null) { ICollection<OperationOptionInfo> empty = CollectionUtil.NewReadOnlySet<OperationOptionInfo>(); return empty; } else { return rv; } }
public bool IsSupportedOperation(SafeType<APIOperation> api) { return _supportedOperations.Contains(api); }
/// <summary> /// </summary> public SchemaBuilder(SafeType<Connector> connectorClass) { Assertions.NullCheck(connectorClass, "connectorClass"); _connectorClass = connectorClass; }
/// <summary> /// Removes the given OperationOptionInfo as a supported option for /// the given operation. /// </summary> /// <param name="op">The SPI operation</param> /// <param name="def">The OperationOptionInfo</param> /// <exception cref="ArgumentException">If the given OperationOptionInfo was /// not already defined using <see cref="DefineOperationOption(OperationOptionInfo)" />.</exception> public void RemoveSupportedOperationOption(SafeType<SPIOperation> op, OperationOptionInfo def) { Assertions.NullCheck(op, "op"); Assertions.NullCheck(def, "def"); ICollection<SafeType<APIOperation>> apis = FrameworkUtil.Spi2Apis(op); if (!_declaredOperationOptions.Contains(def)) { throw new ArgumentException("OperationOption " + def.Name + " not defined in schema."); } foreach (SafeType<APIOperation> api in apis) { ICollection<OperationOptionInfo> infos = CollectionUtil.GetValue(_supportedOptionsByOperation, api, null); if (infos == null) { throw new ArgumentException("Operation " + op + " not implement by connector."); } if (!infos.Contains(def)) { throw new ArgumentException("OperationOption " + def.Name + " already removed for operation " + op); } infos.Remove(def); } }
public OperationRequest(ConnectorKey key, APIConfigurationImpl apiConfiguration, SafeType<APIOperation> operation, string operationMethodName, IList<Object> arguments) { _connectorKey = key; _configuration = apiConfiguration; _operation = operation; _operationMethodName = operationMethodName; _arguments = CollectionUtil.NewReadOnlyList<object>(arguments); }
public RemoteOperationInvocationHandler(RemoteConnectorInfoImpl connectorInfo, String connectorFacadeKey, SafeType<APIOperation> operation) { _connectorInfo = connectorInfo; _connectorFacadeKey = connectorFacadeKey; _operation = operation; }
/// <summary> /// Adds the given ObjectClassInfo as a supported ObjectClass for /// the given operation. /// </summary> /// <param name="op">The SPI operation</param> /// <param name="def">The ObjectClassInfo</param> /// <exception cref="ArgumentException">If the given ObjectClassInfo was /// not already defined using <see cref="DefineObjectClass(ObjectClassInfo)" />.</exception> public void AddSupportedObjectClass(SafeType<SPIOperation> op, ObjectClassInfo def) { Assertions.NullCheck(op, "op"); Assertions.NullCheck(def, "def"); IEnumerable<SafeType<APIOperation>> apis = FrameworkUtil.Spi2Apis(op).Intersect(_defaultSupportedOperations); if (!_declaredObjectClasses.Contains(def)) { throw new ArgumentException("ObjectClass " + def.ObjectType + " not defined in schema."); } foreach (SafeType<APIOperation> api in apis) { if (ObjectClassOperation(api)) { ICollection<ObjectClassInfo> infos = CollectionUtil.GetValue(_supportedObjectClassesByOperation, api, null); if (infos == null) { throw new ArgumentException("Operation " + op + " not implement by connector."); } if (infos.Contains(def)) { throw new ArgumentException("ObjectClass " + def.ObjectType + " already supported for operation " + op); } infos.Add(def); } } }