예제 #1
0
 private SecurityEvent findEvent(Event event, List<SecurityEvent> incomingSecurityEventList) {
   for (SecurityEvent incomingEvent : incomingSecurityEventList) {
     if (event == incomingEvent.getSecurityEventType()) {
       return incomingEvent;
     }
   }
   return null;
 }
예제 #2
0
  private org.apache.xml.security.stax.securityToken.SecurityToken findEncryptedKeyToken()
      throws XMLSecurityException {
    @SuppressWarnings("unchecked")
    final List<SecurityEvent> incomingEventList =
        (List<SecurityEvent>) message.getExchange().get(SecurityEvent.class.getName() + ".in");
    if (incomingEventList != null) {
      for (SecurityEvent incomingEvent : incomingEventList) {
        if (WSSecurityEventConstants.ENCRYPTED_PART == incomingEvent.getSecurityEventType()
            || WSSecurityEventConstants.EncryptedElement == incomingEvent.getSecurityEventType()) {
          org.apache.xml.security.stax.securityToken.SecurityToken token =
              ((AbstractSecuredElementSecurityEvent) incomingEvent).getSecurityToken();
          if (token != null
              && token.getKeyWrappingToken() != null
              && token.getKeyWrappingToken().getSecretKey() != null
              && token.getKeyWrappingToken().getSha1Identifier() != null) {
            return token.getKeyWrappingToken();
          } else if (token != null
              && token.getSecretKey() != null
              && token.getSha1Identifier() != null) {
            return token;
          }
        }
      }

      // Fall back to a Signature in case there was no encrypted Element in the request
      for (SecurityEvent incomingEvent : incomingEventList) {
        if (WSSecurityEventConstants.SIGNED_PART == incomingEvent.getSecurityEventType()
            || WSSecurityEventConstants.SignedElement == incomingEvent.getSecurityEventType()) {
          org.apache.xml.security.stax.securityToken.SecurityToken token =
              ((AbstractSecuredElementSecurityEvent) incomingEvent).getSecurityToken();
          if (token != null
              && token.getKeyWrappingToken() != null
              && token.getKeyWrappingToken().getSecretKey() != null
              && token.getKeyWrappingToken().getSha1Identifier() != null) {
            return token.getKeyWrappingToken();
          } else if (token != null
              && token.getSecretKey() != null
              && token.getSha1Identifier() != null) {
            return token;
          }
        }
      }
    }
    return null;
  }