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

Examples of com.sun.xml.wss.impl.policy.SecurityPolicy


    public static void secureMessage(ProcessingContext context)
    throws XWSSecurityException {

        HarnessUtil.validateContext (context);

        SecurityPolicy policy = context.getSecurityPolicy ();
        SecurityEnvironment handler = context.getSecurityEnvironment ();
        StaticPolicyContext staticContext = context.getPolicyContext ();

        FilterProcessingContext fpContext = setFilterProcessingContext(context);
       
        fpContext.isInboundMessage (false);
         if (fpContext.resetMustUnderstand()) {
            fpContext.getSecurableSoapMessage().setDoNotSetMU(true);
        }
  
        if (PolicyTypeUtil.messagePolicy(policy) &&
                (((MessagePolicy)policy).enableDynamicPolicy() &&
                ((MessagePolicy)policy).size() == 0)) {
            policy = new com.sun.xml.wss.impl.policy.mls.DynamicSecurityPolicy();
        }
       
        if (PolicyTypeUtil.dynamicSecurityPolicy(policy)) {

            // create dynamic callback context
            DynamicApplicationContext dynamicContext = new DynamicApplicationContext (staticContext);
            dynamicContext.setMessageIdentifier (context.getMessageIdentifier ());
            dynamicContext.inBoundMessage (false);
            ProcessingContext.copy (dynamicContext.getRuntimeProperties(), context.getExtraneousProperties());

            // make dynamic policy callback
            DynamicPolicyCallback dpCallback = new DynamicPolicyCallback (policy, dynamicContext);
            try {
               HarnessUtil.makeDynamicPolicyCallback(dpCallback,
                          handler.getCallbackHandler());

            } catch (Exception e) {
               log.log(Level.SEVERE, LogStringsMessages.WSS_0237_FAILED_DYNAMIC_POLICY_CALLBACK(), e);
               throw new XWSSecurityException (e);
            }

            SecurityPolicy result = dpCallback.getSecurityPolicy ();
            fpContext.setSecurityPolicy (result);

            if (PolicyTypeUtil.messagePolicy(result)) {
                processMessagePolicy (fpContext);
            } else
View Full Code Here


        //}
       
        Iterator i = policy.iterator ();

        while (i.hasNext ()) {
            SecurityPolicy sPolicy = (SecurityPolicy) i.next();
            fpContext.setSecurityPolicy (sPolicy);
            HarnessUtil.processDeep (fpContext);
        }

        if(!(fpContext instanceof JAXBFilterProcessingContext)){
View Full Code Here

    public void prepend(SecurityPolicy item)
    throws PolicyGenerationException {
        //BooleanComposer.checkType(item);
        int i = 0;
        for(i = 0; i < info.size(); i++ ){
            SecurityPolicy sp = (SecurityPolicy)info.get(i);
            if(!sp.getType().equals(PolicyTypeUtil.SIGNATURE_CONFIRMATION_POLICY_TYPE)){
                break;
            }
        }
        info.add(i, item);
    }
View Full Code Here

    @SuppressWarnings("unchecked")
    public void appendAll(Collection items)
    throws PolicyGenerationException {
        Iterator i = items.iterator();
        while (i.hasNext()) {
            SecurityPolicy item = (SecurityPolicy) i.next();
            //BooleanComposer.checkType(item);
        }
        info.addAll(items);
    }
View Full Code Here

    public ArrayList getPrimaryPolicies() {
        ArrayList list = new ArrayList();
       
        Iterator i = iterator();
        while (i.hasNext()) {
            SecurityPolicy policy = (SecurityPolicy) i.next();
            if(PolicyTypeUtil.encryptionPolicy(policy) || PolicyTypeUtil.signaturePolicy(policy)){
                list.add(policy);
            }
        }
       
View Full Code Here

    public ArrayList getSecondaryPolicies() {
        ArrayList list = new ArrayList();
       
        Iterator i = iterator();
        while (i.hasNext()) {
            SecurityPolicy policy = (SecurityPolicy) i.next();
           
            if(PolicyTypeUtil.authenticationTokenPolicy(policy) || PolicyTypeUtil.timestampPolicy(policy)){
                list.add(policy);
            }
        }
View Full Code Here

       
        Iterator j = info.iterator();
       
        while (j.hasNext()) {
           
            SecurityPolicy policy = (SecurityPolicy) j.next();
           
            if (policy instanceof WSSPolicy) {
                processWSSPolicy((WSSPolicy) policy);
            } /*else
                if (PolicyTypeUtil.booleanComposerPolicy(policy)) {
View Full Code Here

        List<SecurityPolicy> encPolicies = new ArrayList<SecurityPolicy>();

        for (Object policy : msgPolicy.getPrimaryPolicies()) {

            if (policy instanceof SecurityPolicy) {
                SecurityPolicy secPolicy = (SecurityPolicy) policy;
                if (PolicyTypeUtil.signaturePolicy(secPolicy)) {
                    seenSignPolicy = true;
                    if (!seenEncryptPolicy && isIncoming) {
                        encryptBeforeSign = true;
                    }
                } else if (PolicyTypeUtil.encryptionPolicy(secPolicy)) {
                    seenEncryptPolicy  = true;
                    if (!seenSignPolicy && !isIncoming) {
                        encryptBeforeSign = true;
                    }
                    encPolicies.add(secPolicy);
                }
            }
        }
        if (encryptBeforeSign) {
            for (Object policy : msgPolicy.getPrimaryPolicies()) {
                boolean containsEncryptedHeader  =false;
                if (policy instanceof SecurityPolicy) {
                    SecurityPolicy secPolicy = (SecurityPolicy) policy;
                    if (PolicyTypeUtil.signaturePolicy(secPolicy)) {
                        SignaturePolicy.FeatureBinding sfb = (SignaturePolicy.FeatureBinding) ((SignaturePolicy) secPolicy).getFeatureBinding();
                        ArrayList targets = sfb.getTargetBindings();
                        for (int i = 0; i < targets.size(); i++) {
                            Target t = (Target) targets.get(i);
View Full Code Here

       
    }
    private void removeEmptyPrimaryPolicies(MessagePolicy msgPolicy) {
        for ( Object policy : msgPolicy.getPrimaryPolicies() ) {
            if ( policy instanceof SecurityPolicy) {
                SecurityPolicy secPolicy = (SecurityPolicy)policy;
                if ( PolicyTypeUtil.signaturePolicy(secPolicy)) {
                    if (((SignaturePolicy.FeatureBinding)((SignaturePolicy)secPolicy).getFeatureBinding()).getTargetBindings().size() == 0 ) {
                        msgPolicy.remove(secPolicy);
                    }
                } else if ( PolicyTypeUtil.encryptionPolicy(secPolicy)) {
View Full Code Here

     * @return SecurityTokenReference
     */
    @SuppressWarnings("unchecked")
    protected SecurityTokenReference buildSTR(String strId, Reference ref) {
        SecurityTokenReference str = elementFactory.createSecurityTokenReference(ref);
        SecurityPolicy sp = context.getSecurityPolicy();
        if (sp instanceof SignaturePolicy || sp instanceof AuthenticationTokenPolicy ) {
            ((SecurityElement) str).setId(strId);
        }
        if (context.getWSSAssertion() != null) {
            if ((ref instanceof DirectReference) && context.getWSSAssertion().getType().equals("1.1")) {
View Full Code Here

TOP

Related Classes of com.sun.xml.wss.impl.policy.SecurityPolicy

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.