locked
Enterprise Library Custom securityCacheProvider RRS feed

  • Question

  • I am trying to role my own SecurityCacheProvider and I am having issues.

    This is my section in the config file.

     <securityCacheProviders>
    <securityCacheProvider xsi:type="CustomCachingStoreProviderData" name="Custom Caching Store Provider" type="Pda.Padls.Palims.Security.Caching.CachingStoreProvider, Pda.Padls.Palims.Security.Caching, Version=1.0.2202.17907, Culture=neutral, PublicKeyToken=null" cacheManagerInstanceName="Cache Manager" defaultSlidingSessionExpirationInMinutes="10" defaultAbsoluteSessionExpirationInMinutes="60" />
    </securityCacheProviders>

    This is my starter class.  I understand there is no code.  I am just trying to get the initialize method to be hit. 

    Imports Microsoft.Practices.EnterpriseLibrary.Security
    Imports Microsoft.Practices.EnterpriseLibrary.Common
    Imports Microsoft.Practices.EnterpriseLibrary.Configuration
    Imports Microsoft.Practices.EnterpriseLibrary.Caching
    
    Public Class CachingStoreProvider
        Implements ISecurityCacheProvider
    
    #Region " Class Declaration(s) "
        Private securityConfigurationView As SecurityConfigurationView
    
    #End Region
    
    #Region " Properties "
    
        Private _configurationName As String = "Caching Store Provider"
        Public Property ConfigurationName() As String Implements Microsoft.Practices.EnterpriseLibrary.Configuration.IConfigurationProvider.ConfigurationName
            Get
                Return _configurationName
            End Get
            Set(ByVal value As String)
                _configurationName = value
            End Set
        End Property
    
    #End Region
    
    #Region " Initialize "
        Public Sub Initialize(ByVal configurationView As Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationView) Implements Microsoft.Practices.EnterpriseLibrary.Configuration.IConfigurationProvider.Initialize
            ArgumentValidation.CheckForNullReference(configurationView, "configurationView")
            ArgumentValidation.CheckExpectedType(configurationView, GetType(SecurityConfigurationView))
    
            Me.securityConfigurationView = DirectCast(configurationView, SecurityConfigurationView)
        End Sub
    #End Region
    
    #Region " Identity "
        Public Sub ExpireIdentity(ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.ExpireIdentity
    
        End Sub
    
        Public Function GetIdentity(ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) As System.Security.Principal.IIdentity Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.GetIdentity
    
        End Function
    
        Public Function SaveIdentity(ByVal identity As System.Security.Principal.IIdentity) As Microsoft.Practices.EnterpriseLibrary.Security.IToken Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.SaveIdentity
    
        End Function
    
        Public Sub SaveIdentity(ByVal identity As System.Security.Principal.IIdentity, _
                                ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.SaveIdentity
    
    
        End Sub
    
    #End Region
    
    #Region " Principal"
    
        Public Sub ExpirePrincipal(ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.ExpirePrincipal
    
        End Sub
    
        Public Function GetPrincipal(ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) As System.Security.Principal.IPrincipal Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.GetPrincipal
    
        End Function
    
        Public Function SavePrincipal(ByVal principal As System.Security.Principal.IPrincipal) As Microsoft.Practices.EnterpriseLibrary.Security.IToken Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.SavePrincipal
    
        End Function
    
        Public Sub SavePrincipal(ByVal principal As System.Security.Principal.IPrincipal, _
                                 ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.SavePrincipal
    
        End Sub
    
    #End Region
    
    #Region " Profile "
    
        Public Sub ExpireProfile(ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.ExpireProfile
    
        End Sub
    
        Public Function GetProfile(ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) As Object Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.GetProfile
    
    
        End Function
    
        Public Function SaveProfile(ByVal profile As Object) As Microsoft.Practices.EnterpriseLibrary.Security.IToken Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.SaveProfile
    
        End Function
    
        Public Sub SaveProfile(ByVal profile As Object, _
                               ByVal token As Microsoft.Practices.EnterpriseLibrary.Security.IToken) Implements Microsoft.Practices.EnterpriseLibrary.Security.ISecurityCacheProvider.SaveProfile
    
        End Sub
    
    #End Region
    
    
    End Class
    

    Whenever I run I get the following error and im not sure why.

    ystem.Configuration.ConfigurationException: There is an error in the XML document. The specified type was not recognized: name='CustomCachingStoreProviderData', namespace='http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/security', at . ---> System.InvalidOperationException: There is an error in the XML document. ---> System.InvalidOperationException: The specified type was not recognized: name='CustomCachingStoreProviderData', namespace='http://www.microsoft.com/practices/enterpriselibrary/08-31-2004/security', at .
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSecuritySettings.Read5_SecurityCacheProviderData(Boolean isNullable, Boolean checkType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSecuritySettings.Read17_SecuritySettings(Boolean isNullable, Boolean checkType)
    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderSecuritySettings.Read18_Item()
    --- End of inner exception stack trace ---
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader, String encodingStyle, XmlDeserializationEvents events)
    at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader xmlReader)
    at Microsoft.Practices.EnterpriseLibrary.Configuration.Transformer.XmlSerializerTransformer.Deserialize(Object section)
    --- End of inner exception stack trace ---
    at Microsoft.Practices.EnterpriseLibrary.Configuration.Transformer.XmlSerializerTransformer.Deserialize(Object section)
    at Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationBuilder.ReadConfiguration(String sectionName)
    at Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationContext.GetConfiguration(String sectionName)
    at Microsoft.Practices.EnterpriseLibrary.Security.SecurityConfigurationView.GetSecuritySettings()
    at Microsoft.Practices.EnterpriseLibrary.Security.SecurityConfigurationView.GetAuthenticationProviderData(String authenticationProviderName)
    at Microsoft.Practices.EnterpriseLibrary.Security.AuthenticationProviderFactory.GetConfigurationType(String authenticationProviderName)
    at Microsoft.Practices.EnterpriseLibrary.Configuration.ConfigurationFactory.CreateInstance(String configurationName)
    at Microsoft.Practices.EnterpriseLibrary.Security.AuthenticationProviderFactory.GetAuthenticationProvider(String authenticationProviderName)
    at Microsoft.Practices.EnterpriseLibrary.Security.AuthenticationFactory.GetAuthenticationProvider(String authenticationProvider)
    at Pda.Padls.Palims.RemoteFacade.SecurityFacade.Authenticate(Object credentials) in C:\Projects\USALIMS\src\RemoteFacade\SecurityFacade.vb:line 35]
    I can't tell where my error is.  Can someone please help.

    Thank you,
    Thursday, July 16, 2009 6:27 PM

Answers

  • <securityCacheProviders>
      <securityCacheProvider xsi:type="CustomSecurityCacheProviderData" name="Custom Cache Provider" type="Security.Caching.CachingStoreProvider, Security.Caching, Version=1.0.2202.17907, Culture=neutral, PublicKeyToken=null">
        <extensions>
          <extension name="defaultSlidingSessionExpirationInMinutes" value="10" />
          <extension name="defaultAbsoluteSessionExpirationInMinutes" value="60" />
          <extension name="Cache Manager" value="Cache Manager" />
        </extensions>
      </securityCacheProvider>
    </securityCacheProviders>
    I figured it out.

    The xml should look like this.

    • Marked as answer by Rohrer Friday, July 17, 2009 6:11 PM
    Friday, July 17, 2009 6:11 PM