本文整理汇总了Java中org.apache.neethi.PolicyEngine.getPolicy方法的典型用法代码示例。如果您正苦于以下问题:Java PolicyEngine.getPolicy方法的具体用法?Java PolicyEngine.getPolicy怎么用?Java PolicyEngine.getPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.neethi.PolicyEngine
的用法示例。
在下文中一共展示了PolicyEngine.getPolicy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: 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");
}
}
示例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;
}
示例5: 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);
}
示例6: 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);
}
}
示例7: 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);
}
示例8: 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()));
}
示例9: 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;
}
示例10: toThrottlePolicy
import org.apache.neethi.PolicyEngine; //导入方法依赖的package包/类
public ThrottlePolicy toThrottlePolicy(String policyXML) throws ThrottleComponentException {
try {
OMElement policyOM = createOMElement(policyXML);
Policy policy = PolicyEngine.getPolicy(policyOM);
List<Policy> list = new ArrayList<Policy>();
list.add(policy);
XmlPrimtiveAssertion assertion = this.getThrottlePolicy(list);
return preparePolicyConfigs(assertion, new ThrottlePolicy());
} catch (Exception e) {
throw new ThrottleComponentException("Invalid policy XML ", e);
}
}
示例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);
}
}
示例12: 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");
}
}
示例13: 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");
}
}
示例14: 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;
}
示例15: 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 ");
}
}