Package org.apache.ws.secpolicy.model

Examples of org.apache.ws.secpolicy.model.X509Token


            }
        }
    }
    private void checkForX509PkiPath(WSSecSignature sig, Token token){
        if (token instanceof X509Token) {
            X509Token x509Token = (X509Token) token;
            if (x509Token.getTokenVersionAndType().equals(Constants.WSS_X509_PKI_PATH_V1_TOKEN10)
                    || x509Token.getTokenVersionAndType().equals(Constants.WSS_X509_PKI_PATH_V1_TOKEN11)) {
                sig.setUseSingleCertificate(false);
            }
        }
    }
View Full Code Here


      if (token.getInclusion() == SPConstants.INCLUDE_TOKEN_NEVER) {
     
        boolean tokenTypeSet = false;
       
        if(token instanceof X509Token) {
          X509Token x509Token = (X509Token)token;
         
          if(x509Token.isRequireIssuerSerialReference()) {
            secBase.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
            tokenTypeSet = true;
          } else if (x509Token.isRequireKeyIdentifierReference()) {
            secBase.setKeyIdentifierType(WSConstants.SKI_KEY_IDENTIFIER);
            tokenTypeSet = true;
          } else if (x509Token.isRequireThumbprintReference()) {
            secBase.setKeyIdentifierType(WSConstants.THUMBPRINT_IDENTIFIER);
            tokenTypeSet = true;
          }
        }
       
View Full Code Here

public class X509TokenBuilder implements AssertionBuilder {

    public Assertion build(OMElement element, AssertionBuilderFactory factory)
            throws IllegalArgumentException {
        X509Token x509Token = new X509Token(SPConstants.SP_V12);

        OMElement policyElement = element.getFirstElement();
       
        //Process token inclusion
        OMAttribute  includeAttr = element.getAttribute(SP12Constants.INCLUDE_TOKEN);
        if(includeAttr != null) {
            int inclusion = SP12Constants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
            x509Token.setInclusion(inclusion);
        }

        if (policyElement != null) {
           
            if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_DERIVED_KEYS) != null) {
                x509Token.setDerivedKeys(true);
            } else if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) {
                x509Token.setImpliedDerivedKeys(true);
            } else if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) {
                x509Token.setExplicitDerivedKeys(true);
            }
           
            Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
            policy = (Policy) policy.normalize(false);
View Full Code Here

public class X509TokenBuilder implements AssertionBuilder {

    public Assertion build(OMElement element, AssertionBuilderFactory factory)
            throws IllegalArgumentException {
        X509Token x509Token = new X509Token(SPConstants.SP_V11);

        OMElement policyElement = element.getFirstElement();
       
        //Process token inclusion
        OMAttribute  includeAttr = element.getAttribute(SP11Constants.INCLUDE_TOKEN)
       
        if(includeAttr != null) {
            int inclusion = SP11Constants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
            x509Token.setInclusion(inclusion);
        }

        if (policyElement != null) {
           
            if (policyElement.getFirstChildWithName(SP11Constants.REQUIRE_DERIVED_KEYS) != null) {
                x509Token.setDerivedKeys(true);
            }
           
            Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
            policy = (Policy) policy.normalize(false);
View Full Code Here

            }
        }
    }
    private void checkForX509PkiPath(WSSecSignature sig, Token token){
        if (token instanceof X509Token) {
            X509Token x509Token = (X509Token) token;
            if (x509Token.getTokenVersionAndType().equals(Constants.WSS_X509_PKI_PATH_V1_TOKEN10)
                    || x509Token.getTokenVersionAndType().equals(Constants.WSS_X509_PKI_PATH_V1_TOKEN11)) {
                sig.setUseSingleCertificate(false);
            }
        }
    }
View Full Code Here

            }
        }
    }
    private void checkForX509PkiPath(WSSecSignature sig, Token token){
        if (token instanceof X509Token) {
            X509Token x509Token = (X509Token) token;
            if (x509Token.getTokenVersionAndType().equals(Constants.WSS_X509_PKI_PATH_V1_TOKEN10)
                    || x509Token.getTokenVersionAndType().equals(Constants.WSS_X509_PKI_PATH_V1_TOKEN11)) {
                sig.setUseSingleCertificate(false);
            }
        }
    }
View Full Code Here

    public static final QName ENCRYPTION_USER = new QName("http://ws.apache.org/rampart/policy",
            ENCRYPTION_USER_LN);

    public Assertion build(OMElement element, AssertionBuilderFactory factory)
            throws IllegalArgumentException {
        X509Token x509Token = new X509Token(SPConstants.SP_V11);

        OMElement policyElement = element.getFirstElement();
       
        //Process token inclusion
        OMAttribute  includeAttr = element.getAttribute(SP11Constants.INCLUDE_TOKEN)
       
        if(includeAttr != null) {
            int inclusion = SP11Constants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
            x509Token.setInclusion(inclusion);
        }

        if (policyElement != null) {
           
            if (policyElement.getFirstChildWithName(SP11Constants.REQUIRE_DERIVED_KEYS) != null) {
                x509Token.setDerivedKeys(true);
            }
           
            Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
            policy = (Policy) policy.normalize(false);

            for (Iterator iterator = policy.getAlternatives(); iterator
                    .hasNext();) {
                processAlternative((List) iterator.next(), x509Token);
               
                /*
                 * since there should be only one alternative
                 */
                break;
            }
        }
       
        if (x509Token != null && policyElement != null) {
            OMElement ramp = null;
            ramp = policyElement.getFirstChildWithName(RAMPART_CONFIG);
            if (ramp != null) {
                OMElement child = null;
                if ((child = ramp.getFirstChildWithName(USER_CERT_ALIAS)) != null) {
                    x509Token.setUserCertAlias(child.getText());
                }
                if ((child = ramp.getFirstChildWithName(ENCRYPTION_USER)) != null) {
                    x509Token.setEncryptionUser(child.getText());
                }
            }
        }
       
        return x509Token;
View Full Code Here

    public static final QName ENCRYPTION_USER = new QName("http://ws.apache.org/rampart/policy",
            ENCRYPTION_USER_LN);

    public Assertion build(OMElement element, AssertionBuilderFactory factory)
            throws IllegalArgumentException {
        X509Token x509Token = new X509Token(SPConstants.SP_V12);

        OMElement policyElement = element.getFirstElement();
       
        //Process token inclusion
        OMAttribute  includeAttr = element.getAttribute(SP12Constants.INCLUDE_TOKEN);
        if(includeAttr != null) {
            int inclusion = SP12Constants.getInclusionFromAttributeValue(includeAttr.getAttributeValue());
            x509Token.setInclusion(inclusion);
        }

        if (policyElement != null) {
           
            if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_DERIVED_KEYS) != null) {
                x509Token.setDerivedKeys(true);
            } else if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_IMPLIED_DERIVED_KEYS) != null) {
                x509Token.setImpliedDerivedKeys(true);
            } else if (policyElement.getFirstChildWithName(SP12Constants.REQUIRE_EXPLICIT_DERIVED_KEYS) != null) {
                x509Token.setExplicitDerivedKeys(true);
            }
           
            Policy policy = PolicyEngine.getPolicy(element.getFirstElement());
            policy = (Policy) policy.normalize(false);

            for (Iterator iterator = policy.getAlternatives(); iterator
                    .hasNext();) {
                processAlternative((List) iterator.next(), x509Token);
               
                /*
                 * since there should be only one alternative
                 */
                break;
            }
        }
       
        if (x509Token != null && policyElement != null) {
            OMElement ramp = null;
            ramp = policyElement.getFirstChildWithName(RAMPART_CONFIG);
            if (ramp != null) {
                OMElement child = null;
                if ((child = ramp.getFirstChildWithName(USER_CERT_ALIAS)) != null) {
                    x509Token.setUserCertAlias(child.getText());
                }
                if ((child = ramp.getFirstChildWithName(ENCRYPTION_USER)) != null) {
                    x509Token.setEncryptionUser(child.getText());
                }
            }
        }
       
        return x509Token;
View Full Code Here

      // if(((ProtectionToken)this.assertion ).getClass()==ProtectionToken.class){
      if (this.assertion instanceof ProtectionToken) {
        ProtectionToken tempPToken = (ProtectionToken) this.assertion;
        if (isX509TokenType) {
          X509Token x509Tkn = new X509Token(11);
          tempPToken.setToken(x509Tkn);
          if (log.isDebugEnabled()) {
            log.debug("X509 Token found...");
          }
          //System.out.println("X509 Token found...");
          if (isX509Included) {
            if (log.isDebugEnabled()) {
              log.debug("X509 Token inluded..");
            }
            // System.out.println("X509 Token inluded..");
            x509Tkn.setInclusion(3);
          } else {
            if (log.isDebugEnabled()) {
              log.debug("X509 No Token inluded Never..");
            }
            //System.out.println("X509 No Token inluded Never..");
            x509Tkn.setInclusion(1);
          }
          x509Tkn.setRequireThumbprintReference(hasThumprintReference);
          if (hasThumprintReference) {
            if (log.isDebugEnabled()) {
              log.debug("X509 Thumbprint");
            }
            // System.out.println("X509 Thumbprint");
          }
          x509Tkn.setRequireIssuerSerialReference(hasIssuerSerial);
          if (hasIssuerSerial) {
            if (log.isDebugEnabled()) {
              log.debug("X509 Issuer serial");
            }
            //System.out.println("X509 Issuer serial");
          }
          x509Tkn.setRequireKeyIdentifierReference(hasKeyIdentifierRef);
          if (hasKeyIdentifierRef) {
            if (log.isDebugEnabled()) {
              log.debug("X509 key identifier");
            }
            // System.out.println("X509 key identifier");
View Full Code Here

    this.msgProp = new MessageProperty(new TokenPropertyFactory());
  }

  //for Testing Purposes
  public static void main(String[] args) {
    X509Token xp = new X509Token(11);
    XMLStreamWriter writer;
    try {
      writer = XMLOutputFactory.newInstance().createXMLStreamWriter(System.out);
      xp.setInclusion(3);
      xp.setDerivedKeys(true);
      xp.serialize(writer);
      writer.flush();
    } catch (XMLStreamException e) {
      e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
    }
  }
View Full Code Here

TOP

Related Classes of org.apache.ws.secpolicy.model.X509Token

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.