小编Per*_*ion的帖子

Log4J:如何将OutputStream或Writer重定向到logger的writer?

我有一个方法,它在启动后以异步方式运行,使用OutputStream或Writer作为参数.

它充当OutputStream或Writer的录制适配器(它是我无法更改的第三方API).

我怎么能将Log4J的内部OutputStream或Writer传递给该方法?
...因为Log4J吞下了System.out和System.err,我之前使用过.

java logging log4j outputstream writer

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

使用SignedXml类添加基于Id属性的引用时,"格式错误的引用元素"

当存在名称空间前缀时,无法通过Id属性对元素进行签名:

void Main()
{
    var doc = new XmlDocument();
    doc.LoadXml("<root xmlns:u=\"myuri\"><test u:Id=\"_0\">Zebra</test></root>");

    SignedXml signedXml = new SignedXml(doc);
    signedXml.SigningKey = new RSACryptoServiceProvider();

    Reference reference = new Reference("#_0");
    signedXml.AddReference(reference);

    signedXml.ComputeSignature();
}
Run Code Online (Sandbox Code Playgroud)

ComputeSignature() 这里会出现'格式错误的参考元素'应该怎么做?

c# xml soap cryptography xml-signature

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

使用jQuery在另一个元素中按类名获取元素

如何通过id获取元素,然后在这个元素中使用jQuery按类名获取所有元素?使用标准JS函数getElementById()和getElementsByClassName()很容易做到这一点,但遗憾的是IE 7-8不支持后者.

javascript jquery

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

在mysql数据库中保存数组

我想在将总订单发送到Paypal之前保存额外的信息.对于每个项目,我在我的MySQL数据库中创建了一个我要存储它的列.现在我想将它保存为一个数组,稍后我可以阅读它来创建一个PHP页面.额外字段取自输入表单字段.

通过使用数组,我可以确保不混淆信息吗?

php mysql arrays

19
推荐指数
4
解决办法
8万
查看次数

有没有更简单的方法在Java中签署XML文档?

我正在尝试使用Java 对XML文档进行数字签名.我有一个实现使用一些引用,我发现在javax.xml.crypto.dsig包中使用各种实现.

不过,我目前的实现是像很多的例子我已经看了-这是相当繁琐,使用从不下23种不同的API类包括java.xml.crypto.dsig,javax.xml.transform,和java.security包,等等.感觉就像我进入了工厂工厂的土地,我花了好几个小时来弄清楚发生了什么.

我的问题是,有更简单的方法吗?如果我有公共/私人密钥文件,并且我想要添加<Signature/>到XML文档,那么是否有一个库让我调用类似的东西:

OutputStream signFile(InputStream xmlFile, File privateKey)
Run Code Online (Sandbox Code Playgroud)

...没有所有的XMLSignatureFactory/CanonicalizationMethod/DOMSignContext疯狂?

我不是非常精通密码术,而且像我这样的开发人员试图熟悉数字签名,Java提供的API似乎相当令人生畏.如果所有这些都是必要的,或者目前没有友好的API,那很好,我愿意接受这个作为答案.我只是想知道我是否在这里不必要地走上了艰难的道路.

java xml cryptography digital-signature xml-signature

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

关于XML签名,我需要了解什么才能使SAML正常工作?

在工作中,我们有一个Web应用程序,我们需要使用SAML验证的单点登录与其他公司的Web应用程序进行交互.我们的网络应用程序是用PHP编写的,显然与其他公司使用的语言选择无关.尽管如此,我还需要编写一个简单的API,这个其他公司可以使用SAML请求发送SOAP请求,并生成SAML响应.我从头开始编写它有三个原因:1)用PHP编写的SAML交互似乎没有很多选项,即使我想要一个,2)它限制了添加另一个第三个所涉及的开销-party组件,以及3)从头开始创建东西通常会让我有更好的理解,并且如果需要的话,使我能够更好地适应未来的事情.

无论如何,我对SAML,SOAP和XML标准一般都是新手,所以我一直在教我自己.我已经为我们的目的提供了相当完整的API,但有一个例外,即另一家公司已经指定我们的响应将需要使用证书进行数字签名(我们收到的请求将同样进行数字签名).所以我一直在试图弄清楚如何处理/生成XML签名,但老实说,由于W3C规范并不完全轻松,所以有点令人困惑.

OASIS安全标记语言(SAML)V1.1文件的断言和协议的第5.4.8节(我已经关闭的文件,正如另一家公司所说他们将使用v1.1)包括一个例子包含已签名断言的签名响应,我将在此处引用以供参考:

<Response IssueInstant="2003-04-17T00:46:02Z" MajorVersion="1" MinorVersion="1"
 Recipient="www.opensaml.org" ResponseID="_c7055387-af61-4fce-8b98-e2927324b306"
 xmlns="urn:oasis:names:tc:SAML:1.0:protocol"
 xmlns:samlp="urn:oasis:names:tc:SAML:1.0:protocol"
 xmlns:xsd="http://www.w3.org/2001/XMLSchema"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
  <ds:SignedInfo>
   <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>
   <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
   <ds:Reference URI="#_c7055387-af61-4fce-8b98-e2927324b306">
    <ds:Transforms>
     <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature"/>
     <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
      <InclusiveNamespaces PrefixList="#default saml samlp ds xsd xsi"
       xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
     </ds:Transform>
    </ds:Transforms>
    <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
    <ds:DigestValue>TCDVSuG6grhyHbzhQFWFzGrxIPE=</ds:DigestValue>
   </ds:Reference>
  </ds:SignedInfo>
  <ds:SignatureValue>x/GyPbzmFEe85pGD3c1aXG4Vspb9V9jGCjwcRCKrtwPS6vdVNCcY5rHaFPYWkf+5EIYcPzx+pX1h43SmwviCqXRjRtMANWbHLhWAptaK1ywS7gFgsD01qjyen3CP+m3Dw6vKhaq1ed10BYyrIzb4KkHO4ahNyBVXbJwqv5pUaE4=</ds:SignatureValue>
  <ds:KeyInfo>
   <ds:X509Data>
    <ds:X509Certificate>MIICyjCCAjOgAwIBAgICAnUwDQYJKoZIhvcNAQEEBQAwgakxCzAJBgNVBAYTA1VT ... 8I3bsbmRAUg4UP9hH6ABVq4KQKMknxu1xQxLhpR1y1GPdiowMNTrEG8cCx3w/w==</ds:X509Certificate>
   </ds:X509Data>
  </ds:KeyInfo>
 </ds:Signature>
 <Status><StatusCode Value="samlp:Success"/></Status>
 <Assertion AssertionID="_a75adf55-01d7-40cc-929f-dbd8372ebdfc"
  IssueInstant="2003-04-17T00:46:02Z" Issuer="www.opensaml.org"
  MajorVersion="1" MinorVersion="1" xmlns="urn:oasis:names:tc:SAML:1.0:assertion"
  xmlns:xsd="http://www.w3.org/2001/XMLSchema"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <Conditions NotBefore="2003-04-17T00:46:02Z" NotOnOrAfter="2003-04-17T00:51:02Z">
   <AudienceRestrictionCondition>
    <Audience>http://www.opensaml.org</Audience>
   </AudienceRestrictionCondition>
  </Conditions>
  <AuthenticationStatement AuthenticationInstant="2003-04-17T00:46:00Z" …
Run Code Online (Sandbox Code Playgroud)

php xml saml digital-signature xml-signature

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

目标c是KindOfClass的误解吗?

我有以下对象结构:

动物,狗和猫.正如你所料,狗和猫是从动物遗传的.

我有一个农场班:

 @implementation AnimalFarm

-(Animal*) createAnimal:(AnimalType)type{

  switch (type) {

    case CAT:
      return [Cat new];

    case DOG:
      return [Dog new];

    default:
      return [Animal new];
  }

}

@end
Run Code Online (Sandbox Code Playgroud)

我试着进行单元测试:

  AnimalFarm *farm = [AnimalFarm new];

  Animal *dog = [farm createAnimal:DOG];
  Animal *cat = [farm createAnimal:CAT];

  STAssertTrue([cat isMemberOfClass:[Cat class]],@"cat is not a cat!");
  STAssertTrue([dog isMemberOfClass:[Dog class]],@"Dog is not a dog!");

  STAssertTrue([cat isKindOfClass:[Animal class]],@"Cat is not an animal!");
  STAssertTrue([dog isKindOfClass:[Animal class]],@"Cat is not an animal!");
Run Code Online (Sandbox Code Playgroud)

课程实施:

@interface Cat : Animal {

}


@end

@implementation …
Run Code Online (Sandbox Code Playgroud)

objective-c instanceof

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

如何从证书存储中获取X509Certificate并生成xml签名数据?

如何从证书存储中获取X509Certificate,然后在.net C#中生成XML SignatureData?

.net c# xml x509certificate xml-signature

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

什么是Linux的getDesktopProperty()?

我必须阅读本机操作系统的高对比度模式,并且必须在我的产品上应用设置.现在对于Windows我做了这样的事情:

 try {
       Toolkit toolkit = Toolkit.getDefaultToolkit();
       boolean highContrast = (Boolean)toolkit.getDesktopProperty("win.highContrast.on" );
 }catch(Exception e) {
 }
Run Code Online (Sandbox Code Playgroud)

这适用于Windows,但我需要桌面属性来读取Linux高对比度设置.任何人都可以告诉我什么是Linux的桌面属性?

java linux high-contrast

17
推荐指数
1
解决办法
591
查看次数

配置GitWeb - 404 - 未找到任何项目

我在OpenSUSE(非虚拟主机)中通过Apache在我的系统中配置gitweb.但是,我收到以下错误:404 - No projects found.

/etc/gitweb.conf

# path to git projects (<project>.git)
$projectroot = "/home/zhijian/gitweb";

# directory to use for temp files
$git_temp = "/tmp";

# target of the home link on top of all pages
#$home_link = $my_uri || "/";

# html text to include at home page
$home_text = "/gitweb/static/indextext.html";

# file with project list; by default, simply scan the projectroot dir.
$projects_list = $projectroot;

# stylesheet to use
$stylesheet = "/gitweb/static/gitweb.css";

# logo to use …
Run Code Online (Sandbox Code Playgroud)

gitweb

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