本文整理汇总了Java中org.apache.wss4j.dom.WSConstants类的典型用法代码示例。如果您正苦于以下问题:Java WSConstants类的具体用法?Java WSConstants怎么用?Java WSConstants使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
WSConstants类属于org.apache.wss4j.dom包,在下文中一共展示了WSConstants类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildClientForSecurityTokenRequests
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
/**
* Build client for security token requests.
*
* @param service the rp
* @return the security token service client
*/
public SecurityTokenServiceClient buildClientForSecurityTokenRequests(final WSFederationRegisteredService service) {
final Bus cxfBus = BusFactory.getDefaultBus();
final SecurityTokenServiceClient sts = new SecurityTokenServiceClient(cxfBus);
sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));
sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
sts.setWsdlLocation(prepareWsdlLocation(service));
if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
sts.setWspNamespace(service.getPolicyNamespace());
}
final String namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
sts.setServiceQName(new QName(namespace, StringUtils.defaultIfBlank(service.getWsdlService(), WSFederationConstants.SECURITY_TOKEN_SERVICE)));
sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
sts.getProperties().putAll(new HashMap<>());
return sts;
}
示例2: buildClientForRelyingPartyTokenResponses
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
/**
* Build client for relying party token responses.
*
* @param securityToken the security token
* @param service the service
* @return the security token service client
*/
public SecurityTokenServiceClient buildClientForRelyingPartyTokenResponses(final SecurityToken securityToken,
final WSFederationRegisteredService service) {
final Bus cxfBus = BusFactory.getDefaultBus();
final SecurityTokenServiceClient sts = new SecurityTokenServiceClient(cxfBus);
sts.setAddressingNamespace(StringUtils.defaultIfBlank(service.getAddressingNamespace(), WSFederationConstants.HTTP_WWW_W3_ORG_2005_08_ADDRESSING));
sts.setWsdlLocation(prepareWsdlLocation(service));
final String namespace = StringUtils.defaultIfBlank(service.getNamespace(), WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512);
sts.setServiceQName(new QName(namespace, service.getWsdlService()));
sts.setEndpointQName(new QName(namespace, service.getWsdlEndpoint()));
sts.setEnableAppliesTo(StringUtils.isNotBlank(service.getAppliesTo()));
sts.setOnBehalfOf(securityToken.getToken());
sts.setKeyType(WSFederationConstants.HTTP_DOCS_OASIS_OPEN_ORG_WS_SX_WS_TRUST_200512_BEARER);
sts.setTokenType(StringUtils.defaultIfBlank(service.getTokenType(), WSConstants.WSS_SAML2_TOKEN_TYPE));
if (StringUtils.isNotBlank(service.getPolicyNamespace())) {
sts.setWspNamespace(service.getPolicyNamespace());
}
return sts;
}
示例3: testAES128GCM
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void testAES128GCM () throws Exception
{
final Document doc = _getSoapEnvelope11 ();
final WSSecHeader secHeader = new WSSecHeader (doc);
secHeader.insertSecurityHeader ();
final WSSecEncrypt builder = new WSSecEncrypt (secHeader);
// builder.setUserInfo ("wss40");
builder.setUserInfo (m_aCryptoProperties.getKeyAlias (), m_aCryptoProperties.getKeyPassword ());
builder.setKeyIdentifierType (WSConstants.BST_DIRECT_REFERENCE);
builder.setSymmetricEncAlgorithm (ECryptoAlgorithmCrypt.AES_128_GCM.getAlgorithmURI ());
final Document encryptedDoc = builder.build (m_aCrypto);
final String outputString = XMLUtils.prettyDocumentToString (encryptedDoc);
// System.out.println (outputString);
assertFalse (outputString.contains ("counter_port_type"));
}
示例4: encryptSoapBodyPayload
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Nonnull
public Document encryptSoapBodyPayload (@Nonnull final ESOAPVersion eSOAPVersion,
@Nonnull final Document aDoc,
final boolean bMustUnderstand,
@Nonnull final ECryptoAlgorithmCrypt eCryptAlgo) throws Exception
{
ValueEnforcer.notNull (eSOAPVersion, "SOAPVersion");
ValueEnforcer.notNull (aDoc, "XMLDoc");
ValueEnforcer.notNull (eCryptAlgo, "CryptAlgo");
final CryptoProperties aCryptoProps = m_aCryptoFactory.getCryptoProperties ();
final WSSecHeader aSecHeader = new WSSecHeader (aDoc);
aSecHeader.insertSecurityHeader ();
final WSSecEncrypt aBuilder = new WSSecEncrypt (aSecHeader);
aBuilder.setKeyIdentifierType (WSConstants.BST_DIRECT_REFERENCE);
aBuilder.setSymmetricEncAlgorithm (eCryptAlgo.getAlgorithmURI ());
aBuilder.setUserInfo (aCryptoProps.getKeyAlias (), aCryptoProps.getKeyPassword ());
aBuilder.getParts ().add (new WSEncryptionPart ("Body", eSOAPVersion.getNamespaceURI (), "Content"));
final Attr aMustUnderstand = aSecHeader.getSecurityHeaderElement ()
.getAttributeNodeNS (eSOAPVersion.getNamespaceURI (), "mustUnderstand");
if (aMustUnderstand != null)
aMustUnderstand.setValue (eSOAPVersion.getMustUnderstandValue (bMustUnderstand));
return aBuilder.build (m_aCryptoFactory.getCrypto ());
}
示例5: test101GetConfigWrongPasswordDigest
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test101GetConfigWrongPasswordDigest() throws Exception {
final String TEST_NAME = "test101GetConfigWrongPasswordDigest";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, "wrongAdministratorPassword", WSConstants.PW_DIGEST);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "could not be authenticated or authorized");
}
示例6: test102GetConfigWrongPasswordText
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test102GetConfigWrongPasswordText() throws Exception {
final String TEST_NAME = "test102GetConfigWrongPasswordText";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, "wrongAdministratorPassword", WSConstants.PW_TEXT);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
}
示例7: test103GetConfigEmptyPasswordDigest
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test103GetConfigEmptyPasswordDigest() throws Exception {
final String TEST_NAME = "test103GetConfigEmptyPasswordDigest";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, "", WSConstants.PW_DIGEST);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "could not be authenticated or authorized");
}
示例8: test104GetConfigEmptyPasswordText
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test104GetConfigEmptyPasswordText() throws Exception {
final String TEST_NAME = "test104GetConfigEmptyPasswordText";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, "", WSConstants.PW_TEXT);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "could not be authenticated or authorized");
}
示例9: test105GetConfigWrongUsernameDigest
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test105GetConfigWrongUsernameDigest() throws Exception {
final String TEST_NAME = "test105GetConfigWrongUsernameDigest";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort("admin", USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_DIGEST);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "no user");
}
示例10: test106GetConfigWrongUsernameText
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test106GetConfigWrongUsernameText() throws Exception {
final String TEST_NAME = "test106GetConfigWrongUsernameText";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort("admin", USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_TEXT);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "no user");
}
示例11: test107GetConfigBlankUsernameDigest
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test107GetConfigBlankUsernameDigest() throws Exception {
final String TEST_NAME = "test107GetConfigBlankUsernameDigest";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(" ", USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_DIGEST);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "no username");
}
示例12: test108GetConfigBlankUsernameText
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test108GetConfigBlankUsernameText() throws Exception {
final String TEST_NAME = "test108GetConfigBlankUsernameText";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(" ", USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_TEXT);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "no username");
}
示例13: test110GetConfigGoodPasswordDigest
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test110GetConfigGoodPasswordDigest() throws Exception {
final String TEST_NAME = "test110GetConfigGoodPasswordDigest";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_DIGEST);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
tailer.tail();
assertAuditLoginLogout(tailer);
assertAuditIds(tailer);
tailer.assertAudit(2);
}
示例14: test111GetConfigGoodPasswordText
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test111GetConfigGoodPasswordText() throws Exception {
final String TEST_NAME = "test111GetConfigGoodPasswordText";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_ADMINISTRATOR_USERNAME, USER_ADMINISTRATOR_PASSWORD, WSConstants.PW_TEXT);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
// THEN
assertSuccess(resultHolder);
tailer.tail();
assertAuditLoginLogout(tailer);
assertAuditIds(tailer);
tailer.assertAudit(2);
}
示例15: test121GetConfigAsNobodyWrongPasswordDigest
import org.apache.wss4j.dom.WSConstants; //导入依赖的package包/类
@Test
public void test121GetConfigAsNobodyWrongPasswordDigest() throws Exception {
final String TEST_NAME = "test121GetConfigAsNobodyWrongPasswordDigest";
displayTestTitle(TEST_NAME);
LogfileTestTailer tailer = createLogTailer();
modelPort = createModelPort(USER_NOBODY_USERNAME, "wrongNobodyPassword", WSConstants.PW_DIGEST);
Holder<ObjectType> objectHolder = new Holder<ObjectType>();
Holder<OperationResultType> resultHolder = new Holder<OperationResultType>();
// WHEN
try {
modelPort.getObject(getTypeQName(SystemConfigurationType.class), SystemObjectsType.SYSTEM_CONFIGURATION.value(),
null, objectHolder, resultHolder);
AssertJUnit.fail("Unexpected success");
} catch (SOAPFaultException e) {
assertSoapSecurityFault(e, "FailedAuthentication", "could not be authenticated or authorized");
}
tailer.tail();
assertAuditLoginFailed(tailer, "no authorizations");
}