/** * Check to see if encryption was applied before signature. * Note that results are stored in the reverse order. */ private boolean isEncryptedBeforeSigned(List<WSSecurityEngineResult> results) { boolean encrypted = false; for (WSSecurityEngineResult result : results) { Integer actInt = (Integer)result.get(WSSecurityEngineResult.TAG_ACTION); List<WSDataRef> el = CastUtils.cast((List<?>)result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS)); if (actInt.intValue() == WSConstants.ENCR && el != null) { encrypted = true; } // Don't count an endorsing signature if (actInt.intValue() == WSConstants.SIGN && el != null && !(el.size() == 1 && el.get(0).getName().equals(SIG_QNAME))) { return encrypted; } } return false; }
/** * Check to see if encryption was applied before signature. * Note that results are stored in the reverse order. */ private boolean isEncryptedBeforeSigned(List<WSSecurityEngineResult> results) { boolean encrypted = false; for (WSSecurityEngineResult result : results) { Integer actInt = (Integer)result.get(WSSecurityEngineResult.TAG_ACTION); List<WSDataRef> el = CastUtils.cast((List<?>)result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS)); if (actInt.intValue() == WSConstants.ENCR && el != null) { encrypted = true; } // Don't count an endorsing signature if (actInt.intValue() == WSConstants.SIGN && el != null && !(el.size() == 1 && el.get(0).getName().equals(SIG_QNAME))) { return encrypted; } } return false; }
/** * Check to see if a signature was applied before encryption. * Note that results are stored in the reverse order. */ private boolean isSignedBeforeEncrypted(List<WSSecurityEngineResult> results) { boolean signed = false; for (WSSecurityEngineResult result : results) { Integer actInt = (Integer)result.get(WSSecurityEngineResult.TAG_ACTION); List<WSDataRef> el = CastUtils.cast((List<?>)result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS)); // Don't count an endorsing signature if (actInt.intValue() == WSConstants.SIGN && el != null && !(el.size() == 1 && el.get(0).getName().equals(SIG_QNAME))) { signed = true; } if (actInt.intValue() == WSConstants.ENCR && el != null) { return signed; } } return false; }
/** * Check to see if a signature was applied before encryption. * Note that results are stored in the reverse order. */ private boolean isSignedBeforeEncrypted(List<WSSecurityEngineResult> results) { boolean signed = false; for (WSSecurityEngineResult result : results) { Integer actInt = (Integer)result.get(WSSecurityEngineResult.TAG_ACTION); List<WSDataRef> el = CastUtils.cast((List<?>)result.get(WSSecurityEngineResult.TAG_DATA_REF_URIS)); // Don't count an endorsing signature if (actInt.intValue() == WSConstants.SIGN && el != null && !(el.size() == 1 && el.get(0).getName().equals(SIG_QNAME))) { signed = true; } if (actInt.intValue() == WSConstants.ENCR && el != null) { return signed; } } return false; }
/** * Return true if the Signature is itself signed by one of the token results * @param tokenResults A list of WSSecurityEngineResults corresponding to tokens * @return true if the Signature is itself signed */ private boolean checkSignatureIsSigned(List<WSSecurityEngineResult> tokenResults, List<WSSecurityEngineResult> signedResults) { for (WSSecurityEngineResult signedResult : signedResults) { List<WSDataRef> sl = CastUtils.cast((List<?>)signedResult.get( WSSecurityEngineResult.TAG_DATA_REF_URIS )); if (sl != null && sl.size() >= 1) { for (WSDataRef dataRef : sl) { QName signedQName = dataRef.getName(); if (WSConstants.SIGNATURE.equals(signedQName) && checkSignatureOrEncryptionResult(signedResult, tokenResults)) { return true; } } } } return false; }
/** * Return true if the Signature is itself signed by one of the token results * @param tokenResults A list of WSSecurityEngineResults corresponding to tokens * @return true if the Signature is itself signed */ private boolean checkSignatureIsSigned(List<WSSecurityEngineResult> tokenResults, List<WSSecurityEngineResult> signedResults) { for (WSSecurityEngineResult signedResult : signedResults) { List<WSDataRef> sl = CastUtils.cast((List<?>)signedResult.get( WSSecurityEngineResult.TAG_DATA_REF_URIS )); if (sl != null && sl.size() >= 1) { for (WSDataRef dataRef : sl) { QName signedQName = dataRef.getName(); if (WSConstants.SIGNATURE.equals(signedQName) && checkSignatureOrEncryptionResult(signedResult, tokenResults)) { return true; } } } } return false; }
private boolean checkSignatureIsSignedPlacement( List<WSSecurityEngineResult> results, List<WSSecurityEngineResult> signedResults ) { for (WSSecurityEngineResult signedResult : signedResults) { List<WSDataRef> sl = CastUtils.cast((List<?>)signedResult.get( WSSecurityEngineResult.TAG_DATA_REF_URIS )); if (sl != null && sl.size() >= 1) { for (WSDataRef dataRef : sl) { QName signedQName = dataRef.getName(); if (WSConstants.SIGNATURE.equals(signedQName)) { Element protectedElement = dataRef.getProtectedElement(); if (!isEndorsingSignatureInCorrectPlace(results, signedResult, protectedElement)) { return false; } } } } } return true; }
private boolean checkSignatureIsSignedPlacement( List<WSSecurityEngineResult> results, List<WSSecurityEngineResult> signedResults ) { for (WSSecurityEngineResult signedResult : signedResults) { List<WSDataRef> sl = CastUtils.cast((List<?>)signedResult.get( WSSecurityEngineResult.TAG_DATA_REF_URIS )); if (sl != null && sl.size() >= 1) { for (WSDataRef dataRef : sl) { QName signedQName = dataRef.getName(); if (WSConstants.SIGNATURE.equals(signedQName)) { Element protectedElement = dataRef.getProtectedElement(); if (!isEndorsingSignatureInCorrectPlace(results, signedResult, protectedElement)) { return false; } } } } } return true; }
encryptedSignedRef.setName(encryptedRef.getName()); encryptedSignedRef.setProtectedElement(encryptedRef .getProtectedElement());
encryptedSignedRef.setName(encryptedRef.getName()); encryptedSignedRef.setProtectedElement(encryptedRef .getProtectedElement());
if (sl != null) { if (sl.size() == 1 && sl.get(0).getName().equals(new QName(WSS4JConstants.SIG_NS, WSS4JConstants.SIG_LN))) {
if (sl != null) { if (sl.size() == 1 && sl.get(0).getName().equals(new QName(WSS4JConstants.SIG_NS, WSS4JConstants.SIG_LN))) {