Permalink
Browse files

refactoring SecurityToken stuff

git-svn-id: https://svn.apache.org/repos/asf/webservices/wss4j/trunk@1463136 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information...
1 parent d46f981 commit 2f588c9001961a63377c3d133a23cce1efce1474 Marc Giger committed Apr 1, 2013
Showing with 3,432 additions and 2,443 deletions.
  1. +0 −1 cxf-integration/src/main/java/org/apache/wss4j/cxfIntegration/interceptor/SecurityInInterceptor.java
  2. +0 −1 ...integration/src/main/java/org/apache/wss4j/cxfIntegration/interceptor/SecurityOutInterceptor.java
  3. +4 −3 integration/src/test/java/org/apache/wss4j/integration/test/stax/KerberosTest.java
  4. +2 −29 ws-security-common/src/main/java/org/apache/wss4j/common/principal/PublicKeyPrincipal.java
  5. +51 −0 ws-security-common/src/main/java/org/apache/wss4j/common/principal/PublicKeyPrincipalImpl.java
  6. +5 −59 ws-security-common/src/main/java/org/apache/wss4j/common/principal/SAMLTokenPrincipal.java
  7. +60 −0 ws-security-common/src/main/java/org/apache/wss4j/common/principal/SAMLTokenPrincipalImpl.java
  8. +36 −0 ws-security-common/src/main/java/org/apache/wss4j/common/principal/UsernameTokenPrincipal.java
  9. +4 −4 ws-security-common/src/main/java/org/apache/wss4j/common/principal/WSDerivedKeyTokenPrincipal.java
  10. +35 −31 ...apache/wss4j/common/principal/{WSUsernameTokenPrincipal.java → WSUsernameTokenPrincipalImpl.java}
  11. +41 −0 ws-security-common/src/main/java/org/apache/wss4j/common/saml/SamlAssertionWrapper.java
  12. +3 −3 ws-security-dom/src/main/java/org/apache/wss4j/dom/message/token/UsernameToken.java
  13. +3 −3 ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/BinarySecurityTokenProcessor.java
  14. +4 −4 ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SAMLTokenProcessor.java
  15. +4 −4 ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/SignatureProcessor.java
  16. +6 −6 ws-security-dom/src/main/java/org/apache/wss4j/dom/processor/UsernameTokenProcessor.java
  17. +2 −2 ws-security-dom/src/main/java/org/apache/wss4j/dom/str/SignatureSTRParser.java
  18. +1 −1 ws-security-dom/src/test/java/org/apache/wss4j/dom/message/SignatureKeyValueTest.java
  19. +3 −3 ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java
  20. +1 −1 ws-security-policy-stax/src/main/java/org/apache/wss4j/policy/stax/PolicyEnforcer.java
  21. +1 −1 ...stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/AlgorithmSuiteAssertionState.java
  22. +26 −23 ...cy-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/IssuedTokenAssertionState.java
  23. +6 −5 ...-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/KerberosTokenAssertionState.java
  24. +5 −3 ...-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/KeyValueTokenAssertionState.java
  25. +6 −3 ...-policy-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/LayoutAssertionState.java
  26. +5 −5 ...tax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/ProtectionOrderAssertionState.java
  27. +11 −9 ...licy-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/SamlTokenAssertionState.java
  28. +48 −51 ...y-policy-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/TokenAssertionState.java
  29. +16 −15 ...tax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/TokenProtectionAssertionState.java
  30. +2 −2 ...-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/UsernameTokenAssertionState.java
  31. +34 −25 ...licy-stax/src/main/java/org/apache/wss4j/policy/stax/assertionStates/X509TokenAssertionState.java
  32. +29 −5 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/AbstractPolicyTestBase.java
  33. +8 −8 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/AlgorithmSuiteTest.java
  34. +3 −2 ...policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/AsymmetricBindingIntegrationTest.java
  35. +20 −19 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/AsymmetricBindingTest.java
  36. +71 −59 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/DerivedKeyTests.java
  37. +6 −6 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/HttpsTokenTest.java
  38. +83 −54 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/IssuedTokenTest.java
  39. +29 −20 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/KerberosTokenTest.java
  40. +26 −15 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/KeyValueTokenTest.java
  41. +10 −10 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/LayoutTest.java
  42. +13 −7 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/RelTokenTest.java
  43. +25 −16 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SamlTokenTest.java
  44. +23 −13 ...rity-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SecureConversationTokenTest.java
  45. +23 −13 ...ecurity-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SecurityContextTokenTest.java
  46. +13 −7 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SpnegoContextTokenTest.java
  47. +266 −270 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SupportingTokensTest.java
  48. +20 −20 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/SymmetricBindingTest.java
  49. +59 −33 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TokenProtectionTest.java
  50. +26 −26 ...-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TransportBindingIntegrationTest.java
  51. +10 −10 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/TransportBindingTest.java
  52. +31 −22 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/UsernameTokenTest.java
  53. +24 −14 ws-security-policy-stax/src/test/java/org/apache/wss4j/policy/stax/test/X509TokenTest.java
  54. +35 −34 ws-security-stax/src/main/java/org/apache/wss4j/stax/WSSec.java
  55. +9 −7 ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/InboundWSSec.java
  56. +17 −17 ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/OutboundWSSec.java
  57. +2 −2 .../src/main/java/org/apache/wss4j/stax/ext/{WSSecurityContext.java → WSInboundSecurityContext.java}
  58. +6 −42 ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSConstants.java
  59. +14 −13 ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSSecurityProperties.java
  60. +31 −39 ws-security-stax/src/main/java/org/apache/wss4j/stax/ext/WSSUtils.java
  61. +123 −116 ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/InboundWSSecurityContextImpl.java
  62. +20 −13 ...tax/src/main/java/org/apache/wss4j/stax/impl/processor/input/BinarySecurityTokenInputHandler.java
  63. +20 −18 ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DecryptInputProcessor.java
  64. +29 −24 ...ty-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/DerivedKeyTokenInputHandler.java
  65. +2 −2 ...rity-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/ReferenceListInputHandler.java
  66. +61 −47 ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SAMLTokenInputHandler.java
  67. +16 −14 ...ax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityContextTokenInputHandler.java
  68. +3 −3 ...y-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityHeaderInputProcessor.java
  69. +14 −11 .../src/main/java/org/apache/wss4j/stax/impl/processor/input/SecurityTokenReferenceInputHandler.java
  70. +2 −2 ...x/src/main/java/org/apache/wss4j/stax/impl/processor/input/SignatureConfirmationInputHandler.java
  71. +8 −8 ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/TimestampInputHandler.java
  72. +23 −19 ...rity-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/UsernameTokenInputHandler.java
  73. +3 −3 ...ty-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSEncryptedKeyInputHandler.java
  74. +21 −19 ...urity-stax/src/main/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureInputHandler.java
  75. +13 −9 ...in/java/org/apache/wss4j/stax/impl/processor/input/WSSSignatureReferenceVerifyInputProcessor.java
  76. +19 −17 ...src/main/java/org/apache/wss4j/stax/impl/processor/output/BinarySecurityTokenOutputProcessor.java
  77. +22 −19 ...tax/src/main/java/org/apache/wss4j/stax/impl/processor/output/DerivedKeyTokenOutputProcessor.java
  78. +1 −1 ...-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptEndingOutputProcessor.java
  79. +3 −3 ...curity-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptOutputProcessor.java
  80. +20 −18 ...y-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/EncryptedKeyOutputProcessor.java
  81. +7 −7 ...c/main/java/org/apache/wss4j/stax/impl/processor/output/KerberosSecurityTokenOutputProcessor.java
  82. +15 −13 ...rity-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/SAMLTokenOutputProcessor.java
  83. +9 −7 ...rc/main/java/org/apache/wss4j/stax/impl/processor/output/SecurityContextTokenOutputProcessor.java
  84. +1 −1 ...c/main/java/org/apache/wss4j/stax/impl/processor/output/SignatureConfirmationOutputProcessor.java
  85. +5 −4 ...-stax/src/main/java/org/apache/wss4j/stax/impl/processor/output/UsernameTokenOutputProcessor.java
  86. +20 −19 .../src/main/java/org/apache/wss4j/stax/impl/processor/output/WSSSignatureEndingOutputProcessor.java
  87. +60 −0 ...ity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/DsaKeyValueSecurityTokenImpl.java
  88. +60 −0 ...rity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/ECKeyValueSecurityTokenImpl.java
  89. +32 −17 .../org/apache/wss4j/stax/impl/securityToken/{HttpsSecurityToken.java → HttpsSecurityTokenImpl.java}
  90. +0 −57 ...ecurity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/InboundSecurityTokenImpl.java
  91. +2 −2 ...rity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/KerberosClientSecurityToken.java
  92. +27 −15 ...ax/impl/securityToken/{KerberosServiceSecurityToken.java → KerberosServiceSecurityTokenImpl.java}
  93. +58 −17 ...ty-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/OutboundUsernameSecurityToken.java
  94. +60 −0 ...ity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/RsaKeyValueSecurityTokenImpl.java
  95. +48 −40 ...va/org/apache/wss4j/stax/impl/securityToken/{SAMLSecurityToken.java → SamlSecurityTokenImpl.java}
  96. +39 −0 ...x/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecureConversationSecurityTokenImpl.java
  97. +75 −73 ...ecurity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/SecurityTokenFactoryImpl.java
  98. +25 −22 ...che/wss4j/stax/impl/securityToken/{SecurityTokenReference.java → SecurityTokenReferenceImpl.java}
  99. +7 −7 ...stax/impl/securityToken/{ThumbprintSHA1SecurityToken.java → ThumbprintSHA1SecurityTokenImpl.java}
  100. +0 −103 ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/UsernameSecurityToken.java
  101. +237 −0 ...curity-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/UsernameSecurityTokenImpl.java
  102. +0 −164 ws-security-stax/src/main/java/org/apache/wss4j/stax/impl/securityToken/UsernameToken.java
  103. +7 −6 ...pache/wss4j/stax/impl/securityToken/{X509DataSecurityToken.java → X509DataSecurityTokenImpl.java}
  104. +7 −7 ...wss4j/stax/impl/securityToken/{X509DefaultSecurityToken.java → X509DefaultSecurityTokenImpl.java}
  105. +7 −7 ...j/stax/impl/securityToken/{X509PKIPathv1SecurityToken.java → X509PKIPathv1SecurityTokenImpl.java}
  106. +24 −24 ...va/org/apache/wss4j/stax/impl/securityToken/{X509SecurityToken.java → X509SecurityTokenImpl.java}
  107. +7 −7 ...ken/{X509SubjectKeyIdentifierSecurityToken.java → X509SubjectKeyIdentifierSecurityTokenImpl.java}
  108. +7 −7 .../apache/wss4j/stax/impl/securityToken/{X509_V3SecurityToken.java → X509_V3SecurityTokenImpl.java}
  109. +2 −3 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/DerivedKeyTokenSecurityEvent.java
  110. +6 −16 ...tyToken/SecureConversationSecurityToken.java → securityEvent/EncryptedKeyTokenSecurityEvent.java}
  111. +5 −3 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/EncryptedPartSecurityEvent.java
  112. +2 −19 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/HttpsTokenSecurityEvent.java
  113. +5 −2 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/IssuedTokenSecurityEvent.java
  114. +5 −5 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/KerberosTokenSecurityEvent.java
  115. +29 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/KeyValueTokenSecurityEvent.java
  116. +4 −2 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/RelTokenSecurityEvent.java
  117. +8 −11 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/SamlTokenSecurityEvent.java
  118. +2 −1 ...-stax/src/main/java/org/apache/wss4j/stax/securityEvent/SecureConversationTokenSecurityEvent.java
  119. +4 −1 ...ity-stax/src/main/java/org/apache/wss4j/stax/securityEvent/SecurityContextTokenSecurityEvent.java
  120. +5 −3 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/SignedPartSecurityEvent.java
  121. +2 −1 ...urity-stax/src/main/java/org/apache/wss4j/stax/securityEvent/SpnegoContextTokenSecurityEvent.java
  122. +3 −7 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/UsernameTokenSecurityEvent.java
  123. +29 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityEvent/X509TokenSecurityEvent.java
  124. +22 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/DsaKeyValueSecurityToken.java
  125. +22 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/ECKeyValueSecurityToken.java
  126. +25 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/HttpsSecurityToken.java
  127. +26 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/KerberosServiceSecurityToken.java
  128. +22 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/KeyValueSecurityToken.java
  129. +22 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/RsaKeyValueSecurityToken.java
  130. +22 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/SamlSecurityToken.java
  131. +24 −0 ...urity-stax/src/main/java/org/apache/wss4j/stax/securityToken/SecureConversationSecurityToken.java
  132. +29 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/SecurityTokenReference.java
  133. +6 −8 .../wss4j/stax/{ext/InboundSecurityToken.java → securityToken/SubjectAndPrincipalSecurityToken.java}
  134. +16 −15 ...rg/apache/wss4j/stax/{impl/WSSecurityContextImpl.java → securityToken/UsernameSecurityToken.java}
  135. +59 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/WSSecurityTokenConstants.java
  136. +22 −0 ws-security-stax/src/main/java/org/apache/wss4j/stax/securityToken/X509SecurityToken.java
  137. +1 −1 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/BinarySecurityTokenValidator.java
  138. +11 −10 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/BinarySecurityTokenValidatorImpl.java
  139. +33 −51 ...pache/wss4j/stax/validate/{JAASUsernameTokenValidator.java → JAASUsernameTokenValidatorImpl.java}
  140. +4 −4 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/SamlTokenValidator.java
  141. +10 −9 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/SamlTokenValidatorImpl.java
  142. +1 −1 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/SecurityContextTokenValidator.java
  143. +7 −7 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/SecurityContextTokenValidatorImpl.java
  144. +4 −2 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/SignatureTokenValidator.java
  145. +5 −3 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/SignatureTokenValidatorImpl.java
  146. +6 −6 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/TokenContext.java
  147. +3 −2 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidator.java
  148. +15 −31 ws-security-stax/src/main/java/org/apache/wss4j/stax/validate/UsernameTokenValidatorImpl.java
  149. +2 −2 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AbstractTestBase.java
  150. +9 −8 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/DerivedKeyTokenTest.java
  151. +7 −6 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java
  152. +3 −3 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java
  153. +56 −47 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InboundWSSecurityContextImplTest.java
  154. +166 −31 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java
  155. +10 −9 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureTest.java
  156. +1 −2 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/UsernameTokenTest.java
  157. +9 −7 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenHOKTest.java
  158. +5 −4 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenReferenceTest.java
  159. +10 −8 ws-security-stax/src/test/java/org/apache/wss4j/stax/test/saml/SAMLTokenSVTest.java
@@ -79,7 +79,6 @@ public void registerSecurityEvent(SecurityEvent securityEvent) throws WSSecurity
soapMessage.getExchange().put(SecurityEvent.class.getName() + ".in", incomingSecurityEventList);
try {
- @SuppressWarnings("unchecked")
final List<SecurityEvent> requestSecurityEvents = (List<SecurityEvent>) soapMessage.getExchange().get(SecurityEvent.class.getName() + ".out");
newXmlStreamReader = inboundWSSec.processInMessage(originalXmlStreamReader, requestSecurityEvents, securityEventListener);
soapMessage.setContent(XMLStreamReader.class, newXmlStreamReader);
@@ -80,7 +80,6 @@ public void registerSecurityEvent(SecurityEvent securityEvent) throws WSSecurity
XMLStreamWriter newXMLStreamWriter;
try {
- @SuppressWarnings("unchecked")
final List<SecurityEvent> requestSecurityEvents = (List<SecurityEvent>) soapMessage.getExchange().get(SecurityEvent.class.getName() + ".in");
newXMLStreamWriter = outboundWSSec.processOutMessage(os, encoding, requestSecurityEvents, securityEventListener);
soapMessage.setContent(XMLStreamWriter.class, newXMLStreamWriter);
@@ -264,9 +264,10 @@ public void registerSecurityEvent(SecurityEvent securityEvent) throws XMLSecurit
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
Assert.assertEquals(kerberosTokenSecurityEvents.size(), 2);
- Assert.assertNotNull(((InboundSecurityToken)kerberosTokenSecurityEvents.get(0).getSecurityToken()).getSubject());
- Assert.assertNotNull(((InboundSecurityToken)kerberosTokenSecurityEvents.get(0).getSecurityToken()).getPrincipal());
- Assert.assertEquals(((InboundSecurityToken)kerberosTokenSecurityEvents.get(0).getSecurityToken()).getPrincipal().getName(), "alice@service.ws.apache.org");
+ final KerberosTokenSecurityEvent kerberosTokenSecurityEvent = kerberosTokenSecurityEvents.get(0);
+ Assert.assertNotNull(kerberosTokenSecurityEvent.getSecurityToken().getSubject());
+ Assert.assertTrue(kerberosTokenSecurityEvent.getSecurityToken().getPrincipal() instanceof KerberosPrincipal);
+ Assert.assertEquals(kerberosTokenSecurityEvent.getSecurityToken().getPrincipal().getName(), "alice@service.ws.apache.org");
}
}
@@ -16,39 +16,12 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.wss4j.common.principal;
-import java.io.Serializable;
import java.security.Principal;
import java.security.PublicKey;
-/**
- * This class encapsulates a principal defined by a Public Key. In particular, this class
- * is used for the ds:KeyInfo/ds:KeyValue case in the SignatureProcessor.
- */
-public class PublicKeyPrincipal implements Principal, Serializable {
-
- /**
- *
- */
- private static final long serialVersionUID = -7662669773454821344L;
- private PublicKey publicKey;
-
- public PublicKeyPrincipal(PublicKey publicKey) {
- this.publicKey = publicKey;
- }
-
- public PublicKey getPublicKey() {
- return publicKey;
- }
-
- public String getName() {
- return publicKey.toString();
- }
-
- public void setPublicKey(PublicKey publicKey) {
- this.publicKey = publicKey;
- }
+public interface PublicKeyPrincipal extends Principal {
+ PublicKey getPublicKey();
}
@@ -0,0 +1,51 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.principal;
+
+import java.io.Serializable;
+import java.security.PublicKey;
+
+/**
+ * This class encapsulates a principal defined by a Public Key. In particular, this class
+ * is used for the ds:KeyInfo/ds:KeyValue case in the SignatureProcessor.
+ */
+public class PublicKeyPrincipalImpl implements Serializable, PublicKeyPrincipal {
+
+ private static final long serialVersionUID = -7662669773454821344L;
+ private PublicKey publicKey;
+
+ public PublicKeyPrincipalImpl(PublicKey publicKey) {
+ this.publicKey = publicKey;
+ }
+
+ @Override
+ public PublicKey getPublicKey() {
+ return publicKey;
+ }
+
+ public String getName() {
+ return publicKey.toString();
+ }
+
+ public void setPublicKey(PublicKey publicKey) {
+ this.publicKey = publicKey;
+ }
+
+}
@@ -16,71 +16,17 @@
* specific language governing permissions and limitations
* under the License.
*/
-
package org.apache.wss4j.common.principal;
import org.apache.wss4j.common.saml.SamlAssertionWrapper;
-import org.opensaml.common.SAMLVersion;
-import java.io.Serializable;
import java.security.Principal;
-/**
- * A principal that represents a SAML Token. It parses the Subject and returns the Subject
- * name value as the Principal name.
- */
-public class SAMLTokenPrincipal implements Principal, Serializable {
- private static final long serialVersionUID = 1L;
-
- private String name;
- private SamlAssertionWrapper samlAssertion;
-
- public SAMLTokenPrincipal(SamlAssertionWrapper samlAssertion) {
- this.samlAssertion = samlAssertion;
- if (samlAssertion.getSamlVersion() == SAMLVersion.VERSION_20) {
- org.opensaml.saml2.core.Subject subject = samlAssertion.getSaml2().getSubject();
- if (subject != null && subject.getNameID() != null) {
- name = subject.getNameID().getValue();
- }
- } else {
- org.opensaml.saml1.core.Subject samlSubject = null;
- for (org.opensaml.saml1.core.Statement stmt : samlAssertion.getSaml1().getStatements()) {
- if (stmt instanceof org.opensaml.saml1.core.AttributeStatement) {
- org.opensaml.saml1.core.AttributeStatement attrStmt =
- (org.opensaml.saml1.core.AttributeStatement) stmt;
- samlSubject = attrStmt.getSubject();
- } else if (stmt instanceof org.opensaml.saml1.core.AuthenticationStatement) {
- org.opensaml.saml1.core.AuthenticationStatement authStmt =
- (org.opensaml.saml1.core.AuthenticationStatement) stmt;
- samlSubject = authStmt.getSubject();
- } else {
- org.opensaml.saml1.core.AuthorizationDecisionStatement authzStmt =
- (org.opensaml.saml1.core.AuthorizationDecisionStatement)stmt;
- samlSubject = authzStmt.getSubject();
- }
- if (samlSubject != null) {
- break;
- }
- }
- if (samlSubject != null && samlSubject.getNameIdentifier() != null) {
- name = samlSubject.getNameIdentifier().getNameIdentifier();
- }
- }
- }
-
- public SamlAssertionWrapper getToken() {
- return samlAssertion;
- }
+public interface SAMLTokenPrincipal extends Principal {
+ //todo rename me to getSamlAssertionWrapper?
+ SamlAssertionWrapper getToken();
- public String getName() {
- return this.name;
- }
+ String getName();
- public String getId() {
- if (samlAssertion != null) {
- return samlAssertion.getId();
- }
- return null;
- }
-
+ String getId();
}
@@ -0,0 +1,60 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.wss4j.common.principal;
+
+import org.apache.wss4j.common.saml.SamlAssertionWrapper;
+
+import java.io.Serializable;
+
+/**
+ * A principal that represents a SAML Token. It parses the Subject and returns the Subject
+ * name value as the Principal name.
+ */
+public class SAMLTokenPrincipalImpl implements Serializable, SAMLTokenPrincipal {
+ private static final long serialVersionUID = 1L;
+
+ private String name;
+ private SamlAssertionWrapper samlAssertion;
+
+ public SAMLTokenPrincipalImpl(SamlAssertionWrapper samlAssertion) {
+ this.samlAssertion = samlAssertion;
+ this.name = samlAssertion.getSubjectName();
+ }
+
+ //todo rename me?
+ @Override
+ public SamlAssertionWrapper getToken() {
+ return samlAssertion;
+ }
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public String getId() {
+ if (samlAssertion != null) {
+ return samlAssertion.getId();
+ }
+ return null;
+ }
+
+}
@@ -0,0 +1,36 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.wss4j.common.principal;
+
+import java.security.Principal;
+
+public interface UsernameTokenPrincipal extends Principal {
+
+ boolean isPasswordDigest();
+
+ String getPassword();
+
+ //todo shouldn't we return the raw bytes of the nonce instead of the Base64Encoded string?
+ //otherwise every user of the nonce has to decode it first.
+ String getNonce();
+
+ String getCreatedTime();
+
+ String getPasswordType();
+}
@@ -37,6 +37,10 @@
private int offset;
private String basetokenId;
private byte[] secret;
+
+ public WSDerivedKeyTokenPrincipal(String id) {
+ this.id = id;
+ }
public String getLabel() {
return label;
@@ -74,10 +78,6 @@ public String getNonce() {
return nonce;
}
- public WSDerivedKeyTokenPrincipal(String id) {
- this.id = id;
- }
-
public String getName() {
return id;
}
Oops, something went wrong.

0 comments on commit 2f588c9

Please sign in to comment.