/** * Constructor. * * @param elem A SecurityTokenReference element * @param bspCompliant whether the SecurityTokenReference processing complies with the * BSP spec * @throws WSSecurityException */ public SecurityTokenReference(Element elem, boolean bspCompliant) throws WSSecurityException { element = elem; QName el = new QName(element.getNamespaceURI(), element.getLocalName()); if (!STR_QNAME.equals(el)) { throw new WSSecurityException(WSSecurityException.FAILURE, "badElement", new Object[] {STR_QNAME, el}); } if (bspCompliant) { checkBSPCompliance(); } if (containsReference()) { Node node = element.getFirstChild(); while (node != null) { if (Node.ELEMENT_NODE == node.getNodeType() && WSConstants.WSSE_NS.equals(node.getNamespaceURI()) && "Reference".equals(node.getLocalName())) { reference = new Reference((Element)node); break; } node = node.getNextSibling(); } } }
/** * Constructor. * * @param elem A SecurityTokenReference element * @param bspCompliant whether the SecurityTokenReference processing complies with the * BSP spec * @throws WSSecurityException */ public SecurityTokenReference(Element elem, boolean bspCompliant) throws WSSecurityException { element = elem; QName el = new QName(element.getNamespaceURI(), element.getLocalName()); if (!STR_QNAME.equals(el)) { throw new WSSecurityException(WSSecurityException.FAILURE, "badElement", new Object[] {STR_QNAME, el}); } if (bspCompliant) { checkBSPCompliance(); } if (containsReference()) { Node node = element.getFirstChild(); while (node != null) { if (Node.ELEMENT_NODE == node.getNodeType() && WSConstants.WSSE_NS.equals(node.getNamespaceURI()) && "Reference".equals(node.getLocalName())) { reference = new Reference((Element)node); break; } node = node.getNextSibling(); } } }
/** * Check that the Username token referenced by the SecurityTokenReference argument * is BSP compliant. * @param secRef The SecurityTokenReference to the Username token * @throws WSSecurityException */ public static void checkUsernameTokenBSPCompliance( SecurityTokenReference secRef ) throws WSSecurityException { if (!secRef.containsReference()) { // BSP does not permit using a KeyIdentifier to refer to a U/T throw new WSSecurityException( WSSecurityException.FAILED_CHECK, "unsupportedKeyId" ); } String valueType = secRef.getReference().getValueType(); if (!WSConstants.WSS_USERNAME_TOKEN_VALUE_TYPE.equals(valueType)) { // BSP says the Reference must have a ValueType of UsernameToken throw new WSSecurityException( WSSecurityException.INVALID_SECURITY, "invalidValueType", new Object[]{valueType} ); } }
/** * Check that the Username token referenced by the SecurityTokenReference argument * is BSP compliant. * @param secRef The SecurityTokenReference to the Username token * @throws WSSecurityException */ public static void checkUsernameTokenBSPCompliance( SecurityTokenReference secRef ) throws WSSecurityException { if (!secRef.containsReference()) { // BSP does not permit using a KeyIdentifier to refer to a U/T throw new WSSecurityException( WSSecurityException.FAILED_CHECK, "unsupportedKeyId" ); } String valueType = secRef.getReference().getValueType(); if (!WSConstants.WSS_USERNAME_TOKEN_VALUE_TYPE.equals(valueType)) { // BSP says the Reference must have a ValueType of UsernameToken throw new WSSecurityException( WSSecurityException.INVALID_SECURITY, "invalidValueType", new Object[]{valueType} ); } }
BinarySecurity token ) throws WSSecurityException { if (secRef.containsReference()) {
BinarySecurity token ) throws WSSecurityException { if (secRef.containsReference()) {
if (secRef.containsReference()) { if (log.isDebugEnabled()) { log.debug("STR: Reference");
if (secRef.containsReference()) { if (log.isDebugEnabled()) { log.debug("STR: Reference");
if (secRef.containsReference()) { uri = secRef.getReference().getURI(); if (uri.charAt(0) == '#') { referenceType = REFERENCE_TYPE.ISSUER_SERIAL; certs = secRef.getX509IssuerSerial(crypto); } else if (secRef.containsReference()) { Element bstElement = secRef.getTokenElement(strElement.getOwnerDocument(), wsDocInfo, data.getCallbackHandler());
private void processValidateTarget()throws TrustException{ OMElement validateTargetElem = this.rstElement .getFirstChildWithName(new QName(this.wstNs, RahasConstants.LocalNames.VALIDATE_TARGET)); if (validateTargetElem != null) { OMElement strElem = validateTargetElem.getFirstChildWithName(new QName(WSConstants.WSSE_NS, "SecurityTokenReference")); Element elem = (Element)OMXMLBuilderFactory.createStAXOMBuilder( OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory(), strElem.getXMLStreamReader()).getDocumentElement(); try { SecurityTokenReference str = new SecurityTokenReference((Element)elem); if (str.containsReference()) { tokenId = str.getReference().getURI(); } else if(str.containsKeyIdentifier()){ tokenId = str.getKeyIdentifierValue(); } } catch (WSSecurityException e) { throw new TrustException("errorExtractingTokenId",e); } } }
if (secRef.containsReference()) { uri = secRef.getReference().getURI(); if (uri.charAt(0) == '#') { referenceType = REFERENCE_TYPE.ISSUER_SERIAL; certs = secRef.getX509IssuerSerial(crypto); } else if (secRef.containsReference()) { Element bstElement = secRef.getTokenElement(strElement.getOwnerDocument(), wsDocInfo, data.getCallbackHandler());
if (assertion.getSaml2() != null && secRef.containsReference()) { String valueType = secRef.getReference().getValueType(); if (valueType != null && !"".equals(valueType)) {
if (assertion.getSaml2() != null && secRef.containsReference()) { String valueType = secRef.getReference().getValueType(); if (valueType != null && !"".equals(valueType)) {
if (str.containsReference()) { tokenId = str.getReference().getURI(); } else if(str.containsKeyIdentifier()){
/** * Create a WSDerivedKeyTokenPrincipal from this DerivedKeyToken object */ public Principal createPrincipal() throws WSSecurityException { WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(getID()); principal.setNonce(getNonce()); principal.setLabel(getLabel()); principal.setLength(getLength()); principal.setOffset(getOffset()); principal.setAlgorithm(getAlgorithm()); String basetokenId = null; SecurityTokenReference securityTokenReference = getSecurityTokenReference(); if (securityTokenReference.containsReference()) { basetokenId = securityTokenReference.getReference().getURI(); if (basetokenId.charAt(0) == '#') { basetokenId = basetokenId.substring(1); } } else { // KeyIdentifier basetokenId = securityTokenReference.getKeyIdentifierValue(); } principal.setBasetokenId(basetokenId); return principal; }
if (secRef.containsReference()) { uri = secRef.getReference().getURI(); if (uri.charAt(0) == '#') { ); } else if (secRef.containsReference()) { Reference reference = secRef.getReference();
/** * Create a WSDerivedKeyTokenPrincipal from this DerivedKeyToken object */ public Principal createPrincipal() throws WSSecurityException { WSDerivedKeyTokenPrincipal principal = new WSDerivedKeyTokenPrincipal(getID()); principal.setNonce(getNonce()); principal.setLabel(getLabel()); principal.setLength(getLength()); principal.setOffset(getOffset()); principal.setAlgorithm(getAlgorithm()); String basetokenId = null; SecurityTokenReference securityTokenReference = getSecurityTokenReference(); if (securityTokenReference.containsReference()) { basetokenId = securityTokenReference.getReference().getURI(); if (basetokenId.charAt(0) == '#') { basetokenId = basetokenId.substring(1); } } else { // KeyIdentifier basetokenId = securityTokenReference.getKeyIdentifierValue(); } principal.setBasetokenId(basetokenId); return principal; }
if (secRef.containsReference()) { uri = secRef.getReference().getURI(); if (uri.charAt(0) == '#') { ); } else if (secRef.containsReference()) { Reference reference = secRef.getReference();
if (secRef.containsReference()) { uri = secRef.getReference().getURI(); if (uri.charAt(0) == '#') { if (result != null) { processPreviousResult(result, secRef, data, wsDocInfo, bspCompliant); } else if (secRef.containsReference()) {
if (secRef.containsReference()) { uri = secRef.getReference().getURI(); if (uri.charAt(0) == '#') { if (result != null) { processPreviousResult(result, secRef, data, wsDocInfo, bspCompliant); } else if (secRef.containsReference()) {