Exemplo n.º 1
0
 private void initThrottle(ConfigurationContext cc) {
   Object entryValue = null;
   if (throttle == null) {
     entryValue = ThrottleUtils.lookup(APIManagerConstants.APPLICATION_THROTTLE_POLICY_KEY);
   }
   if (isClusteringEnable && concurrentAccessController != null && throttle != null) {
     concurrentAccessController = null; // set null ,
     // because need to reload
   }
   if (throttle == null) {
     try {
       throttle =
           ThrottleFactory.createMediatorThrottle(PolicyEngine.getPolicy((OMElement) entryValue));
       // For non-clustered  environment , must re-initiates
       // For  clustered  environment,
       // concurrent access controller is null ,
       // then must re-initiates
       if (throttle != null && (concurrentAccessController == null || !isClusteringEnable)) {
         concurrentAccessController = throttle.getConcurrentAccessController();
         if (concurrentAccessController != null) {
           cc.setProperty(key, concurrentAccessController);
         } else {
           cc.removeProperty(key);
         }
       }
     } catch (ThrottleException e) {
       // TODO Auto-generated catch block
       e.printStackTrace();
     }
   }
 }
  public Assertion build(OMElement element, AssertionBuilderFactory factory)
      throws IllegalArgumentException {
    TransportBinding transportBinding = new TransportBinding(SPConstants.SP_V12);

    Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
    policy = (Policy) policy.normalize(false);

    for (List<PolicyComponent> alts : policy.getAlternatives()) {
      processAlternative(alts, transportBinding, factory);
      break;
    }

    return transportBinding;
  }
Exemplo n.º 3
0
  public Policy loadPolicy(String xmlPath, String clientKey) throws Exception {

    StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
    Policy policy = PolicyEngine.getPolicy(builder.getDocumentElement());

    RampartConfig rc = new RampartConfig();

    rc.setUser("admin");
    rc.setUserCertAlias("wso2carbon");
    rc.setEncryptionUser("wso2carbon");
    rc.setPwCbClass(SecurityClient.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;
  }
Exemplo n.º 4
0
 private static Policy loadPolicy(String xmlPath) throws Exception {
   StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
   return PolicyEngine.getPolicy(builder.getDocumentElement());
 }
Exemplo n.º 5
0
 private Policy loadPolicy(String policyPath) throws XMLStreamException, FileNotFoundException {
   StAXOMBuilder omBuilder = new StAXOMBuilder(policyPath);
   return PolicyEngine.getPolicy(omBuilder.getDocumentElement());
 }