尝试使用SAML 2.0解密加密断言时遇到问题.我使用的库是OpenSAML Java库2.5.2.
加密的断言如下所示:
<EncryptedAssertion xmlns="urn:oasis:names:tc:SAML:2.0:assertion">
<enc:EncryptedData Type="http://www.w3.org/2001/04/xmlenc#Element"
xmlns:enc="http://www.w3.org/2001/04/xmlenc#">
<enc:EncryptionMethod Algorithm="http://www.w3.org/2001/04/xmlenc#aes256-cbc" />
<KeyInfo xmlns="http://www.w3.org/2000/09/xmldsig#">
<e:EncryptedKey xmlns:e="http://www.w3.org/2001/04/xmlenc#">
<e:EncryptionMethod
Algorithm="http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p">
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
</e:EncryptionMethod>
<KeyInfo>
<o:SecurityTokenReference
xmlns:o="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-
1.0.xsd">
<o:KeyIdentifier
ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-
1.1#ThumbprintSHA1"
EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-
message-security-1.0#Base64Binary">
1H3mV/pJAlVZAst/Dt0rqbBd67g=
</o:KeyIdentifier>
</o:SecurityTokenReference>
</KeyInfo>
<e:CipherData>
<e:CipherValue>
... ENCRYPTED KEY HERE ...
</e:CipherValue>
</e:CipherData>
</e:EncryptedKey>
</KeyInfo>
<enc:CipherData>
<enc:CipherValue>
... ENCRYPTED ASSERTIONS HERE ...
</enc:CipherValue>
</enc:CipherData>
</enc:EncryptedData>
</EncryptedAssertion>
Run Code Online (Sandbox Code Playgroud)
我确实使用以下openssl命令将PEM格式的私钥转换为pkcs8格式:
openssl pkcs8 -topk8 -nocrypt -inform PEM -in rsa_private_key.key -outform DER -out rsa_private_key.pk8
Run Code Online (Sandbox Code Playgroud)
然后我准备尝试解密加密的断言.这是我的Java代码:
...
// Load the XML file and parse it. …Run Code Online (Sandbox Code Playgroud) 我目前遇到了模板化方法的问题.我有这个实现模板方法的公共类:
namespace Private { class InternalClass; }
namespace Public
{
class PublicClass
{
public:
PublicClass();
virtual ~PublicClass();
template<class T>
bool Add(bool primary);
private:
Private::InternalClass* _pInternal;
};
template<class T>
bool PublicClass::Add(bool primary) { return _pInternal->Add<T>(primary); }
}
Run Code Online (Sandbox Code Playgroud)
内部类以这种方式实现:
namespace Private
{
class InternalClass
{
public:
InternalClass();
virtual ~InternalClass();
template <class T>
bool Add(bool primary);
};
template<class T>
bool InternalClass::Add(bool primary) { return false; }
}
Run Code Online (Sandbox Code Playgroud)
由于这个内部类头不能与提供的源一起使用,我必须在PublicClass头中转发它,并在PublicClass.cpp文件中添加include到PrivateClass.h.
1)知道为什么我会收到以下错误:
错误:成员访问不完整类型'Private :: InternalClass'/ note:forward>'Private :: InternalClass'的声明
2)隐藏我的PublicClass :: Add()实现的最佳方法是什么?
更新
原因1错误),是因为这是由玉米秆说.
对于2),如何在不在PublicClass头文件中包含PrivateClass.h的情况下隐藏我的实现?
我在Linux 64位上使用CMake时遇到问题.我在C中有一个必须链接到库(xr_arp.a)的示例,该库对另一个库(libcrypto.a)具有链接依赖性.我为构建示例代码所做的以下makefile是成功链接的:
CFLAGS = -I../Common -I../xr -I../../../openssl/include
LIBS = ../xr/xr_arp.a ../../../openssl/lib/libcrypto.a
TARGET = sample
OBJFILES = sample.o
all: $(TARGET)
$(TARGET): Makefile $(OBJFILES)
$(CC) -o $@ $(OBJFILES) $(LIBS)
clean:
rm -rf *.o $(TARGET)
.SUFFIXES: .c .o
.c.o:
$(CC) -Wall $(CFLAGS) -c $<
Run Code Online (Sandbox Code Playgroud)
但是,我想将此makefile转换为使用CMake.当我使用下面的CMakeLists.txt文件时,我得到xr_arp.c对`SHA1'的未定义引用,因为它似乎无法将xr_arp.a链接到libcrypto.a:
cmake_minimum_required(VERSION 2.8)
project (SAMPLE C)
set(CMAKE_C_FLAGS "-Wall")
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../Common
${CMAKE_CURRENT_SOURCE_DIR}/../xr
)
add_executable(
sample
sample.c
)
target_link_libraries(
sample
${CMAKE_CURRENT_SOURCE_DIR}/../../../openssl/lib/libcrypto.a
${CMAKE_CURRENT_SOURCE_DIR}/../xr/xr_arp.a
)
Run Code Online (Sandbox Code Playgroud)
有人能指出我这两个文件有什么区别吗?为什么它使用makefile而不是CMake?有没有我可以用来强制xr_arp.a和libcrypto.a之间链接的程序?请注意,这两个库都是第三方,不是我的.