小编Ras*_*tko的帖子

单元测试HttpContext Response.Redirect

我正在使用HttpSimulator进行单元测试.我正在测试一个在代码链中调用更深层的方法Response.Redirect.我面临着问题.我越来越

System.NullReferenceException was unhandled by user code
  HResult=-2147467261
  Message= Object reference not set to an instance of an object.
  Source=System.Web
  StackTrace:
       at System.Web.HttpApplication.CompleteRequest()
       at System.Web.HttpResponse.End()
       at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent)
       at System.Web.HttpResponse.Redirect(String url, Boolean endResponse)
Run Code Online (Sandbox Code Playgroud)

然后我反映了HttpApplication类型并找到了提到的方法:

public void CompleteRequest()
{
    this._stepManager.CompleteRequest();
}
Run Code Online (Sandbox Code Playgroud)

我正在通过以下方式之一初始化HttpApplication:

 HttpContext.Current.ApplicationInstance = new HttpApplication();
 // or with Mock framework
 var httpApplicationMock = new Mock<HttpApplication>()
 var applicationInstance = httpApplicationMock.Object;
Run Code Online (Sandbox Code Playgroud)

当我从ASP文档中获得时,_stepManager负责模块和处理程序的执行顺序和协调.初始化此字段取决于应用程序是在经典模式还是集成模式下.

然后我打电话给我的测试:

object stepManager = typeof(HttpApplication).GetField("_stepManager", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(HttpContext.Current.ApplicationInstance);
Run Code Online (Sandbox Code Playgroud)

我得到的stepManager为null,这是从上面的异常中得到的.StepManager在方法中初始化:

internal void InitInternal(HttpContext context, HttpApplicationState …
Run Code Online (Sandbox Code Playgroud)

asp.net

6
推荐指数
0
解决办法
1547
查看次数

ADFS 服务器是否支持 scim 协议

当前的 Microsoft ADFS 2.0 服务器(或新的 ADFS 3.0 RTM)是否支持 SCIM 配置协议?如果没有,SPML 可能计划了哪一种配置协议?

adfs provisioning adfs2.0 scim

5
推荐指数
1
解决办法
2948
查看次数

使用打开的 xml 将 altChunk 转换为段落

我已经使用 OpenXML 在 C# 中生成了 Word/docx 文档。使用 altChunk 添加/合并了另一份 docx 文档。当您打开该文档时,它看起来很棒。但进一步我需要使用 C# 代码处理该文档。我看到仍然存在 altChunk,它实际上具有指向合并文档的二进制序列化内容的指针。如果您在 Word - SaveAs 中执行此操作,并将文档保存到新文件并反映该文档(OpenXML 工具或 VS 扩展),那么您会发现 Word 引擎已将 altChunk 转换为段落。那太棒了。但我无法通过 C# 代码实现这一点。

如果我复制到新文件并保存,则什么也不会发生:

    public static void SaveAgain(string masterDocumentPath)
    {
        string newDocumentPath = @"F:\test.docx";
        using (Stream original = new FileStream(masterDocumentPath, FileMode.Open))
        {
            using (FileStream fs = File.Create(newDocumentPath))
            {
                original.CopyTo(fs);
            }
        }

        using (WordprocessingDocument myDocNew =
            WordprocessingDocument.Open(newDocumentPath, true))
        {
            myDocNew.MainDocumentPart.Document.Save();
        }
    }
Run Code Online (Sandbox Code Playgroud)

我在构建代码时使用了这篇文章(如何使用 altChunk 进行文档组装)。我缺少什么?

更新

我已经通过 Interop 成功地做到了这一点。这是片段:

    public static string SaveAsWithInterop(string masterDocumentPath)
    { …
Run Code Online (Sandbox Code Playgroud)

c# ms-word openxml openxml-sdk

5
推荐指数
0
解决办法
1977
查看次数

Quartz作业存储与活动数据有关吗?

正如我从Quartz官方文档中所理解的那样,AdoStore必须用于存储JobDataMap和其他数据之类的活动数据.如果我错了,请纠正我.

除了这个澄清之外,我想知道有没有办法从数据库加载作业和触发器定义.Quartz.Plugin.Xml.XMLSchedulingDataProcessorPlugin用于从xml文件中读取的插件或类似的东西.

如果没有,是否是实现自定义插件的最佳解决方案,该插件将从数据库读取或使用其他方法?

[编辑] Rastko 8/13/2012 11:16:28 AM

从吼叫的答案我认为我没有把问题描述给你好.我想从数据库加载作业和触发器配置.就像它在代码或xml中定义的那样:

    <job>
  <name>WriterJob</name>
  <group>CommonGroup</group>
  <description>Test WriteJob</description>
  <job-type>Console.WriteJob, Console</job-type>
</job>
<trigger>
  <simple>
    <name>WriterJobTrigger</name>
    <group>CommonTriggerGroup</group>
    <description>Simple trigger to simply fire sample job</description>
    <job-name>WriterJob</job-name>
    <job-group>CommonGroup</job-group>
    <misfire-instruction>SmartPolicy</misfire-instruction>
    <repeat-count>-1</repeat-count>
    <repeat-interval>10000</repeat-interval>
  </simple>
</trigger>
Run Code Online (Sandbox Code Playgroud)

我想在DataBase中以相同的方式使用它.从ADOJobStore的生成表中我看到这些表与跟踪当前活动作业更相关 - 跟踪其状态,触发器触发等.

我希望我现在更清楚了.如果您需要任何其他说明,请随时问我.

.net c# quartz.net

4
推荐指数
1
解决办法
4875
查看次数

STS 不支持请求的身份验证方法

我们的 Java 应用程序与客户的 ADFS 3.0 服务器联合。通过 SAMLP 向 ADFS 服务器发送身份验证请求(SP 发起)后出现问题。它适用于 Intranet 用例,其中 Windows 身份验证在身份验证策略中的 ADFS 服务器上指定。SP 应用程序正在使用 ForgeRock 的 Fedlet 库,该库通过 SAML 身份验证请求强制发送 RequestedAuthnContext 属性:

samlp:RequestedAuthnContext xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                             Comparison="exact"
                             >
    <saml:AuthnContextClassRef xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">urn:oasis:names:tc:SAML:2.0:ac:classes:Password</saml:AuthnContextClassRef>
</samlp:RequestedAuthnContext>
Run Code Online (Sandbox Code Playgroud)

我们最初也遇到了 Extranet 身份验证的问题,其中在 ADFS 上选择了表单身份验证。我们通过为我们的 RP 添加 Claim 自定义规则解决了这个问题:

exists([Type == "http://schemas.xmlsoap.org/ws/2005/05/identity/claims/nameidentifier"]) => issue(Type = "http://schemas.microsoft.com/ws/2008/06/identity/claims/authenticationmethod", Value = "urn:oasis:names:tc:SAML:2.0:ac:classes:Password");
Run Code Online (Sandbox Code Playgroud)

现在我们堆满了 Intranet 用例。在 ADFS 方面,我们收到以下错误:

MSIS7102: Requested Authentication Method is not supported on the STS.
   at Microsoft.IdentityServer.Web.Authentication.GlobalAuthenticationPolicyEvaluator.EvaluatePolicy(IList`1 mappedRequestedAuthMethods, AccessLocation location, ProtocolContext context, HashSet`1 authMethodsInToken, Boolean& validAuthMethodsInToken)
   at Microsoft.IdentityServer.Web.Authentication.AuthenticationPolicyEvaluator.RetrieveFirstStageAuthenticationDomain(Boolean& …
Run Code Online (Sandbox Code Playgroud)

adfs windows-authentication saml saml-2.0 adfs3.0

3
推荐指数
1
解决办法
7782
查看次数

设置 gRPC ServerInterceptors 的执行顺序

在 io.grpc.internal.AbstractServerImplBuilder 中,您可以将 ServerInterceptor 的实现添加到最终列表中

final List<ServerInterceptor> interceptors = new ArrayList<>();
Run Code Online (Sandbox Code Playgroud)

然后在构建器的默认服务器实现中 - io.grpc.internal.ServerImpl 它在 foreach 循环中调用它们

/** Never returns {@code null}. */
private <ReqT, RespT> ServerStreamListener startCall(ServerStream stream, String fullMethodName,
    ServerMethodDefinition<ReqT, RespT> methodDef, Metadata headers,
    Context.CancellableContext context, StatsTraceContext statsTraceCtx, Tag tag) {
  // TODO(ejona86): should we update fullMethodName to have the canonical path of the method?
  statsTraceCtx.serverCallStarted(
      new ServerCallInfoImpl<>(
          methodDef.getMethodDescriptor(), // notify with original method descriptor
          stream.getAttributes(),
          stream.getAuthority()));
  ServerCallHandler<ReqT, RespT> handler = methodDef.getServerCallHandler();
  for (ServerInterceptor interceptor : interceptors) { …
Run Code Online (Sandbox Code Playgroud)

java spring grpc grpc-java

3
推荐指数
1
解决办法
2569
查看次数

ADFS服务器上的SAML LogOutRequest处理失败

我有ADFS服务器作为IdP.我有单独的SP应用程序.这些是在信任圈中定义的.SAML协议上的SSO工作正常.当我尝试SP启动注销请求时,我在ADFS端遇到错误:

MSIS7000:登录请求不符合Web浏览器客户端的WS-Federation语言或SAML 2.0协议WebSSO配置文件.

编辑来自ADFS事件跟踪的更多详细信息:

MSIS7015:此请求不包含预期的协议消息,或者根据HTTP SAML协议绑定找到了不正确的协议参数.

我已经审查了mu注销SAML消息并且看起来正确.只是提到同一个SP正在使用ForgeRocks IdP(来自Sun OpenSSO)正确注销.

Saml loout请求消息:

<samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                 ID="b00b3f55-f3e3-4935-9e91-da6bf8b62efd"
                 Version="2.0"
                 IssueInstant="2013-08-27T09:45:08Z"
                 Destination="https://00.00.00.00/adfs/ls/"
                 Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                 NotOnOrAfter="2013-08-27T09:50:08Z"
                 >
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">SPEntityId/</saml:Issuer>                    
<saml:NameID xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">jsmith@company.com</saml:NameID>
<samlp:SessionIndex>_ea853497-c58a-408a-bc23-c849752d9741</samlp:SessionIndex>
Run Code Online (Sandbox Code Playgroud)

编辑

Lan向我建议签署注销请求消息是强制性的.他是对的.在OASIS规范(http://docs.oasis-open.org/security/saml/v2.0/saml-profiles-2.0-os.pdf)第4.4.3.1节中.它被描述.根据我现在发送签名的消息,但我有同样的问题.

签名留言:

<samlp:LogoutRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol"
                 ID="aed640c0-9455-49ea-9450-4ad7c08d98e7"
                 Version="2.0"
                 IssueInstant="2013-08-29T15:22:45Z"
                 Destination="https://server/adfs/ls/"
                 Consent="urn:oasis:names:tc:SAML:2.0:consent:unspecified"
                 NotOnOrAfter="2013-08-29T03:27:45Z"
                 >
<saml:NameID xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion"
             Format="urn:oasis:names:tc:SAML:2.0:nameid-format:transient">user</saml:NameID>
<samlp:SessionIndex>_677952a2-7fb3-4e7a-b439-326366e677db</samlp:SessionIndex>
<saml:Issuer xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion">SPIssuer</saml:Issuer>
<Signature xmlns="http://www.w3.org/2000/09/xmldsig#">
    <SignedInfo>
        <CanonicalizationMethod Algorithm="http://www.w3.org/TR/2001/REC-xml-c14n-20010315" />
        <SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
        <Reference URI="#aed640c0-9455-49ea-9450-4ad7c08d98e7">
            <Transforms>
                <Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
            </Transforms>
            <DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
            <DigestValue>53jjPvQ2Ty1Z+VikwrUwW4Erj3k=</DigestValue>
        </Reference>
    </SignedInfo>
    <SignatureValue>signed value</SignatureValue>
    <KeyInfo>
        <X509Data>
            <X509Certificate>certificate</X509Certificate>
        </X509Data>
    </KeyInfo>
</Signature>
Run Code Online (Sandbox Code Playgroud)

我做错了什么?应该在ADFS上指定一些其他端点吗?因为我得到的应该与登录请求一样使用(这完全在我身边工作).

谢谢,拉斯特科

adfs saml federation adfs2.0 saml-2.0

2
推荐指数
1
解决办法
1万
查看次数