当前位置: 首页>>代码示例>>Java>>正文


Java Policy类代码示例

本文整理汇总了Java中org.apache.neethi.Policy的典型用法代码示例。如果您正苦于以下问题:Java Policy类的具体用法?Java Policy怎么用?Java Policy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Policy类属于org.apache.neethi包,在下文中一共展示了Policy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSecurityConfig

import org.apache.neethi.Policy; //导入依赖的package包/类
/**
 * Extract carbon security config element from the Policy
 *
 * @param policy Security Policy
 * @return security config element
 */
private OMElement getSecurityConfig(Policy policy) {
    Iterator<PolicyComponent> iterator = policy.getPolicyComponents().iterator();
    while (iterator.hasNext()) {
        PolicyComponent component = iterator.next();
        if (component instanceof XmlPrimtiveAssertion) {
            OMElement value = ((XmlPrimtiveAssertion) component).getValue();
            if (value != null &&
                SecurityConfigParamBuilder.SECURITY_CONFIG_QNAME.equals(value.getQName())) {
                if (log.isDebugEnabled()) {
                    log.debug("Carbon Security config found : " + value.toString());
                }
                return value;
            }
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:24,代码来源:SecurityDeploymentInterceptor.java

示例2: applyPolicyToBindings

import org.apache.neethi.Policy; //导入依赖的package包/类
private Policy applyPolicyToBindings(AxisService axisService) throws ServerException {
    Parameter parameter = axisService.getParameter(APPLY_POLICY_TO_BINDINGS);
    if (parameter != null && "true".equalsIgnoreCase(parameter.getValue().toString()) &&
            axisService.getPolicySubject() != null && axisService.getPolicySubject().getAttachedPolicyComponents()
            != null) {
        Iterator iterator = axisService.getPolicySubject().
                getAttachedPolicyComponents().iterator();
        while (iterator.hasNext()) {
            PolicyComponent currentPolicyComponent = (PolicyComponent) iterator.next();
            if (currentPolicyComponent instanceof Policy) {
                Policy policy = ((Policy) currentPolicyComponent);
                String policyId = policy.getId();
                axisService.getPolicySubject().detachPolicyComponent(policyId);
                addPolicyToAllBindings(axisService, policy);
                return policy;
            }
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:21,代码来源:SecurityDeploymentInterceptor.java

示例3: getCarbonSecConfigs

import org.apache.neethi.Policy; //导入依赖的package包/类
private OMElement getCarbonSecConfigs(Policy policy) {
    if (log.isDebugEnabled() && policy != null) {
        log.debug("Retrieving carbonSecConfigs from policy id : " + policy.getId());
    }
    if (policy != null) {
        List it = (List) policy.getAlternatives().next();
        for (Iterator iter = it.iterator(); iter.hasNext(); ) {
            Assertion assertion = (Assertion) iter.next();
            if (assertion instanceof XmlPrimtiveAssertion) {
                OMElement xmlPrimitiveAssertion = (((XmlPrimtiveAssertion) assertion).getValue());
                if (SecurityConstants.CARBON_SEC_CONFIG.equals(xmlPrimitiveAssertion.getLocalName())) {
                    OMElement carbonSecConfigElement = (((XmlPrimtiveAssertion) assertion).getValue());
                    if (log.isDebugEnabled()) {
                        log.debug("carbonSecConfig : " + carbonSecConfigElement.toString());
                    }
                    return carbonSecConfigElement;
                }
            }
        }
    }
    return null;
}
 
开发者ID:wso2,项目名称:carbon-identity-framework,代码行数:23,代码来源:SecurityConfigAdmin.java

示例4: getSignOnlyPolicy

import org.apache.neethi.Policy; //导入依赖的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

示例5: handleMessage

import org.apache.neethi.Policy; //导入依赖的package包/类
public void handleMessage(SoapMessage message) {
	try {
		// 1. Build effective policy for response
		org.apache.cxf.ws.policy.PolicyBuilder builder = message
				.getExchange().getBus()
				.getExtension(org.apache.cxf.ws.policy.PolicyBuilder.class);
		InputStream xmlGenericPolicy = new FileInputStream("/home/hans/workspace/TechyTax/src/org/techytax/xbrl/policy.xml");
		Policy effectivePolicy = builder.getPolicy(xmlGenericPolicy);

		// 2. Apply effective policy
		message.put(PolicyConstants.POLICY_OVERRIDE, effectivePolicy);

	} catch (Exception e) {
		e.printStackTrace();
	}

}
 
开发者ID:beemsoft,项目名称:techytax-zk,代码行数:18,代码来源:PolicyControlOutInterceptor.java

示例6: getIWAClient

import org.apache.neethi.Policy; //导入依赖的package包/类
/**
 * @param request
 * @return
 * @throws AxisFault
 */
private IWAAuthenticatorStub getIWAClient(HttpServletRequest request)
        throws AxisFault, IdentityException {

    HttpSession session = request.getSession();
    ServletContext servletContext = session.getServletContext();
    String backendServerURL = request.getParameter("backendURL");
    if (backendServerURL == null) {
        backendServerURL = CarbonUIUtil.getServerURL(servletContext, request.getSession());
    }

    ConfigurationContext configContext = (ConfigurationContext) servletContext
            .getAttribute(CarbonConstants.CONFIGURATION_CONTEXT);

    String serviceEPR = backendServerURL + "IWAAuthenticator";
    IWAAuthenticatorStub stub = new IWAAuthenticatorStub(configContext, serviceEPR);
    ServiceClient client = stub._getServiceClient();
    client.engageModule("rampart");
    Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
    Policy signOnly = IdentityBaseUtil.getSignOnlyPolicy();
    Policy mergedPolicy = signOnly.merge(rampartConfig);
    Options options = client.getOptions();
    options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, mergedPolicy);
    options.setManageSession(true);
    return stub;
}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:31,代码来源:IWAUIAuthenticator.java

示例7: populateRampartConfig

import org.apache.neethi.Policy; //导入依赖的package包/类
/**
 * Updates RelyingPartyService with Crypto information
 *
 * @param config AxisConfiguration
 * @throws Exception
 */
public static void populateRampartConfig(AxisConfiguration config) throws Exception {

    AxisService service;

    // Get the RelyingParty Service to update security policy with keystore information
    service = config.getService(IWA_SERVICE_NAME);
    if (service == null) {
        String msg = IWA_SERVICE_NAME + " is not available in the Configuration Context";
        log.error(msg);
    }

    // Create a Rampart Config with default crypto information
    //Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
    Policy rampartConfig = IdentityBaseUtil.getDefaultRampartConfig();
    // Add the RampartConfig to service policy
    service.getPolicySubject().attachPolicy(rampartConfig);

}
 
开发者ID:wso2-attic,项目名称:carbon-identity,代码行数:25,代码来源:IWADeploymentInterceptor.java

示例8: getSignOnlyPolicy

import org.apache.neethi.Policy; //导入依赖的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

示例9: testSymmBinding

import org.apache.neethi.Policy; //导入依赖的package包/类
public void testSymmBinding() {
    try {
        Policy p = this.getPolicy(System.getProperty("basedir", ".") +
                "/test-resources/policy-mtom-security.xml");
        List assertions = (List)p.getAlternatives().next();

        boolean isMTOMAssertionFound = false;

        for (Iterator iter = assertions.iterator(); iter.hasNext();) {
            Assertion assertion = (Assertion)iter.next();
            if (assertion instanceof MTOM10Assertion) {
                isMTOMAssertionFound = true;
                MTOM10Assertion mtomModel = (MTOM10Assertion)assertion;
                assertEquals("MIME Serialization assertion not processed", false,
                             mtomModel.isOptional());
            }

        }
        //The Asymm binding mean is not built in the policy processing :-(
        assertTrue("MTOM10 Assertion not found.", isMTOMAssertionFound);

    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:MTOMAssertionTest.java

示例10: testMTOM10Optional

import org.apache.neethi.Policy; //导入依赖的package包/类
public void testMTOM10Optional() {
    //Testing the wsp:Optional attribute in WS-MTOMPolicy 1.0 assertion
    try {
        Policy p = this.getPolicy(System.getProperty("basedir", ".") +
                "/test-resources/policy-mtom-optional.xml");
        List assertions = (List)p.getAlternatives().next();

        for (Iterator iter = assertions.iterator(); iter.hasNext();) {
            Assertion assertion = (Assertion)iter.next();
            if (assertion instanceof MTOM10Assertion) {
                MTOM10Assertion mtomModel = (MTOM10Assertion)assertion;
                assertEquals("wsp:Optional attribute is not processed", true,
                             mtomModel.isOptional());
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:24,代码来源:MTOMAssertionTest.java

示例11: testMTOM11Assertion

import org.apache.neethi.Policy; //导入依赖的package包/类
public void testMTOM11Assertion () {
    // Testing the WS-MTOMPolicy 1.1 assertion
    try {
        Policy p = this.getPolicy(System.getProperty("basedir", ".") +
                "/test-resources/policy-mtom11.xml");
        List assertions = (List)p.getAlternatives().next();

        boolean isMTOMAssertionFound = false;

        for (Iterator iter = assertions.iterator(); iter.hasNext();) {
            Assertion assertion = (Assertion)iter.next();
            if (assertion instanceof MTOM11Assertion) {
                isMTOMAssertionFound = true;
                MTOM11Assertion mtomModel = (MTOM11Assertion)assertion;
            }

        }
        assertTrue("MTOM11 Assertion not found.", isMTOMAssertionFound);

    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
    
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:26,代码来源:MTOMAssertionTest.java

示例12: testMTOM11AssertionOptional

import org.apache.neethi.Policy; //导入依赖的package包/类
public void testMTOM11AssertionOptional() {
  //Testing the wsp:Optional attribute in WS-MTOMPolicy 1.0 assertion
    try {
        Policy p = this.getPolicy(System.getProperty("basedir", ".") +
                "/test-resources/policy-mtom11-optional.xml");
        List assertions = (List)p.getAlternatives().next();

        for (Iterator iter = assertions.iterator(); iter.hasNext();) {
            Assertion assertion = (Assertion)iter.next();
            if (assertion instanceof MTOM10Assertion) {
                MTOM10Assertion mtomModel = (MTOM10Assertion)assertion;
                assertEquals("wsp:Optional attribute is not processed", true,
                             mtomModel.isOptional());
            }

        }

    } catch (Exception e) {
        e.printStackTrace();
        fail(e.getMessage());
    }
}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:23,代码来源:MTOMAssertionTest.java

示例13: engageNotify

import org.apache.neethi.Policy; //导入依赖的package包/类
public void engageNotify(AxisDescription axisDescription) throws AxisFault {

        if (log.isDebugEnabled()) {
            log.debug("MTOMPolicy module has been engaged to "
                    + axisDescription.getClass().getName());
        }

        AxisService axisService = Utils.locateAxisService(axisDescription);

        if (axisService == null) {
            if (log.isDebugEnabled()) {
                log.debug("MTOMPolicy module couldn't find the Axis Service ");
            }
            return;
        }

        Parameter param = axisService
                .getParameter(Constants.Configuration.ENABLE_MTOM);

        Policy mtomPolicy = Utils.getMTOMPolicy(param);

        if (mtomPolicy != null) {
            Utils.applyPolicyToSOAPBindings(axisService, mtomPolicy);
        }

    }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:27,代码来源:MTOMPolicy.java

示例14: invoke

import org.apache.neethi.Policy; //导入依赖的package包/类
/**
* Checks if the message should be MTOMised. If it is not but the policy states that it should be </br>
* then an {@link AxisFault} is thrown.
   * 
   * @param msgCtx the {@link MessageContext}
   * 
   * @throws AxisFault if the message is not MTOMised, but the policy states so.
*/
  public InvocationResponse invoke(MessageContext msgCtx) throws AxisFault {
      Policy policy = msgCtx.getEffectivePolicy();
      if (policy == null) {
          return InvocationResponse.CONTINUE;
      }
      List<Assertion> list = (List<Assertion>) policy.getAlternatives()
              .next();
      for (Assertion assertion : list) {
          if (assertion instanceof MTOMAssertion) {
              String contentType = (String) msgCtx.getProperty(Constants.Configuration.CONTENT_TYPE);
              if (!assertion.isOptional()) {
                  if (contentType == null || contentType.indexOf(MTOMConstants.MTOM_TYPE) == -1) {
                      if (msgCtx.isServerSide()) {
                      throw new AxisFault(
                              "The SOAP REQUEST sent by the client IS NOT MTOMized!");
                      } else {
                          throw new AxisFault(
                          "The SOAP RESPONSE sent by the service IS NOT MTOMized!");
                      }
                  }
              }
          }
      }
      return InvocationResponse.CONTINUE;
  }
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:34,代码来源:MTOMInHandler.java

示例15: getMTOMPolicy

import org.apache.neethi.Policy; //导入依赖的package包/类
/**
 * Based on the parameter passed a {@link MTOM10Assertion} object is created by default. </br>
 * Then it is added to a {@link Policy} object and returned. 
 * 
 * @param param the {@link Parameter} object that contains the value of the "enableMTOM" parameter: </br>
 * "true" or "optional".
 * @return The {@link Policy} object for the MTOM assertion. 
 */
public static Policy getMTOMPolicy(Parameter param) {

    if (param == null) {
        return null;
    }

    // TODO We need to give the user the ability to specify if MTOM 1.0 or MTOM 1.1 should be used.
    MTOMAssertion mtom10;

    if (Constants.VALUE_TRUE.equals(param.getValue())) {
        mtom10 = new MTOM10Assertion();
    } else if (Constants.VALUE_OPTIONAL.equals(param.getValue())) {
        mtom10 = new MTOM10Assertion();
        mtom10.setOptional(true);
    } else {
        return null;
    }

    Policy policy = new Policy();
    policy.addAssertion(mtom10);

    return policy;

}
 
开发者ID:wso2,项目名称:wso2-axis2,代码行数:33,代码来源:Utils.java


注:本文中的org.apache.neethi.Policy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。