本文整理汇总了Java中org.apache.neethi.PolicyEngine类的典型用法代码示例。如果您正苦于以下问题:Java PolicyEngine类的具体用法?Java PolicyEngine怎么用?Java PolicyEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PolicyEngine类属于org.apache.neethi包,在下文中一共展示了PolicyEngine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSignOnlyPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static Policy getSignOnlyPolicy() throws IdentityException {
Policy policy;
try {
OMElement policyOM = AXIOMUtil.stringToOM(policyString);
PolicyEngine policyEngine = new PolicyEngine();
policy = policyEngine.getPolicy(policyOM);
} catch (Exception e) {
String msg = "error building policy from " + policyString;
log.error(msg);
throw IdentityException.error(msg, e);
}
return policy;
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:18,代码来源:IdentityBaseUtil.java
示例2: getSignOnlyPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static Policy getSignOnlyPolicy() throws RegistryException {
Policy policy;
try {
OMElement policyOM = AXIOMUtil.stringToOM(policyString);
policy = PolicyEngine.getPolicy(policyOM);
} catch (Exception e) {
String msg = "error building policy from " + policyString;
log.error(msg);
throw new RegistryException(msg, e);
}
return policy;
}
开发者ID:wso2,项目名称:carbon-registry,代码行数:17,代码来源:SecurityUtil.java
示例3: getPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
private static Policy getPolicy(String key, Registry registry)
throws DiscoveryException, RegistryException {
if (!registry.resourceExists(key)) {
throw new DiscoveryException("Policy resource " + key + " does not exist");
}
Resource policy = registry.get(key);
ByteArrayInputStream in = new ByteArrayInputStream((byte[]) policy.getContent());
try {
StAXOMBuilder builder = new StAXOMBuilder(in);
Policy secPolicy = PolicyEngine.getPolicy(builder.getDocumentElement());
policy.discard();
return secPolicy;
} catch (XMLStreamException e) {
policy.discard();
throw new DiscoveryException("Error while loading the policy from resource " + key, e);
}
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:20,代码来源:DiscoveryMgtUtils.java
示例4: readExternalGlobalPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
/**
* An external policy can be configured using a parameter in the axis2.xml which points to the
* absolute path of the policy file. This method reads the policy file and creates a
* PolicySubject.
*
* @param axisConfig - AxisConfiguration instance
* @return - PolicySubject instance if the file found. Otherwise null..
*/
public static PolicySubject readExternalGlobalPolicy(AxisConfiguration axisConfig) {
PolicySubject extPolicySubject = null;
// read the global throttle parameter from axisConfig
Parameter globalThrottlePolicyParam = axisConfig
.getParameter(ThrottleConstants.GLOBAL_THROTTLE_PATH_PARAM);
if (globalThrottlePolicyParam != null &&
!"".equals(globalThrottlePolicyParam.getValue())) {
// If the path found, try to read the file
String policyPath = (String) globalThrottlePolicyParam.getValue();
File policyFile = new File(policyPath);
if (policyFile.exists()) {
try {
// If the file exists, try to build the policy
Policy globalPolicy = PolicyEngine.getPolicy(new FileInputStream(policyFile));
extPolicySubject = new PolicySubject();
extPolicySubject.attachPolicy(globalPolicy);
} catch (FileNotFoundException e) {
log.error("Error while reading global policy file..", e);
}
}
}
return extPolicySubject;
}
开发者ID:wso2-attic,项目名称:carbon-qos,代码行数:32,代码来源:ThrottleEnguageUtils.java
示例5: handleSecurityProxy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
/**
* Helper method to handle security policies.
*
* @param file deployment data file.
* @param axisService to be modified.
* @return true if security is enabled, false otherwise.
* @throws DataServiceFault
*/
private boolean handleSecurityProxy(DeploymentFileData file, AxisService axisService) throws DataServiceFault{
try {
boolean secEnabled = false;
StAXOMBuilder builder = new StAXOMBuilder(new FileInputStream(file.getFile().getAbsoluteFile()));
OMElement documentElement = builder.getDocumentElement();
OMElement enableSecElement= documentElement.getFirstChildWithName(new QName(DBSFields.ENABLESEC));
if (enableSecElement != null) {
secEnabled = true;
}
OMElement policyElement= documentElement.getFirstChildWithName(new QName(DBSFields.POLICY));
if (policyElement != null) {
String policyKey = policyElement.getAttributeValue(new QName(DBSFields.POLICY_KEY));
if (null == policyKey) {
throw new DataServiceFault("Policy key element should contain a policy key in " + file.getFile().getName());
}
Policy policy = PolicyEngine.getPolicy(DBUtils.getInputStreamFromPath(policyKey));
axisService.getPolicySubject().attachPolicy(policy);
}
return secEnabled;
}catch (Exception e) {
throw new DataServiceFault(e, "Error in processing security policy");
}
}
开发者ID:wso2,项目名称:carbon-data,代码行数:32,代码来源:DBDeployer.java
示例6: loadPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException, XMLStreamException {
InputStream in = resource.getContentStream();
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
xmlInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", false);
XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement policyElement = builder.getDocumentElement();
return PolicyEngine.getPolicy(policyElement);
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:15,代码来源:SecurityDeploymentInterceptor.java
示例7: applySecurity
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public void applySecurity(String serviceName, String scenarioId, KerberosConfigData kerberosConfigurations)
throws SecurityConfigException {
if (kerberosConfigurations == null) {
log.error("Kerberos configurations provided are invalid.");
throw new SecurityConfigException("Kerberos configuration parameters are null. " +
"Please specify valid kerberos configurations.");
}
AxisService service = axisConfig.getServiceForActivation(serviceName);
if (service == null) {
throw new SecurityConfigException("nullService");
}
// Disable security if already a policy is applied
this.disableSecurityOnService(serviceName); //todo fix the method
OMElement policyElement = loadPolicyAsXML(scenarioId, null);
OMElement carbonSecConfigs = addUserParameters(policyElement, null, null, null, kerberosConfigurations,
false, null);
policyElement.addChild(buildRampartConfigXML(null, null, kerberosConfigurations));
Policy policy = PolicyEngine.getPolicy(policyElement);
//service.getPolicySubject().attachPolicy(policy);
try {
persistPolicy(service, policyElement, policy.getId());
applyPolicy(service, policy, carbonSecConfigs);
this.getPOXCache().remove(serviceName);
} catch (Exception e) {
throw new SecurityConfigException("Error while persisting policy in registry ", e);
}
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:33,代码来源:SecurityConfigAdmin.java
示例8: loadPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
private Policy loadPolicy(Resource resource) throws org.wso2.carbon.registry.api.RegistryException,
XMLStreamException {
InputStream in = resource.getContentStream();
XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance();
xmlInputFactory.setProperty(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
XMLStreamReader parser = xmlInputFactory.createXMLStreamReader(in);
StAXOMBuilder builder = new StAXOMBuilder(parser);
OMElement policyElement = builder.getDocumentElement();
return PolicyEngine.getPolicy(policyElement);
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:14,代码来源:SecurityConfigAdmin.java
示例9: getSecurityPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static Policy getSecurityPolicy() {
String policyString = " <wsp:Policy wsu:Id=\"UTOverTransport\" xmlns:wsp=\"http://schemas.xmlsoap.org/ws/2004/09/policy\"\n" +
" xmlns:wsu=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd\">\n" +
" <wsp:ExactlyOne>\n" +
" <wsp:All>\n" +
" <sp:TransportBinding xmlns:sp=\"http://schemas.xmlsoap.org/ws/2005/07/securitypolicy\">\n" +
" <wsp:Policy>\n" +
" <sp:TransportToken>\n" +
" <wsp:Policy>\n" +
" <sp:HttpsToken RequireClientCertificate=\"true\"/>\n" +
" </wsp:Policy>\n" +
" </sp:TransportToken>\n" +
" <sp:AlgorithmSuite>\n" +
" <wsp:Policy>\n" +
" <sp:Basic256/>\n" +
" </wsp:Policy>\n" +
" </sp:AlgorithmSuite>\n" +
" <sp:Layout>\n" +
" <wsp:Policy>\n" +
" <sp:Lax/>\n" +
" </wsp:Policy>\n" +
" </sp:Layout>\n" +
" <sp:IncludeTimestamp/>\n" +
" </wsp:Policy>\n" +
" </sp:TransportBinding>\n" +
" </wsp:All>\n" +
" </wsp:ExactlyOne>\n" +
" </wsp:Policy>";
return PolicyEngine.getPolicy(new ByteArrayInputStream(policyString.getBytes()));
}
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:34,代码来源:Utils.java
示例10: loadPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
private static Policy loadPolicy(String xmlPath, String clientKey, String userName)
throws Exception {
StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());
RampartConfig rc = new RampartConfig();
rc.setUser(userName);
rc.setUserCertAlias("wso2carbon");
rc.setEncryptionUser("wso2carbon");
rc.setPwCbClass(SecurityWithServiceDescriptorTest.class.getName());
CryptoConfig sigCryptoConfig = new CryptoConfig();
sigCryptoConfig.setProvider("org.apache.ws.security.components.crypto.Merlin");
Properties prop1 = new Properties();
prop1.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
prop1.put("org.apache.ws.security.crypto.merlin.file", clientKey);
prop1.put("org.apache.ws.security.crypto.merlin.keystore.password", "wso2carbon");
sigCryptoConfig.setProp(prop1);
CryptoConfig encrCryptoConfig = new CryptoConfig();
encrCryptoConfig.setProvider("org.apache.ws.security.components.crypto.Merlin");
Properties prop2 = new Properties();
prop2.put("org.apache.ws.security.crypto.merlin.keystore.type", "JKS");
prop2.put("org.apache.ws.security.crypto.merlin.file", clientKey);
prop2.put("org.apache.ws.security.crypto.merlin.keystore.password", "wso2carbon");
encrCryptoConfig.setProp(prop2);
rc.setSigCryptoConfig(sigCryptoConfig);
rc.setEncrCryptoConfig(encrCryptoConfig);
policy.addAssertion(rc);
return policy;
}
开发者ID:wso2,项目名称:product-ei,代码行数:38,代码来源:SecurityWithServiceDescriptorTest.java
示例11: processPolicyElements
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
protected void processPolicyElements(Iterator policyElements,
PolicySubject policySubject) {
while (policyElements.hasNext()) {
Policy p = PolicyEngine
.getPolicy((OMElement) policyElements.next());
policySubject.attachPolicy(p);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:DescriptionBuilder.java
示例12: processPolicyRefElements
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
protected void processPolicyRefElements(Iterator policyRefElements,
PolicySubject policySubject) {
while (policyRefElements.hasNext()) {
PolicyReference policyReference = PolicyEngine
.getPolicyReference((OMElement) policyRefElements.next());
policySubject.attachPolicyReference(policyReference);
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:DescriptionBuilder.java
示例13: getPolicyComponentFromOMElement
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static PolicyComponent getPolicyComponentFromOMElement(
OMElement policyComponent) throws IllegalArgumentException {
if (Constants.Q_ELEM_POLICY.equals(policyComponent.getQName())) {
return PolicyEngine.getPolicy(policyComponent);
} else if (policyComponent.getQName().equals(
new QName(Constants.URI_POLICY_NS, Constants.ELEM_POLICY_REF))) {
return PolicyEngine.getPolicyReference(policyComponent);
} else {
throw new IllegalArgumentException(
"Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:16,代码来源:PolicyUtil.java
示例14: getPolicyFromOMElement
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static Policy getPolicyFromOMElement(OMElement policyElement) {
if (Constants.Q_ELEM_POLICY.equals(policyElement.getQName())) {
return PolicyEngine.getPolicy(policyElement);
} else {
throw new IllegalArgumentException(
"argument is not a <wsp:Policy ..> element");
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:9,代码来源:PolicyUtil.java
示例15: getPolicyReferenceFromOMElement
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static PolicyReference getPolicyReferenceFromOMElement(
OMElement policyRefElement) {
if (Constants.URI_POLICY_NS.equals(policyRefElement.getNamespace()
.getNamespaceURI())
&& Constants.ELEM_POLICY_REF.equals(policyRefElement
.getLocalName())) {
return PolicyEngine.getPolicyReference(policyRefElement);
} else {
throw new IllegalArgumentException(
"argument is not a <wsp:PolicyReference> element");
}
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:13,代码来源:PolicyUtil.java
示例16: getPolicyComponent
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static PolicyComponent getPolicyComponent(org.w3c.dom.Element element) {
if (Constants.URI_POLICY_NS.equals(element.getNamespaceURI())) {
if (Constants.ELEM_POLICY.equals(element.getLocalName())) {
return PolicyEngine.getPolicy(nodeToStream(element));
} else if (Constants.ELEM_POLICY_REF.equals(element.getLocalName())) {
return PolicyEngine.getPolicyReferene(nodeToStream(element));
}
}
throw new IllegalArgumentException(
"Agrument is neither a <wsp:Policy> nor a <wsp:PolicyReference> element");
}
开发者ID:wso2,项目名称:wso2-axis2,代码行数:14,代码来源:PolicyUtil.java
示例17: getClientSecurityPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
/**
* Get the client side security policy for the remote discovery proxy. This method first checks
* whether a resource named DiscoveryConstants.DISCOVERY_CLIENT_POLICY is available at the
* root of the configuration registry. If not it attempts to load the policy from a file named
* DiscoveryConstants.DISCOVERY_CLIENT_POLICY which should reside in the configuration file
* directory of Carbon.
*
* @param registry Configuration registry
* @return a Policy instance or null
* @throws RegistryException If the registry cannot be accessed
* @throws XMLStreamException If the policy XML cannot be parsed
*/
public static Policy getClientSecurityPolicy(Registry registry) throws RegistryException,
XMLStreamException {
//TODO: Improve this logic so that user can put the security policy anywhere in the registry
InputStream in;
Resource policyResource = null;
if (registry.resourceExists(DiscoveryConstants.DISCOVERY_CLIENT_POLICY)) {
policyResource = registry.get(DiscoveryConstants.DISCOVERY_CLIENT_POLICY);
in = policyResource.getContentStream();
} else {
String file = CarbonUtils.getCarbonConfigDirPath() + File.separator +
DiscoveryConstants.DISCOVERY_CLIENT_POLICY;
try {
in = new FileInputStream(file);
} catch (FileNotFoundException ignored) {
return null;
}
}
Policy policy = null;
if (in != null) {
StAXOMBuilder builder = new StAXOMBuilder(in);
policy = PolicyEngine.getPolicy(builder.getDocumentElement());
}
if (policyResource != null) {
policyResource.discard();
}
return policy;
}
开发者ID:wso2,项目名称:carbon-commons,代码行数:43,代码来源:DiscoveryMgtUtils.java
示例18: retrieveCachingAssertionAndPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
/**
* Retrieves the caching assertion and caching policy components.
*
* @param policyComponents the set of policy components associated with the service.
* @return the caching assertion and caching policy components as a <code>Policy</code> array.
*/
public Policy[] retrieveCachingAssertionAndPolicy(Collection policyComponents) {
for (Object policyComponent : policyComponents) {
if (policyComponent instanceof Policy) {
Policy parentPolicy = (Policy) policyComponent;
for (Iterator iterator = parentPolicy.getAlternatives();
iterator.hasNext();) {
Object object = iterator.next();
if (object instanceof List) {
List list = (List) object;
for (Object assertObj : list) {
if (assertObj instanceof XmlPrimtiveAssertion) {
XmlPrimtiveAssertion primitiveAssertion = (XmlPrimtiveAssertion)
assertObj;
if (primitiveAssertion.getName().equals(CachingComponentConstants
.CACHING_ASSERTION_QNAME)) {
return new Policy[]{PolicyEngine
.getPolicy(primitiveAssertion.getValue()), parentPolicy};
}
}
}
}
}
}
}
if (log.isDebugEnabled()) {
log.debug("Returns null as no caching assertion was found");
}
return null;
}
开发者ID:wso2-attic,项目名称:carbon-qos,代码行数:38,代码来源:CachingPolicyUtils.java
示例19: initDefaultPolicy
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
private void initDefaultPolicy() throws AxisFault {
InputStream inputStream =
this.getClass().getResourceAsStream("/resources/policy/default_module_policy.xml");
if (inputStream != null) {
defaultPolicy = PolicyEngine.getPolicy(inputStream);
} else {
throw new AxisFault("Couldn't load the default throttle policy.The module is invalid ");
}
}
开发者ID:wso2-attic,项目名称:carbon-qos,代码行数:10,代码来源:ThrottleModule.java
示例20: getThrottle
import org.apache.neethi.PolicyEngine; //导入依赖的package包/类
public static Throttle getThrottle(String policyStr) throws Exception {
OMElement policyOM = createOMElement(policyStr);
Policy policy = PolicyEngine.getPolicy(policyOM);
Throttle throttle = ThrottleFactory.createModuleThrottle(policy);
return throttle;
}
开发者ID:wso2-attic,项目名称:carbon-qos,代码行数:8,代码来源:ThrottleTestFactory.java
注:本文中的org.apache.neethi.PolicyEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论