Package com.sun.xml.wss.impl.policy.mls

Examples of com.sun.xml.wss.impl.policy.mls.MessagePolicy


               _sEnvironment.setSubject(subject, context.getExtraneousProperties());

               populateContextFromSharedState(context, sharedState);

               MessagePolicy senderCnfg =
                 ((DeclarativeSecurityConfiguration)_policy).senderSettings();
             
               SOAPMessage msg = AuthParamHelper.getResponse(param);
               context.setSecurityPolicy(senderCnfg);
               context.setSOAPMessage(msg);
View Full Code Here


       
        HarnessUtil.validateContext(context);
        FilterProcessingContext fpContext = new FilterProcessingContext(context);
        fpContext.isInboundMessage(true);
        SecurityPolicy pol = fpContext.getSecurityPolicy();
        MessagePolicy msgPolicy = null;
        List<MessagePolicy> messagePolicies = null;

        //we have to retain this stuff for old Metro 2.0 style backward compatibility
        if (pol instanceof MessagePolicy) {
            msgPolicy = (MessagePolicy) pol;
        } else if (pol instanceof PolicyAlternatives) {
            messagePolicies = ((PolicyAlternatives) pol).getSecurityPolicy();
        }

        if ((msgPolicy != null) && (msgPolicy.dumpMessages())) {
            DumpFilter.process(fpContext);
        }
        fpContext.setSecurityPolicyVersion( ((ProcessingContextImpl)context).getSecurityPolicyVersion());
        //unconditionally set these since the policy is unknown
        fpContext.setExtraneousProperty("EnableWSS11PolicyReceiver","true");
        List scList = new ArrayList();
        fpContext.setExtraneousProperty("receivedSignValues", scList);
        fpContext.setMode(FilterProcessingContext.WSDL_POLICY);

        pProcess(fpContext);
       
        if(PolicyUtils.isEmpty(pol)){
            PolicyResolver opResolver =
                    (PolicyResolver)fpContext.getExtraneousProperty(fpContext.OPERATION_RESOLVER);
            if(opResolver != null){
                pol = opResolver.resolvePolicy(fpContext);
            }
        }
        //we have to retain this stuff for old Metro 2.0 style backward compatibility
        if (pol instanceof MessagePolicy) {
            msgPolicy = (MessagePolicy) pol;
        } else if (pol instanceof PolicyAlternatives) {
            messagePolicies = ((PolicyAlternatives) pol).getSecurityPolicy();
            //temporary workaround for this legacy code
            msgPolicy = (messagePolicies != null) ? messagePolicies.get(0) : null;
        }


        //TODO: this is a workaround for PROTOCOL Message
        try {
            if (msgPolicy == null ||
                    (msgPolicy.size() == 0 && fpContext.getSOAPMessage().getSOAPBody().hasFault())) {
               
                fpContext.getSecurableSoapMessage().deleteSecurityHeader();
                fpContext.getSOAPMessage().saveChanges();
                return;
            }
View Full Code Here

     */
    private static void pProcess(FilterProcessingContext fpContext)
    throws XWSSecurityException {
       
        SecurityHeader header = fpContext.getSecurableSoapMessage().findSecurityHeader();
        MessagePolicy policy = (MessagePolicy)fpContext.getSecurityPolicy();
       
        if (header == null) {
            if (policy != null) {
                if (PolicyTypeUtil.messagePolicy(policy)) {
                    if (!((MessagePolicy)policy).isEmpty()) {
                        log.log(Level.SEVERE, LogStringsMessages.WSS_0253_INVALID_MESSAGE());
                        throw new XWSSecurityException(
                                "Message does not conform to configured policy: " +
                                "No Security Header found in incoming message");
                       
                    }
                } else {
                    log.log(Level.SEVERE, LogStringsMessages.WSS_0253_INVALID_MESSAGE());
                    throw new XWSSecurityException(
                            "Message does not conform to configured policy: " +
                            "No Security Header found in incoming message");
                }
            }
           
            return;
        }
       
        if ((policy != null) && policy.dumpMessages()) {
            DumpFilter.process(fpContext);
        }
        SOAPElement current = header.getCurrentHeaderBlockElement();
        SOAPElement first = current;
       
View Full Code Here

       * @throws RuntimeException
       */
       @SuppressWarnings("unchecked")
       private void augmentConfiguration(int requiredState, boolean modifyReceiverSettings, CallbackHandler handler, boolean debugON,
           String signAlias, String encryptAlias) throws PolicyGenerationException {
              MessagePolicy mPolicy = null;
              DeclarativeSecurityConfiguration dConfiguration = (DeclarativeSecurityConfiguration) _policy;
              boolean senderConfiguration = false;
              if (requiredState == EMPTY_POLICY_STATE)  {
                  if (modifyReceiverSettings) {
                      mPolicy = dConfiguration.receiverSettings();
                      mPolicy.removeAll();
                  } else {
                     mPolicy = dConfiguration.senderSettings();
                     mPolicy.removeAll();
                  }
                  if (debugON) {
                      mPolicy.dumpMessages(true);
                  }
                  return;
              }
              if (modifyReceiverSettings) {
                 mPolicy = dConfiguration.receiverSettings();
              } else {
                 mPolicy = dConfiguration.senderSettings();
                 senderConfiguration = !senderConfiguration;
              }
              Collection newMPolicy = null;
              WSSPolicy ts = getTimestampPolicy(mPolicy, handler, senderConfiguration);
              boolean requireTimestampPolicy = false;
              switch (requiredState) {
                 case AUTHENTICATE_RECIPIENT_ONLY:
                                  // Resultant List:  (encrypt+)
                                  newMPolicy = getEncryptPolicies(mPolicy, handler, senderConfiguration);
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  break;
                 case AUTHENTICATE_SENDER_TOKEN_ONLY:
                                  // Resultant List:  (authenticate, encrypt?)
                                  newMPolicy = getUsernamePolicies(mPolicy, handler, senderConfiguration);
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  if (!modifyReceiverSettings && configOptimizeAttribute) {
                                      optimize=MessageConstants.SECURITY_HEADERS;
                                  }
                                  break;
                 case AUTHENTICATE_SENDER_SIGNATURE_ONLY:
                                  // Resultant List: (sign+)
                                  newMPolicy = getSignPolicies(mPolicy, handler, senderConfiguration);
                                  requireTimestampPolicy = !(newMPolicy.isEmpty());
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  if (!modifyReceiverSettings && configOptimizeAttribute) {
                                      optimize=MessageConstants.SIGN_BODY;
                                  }
                                  break
                 case AUTHENTICATE_RECIPIENT_AUTHENTICATE_SENDER_TOKEN:
                                  /* Resultant List: (encrypt+, authenticate, encrypt?) */
                                  newMPolicy = getEncryptUsernamePolicies(mPolicy, handler, senderConfiguration);
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  break
                 case AUTHENTICATE_SENDER_TOKEN_AUTHENTICATE_RECIPIENT:
                                  /* Resultant List: (authenticate, encrypt+) */
                                  newMPolicy =  getUsernameEncryptPolicies(mPolicy, handler, senderConfiguration);
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  break
                 case AUTHENTICATE_RECIPIENT_AUTHENTICATE_SENDER_SIGNATURE:
                                  /* Resultant List: (encrypt+, sign+) */
                                  newMPolicy =  getEncryptPolicies(mPolicy, handler, senderConfiguration);
                                  Collection signPolicies = getSignPolicies(mPolicy, handler, senderConfiguration);
                                  requireTimestampPolicy = !(signPolicies.isEmpty());
                                  newMPolicy.addAll(signPolicies);
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  break
                 case AUTHENTICATE_SENDER_SIGNATURE_AUTHENTICATE_RECIPIENT:
                                  /* Resultant List: (sign+, encrypt+) */
          newMPolicy = getSignPolicies(mPolicy, handler, senderConfiguration);
                                  requireTimestampPolicy = !(newMPolicy.isEmpty());
                                  newMPolicy.addAll(getEncryptPolicies(mPolicy, handler, senderConfiguration));
                                  mPolicy.removeAll();
                                  mPolicy.appendAll(newMPolicy);
                                  if (!modifyReceiverSettings && configOptimizeAttribute) {
                                      optimize=MessageConstants.SIGN_ENCRYPT_BODY;
                                  }
                                  break
                 default:
                                  break;
              }
              if ((ts != null) && requireTimestampPolicy) {
                  mPolicy.prepend(ts);
              }
              if (debugON) {
                  mPolicy.dumpMessages(true);
              }
              augmentSignAlias(mPolicy, signAlias);
              augmentEncryptAlias(mPolicy, encryptAlias);
       }
View Full Code Here

        Message message = packet.getMessage();
        for (PolicyAlternativeHolder p : this.policyAlternatives) {
            WSDLBoundOperation operation = message.getOperation(pipeConfig.getWSDLPort());
            SecurityPolicyHolder sph = (SecurityPolicyHolder) p.getOutMessagePolicyMap().get(operation);
            if (sph != null && sph.isIssuedTokenAsEncryptedSupportingToken()) {
                MessagePolicy policy = sph.getMessagePolicy();
                ArrayList list = policy.getPrimaryPolicies();
                Iterator i = list.iterator();
                boolean breakOuterLoop = false;
                while (i.hasNext()) {
                    SecurityPolicy primaryPolicy = (SecurityPolicy) i.next();
                    if (PolicyTypeUtil.encryptionPolicy(primaryPolicy)) {
View Full Code Here

       
        ApplicationSecurityConfiguration configuration = (ApplicationSecurityConfiguration) fpContext.getSecurityPolicy();
       
        Collection mConfiguration = configuration.getAllReceiverPolicies();
       
        fpContext.setSecurityPolicy(new MessagePolicy());
       
        SOAPElement current = fpContext.getSecurableSoapMessage().findSecurityHeader().getFirstChildElement();
        MessagePolicy policy = null;
        while (current != null) {
            fpContext.getSecurableSoapMessage().findSecurityHeader().setCurrentHeaderElement(current);
            pProcessOnce(fpContext,current, false);
            if (!mConfiguration.isEmpty())
                try {
                    MessagePolicy mp =  (MessagePolicy) fpContext.getSecurityPolicy();
                    if(!mp.isEmpty()){
                        redux(mp,mConfiguration,fpContext.getSecurableSoapMessage(),
                                false);
                    }
                } catch (Exception e) {
                    log.log(Level.SEVERE, LogStringsMessages.WSS_0256_FAILED_CONFIGURE_ASC(), e);
                    throw new XWSSecurityException(e);
                }
            policy = resolveMP(fpContext,configuration);
            if (policy != null) {
                if (!mConfiguration.contains(policy)) {
                    // log
                    StringBuffer buf = null;
                    if ( PolicyTypeUtil.messagePolicy(policy)) {
                        for ( int it=0; it<policy.size(); it++) {
                            if ( buf == null)
                                buf = new StringBuffer();
                            try {
                                buf.append(policy.get(it).getType() + " ");
                            } catch (Exception e) {
                                //ignore
                            }
                        }
                        log.log(Level.SEVERE, LogStringsMessages.WSS_0261_INVALID_MESSAGE_POLICYSET());
                        throw new XWSSecurityException("Message does not conform to configured policy : [ " +
                                buf.toString() + "] policy set is not present in Receiver requirements.");
                    } else {
                        log.log(Level.SEVERE,LogStringsMessages.WSS_0262_INVALID_MESSAGE_POLICYTYPE());
                        throw new XWSSecurityException("Message does not conform to configured policy : " +
                                policy.getType() + " is not present in Receiver requirements.");
                    }
                } else {
                    MessagePolicy policyCopy = new MessagePolicy();
                    int size = ((MessagePolicy) fpContext.getSecurityPolicy()).size();
                    int ppCount = 0;
                    for(int i=0;i<policy.size();i++){
                        try {
                            WSSPolicy wp =(WSSPolicy) policy.get(i);
                            if(PolicyTypeUtil.isSecondaryPolicy(wp)){
                                if(log.isLoggable(Level.FINEST)){
                                    log.log(Level.FINEST, wp.getType());
                                }
                                policyCopy.append(wp);
                            }else{
                                if(ppCount >= size){
                                    if(log.isLoggable(Level.FINEST)){
                                        log.log(Level.FINEST, wp.getType());
                                    }
                                    policyCopy.append(wp);
                                }else{
                                    if(log.isLoggable(Level.FINEST)){
                                        log.log(Level.FINEST, "skipped"+wp.getType());
                                    }
                                }
View Full Code Here

        ((StaticApplicationContext) context).setOperationIdentifier(identifier);
        //} else {}
       
        SecurityPolicy policy = configuration.getSecurityConfiguration((StaticApplicationContext)context);
       
        MessagePolicy mPolicy = null;
       
        if (PolicyTypeUtil.dynamicSecurityPolicy(policy)) {
           
            // create dynamic callback context
            DynamicApplicationContext dynamicContext = new DynamicApplicationContext(context);
View Full Code Here

        ArrayList reduxx = new ArrayList();
       
        Iterator i = configuration.iterator();
        while (i.hasNext()) {
            try {
                MessagePolicy policyx = (MessagePolicy) i.next();
                int spSize = mPolicy.getSecondaryPolicies().size()-1;
                ArrayList policyxList = policyx.getPrimaryPolicies();
               
                WSSPolicy wssPolicyx  = null;
                if(isSecondary && spSize >= 0){
                    wssPolicyx = (WSSPolicy) policyx.get(spSize);
                }else {
                    int pSize = mPolicy.getPrimaryPolicies().size()-1;
                    if(pSize >=0 && pSize < policyxList.size()){
                        wssPolicyx =(WSSPolicy) policyxList.get(pSize);
                    }else{
                        continue;
                    }
                }
                if (wssPolicyx != null){
                   
                    if(!policy.equalsIgnoreTargets(wssPolicyx)){
                        reduxx.add(policyx);
                    }
                }
               
            } catch (ClassCastException cce) {
                // ignore DynamicSecurityPolicies
                cce.printStackTrace();
                //log
                //throw new RuntimeException(cce);
            }
        }
       
        Iterator j = configuration.iterator();
        while (j.hasNext()) {
            try {
               
                int spSize = mPolicy.getSecondaryPolicies().size()-1;
                MessagePolicy policyy = ((MessagePolicy) j.next());
                ArrayList policyyList = policyy.getPrimaryPolicies();
               
                WSSPolicy wssPolicyy  = null;
                if(isSecondary && spSize >= 0){
                    wssPolicyy = (WSSPolicy) policyy.get(spSize);
                }else {
                    int pSize = mPolicy.getPrimaryPolicies().size()-1;
                    if(pSize >=0 && pSize < policyyList.size()){
                        wssPolicyy =(WSSPolicy) policyyList.get(pSize);
                    }else{
View Full Code Here

       
        if (policy != null) {
            Iterator i = configuration.iterator();
           
            while (i.hasNext()) {
                MessagePolicy mPolicy = (MessagePolicy) i.next();
               
                if (policy == mPolicy){
                    return;
                }
            }
View Full Code Here

     * @throws com.sun.xml.wss.XWSSecurityException
     */
    private static void processMessagePolicy(FilterProcessingContext fpContext)
    throws XWSSecurityException {
       
        MessagePolicy policy = (MessagePolicy) fpContext.getSecurityPolicy();
       
        if (policy.dumpMessages()) {
            DumpFilter.process(fpContext);
        }
       
        if (policy.size() == 0) {
            fpContext.setMode(FilterProcessingContext.DEFAULT);
            pProcess(fpContext);
            return;
        }

        //TODO: hack till we fix this in PolicyTranslator
        //TO be removed before Plugfest
        try {
            if ((policy.size() == 1&&
                (PolicyTypeUtil.signatureConfirmationPolicy(policy.get(0)))) {
                fpContext.setMode(FilterProcessingContext.DEFAULT);
                pProcess(fpContext);
                return;
            }
        }catch (Exception e) {
            log.log(Level.SEVERE,LogStringsMessages.WSS_0273_FAILEDTO_PROCESS_POLICY(), e);
            throw new RuntimeException(e);
        }

       
       
        SecurityHeader header = fpContext.getSecurableSoapMessage().findSecurityHeader();
        if (header == null) {
            StringBuffer buf = new StringBuffer();
            for(int it=0; it<policy.size(); it++) {
                try {
                    buf.append(policy.get(it).getType() );
                    if ( PolicyTypeUtil.isPrimaryPolicy((WSSPolicy)policy.get(it))) {
                        buf.append("(P) ");
                    } else {
                        buf.append("(S) ");
                    }
                } catch (Exception ex) {
View Full Code Here

TOP

Related Classes of com.sun.xml.wss.impl.policy.mls.MessagePolicy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.