Examples of KeyIdentifierType


Examples of org.apache.cxf.ws.security.sts.provider.model.secext.KeyIdentifierType

            String identifier = tokenReference.getIdentifier();
            if (identifier.charAt(0) == '#') {
                identifier = identifier.substring(1);
            }
           
            KeyIdentifierType keyIdentifierType =
                QNameConstants.WSSE_FACTORY.createKeyIdentifierType();
            keyIdentifierType.setValue(identifier);
            String valueType = tokenReference.getWsseValueType();
            if (valueType != null) {
                keyIdentifierType.setValueType(valueType);
            }
            JAXBElement<KeyIdentifierType> keyIdentifier =
                QNameConstants.WSSE_FACTORY.createKeyIdentifier(keyIdentifierType);
            securityTokenReferenceType.getAny().add(keyIdentifier);
        } else if (tokenReference.isUseDirectReference()) {
View Full Code Here

Examples of org.apache.cxf.ws.security.sts.provider.model.secext.KeyIdentifierType

        if (tokenType != null) {
            securityTokenReferenceType.getOtherAttributes().put(TOKEN_TYPE, tokenType);
        }
       
        if (tokenReference.isUseKeyIdentifier()) {
            KeyIdentifierType keyIdentifierType =
                QNameConstants.WSSE_FACTORY.createKeyIdentifierType();
            keyIdentifierType.setValue(identifier);
            String valueType = tokenReference.getWsseValueType();
            if (valueType != null) {
                keyIdentifierType.setValueType(valueType);
            }
            JAXBElement<KeyIdentifierType> keyIdentifier =
                QNameConstants.WSSE_FACTORY.createKeyIdentifier(keyIdentifierType);
            securityTokenReferenceType.getAny().add(keyIdentifier);
        } else if (tokenReference.isUseDirectReference()) {
View Full Code Here

Examples of org.apache.wss4j.binding.wss10.KeyIdentifierType

            String tokenType =
                    XMLSecurityUtils.getQNameAttribute(
                        securityTokenReferenceType.getOtherAttributes(),
                        WSSConstants.ATT_wsse11_TokenType);

            final KeyIdentifierType keyIdentifierType
                    = XMLSecurityUtils.getQNameType(securityTokenReferenceType.getAny(), WSSConstants.TAG_wsse_KeyIdentifier);
            if (keyIdentifierType != null) {
                String valueType = keyIdentifierType.getValueType();
                if (valueType == null) {
                    ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R3054);
                }
                String encodingType = keyIdentifierType.getEncodingType();

                byte[] binaryContent = null;
                if (WSSConstants.SOAPMESSAGE_NS10_BASE64_ENCODING.equals(encodingType)) {
                    binaryContent = Base64.decodeBase64(keyIdentifierType.getValue());
                } else if (!WSSConstants.NS_SAML10_TYPE.equals(valueType) && !WSSConstants.NS_SAML20_TYPE.equals(valueType)) {
                    if (encodingType == null) {
                        ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R3070);
                    } else {
                        ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R3071);
                    }
                } else if (encodingType != null
                        && (WSSConstants.NS_SAML10_TYPE.equals(valueType) || WSSConstants.NS_SAML20_TYPE.equals(valueType))) {
                    ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R6604);
                }

                if (WSSConstants.NS_X509_V3_TYPE.equals(valueType)) {
                    return new X509V3SecurityTokenImpl(
                            (WSInboundSecurityContext) inboundSecurityContext, crypto, callbackHandler,
                            binaryContent, securityTokenReferenceType.getId(), securityProperties);
                } else if (WSSConstants.NS_X509SubjectKeyIdentifier.equals(valueType)) {
                    return new X509SKISecurityTokenImpl(
                            (WSInboundSecurityContext) inboundSecurityContext, crypto, callbackHandler, binaryContent,
                            securityTokenReferenceType.getId(), securityProperties);
                } else if (WSSConstants.NS_THUMBPRINT.equals(valueType)) {
                    try {
                        MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
                        //first look if the token is included in the message (necessary for TokenInclusion policy)...
                        List<SecurityTokenProvider<? extends InboundSecurityToken>> securityTokenProviders =
                                inboundSecurityContext.getRegisteredSecurityTokenProviders();
                        for (int i = 0; i < securityTokenProviders.size(); i++) {
                            SecurityTokenProvider<? extends InboundSecurityToken> tokenProvider = securityTokenProviders.get(i);
                            InboundSecurityToken inboundSecurityToken = tokenProvider.getSecurityToken();
                            if (inboundSecurityToken instanceof X509SecurityToken) {
                                X509SecurityToken x509SecurityToken = (X509SecurityToken)inboundSecurityToken;
                                byte[] tokenDigest = messageDigest.digest(x509SecurityToken.getX509Certificates()[0].getEncoded());

                                if (Arrays.equals(tokenDigest, binaryContent)) {
                                    return createSecurityTokenProxy(inboundSecurityToken,
                                            WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier);
                                }
                            }
                        }
                    } catch (NoSuchAlgorithmException e) {
                        throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
                    } catch (CertificateEncodingException e) {
                        throw new WSSecurityException(WSSecurityException.ErrorCode.INVALID_SECURITY_TOKEN);
                    }

                    //...then if none is found create a new SecurityToken instance
                    return new X509ThumbprintSHA1SecurityTokenImpl(
                            (WSInboundSecurityContext) inboundSecurityContext, crypto, callbackHandler, binaryContent,
                            securityTokenReferenceType.getId(), securityProperties);
                } else if (WSSConstants.NS_ENCRYPTED_KEY_SHA1.equals(valueType)) {
                    return new EncryptedKeySha1SecurityTokenImpl(
                            (WSInboundSecurityContext) inboundSecurityContext, callbackHandler, keyIdentifierType.getValue(),
                            securityTokenReferenceType.getId());
                } else if (WSSConstants.NS_SAML10_TYPE.equals(valueType) || WSSConstants.NS_SAML20_TYPE.equals(valueType)) {
                    if (WSSConstants.NS_SAML20_TYPE.equals(valueType) && !WSSConstants.NS_SAML20_TOKEN_PROFILE_TYPE.equals(tokenType)) {
                        ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R6617);
                    } else if (WSSConstants.NS_SAML10_TYPE.equals(valueType) && !WSSConstants.NS_SAML11_TOKEN_PROFILE_TYPE.equals(tokenType)) {
                        ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R6611);
                    }
                    SecurityTokenProvider<? extends InboundSecurityToken> securityTokenProvider =
                            inboundSecurityContext.getSecurityTokenProvider(keyIdentifierType.getValue());
                    if (securityTokenProvider != null) {
                        return createSecurityTokenProxy(securityTokenProvider.getSecurityToken(),
                            WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
                    }
                   
                    // Delegate to a CallbackHandler, in case the token is not in the request
                    return new SamlSecurityTokenImpl((WSInboundSecurityContext) inboundSecurityContext,
                                                     keyIdentifierType.getValue(),
                                                     WSSecurityTokenConstants.KeyIdentifier_ExternalReference,
                                                     securityProperties);
                } else if (WSSConstants.NS_Kerberos5_AP_REQ_SHA1.equals(valueType)) {
                    SecurityTokenProvider<? extends InboundSecurityToken> securityTokenProvider =
                            inboundSecurityContext.getSecurityTokenProvider(keyIdentifierType.getValue());
                    if (securityTokenProvider != null) {
                        return createSecurityTokenProxy(securityTokenProvider.getSecurityToken(),
                                WSSecurityTokenConstants.KeyIdentifier_SecurityTokenDirectReference);
                    }
                   
                    try {
                        //ok we have to find the token via digesting...
                        MessageDigest messageDigest = MessageDigest.getInstance("SHA-1");
                        List<SecurityTokenProvider<? extends InboundSecurityToken>> securityTokenProviders =
                                inboundSecurityContext.getRegisteredSecurityTokenProviders();
                        for (int i = 0; i < securityTokenProviders.size(); i++) {
                            SecurityTokenProvider<? extends InboundSecurityToken> tokenProvider = securityTokenProviders.get(i);
                            InboundSecurityToken inboundSecurityToken = tokenProvider.getSecurityToken();
                            if (inboundSecurityToken instanceof KerberosServiceSecurityToken) {
                                KerberosServiceSecurityToken kerberosSecurityToken = (KerberosServiceSecurityToken)inboundSecurityToken;
                                byte[] tokenDigest = messageDigest.digest(kerberosSecurityToken.getBinaryContent());
                                if (Arrays.equals(tokenDigest, binaryContent)) {
                                    return createSecurityTokenProxy(inboundSecurityToken,
                                            WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier);
                                }
                            }
                        }
                    } catch (NoSuchAlgorithmException e) {
                        throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
                    }

                    // Finally, just delegate to a Callback as per EncryptedKeySHA1
                    return new EncryptedKeySha1SecurityTokenImpl(
                            (WSInboundSecurityContext) inboundSecurityContext, callbackHandler,
                            keyIdentifierType.getValue(), securityTokenReferenceType.getId());
                } else {
                    //we do enforce BSP compliance here but will fail anyway since we cannot identify the referenced token
                    ((WSInboundSecurityContext) inboundSecurityContext).handleBSPRule(BSPRule.R3063);
                }
            }
View Full Code Here

Examples of org.apache.wss4j.binding.wss10.KeyIdentifierType

                ((JAXBElement<SecurityTokenReferenceType>) parseStructure(eventQueue, index, securityProperties)).getValue();

        QName attributeName = null;
        String attributeValue = null;

        final KeyIdentifierType keyIdentifierType = XMLSecurityUtils.getQNameType(
                securityTokenReferenceType.getAny(), WSSConstants.TAG_wsse_KeyIdentifier);
        if (keyIdentifierType != null) {
            attributeValue = keyIdentifierType.getValue().trim();
            if (WSSConstants.NS_SAML10_TYPE.equals(keyIdentifierType.getValueType())) {
                attributeName = WSSConstants.ATT_NULL_AssertionID;
            } else if (WSSConstants.NS_SAML20_TYPE.equals(keyIdentifierType.getValueType())) {
                attributeName = WSSConstants.ATT_NULL_ID;
            }
        }
        final ReferenceType referenceType = XMLSecurityUtils.getQNameType(
                securityTokenReferenceType.getAny(), WSSConstants.TAG_wsse_Reference);
View Full Code Here

Examples of org.jboss.identity.federation.ws.wss.secext.KeyIdentifierType

    * @param value a {@code String} representing the identifier value.
    * @return the constructed {@code KeyIdentifierType} instance.
    */
   public static KeyIdentifierType createKeyIdentifier(String valueType, String value)
   {
      KeyIdentifierType keyIdentifier = new KeyIdentifierType();
      keyIdentifier.setValueType(valueType);
      keyIdentifier.setValue(value);
      return keyIdentifier;
   }
View Full Code Here

Examples of org.jboss.identity.federation.ws.wss.secext.KeyIdentifierType

      SecurityToken token = new StandardSecurityToken(context.getRequestSecurityToken().getTokenType().toString(),
            assertionElement, assertionID);
      context.setSecurityToken(token);

      // set the SAML assertion attached reference.
      KeyIdentifierType keyIdentifier = WSTrustUtil.createKeyIdentifier(SAMLUtil.SAML2_VALUE_TYPE, "#" + assertionID);
      Map<QName, String> attributes = new HashMap<QName, String>();
      attributes.put(new QName(WSTrustConstants.WSSE11_NS, "TokenType"), SAMLUtil.SAML2_TOKEN_TYPE);
      RequestedReferenceType attachedReference = WSTrustUtil.createRequestedReference(keyIdentifier, attributes);
      context.setAttachedReference(attachedReference);
   }
View Full Code Here

Examples of org.jboss.identity.federation.ws.wss.secext.KeyIdentifierType

    * @param value a {@code String} representing the identifier value.
    * @return the constructed {@code KeyIdentifierType} instance.
    */
   public static KeyIdentifierType createKeyIdentifier(String valueType, String value)
   {
      KeyIdentifierType keyIdentifier = new KeyIdentifierType();
      keyIdentifier.setValueType(valueType);
      keyIdentifier.setValue(value);
      return keyIdentifier;
   }
View Full Code Here

Examples of org.jboss.identity.federation.ws.wss.secext.KeyIdentifierType

      SecurityToken token = new StandardSecurityToken(context.getRequestSecurityToken().getTokenType().toString(),
            assertionElement, assertionID);
      context.setSecurityToken(token);

      // set the SAML assertion attached reference.
      KeyIdentifierType keyIdentifier = WSTrustUtil.createKeyIdentifier(SAMLUtil.SAML2_VALUE_TYPE, "#" + assertionID);
      Map<QName, String> attributes = new HashMap<QName, String>();
      attributes.put(new QName(WSTrustConstants.WSSE11_NS, "TokenType"), SAMLUtil.SAML2_TOKEN_TYPE);
      RequestedReferenceType attachedReference = WSTrustUtil.createRequestedReference(keyIdentifier, attributes);
      context.setAttachedReference(attachedReference);
   }
View Full Code Here

Examples of org.jboss.identity.federation.ws.wss.secext.KeyIdentifierType

    * @param value a {@code String} representing the identifier value.
    * @return the constructed {@code KeyIdentifierType} instance.
    */
   public static KeyIdentifierType createKeyIdentifier(String valueType, String value)
   {
      KeyIdentifierType keyIdentifier = new KeyIdentifierType();
      keyIdentifier.setValueType(valueType);
      keyIdentifier.setValue(value);
      return keyIdentifier;
   }
View Full Code Here

Examples of org.jboss.identity.federation.ws.wss.secext.KeyIdentifierType

      SecurityToken token = new StandardSecurityToken(context.getRequestSecurityToken().getTokenType().toString(),
            assertionElement, assertionID);
      context.setSecurityToken(token);

      // set the SAML assertion attached reference.
      KeyIdentifierType keyIdentifier = WSTrustUtil.createKeyIdentifier(SAMLUtil.SAML2_VALUE_TYPE, "#" + assertionID);
      Map<QName, String> attributes = new HashMap<QName, String>();
      attributes.put(new QName(WSTrustConstants.WSSE11_NS, "TokenType"), SAMLUtil.SAML2_TOKEN_TYPE);
      RequestedReferenceType attachedReference = WSTrustUtil.createRequestedReference(keyIdentifier, attributes);
      context.setAttachedReference(attachedReference);
   }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.