You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/12/15 17:40:42 UTC
svn commit: r1720192 [16/33] - in /webservices/wss4j/trunk:
bindings/src/main/java/org/apache/wss4j/binding/wss10/
bindings/src/main/java/org/apache/wss4j/binding/wss11/
bindings/src/main/java/org/apache/wss4j/binding/wssc13/
bindings/src/main/java/org...
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/WSSecurityUtil.java Tue Dec 15 16:40:37 2015
@@ -64,25 +64,25 @@ import javax.security.auth.callback.Unsu
* WS-Security Utility methods. <p/>
*/
public final class WSSecurityUtil {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(WSSecurityUtil.class);
private WSSecurityUtil() {
// Complete
}
-
+
public static Element getSOAPHeader(Document doc) {
String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
- return
+ return
XMLUtils.getDirectChildElement(
doc.getDocumentElement(), WSConstants.ELEM_HEADER, soapNamespace
);
}
-
+
/**
* Returns the first WS-Security header element for a given actor. Only one
* WS-Security header is allowed for an actor.
- *
+ *
* @param doc
* @param actor
* @return the <code>wsse:Security</code> element or <code>null</code>
@@ -93,37 +93,37 @@ public final class WSSecurityUtil {
if (soapHeaderElement == null) { // no SOAP header at all
return null;
}
-
+
String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
return getSecurityHeader(soapHeaderElement, actor, WSConstants.URI_SOAP12_ENV.equals(soapNamespace));
}
-
+
/**
* Returns the first WS-Security header element for a given actor. Only one
* WS-Security header is allowed for an actor.
*/
public static Element getSecurityHeader(Element soapHeader, String actor, boolean soap12) throws WSSecurityException {
-
+
String actorLocal = WSConstants.ATTR_ACTOR;
String soapNamespace = WSConstants.URI_SOAP11_ENV;
if (soap12) {
actorLocal = WSConstants.ATTR_ROLE;
soapNamespace = WSConstants.URI_SOAP12_ENV;
}
-
+
//
// Iterate through the security headers
//
Element foundSecurityHeader = null;
for (
- Node currentChild = soapHeader.getFirstChild();
- currentChild != null;
+ Node currentChild = soapHeader.getFirstChild();
+ currentChild != null;
currentChild = currentChild.getNextSibling()
) {
if (Node.ELEMENT_NODE == currentChild.getNodeType()
&& WSConstants.WSSE_LN.equals(currentChild.getLocalName())
&& WSConstants.WSSE_NS.equals(currentChild.getNamespaceURI())) {
-
+
Element elem = (Element)currentChild;
Attr attr = elem.getAttributeNodeNS(soapNamespace, actorLocal);
String hActor = (attr != null) ? attr.getValue() : null;
@@ -148,41 +148,41 @@ public final class WSSecurityUtil {
/**
* Compares two actor strings and returns true if these are equal. Takes
* care of the null length strings and uses ignore case.
- *
+ *
* @param actor
* @param hActor
* @return true is the actor arguments are equal
*/
public static boolean isActorEqual(String actor, String hActor) {
- if ((hActor == null || hActor.length() == 0)
+ if ((hActor == null || hActor.length() == 0)
&& (actor == null || actor.length() == 0)) {
return true;
}
-
+
if (hActor != null && actor != null && hActor.equalsIgnoreCase(actor)) {
return true;
}
-
+
return false;
}
/**
* Gets all direct children with specified localname and namespace. <p/>
- *
+ *
* @param fNode the node where to start the search
* @param localName local name of the children to get
* @param namespace the namespace of the children to get
* @return the list of nodes or <code>null</code> if not such nodes are found
*/
public static List<Element> getDirectChildElements(
- Node fNode,
+ Node fNode,
String localName,
String namespace
) {
List<Element> children = new ArrayList<>();
for (
- Node currentChild = fNode.getFirstChild();
- currentChild != null;
+ Node currentChild = fNode.getFirstChild();
+ currentChild != null;
currentChild = currentChild.getNextSibling()
) {
if (Node.ELEMENT_NODE == currentChild.getNodeType()
@@ -193,11 +193,11 @@ public final class WSSecurityUtil {
}
return children;
}
-
+
/**
* return the first soap "Body" element. <p/>
- *
+ *
* @param doc
* @return the body element or <code>null</code> if document does not
* contain a SOAP body
@@ -207,12 +207,12 @@ public final class WSSecurityUtil {
String ns = docElement.getNamespaceURI();
return XMLUtils.getDirectChildElement(docElement, WSConstants.ELEM_BODY, ns);
}
-
-
+
+
/**
- * Find the DOM Element in the SOAP Envelope that is referenced by the
+ * Find the DOM Element in the SOAP Envelope that is referenced by the
* WSEncryptionPart argument. The "Id" is used before the Element localname/namespace.
- *
+ *
* @param part The WSEncryptionPart object corresponding to the DOM Element(s) we want
* @param callbackLookup The CallbackLookup object used to find Elements
* @param doc The owning document
@@ -225,7 +225,7 @@ public final class WSSecurityUtil {
if (part.getElement() != null) {
return Collections.singletonList(part.getElement());
}
-
+
// Next try to find the Element via its wsu:Id
String id = part.getId();
if (id != null) {
@@ -235,21 +235,21 @@ public final class WSSecurityUtil {
// Otherwise just lookup all elements with the localname/namespace
return callbackLookup.getElements(part.getName(), part.getNamespace());
}
-
-
+
+
/**
* Get the default encryption part - the SOAP Body of type "Content".
*/
public static WSEncryptionPart getDefaultEncryptionPart(Document doc) {
- String soapNamespace =
+ String soapNamespace =
WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
return new WSEncryptionPart(WSConstants.ELEM_BODY, soapNamespace, "Content");
}
/**
* create a new element in the same namespace <p/>
- *
+ *
* @param parent for the new element
* @param localName of the new element
* @return the new element
@@ -260,7 +260,7 @@ public final class WSSecurityUtil {
if (prefix != null && prefix.length() > 0) {
qName = prefix + ":" + localName;
}
-
+
String nsUri = parent.getNamespaceURI();
return parent.getOwnerDocument().createElementNS(nsUri, qName);
}
@@ -268,7 +268,7 @@ public final class WSSecurityUtil {
/**
* prepend a child element <p/>
- *
+ *
* @param parent element of this child element
* @param child the element to append
* @return the child element
@@ -288,7 +288,7 @@ public final class WSSecurityUtil {
/**
* find the first ws-security header block <p/>
- *
+ *
* @param doc the DOM document (SOAP request)
* @param envelope the SOAP envelope
* @param doCreate if true create a new WSS header block if none exists
@@ -296,7 +296,7 @@ public final class WSSecurityUtil {
*/
public static Element findWsseSecurityHeaderBlock(
Document doc,
- Element envelope,
+ Element envelope,
boolean doCreate
) throws WSSecurityException {
return findWsseSecurityHeaderBlock(doc, envelope, null, doCreate);
@@ -304,7 +304,7 @@ public final class WSSecurityUtil {
/**
* find a WS-Security header block for a given actor <p/>
- *
+ *
* @param doc the DOM document (SOAP request)
* @param envelope the SOAP envelope
* @param actor the actor (role) name of the WSS header
@@ -314,14 +314,14 @@ public final class WSSecurityUtil {
public static Element findWsseSecurityHeaderBlock(
Document doc,
Element envelope,
- String actor,
+ String actor,
boolean doCreate
) throws WSSecurityException {
String soapNamespace = WSSecurityUtil.getSOAPNamespace(doc.getDocumentElement());
- Element header =
+ Element header =
XMLUtils.getDirectChildElement(
- doc.getDocumentElement(),
- WSConstants.ELEM_HEADER,
+ doc.getDocumentElement(),
+ WSConstants.ELEM_HEADER,
soapNamespace
);
if (header == null) { // no SOAP header at all
@@ -332,25 +332,25 @@ public final class WSSecurityUtil {
return null;
}
}
-
+
String actorLocal = WSConstants.ATTR_ACTOR;
if (WSConstants.URI_SOAP12_ENV.equals(soapNamespace)) {
actorLocal = WSConstants.ATTR_ROLE;
}
-
+
//
// Iterate through the security headers
//
Element foundSecurityHeader = null;
for (
- Node currentChild = header.getFirstChild();
- currentChild != null;
+ Node currentChild = header.getFirstChild();
+ currentChild != null;
currentChild = currentChild.getNextSibling()
) {
if (Node.ELEMENT_NODE == currentChild.getNodeType()
&& WSConstants.WSSE_LN.equals(currentChild.getLocalName())
&& WSConstants.WSSE_NS.equals(currentChild.getNamespaceURI())) {
-
+
Element elem = (Element)currentChild;
Attr attr = elem.getAttributeNodeNS(soapNamespace, actorLocal);
String hActor = (attr != null) ? attr.getValue() : null;
@@ -380,7 +380,7 @@ public final class WSSecurityUtil {
/**
* create a base64 test node <p/>
- *
+ *
* @param doc the DOM document (SOAP request)
* @param data to encode
* @return a Text node containing the base64 encoded data
@@ -397,11 +397,11 @@ public final class WSSecurityUtil {
}
return new SOAP11Constants();
}
-
+
public static String getSOAPNamespace(Element startElement) {
return getSOAPConstants(startElement).getEnvelopeURI();
}
-
+
public static List<Integer> decodeAction(String action) throws WSSecurityException {
String actionToParse = action;
if (actionToParse == null) {
@@ -411,7 +411,7 @@ public final class WSSecurityUtil {
if ("".equals(actionToParse)) {
return Collections.emptyList();
}
-
+
List<Integer> actions = new ArrayList<>();
String single[] = actionToParse.split("\\s");
for (int i = 0; i < single.length; i++) {
@@ -449,8 +449,8 @@ public final class WSSecurityUtil {
}
return actions;
}
-
-
+
+
/**
* Decode an action String. This method should only be called on the outbound side.
* @param action The initial String of actions to perform
@@ -459,13 +459,13 @@ public final class WSSecurityUtil {
* @throws WSSecurityException
*/
public static List<HandlerAction> decodeHandlerAction(
- String action,
+ String action,
WSSConfig wssConfig
) throws WSSecurityException {
if (action == null) {
return Collections.emptyList();
}
-
+
List<HandlerAction> actions = new ArrayList<>();
String single[] = action.split(" ");
for (int i = 0; i < single.length; i++) {
@@ -513,7 +513,7 @@ public final class WSSecurityUtil {
/**
* Generate a nonce of the given length using the SHA1PRNG algorithm. The SecureRandom
* instance that backs this method is cached for efficiency.
- *
+ *
* @return a nonce of the given length
* @throws WSSecurityException
*/
@@ -526,18 +526,18 @@ public final class WSSecurityUtil {
);
}
}
-
+
public static void verifySignedElement(Element elem, WSDocInfo wsDocInfo)
throws WSSecurityException {
verifySignedElement(elem, wsDocInfo.getResultsByTag(WSConstants.SIGN));
}
-
+
public static void verifySignedElement(Element elem, List<WSSecurityEngineResult> signedResults)
throws WSSecurityException {
if (signedResults != null) {
for (WSSecurityEngineResult signedResult : signedResults) {
@SuppressWarnings("unchecked")
- List<WSDataRef> dataRefs =
+ List<WSDataRef> dataRefs =
(List<WSDataRef>)signedResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
if (dataRefs != null) {
for (WSDataRef dataRef : dataRefs) {
@@ -548,16 +548,16 @@ public final class WSSecurityUtil {
}
}
}
-
+
throw new WSSecurityException(
- WSSecurityException.ErrorCode.FAILED_CHECK, "elementNotSigned",
+ WSSecurityException.ErrorCode.FAILED_CHECK, "elementNotSigned",
new Object[] {elem});
}
-
+
/**
- * Does the current element or some ancestor of it correspond to the known "signedElement"?
+ * Does the current element or some ancestor of it correspond to the known "signedElement"?
*/
- private static boolean isElementOrAncestorSigned(Element elem, Element signedElement)
+ private static boolean isElementOrAncestorSigned(Element elem, Element signedElement)
throws WSSecurityException {
final Element envelope = elem.getOwnerDocument().getDocumentElement();
Node cur = elem;
@@ -567,10 +567,10 @@ public final class WSSecurityUtil {
}
cur = cur.getParentNode();
}
-
+
return false;
}
-
+
public static byte[] getBytesFromAttachment(
String xopUri, RequestData data
) throws WSSecurityException {
@@ -596,7 +596,7 @@ public final class WSSecurityUtil {
attachmentCallbackHandler.handle(new Callback[]{attachmentRequestCallback});
List<Attachment> attachments = attachmentRequestCallback.getAttachments();
- if (attachments == null || attachments.isEmpty()
+ if (attachments == null || attachments.isEmpty()
|| !attachmentId.equals(attachments.get(0).getId())) {
throw new WSSecurityException(
WSSecurityException.ErrorCode.INVALID_SECURITY,
@@ -624,12 +624,12 @@ public final class WSSecurityUtil {
doc.createElementNS(WSConstants.XOP_NS, "xop:Include");
xopInclude.setAttributeNS(null, "href", "cid:" + attachmentId);
parentElement.appendChild(xopInclude);
-
+
Attachment resultAttachment = new Attachment();
resultAttachment.setId(attachmentId);
resultAttachment.setMimeType("application/ciphervalue");
resultAttachment.setSourceStream(new ByteArrayInputStream(bytes));
-
+
AttachmentResultCallback attachmentResultCallback = new AttachmentResultCallback();
attachmentResultCallback.setAttachmentId(attachmentId);
attachmentResultCallback.setAttachment(resultAttachment);
@@ -638,6 +638,6 @@ public final class WSSecurityUtil {
} catch (Exception e) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, e);
}
-
+
}
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/X509Util.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/X509Util.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/X509Util.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/X509Util.java Tue Dec 15 16:40:37 2015
@@ -33,9 +33,9 @@ import javax.security.auth.callback.Unsu
import java.io.IOException;
public final class X509Util {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(X509Util.class);
-
+
private X509Util() {
// Complete
}
@@ -51,7 +51,7 @@ public final class X509Util {
}
public static String getEncAlgo(Node encBodyData) throws WSSecurityException {
- Element tmpE =
+ Element tmpE =
XMLUtils.getDirectChildElement(
encBodyData, "EncryptionMethod", WSConstants.ENC_NS
);
@@ -77,7 +77,7 @@ public final class X509Util {
byte[] encryptedKey
) throws WSSecurityException {
String keyName = null;
- Element keyNmElem =
+ Element keyNmElem =
XMLUtils.getDirectChildElement(
keyInfoElem, "KeyName", WSConstants.SIG_NS
);
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/util/XmlSchemaDateFormat.java Tue Dec 15 16:40:37 2015
@@ -35,14 +35,14 @@ import java.util.TimeZone;
*/
public class XmlSchemaDateFormat extends DateFormat {
/**
- *
+ *
*/
private static final long serialVersionUID = 5152684993503882396L;
/**
* Logger.
*/
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(XmlSchemaDateFormat.class);
/**
@@ -54,7 +54,7 @@ public class XmlSchemaDateFormat extends
static {
DATEFORMAT_XSD_ZULU.setTimeZone(TimeZone.getTimeZone("UTC"));
}
-
+
@Override
public void setLenient(boolean lenient) {
DATEFORMAT_XSD_ZULU.setLenient(lenient);
@@ -206,7 +206,7 @@ public class XmlSchemaDateFormat extends
private void handleParseError(ParsePosition parsePos, String errorReason)
throws ParseException {
throw new ParseException(
- "INVALID_XSD_DATETIME: " + errorReason,
+ "INVALID_XSD_DATETIME: " + errorReason,
parsePos.getErrorIndex()
);
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Credential.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Credential.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Credential.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Credential.java Tue Dec 15 16:40:37 2015
@@ -33,11 +33,11 @@ import org.apache.wss4j.dom.message.toke
/**
* This class stores various Credential types that can be validated and/or returned by a
- * Validator implementation. It also stores an optional Principal object which can provide
+ * Validator implementation. It also stores an optional Principal object which can provide
* context information to the validators.
*/
public class Credential {
-
+
private PublicKey publicKey;
private X509Certificate[] certs;
private Timestamp timestamp;
@@ -50,7 +50,7 @@ public class Credential {
private byte[] secretKey;
private Subject subject;
private Object delegationCredential;
-
+
/**
* Set a SecurityContextToken to be validated
* @param securityContextToken a SecurityContextToken to be validated
@@ -58,7 +58,7 @@ public class Credential {
public void setSecurityContextToken(SecurityContextToken securityContextToken) {
this.securityContextToken = securityContextToken;
}
-
+
/**
* Get a SecurityContextToken to be validated
* @return a SecurityContextToken to be validated
@@ -66,7 +66,7 @@ public class Credential {
public SecurityContextToken getSecurityContextToken() {
return securityContextToken;
}
-
+
/**
* Set a SecretKey (byte[]) to be validated
* @param secretKey a SecretKey (byte) to be validated
@@ -74,7 +74,7 @@ public class Credential {
public void setSecretKey(byte[] secretKey) {
this.secretKey = secretKey;
}
-
+
/**
* Get a SecretKey (byte[]) to be validated
* @return a SecretKey (byte[]) to be validated
@@ -82,8 +82,8 @@ public class Credential {
public byte[] getSecretKey() {
return secretKey;
}
-
-
+
+
/**
* Set a PublicKey to be validated
* @param publicKey a PublicKey to be validated
@@ -91,7 +91,7 @@ public class Credential {
public void setPublicKey(PublicKey publicKey) {
this.publicKey = publicKey;
}
-
+
/**
* Get a PublicKey to be validated
* @return a PublicKey to be validated
@@ -99,7 +99,7 @@ public class Credential {
public PublicKey getPublicKey() {
return publicKey;
}
-
+
/**
* Set an X509Certificate chain to be validated
* @param certs an X509Certificate chain to be validated
@@ -107,7 +107,7 @@ public class Credential {
public void setCertificates(X509Certificate[] certs) {
this.certs = certs;
}
-
+
/**
* Get an X509Certificate chain to be validated
* @return an X509Certificate chain to be validated
@@ -115,7 +115,7 @@ public class Credential {
public X509Certificate[] getCertificates() {
return certs;
}
-
+
/**
* Set a Timestamp to be validated
* @param timestamp a Timestamp to be validated
@@ -123,7 +123,7 @@ public class Credential {
public void setTimestamp(Timestamp timestamp) {
this.timestamp = timestamp;
}
-
+
/**
* Get a Timestamp to be validated
* @return a Timestamp to be validated
@@ -131,7 +131,7 @@ public class Credential {
public Timestamp getTimestamp() {
return timestamp;
}
-
+
/**
* Set a UsernameToken to be validated
* @param usernametoken a UsernameToken to be validated
@@ -139,7 +139,7 @@ public class Credential {
public void setUsernametoken(UsernameToken usernametoken) {
this.usernametoken = usernametoken;
}
-
+
/**
* Get a UsernameToken to be validated
* @return a UsernameToken to be validated
@@ -147,7 +147,7 @@ public class Credential {
public UsernameToken getUsernametoken() {
return usernametoken;
}
-
+
/**
* Set the BinarySecurityToken to be validated
* @param binarySecurityToken the BinarySecurityToken to be validated
@@ -155,7 +155,7 @@ public class Credential {
public void setBinarySecurityToken(BinarySecurity binarySecurityToken) {
this.binarySecurityToken = binarySecurityToken;
}
-
+
/**
* Get the BinarySecurityToken to be validated
* @return the BinarySecurityToken to be validated
@@ -163,7 +163,7 @@ public class Credential {
public BinarySecurity getBinarySecurityToken() {
return binarySecurityToken;
}
-
+
/**
* Set an SamlAssertionWrapper to be validated
* @param samlAssertion an SamlAssertionWrapper to be validated
@@ -171,7 +171,7 @@ public class Credential {
public void setSamlAssertion(SamlAssertionWrapper samlAssertion) {
this.samlAssertion = samlAssertion;
}
-
+
/**
* Get an SamlAssertionWrapper to be validated
* @return an SamlAssertionWrapper to be validated
@@ -179,7 +179,7 @@ public class Credential {
public SamlAssertionWrapper getSamlAssertion() {
return samlAssertion;
}
-
+
/**
* Set an SamlAssertionWrapper instance which corresponds to a Transformed Token.
* @param transformedToken a transformed SamlAssertionWrapper instance
@@ -187,7 +187,7 @@ public class Credential {
public void setTransformedToken(SamlAssertionWrapper transformedToken) {
this.transformedToken = transformedToken;
}
-
+
/**
* Get an SamlAssertionWrapper instance which corresponds to a Transformed Token.
* @return a transformed SamlAssertionWrapper instance
@@ -195,7 +195,7 @@ public class Credential {
public SamlAssertionWrapper getTransformedToken() {
return transformedToken;
}
-
+
/**
* Set the principal that supplies context information to the validators.
* @param principal the principal that supplies context information to the validators
@@ -203,7 +203,7 @@ public class Credential {
public void setPrincipal(Principal principal) {
this.principal = principal;
}
-
+
/**
* Get the principal
* @return the principal
@@ -211,7 +211,7 @@ public class Credential {
public Principal getPrincipal() {
return principal;
}
-
+
/**
* Set the subject that may result from the Validation process
* @param subject the subject that may result from the Validation process
@@ -219,7 +219,7 @@ public class Credential {
public void setSubject(Subject subject) {
this.subject = subject;
}
-
+
/**
* Get the subject that may result from the Validation process
* @return the subject that may result from the Validation process
@@ -235,5 +235,5 @@ public class Credential {
public void setDelegationCredential(Object delegationCredential) {
this.delegationCredential = delegationCredential;
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/JAASUsernameTokenValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/JAASUsernameTokenValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/JAASUsernameTokenValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/JAASUsernameTokenValidator.java Tue Dec 15 16:40:37 2015
@@ -37,30 +37,30 @@ import org.apache.wss4j.dom.message.toke
* Username/password validation is delegated to JAAS LoginContext.
*/
public class JAASUsernameTokenValidator implements Validator {
-
- private static final org.slf4j.Logger LOG =
+
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(JAASUsernameTokenValidator.class);
-
+
private String contextName;
-
+
public void setContextName(String name) {
contextName = name;
}
-
+
public String getContextName() {
return contextName;
}
-
+
/**
- * Validate the credential argument. It must contain a non-null UsernameToken. A
+ * Validate the credential argument. It must contain a non-null UsernameToken. A
* CallbackHandler implementation is also required to be set.
* Validator
- * If the password type is either digest or plaintext, it extracts a password from the
+ * If the password type is either digest or plaintext, it extracts a password from the
* CallbackHandler and then compares the passwords appropriately.
- *
+ *
* If the password is null it queries a hook to allow the user to validate UsernameTokens
- * of this type.
- *
+ * of this type.
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -69,39 +69,39 @@ public class JAASUsernameTokenValidator
if (credential == null || credential.getUsernametoken() == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCredential");
}
-
+
String user = null;
String password = null;
-
+
UsernameToken usernameToken = credential.getUsernametoken();
-
+
user = usernameToken.getName();
String pwType = usernameToken.getPasswordType();
if (LOG.isDebugEnabled()) {
LOG.debug("UsernameToken user " + usernameToken.getName());
LOG.debug("UsernameToken password type " + pwType);
}
-
+
if (usernameToken.isHashed()) {
LOG.warn("Authentication failed as hashed username token not supported");
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
}
-
+
password = usernameToken.getPassword();
-
+
if (!WSConstants.PASSWORD_TEXT.equals(pwType)) {
LOG.warn("Password type " + pwType + " not supported");
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
}
-
+
if (!(user != null && user.length() > 0 && password != null && password.length() > 0)) {
LOG.warn("User or password empty");
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
}
-
+
try {
- CallbackHandler handler = getCallbackHandler(user, password);
- LoginContext ctx = new LoginContext(getContextName(), handler);
+ CallbackHandler handler = getCallbackHandler(user, password);
+ LoginContext ctx = new LoginContext(getContextName(), handler);
ctx.login();
Subject subject = ctx.getSubject();
credential.setSubject(subject);
@@ -112,13 +112,13 @@ public class JAASUsernameTokenValidator
WSSecurityException.ErrorCode.FAILED_AUTHENTICATION, ex
);
}
-
+
return credential;
-
+
}
protected CallbackHandler getCallbackHandler(String name, String password) {
return new NamePasswordCallbackHandler(name, password);
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/KerberosTokenValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/KerberosTokenValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/KerberosTokenValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/KerberosTokenValidator.java Tue Dec 15 16:40:37 2015
@@ -122,8 +122,8 @@ public class KerberosTokenValidator impl
}
/**
- * Validate the credential argument. It must contain a non-null BinarySecurityToken.
- *
+ * Validate the credential argument. It must contain a non-null BinarySecurityToken.
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -166,7 +166,7 @@ public class KerberosTokenValidator impl
}
throw new WSSecurityException(
WSSecurityException.ErrorCode.FAILURE, ex,
- "kerberosLoginError",
+ "kerberosLoginError",
new Object[] {ex.getMessage()}
);
}
@@ -183,7 +183,7 @@ public class KerberosTokenValidator impl
Set<Principal> principals = subject.getPrincipals();
if (principals.isEmpty()) {
throw new WSSecurityException(
- WSSecurityException.ErrorCode.FAILURE,
+ WSSecurityException.ErrorCode.FAILURE,
"kerberosLoginError",
new Object[] {"No Client principals found after login"});
}
@@ -191,8 +191,8 @@ public class KerberosTokenValidator impl
}
// Validate the ticket
- KerberosServiceExceptionAction action =
- new KerberosServiceExceptionAction(token, service,
+ KerberosServiceExceptionAction action =
+ new KerberosServiceExceptionAction(token, service,
isUsernameServiceNameForm(), spnego);
KerberosServiceContext krbServiceCtx = null;
try {
@@ -220,11 +220,11 @@ public class KerberosTokenValidator impl
} else {
LOG.debug("Session key is not found in the KerberosServiceContext.");
}
-
+
// Otherwise, try to extract the session key from the token if a KerberosTokenDecoder implementation is
// available
- if (null == credential.getSecretKey() && kerberosTokenDecoder != null) {
- LOG.debug("KerberosTokenDecoder is set.Trying to obtain the session key from it.");
+ if (null == credential.getSecretKey() && kerberosTokenDecoder != null) {
+ LOG.debug("KerberosTokenDecoder is set.Trying to obtain the session key from it.");
kerberosTokenDecoder.clear();
kerberosTokenDecoder.setToken(token);
kerberosTokenDecoder.setSubject(subject);
@@ -239,7 +239,7 @@ public class KerberosTokenValidator impl
} catch (KerberosTokenDecoderException e) {
// TODO
throw new WSSecurityException(ErrorCode.FAILURE, e, "Error retrieving session key.");
- }
+ }
} else {
LOG.debug("KerberosTokenDecoder is not set.");
}
@@ -255,9 +255,9 @@ public class KerberosTokenValidator impl
* SPN can be configured to be in either <b>"hostbased"</b> or <b>"username"</b> form.<br/>
* - <b>"hostbased"</b> - specifies that the service principal name should be interpreted as a "host-based" name as specified in GSS API Rfc, section "4.1: Host-Based Service Name Form" - The service name, as it is specified in LDAP/AD, as it is listed in the KDC.<br/>
* - <b>"username"</b> - specifies that the service principal name should be interpreted as a "username" name as specified in GSS API Rfc, section "4.2: User Name Form" � This is usually the client username in LDAP/AD used for authentication to the KDC.
- *
+ *
* <br/><br/>Default is <b>"hostbased"</b>.
- *
+ *
* @return the isUsernameServiceNameForm
*/
public boolean isUsernameServiceNameForm() {
@@ -267,9 +267,9 @@ public class KerberosTokenValidator impl
/**
* If true - sets the SPN form to "username"
* <br/>If false<b>(default)</b> - the SPN form is "hostbased"
- *
+ *
* @see KerberosSecurity#retrieveServiceTicket(String, CallbackHandler, String, boolean)
- *
+ *
* @param isUsernameServiceNameForm the isUsernameServiceNameForm to set
*/
public void setUsernameServiceNameForm(boolean isUsernameServiceNameForm) {
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/NoOpValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/NoOpValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/NoOpValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/NoOpValidator.java Tue Dec 15 16:40:37 2015
@@ -27,10 +27,10 @@ import org.apache.wss4j.dom.handler.Requ
* This class does not do any Validation at all.
*/
public class NoOpValidator implements Validator {
-
+
/**
- * Validate the credential argument.
- *
+ * Validate the credential argument.
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -38,5 +38,5 @@ public class NoOpValidator implements Va
public Credential validate(Credential credential, RequestData data) throws WSSecurityException {
return credential;
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SamlAssertionValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SamlAssertionValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SamlAssertionValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SamlAssertionValidator.java Tue Dec 15 16:40:37 2015
@@ -38,60 +38,60 @@ import org.opensaml.saml.common.SAMLVers
* It assumes that the SamlAssertionWrapper instance has already verified the signature on the
* assertion (done by the SAMLTokenProcessor). It verifies trust in the signature, and also
* checks that the Subject contains a KeyInfo (and processes it) for the holder-of-key case,
- * and verifies that the Assertion is signed as well for holder-of-key.
+ * and verifies that the Assertion is signed as well for holder-of-key.
*/
public class SamlAssertionValidator extends SignatureTrustValidator {
-
- private static final org.slf4j.Logger LOG =
+
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(SamlAssertionValidator.class);
-
+
/**
- * The time in seconds in the future within which the NotBefore time of an incoming
+ * The time in seconds in the future within which the NotBefore time of an incoming
* Assertion is valid. The default is 60 seconds.
*/
private int futureTTL = 60;
-
+
/**
* The time in seconds within which a SAML Assertion is valid, if it does not contain
* a NotOnOrAfter Condition. The default is 30 minutes.
*/
private int ttl = 60 * 30;
-
+
/**
- * Whether to validate the signature of the Assertion (if it exists) against the
+ * Whether to validate the signature of the Assertion (if it exists) against the
* relevant profile. Default is true.
*/
private boolean validateSignatureAgainstProfile = true;
-
+
/**
* If this is set, then the value must appear as one of the Subject Confirmation Methods
*/
private String requiredSubjectConfirmationMethod;
-
+
/**
* If this is set, at least one of the standard Subject Confirmation Methods *must*
* be present in the assertion (Bearer / SenderVouches / HolderOfKey).
*/
private boolean requireStandardSubjectConfirmationMethod = true;
-
+
/**
* If this is set, an Assertion with a Bearer SubjectConfirmation Method must be
- * signed
+ * signed
*/
private boolean requireBearerSignature = true;
-
+
/**
- * Set the time in seconds in the future within which the NotBefore time of an incoming
+ * Set the time in seconds in the future within which the NotBefore time of an incoming
* Assertion is valid. The default is 60 seconds.
*/
public void setFutureTTL(int newFutureTTL) {
futureTTL = newFutureTTL;
}
-
+
/**
* Validate the credential argument. It must contain a non-null SamlAssertionWrapper.
* A Crypto and a CallbackHandler implementation is also required to be set.
- *
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -101,19 +101,19 @@ public class SamlAssertionValidator exte
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCredential");
}
SamlAssertionWrapper samlAssertion = credential.getSamlAssertion();
-
+
// Check the Subject Confirmation requirements
verifySubjectConfirmationMethod(samlAssertion);
-
+
// Check conditions
checkConditions(samlAssertion, data.getAudienceRestrictions());
-
+
// Check the AuthnStatements of the assertion (if any)
checkAuthnStatements(samlAssertion);
-
+
// Check OneTimeUse Condition
checkOneTimeUse(samlAssertion, data);
-
+
// Validate the assertion against schemas/profiles
validateAssertion(samlAssertion);
@@ -123,27 +123,27 @@ public class SamlAssertionValidator exte
}
return credential;
}
-
+
/**
* Check the Subject Confirmation method requirements
*/
protected void verifySubjectConfirmationMethod(
SamlAssertionWrapper samlAssertion
) throws WSSecurityException {
-
+
List<String> methods = samlAssertion.getConfirmationMethods();
if (methods == null || methods.isEmpty()) {
if (requiredSubjectConfirmationMethod != null) {
LOG.debug("A required subject confirmation method was not present");
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"invalidSAMLsecurity");
} else if (requireStandardSubjectConfirmationMethod) {
LOG.debug("A standard subject confirmation method was not present");
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"invalidSAMLsecurity");
}
}
-
+
boolean signed = samlAssertion.isSigned();
boolean requiredMethodFound = false;
boolean standardMethodFound = false;
@@ -153,7 +153,7 @@ public class SamlAssertionValidator exte
LOG.debug("There is no Subject KeyInfo to match the holder-of-key subject conf method");
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noKeyInSAMLToken");
}
-
+
// The assertion must have been signed for HOK
if (!signed) {
LOG.debug("A holder-of-key assertion must be signed");
@@ -161,7 +161,7 @@ public class SamlAssertionValidator exte
}
standardMethodFound = true;
}
-
+
if (method != null) {
if (method.equals(requiredSubjectConfirmationMethod)) {
requiredMethodFound = true;
@@ -171,7 +171,7 @@ public class SamlAssertionValidator exte
standardMethodFound = true;
if (requireBearerSignature && !signed) {
LOG.debug("A Bearer Assertion was not signed");
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"invalidSAMLsecurity");
}
} else if (SAML2Constants.CONF_SENDER_VOUCHES.equals(method)
@@ -180,20 +180,20 @@ public class SamlAssertionValidator exte
}
}
}
-
+
if (!requiredMethodFound && requiredSubjectConfirmationMethod != null) {
LOG.debug("A required subject confirmation method was not present");
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"invalidSAMLsecurity");
}
-
+
if (!standardMethodFound && requireStandardSubjectConfirmationMethod) {
LOG.debug("A standard subject confirmation method was not present");
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE,
"invalidSAMLsecurity");
}
}
-
+
/**
* Verify trust in the signature of a signed Assertion. This method is separate so that
* the user can override if if they want.
@@ -212,7 +212,7 @@ public class SamlAssertionValidator exte
trustCredential.setCertificates(samlKeyInfo.getCerts());
return super.validate(trustCredential, data);
}
-
+
/**
* Check the Conditions of the Assertion.
*/
@@ -222,7 +222,7 @@ public class SamlAssertionValidator exte
checkConditions(samlAssertion);
samlAssertion.checkAudienceRestrictions(audienceRestrictions);
}
-
+
/**
* Check the Conditions of the Assertion.
*/
@@ -230,14 +230,14 @@ public class SamlAssertionValidator exte
samlAssertion.checkConditions(futureTTL);
samlAssertion.checkIssueInstant(futureTTL, ttl);
}
-
+
/**
* Check the AuthnStatements of the Assertion (if any)
*/
protected void checkAuthnStatements(SamlAssertionWrapper samlAssertion) throws WSSecurityException {
samlAssertion.checkAuthnStatements(futureTTL);
}
-
+
/**
* Check the "OneTimeUse" Condition of the Assertion. If this is set then the Assertion
* is cached (if a cache is defined), and must not have been previously cached
@@ -250,7 +250,7 @@ public class SamlAssertionValidator exte
&& samlAssertion.getSaml2().getConditions().getOneTimeUse() != null
&& data.getSamlOneTimeUseReplayCache() != null) {
String identifier = samlAssertion.getId();
-
+
ReplayCache replayCache = data.getSamlOneTimeUseReplayCache();
if (replayCache.contains(identifier)) {
throw new WSSecurityException(
@@ -258,7 +258,7 @@ public class SamlAssertionValidator exte
"badSamlToken",
new Object[] {"A replay attack has been detected"});
}
-
+
DateTime expires = samlAssertion.getSaml2().getConditions().getNotOnOrAfter();
if (expires != null) {
Date rightNow = new Date();
@@ -268,11 +268,11 @@ public class SamlAssertionValidator exte
} else {
replayCache.add(identifier);
}
-
+
replayCache.add(identifier);
}
}
-
+
/**
* Validate the samlAssertion against schemas/profiles
*/
@@ -283,7 +283,7 @@ public class SamlAssertionValidator exte
}
/**
- * Whether to validate the signature of the Assertion (if it exists) against the
+ * Whether to validate the signature of the Assertion (if it exists) against the
* relevant profile. Default is true.
*/
public boolean isValidateSignatureAgainstProfile() {
@@ -291,7 +291,7 @@ public class SamlAssertionValidator exte
}
/**
- * Whether to validate the signature of the Assertion (if it exists) against the
+ * Whether to validate the signature of the Assertion (if it exists) against the
* relevant profile. Default is true.
*/
public void setValidateSignatureAgainstProfile(boolean validateSignatureAgainstProfile) {
@@ -321,7 +321,7 @@ public class SamlAssertionValidator exte
public void setRequireBearerSignature(boolean requireBearerSignature) {
this.requireBearerSignature = requireBearerSignature;
}
-
+
public int getTtl() {
return ttl;
}
@@ -329,5 +329,5 @@ public class SamlAssertionValidator exte
public void setTtl(int ttl) {
this.ttl = ttl;
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SignatureTrustValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SignatureTrustValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SignatureTrustValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/SignatureTrustValidator.java Tue Dec 15 16:40:37 2015
@@ -33,17 +33,17 @@ import org.apache.wss4j.dom.handler.Requ
* from the Credential passed to the validate method.
*/
public class SignatureTrustValidator implements Validator {
-
- private static final org.slf4j.Logger LOG =
+
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(SignatureTrustValidator.class);
-
+
/**
* Validate the credential argument. It must contain a non-null X509Certificate chain
* or a PublicKey. A Crypto implementation is also required to be set.
- *
+ *
* This implementation first attempts to verify trust on the certificate (chain). If
* this is not successful, then it will attempt to verify trust on the Public Key.
- *
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -58,7 +58,7 @@ public class SignatureTrustValidator imp
if (crypto == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noSigCryptoFile");
}
-
+
if (certs != null && certs.length > 0) {
validateCertificates(certs);
verifyTrustInCerts(certs, crypto, data, data.isRevocationEnabled());
@@ -80,14 +80,14 @@ public class SignatureTrustValidator imp
* Validate the certificates by checking the validity of each cert
* @throws WSSecurityException
*/
- protected void validateCertificates(X509Certificate[] certificates)
+ protected void validateCertificates(X509Certificate[] certificates)
throws WSSecurityException {
// Nothing
}
-
+
/**
* Evaluate whether the given certificate chain should be trusted.
- *
+ *
* @param certificates the certificate chain that should be validated against the keystore
* @param crypto A Crypto instance
* @param data A RequestData instance
@@ -95,13 +95,13 @@ public class SignatureTrustValidator imp
* @throws WSSecurityException if the certificate chain is not trusted
*/
protected void verifyTrustInCerts(
- X509Certificate[] certificates,
+ X509Certificate[] certificates,
Crypto crypto,
RequestData data,
boolean enableRevocation
) throws WSSecurityException {
//
- // Use the validation method from the crypto to check whether the subjects'
+ // Use the validation method from the crypto to check whether the subjects'
// certificate was really signed by the issuer stated in the certificate
//
Collection<Pattern> subjectCertConstraints = data.getSubjectCertConstraints();
@@ -113,14 +113,14 @@ public class SignatureTrustValidator imp
);
}
}
-
+
/**
* Validate a public key
* @throws WSSecurityException
*/
- protected void validatePublicKey(PublicKey publicKey, Crypto crypto)
+ protected void validatePublicKey(PublicKey publicKey, Crypto crypto)
throws WSSecurityException {
crypto.verifyTrust(publicKey);
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/TimestampValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/TimestampValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/TimestampValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/TimestampValidator.java Tue Dec 15 16:40:37 2015
@@ -29,10 +29,10 @@ import org.apache.wss4j.dom.message.toke
* the validate method.
*/
public class TimestampValidator implements Validator {
-
+
/**
* Validate the credential argument. It must contain a non-null Timestamp.
- *
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -42,15 +42,15 @@ public class TimestampValidator implemen
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCredential");
}
if (data.getWssConfig() == null) {
- throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
+ throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "empty",
new Object[] {"WSSConfig cannot be null"});
}
boolean timeStampStrict = data.isTimeStampStrict();
int timeStampTTL = data.getTimeStampTTL();
int futureTimeToLive = data.getTimeStampFutureTTL();
-
+
Timestamp timeStamp = credential.getTimestamp();
-
+
// See if the Timestamp has expired
if (timeStampStrict && timeStamp.isExpired()) {
throw new WSSecurityException(
@@ -58,7 +58,7 @@ public class TimestampValidator implemen
"invalidTimestamp",
new Object[] {"The message timestamp has expired"});
}
-
+
// Validate the Created date
if (!timeStamp.verifyCreated(timeStampTTL, futureTimeToLive)) {
throw new WSSecurityException(
@@ -66,7 +66,7 @@ public class TimestampValidator implemen
"invalidTimestamp",
new Object[] {"The message timestamp is out of range"});
}
-
+
if (data.isRequireTimestampExpires() && timeStamp.getExpires() == null) {
throw new WSSecurityException(
WSSecurityException.ErrorCode.SECURITY_ERROR,
@@ -75,7 +75,7 @@ public class TimestampValidator implemen
}
return credential;
}
-
-
+
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/UsernameTokenValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/UsernameTokenValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/UsernameTokenValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/UsernameTokenValidator.java Tue Dec 15 16:40:37 2015
@@ -37,20 +37,20 @@ import org.apache.xml.security.utils.Bas
* the validate method.
*/
public class UsernameTokenValidator implements Validator {
-
- private static final org.slf4j.Logger LOG =
+
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(UsernameTokenValidator.class);
-
+
/**
- * Validate the credential argument. It must contain a non-null UsernameToken. A
+ * Validate the credential argument. It must contain a non-null UsernameToken. A
* CallbackHandler implementation is also required to be set.
- *
- * If the password type is either digest or plaintext, it extracts a password from the
+ *
+ * If the password type is either digest or plaintext, it extracts a password from the
* CallbackHandler and then compares the passwords appropriately.
- *
+ *
* If the password is null it queries a hook to allow the user to validate UsernameTokens
- * of this type.
- *
+ * of this type.
+ *
* @param credential the Credential to be validated
* @param data the RequestData associated with the request
* @throws WSSecurityException on a failed validation
@@ -59,28 +59,28 @@ public class UsernameTokenValidator impl
if (credential == null || credential.getUsernametoken() == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCredential");
}
-
+
boolean handleCustomPasswordTypes = data.isHandleCustomPasswordTypes();
boolean passwordsAreEncoded = data.isEncodePasswords();
String requiredPasswordType = data.getRequiredPasswordType();
-
+
UsernameToken usernameToken = credential.getUsernametoken();
usernameToken.setPasswordsAreEncoded(passwordsAreEncoded);
-
+
String pwType = usernameToken.getPasswordType();
if (LOG.isDebugEnabled()) {
LOG.debug("UsernameToken user " + usernameToken.getName());
LOG.debug("UsernameToken password type " + pwType);
}
-
+
if (requiredPasswordType != null && !requiredPasswordType.equals(pwType)) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Authentication failed as the received password type does not "
+ LOG.debug("Authentication failed as the received password type does not "
+ "match the required password type of: " + requiredPasswordType);
}
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
}
-
+
//
// If the UsernameToken is hashed or plaintext, then retrieve the password from the
// callback handler and compare directly. If the UsernameToken is of some unknown type,
@@ -105,13 +105,13 @@ public class UsernameTokenValidator impl
}
return credential;
}
-
+
/**
* Verify a UsernameToken containing a password of some unknown (but specified) password
* type. It does this by querying a CallbackHandler instance to obtain a password for the
* given username, and then comparing it against the received password.
* This method currently uses the same LOG.c as the verifyPlaintextPassword case, but it in
- * a separate protected method to allow users to override the validation of the custom
+ * a separate protected method to allow users to override the validation of the custom
* password type specific case.
* @param usernameToken The UsernameToken instance to verify
* @throws WSSecurityException on a failed authentication.
@@ -120,13 +120,13 @@ public class UsernameTokenValidator impl
RequestData data) throws WSSecurityException {
verifyPlaintextPassword(usernameToken, data);
}
-
+
/**
- * Verify a UsernameToken containing a plaintext password. It does this by querying a
+ * Verify a UsernameToken containing a plaintext password. It does this by querying a
* CallbackHandler instance to obtain a password for the given username, and then comparing
* it against the received password.
* This method currently uses the same LOG.c as the verifyDigestPassword case, but it in
- * a separate protected method to allow users to override the validation of the plaintext
+ * a separate protected method to allow users to override the validation of the plaintext
* password specific case.
* @param usernameToken The UsernameToken instance to verify
* @throws WSSecurityException on a failed authentication.
@@ -135,9 +135,9 @@ public class UsernameTokenValidator impl
RequestData data) throws WSSecurityException {
verifyDigestPassword(usernameToken, data);
}
-
+
/**
- * Verify a UsernameToken containing a password digest. It does this by querying a
+ * Verify a UsernameToken containing a password digest. It does this by querying a
* CallbackHandler instance to obtain a password for the given username, and then comparing
* it against the received password.
* @param usernameToken The UsernameToken instance to verify
@@ -148,15 +148,15 @@ public class UsernameTokenValidator impl
if (data.getCallbackHandler() == null) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "noCallback");
}
-
+
String user = usernameToken.getName();
String password = usernameToken.getPassword();
String nonce = usernameToken.getNonce();
String createdTime = usernameToken.getCreated();
String pwType = usernameToken.getPasswordType();
boolean passwordsAreEncoded = usernameToken.getPasswordsAreEncoded();
-
- WSPasswordCallback pwCb =
+
+ WSPasswordCallback pwCb =
new WSPasswordCallback(user, null, pwType, WSPasswordCallback.USERNAME_TOKEN);
try {
data.getCallbackHandler().handle(new Callback[]{pwCb});
@@ -197,7 +197,7 @@ public class UsernameTokenValidator impl
}
}
}
-
+
/**
* Verify a UsernameToken containing no password. An exception is thrown unless the user
* has explicitly allowed this use-case via WSHandlerConstants.ALLOW_USERNAMETOKEN_NOPASSWORD
@@ -206,7 +206,7 @@ public class UsernameTokenValidator impl
*/
protected void verifyUnknownPassword(UsernameToken usernameToken,
RequestData data) throws WSSecurityException {
-
+
boolean allowUsernameTokenDerivedKeys = data.isAllowUsernameTokenNoPassword();
if (!allowUsernameTokenDerivedKeys) {
if (LOG.isDebugEnabled()) {
@@ -216,5 +216,5 @@ public class UsernameTokenValidator impl
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILED_AUTHENTICATION);
}
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Validator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Validator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Validator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/main/java/org/apache/wss4j/dom/validate/Validator.java Tue Dec 15 16:40:37 2015
@@ -28,7 +28,7 @@ import org.apache.wss4j.dom.handler.Requ
* by the processors.
*/
public interface Validator {
-
+
/**
* Validate the credential argument. This method returns a Credential instance that
* represents the validated credential. This instance can be the same as the instance
@@ -40,6 +40,6 @@ public interface Validator {
* @throws WSSecurityException on a failed validation
*/
Credential validate(Credential credential, RequestData data) throws WSSecurityException;
-
-
+
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/AbstractSAMLCallbackHandler.java Tue Dec 15 16:40:37 2015
@@ -52,11 +52,11 @@ import java.util.List;
* authentication assertion.
*/
public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
-
+
public enum Statement {
AUTHN, ATTR, AUTHZ
}
-
+
protected String subjectName = null;
protected String subjectQualifier = null;
protected String confirmationMethod = null;
@@ -87,64 +87,64 @@ public abstract class AbstractSAMLCallba
private String issuerName;
private String issuerPassword;
private Element assertionAdviceElement;
-
+
public void setSubjectConfirmationData(SubjectConfirmationDataBean subjectConfirmationData) {
this.subjectConfirmationData = subjectConfirmationData;
}
-
+
public void setConditions(ConditionsBean conditionsBean) {
this.conditions = conditionsBean;
}
-
+
public void setConfirmationMethod(String confMethod) {
confirmationMethod = confMethod;
}
-
+
public void setSessionNotOnOrAfter(DateTime sessionNotOnOrAfter) {
this.sessionNotOnOrAfter = sessionNotOnOrAfter;
}
-
+
public void setStatement(Statement statement) {
this.statement = statement;
}
-
+
public void setCertIdentifier(CERT_IDENTIFIER certIdentifier) {
this.certIdentifier = certIdentifier;
}
-
+
public void setCerts(X509Certificate[] certs) {
this.certs = certs;
}
-
+
public byte[] getEphemeralKey() {
return ephemeralKey;
}
-
+
public void setIssuer(String issuer) {
this.issuer = issuer;
}
-
+
public void setIssuerFormat(String issuerFormat) {
this.issuerFormat = issuerFormat;
}
-
+
public void setSubjectNameIDFormat(String subjectNameIDFormat) {
this.subjectNameIDFormat = subjectNameIDFormat;
}
-
+
public void setSubjectLocality(String ipAddress, String dnsAddress) {
this.subjectLocalityIpAddress = ipAddress;
this.subjectLocalityDnsAddress = dnsAddress;
}
-
+
public void setResource(String resource) {
this.resource = resource;
}
-
+
public void setCustomAttributeValues(List<Object> customAttributeValues) {
this.customAttributeValues = customAttributeValues;
}
-
+
/**
* Note that the SubjectBean parameter should be null for SAML2.0
*/
@@ -175,7 +175,7 @@ public abstract class AbstractSAMLCallba
attributeBean.setQualifiedName("role");
}
if (customAttributeValues != null) {
- attributeBean.setAttributeValues(customAttributeValues);
+ attributeBean.setAttributeValues(customAttributeValues);
} else {
List<Object> attributes = new ArrayList<>();
attributes.add("user");
@@ -197,7 +197,7 @@ public abstract class AbstractSAMLCallba
callback.setAuthDecisionStatementData(Collections.singletonList(authzBean));
}
}
-
+
protected KeyInfoBean createKeyInfo() throws Exception {
KeyInfoBean keyInfo = new KeyInfoBean();
if (statement == Statement.AUTHN) {
@@ -205,12 +205,12 @@ public abstract class AbstractSAMLCallba
keyInfo.setCertIdentifer(certIdentifier);
} else if (statement == Statement.ATTR) {
// Build a new Document
- DocumentBuilderFactory docBuilderFactory =
+ DocumentBuilderFactory docBuilderFactory =
DocumentBuilderFactory.newInstance();
docBuilderFactory.setNamespaceAware(true);
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
-
+
// Create an Encrypted Key
WSSecEncryptedKey encrKey = new WSSecEncryptedKey();
encrKey.setKeyIdentifierType(WSConstants.ISSUER_SERIAL);
@@ -218,9 +218,9 @@ public abstract class AbstractSAMLCallba
encrKey.prepare(doc, null);
ephemeralKey = encrKey.getEphemeralKey();
Element encryptedKeyElement = encrKey.getEncryptedKeyElement();
-
+
// Append the EncryptedKey to a KeyInfo element
- Element keyInfoElement =
+ Element keyInfoElement =
doc.createElementNS(
WSConstants.SIG_NS, WSConstants.SIG_PREFIX + ":" + WSConstants.KEYINFO_LN
);
@@ -228,7 +228,7 @@ public abstract class AbstractSAMLCallba
WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS
);
keyInfoElement.appendChild(encryptedKeyElement);
-
+
keyInfo.setElement(keyInfoElement);
}
return keyInfo;
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CombinedCallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CombinedCallbackHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CombinedCallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CombinedCallbackHandler.java Tue Dec 15 16:40:37 2015
@@ -28,21 +28,21 @@ import javax.security.auth.callback.Unsu
import org.apache.wss4j.common.ext.WSPasswordCallback;
/**
- * A combined Callback Handler implementation which wraps the SecretKeyCallbackHandler and the
+ * A combined Callback Handler implementation which wraps the SecretKeyCallbackHandler and the
* KeystoreCallbackHandler.
*/
public class CombinedCallbackHandler implements CallbackHandler {
-
+
private final CallbackHandler secretCallbackHandler;
private final CallbackHandler keystoreCallbackHandler;
-
+
public CombinedCallbackHandler(
CallbackHandler secretCallbackHandler, CallbackHandler keystoreCallbackHandler
) {
this.secretCallbackHandler = secretCallbackHandler;
this.keystoreCallbackHandler = keystoreCallbackHandler;
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomAction.java Tue Dec 15 16:40:37 2015
@@ -29,10 +29,10 @@ import org.apache.wss4j.dom.handler.Requ
* a custom action that leaves a breadcumb
*/
public class CustomAction implements Action {
-
- public void
+
+ public void
execute(
- WSHandler handler,
+ WSHandler handler,
SecurityActionToken action,
org.w3c.dom.Document doc,
RequestData reqData
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomCrypto.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomCrypto.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomCrypto.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomCrypto.java Tue Dec 15 16:40:37 2015
@@ -22,9 +22,9 @@ package org.apache.wss4j.dom.common;
import org.apache.wss4j.common.crypto.Merlin;
public class CustomCrypto extends Merlin {
-
+
private java.util.Map<String, Object> config = null;
-
+
public
CustomCrypto(
java.util.Map<String, Object> config,
@@ -33,7 +33,7 @@ public class CustomCrypto extends Merlin
this.config = config;
}
- public String
+ public String
getDefaultX509Alias() {
return null;
}
@@ -41,7 +41,7 @@ public class CustomCrypto extends Merlin
public String getCryptoProvider() {
return null;
}
-
+
public java.util.Map<String, Object> getConfig() {
return config;
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomHandler.java Tue Dec 15 16:40:37 2015
@@ -36,30 +36,30 @@ import java.util.Map;
* A trivial extension of the WSHandler type for use in unit-testing.
*/
public class CustomHandler extends WSHandler {
-
+
private Map<String, Object> optionsMap = new HashMap<>();
- public Object
+ public Object
getOption(String key) {
return optionsMap.get(key);
}
-
+
public void
setOption(String key, Object option) {
optionsMap.put(key, option);
}
@SuppressWarnings("unchecked")
- public void
+ public void
setProperty(
- Object ctx,
- String key,
+ Object ctx,
+ String key,
Object value
) {
((Map<String, Object>)ctx).put(key, value);
}
- public Object
+ public Object
getProperty(Object ctx, String key) {
if (ctx instanceof Map<?,?>) {
return ((Map<?,?>)ctx).get(key);
@@ -67,11 +67,11 @@ public class CustomHandler extends WSHan
return null;
}
- public void
+ public void
setPassword(Object msgContext, String password) {
}
- public String
+ public String
getPassword(Object msgContext) {
if (msgContext instanceof Map<?,?>) {
return (String)((Map<?,?>)msgContext).get("password");
@@ -81,24 +81,24 @@ public class CustomHandler extends WSHan
public void send(
Document doc,
- RequestData reqData,
+ RequestData reqData,
List<HandlerAction> actions,
boolean request
) throws WSSecurityException {
doSenderAction(
- doc,
- reqData,
+ doc,
+ reqData,
actions,
request
);
}
-
+
public void receive(
- List<Integer> actions,
+ List<Integer> actions,
RequestData reqData
) throws WSSecurityException {
doReceiverAction(
- actions,
+ actions,
reqData
);
}
@@ -109,7 +109,7 @@ public class CustomHandler extends WSHan
) throws WSSecurityException {
checkSignatureConfirmation(requestData, handlerResults);
}
-
+
public boolean checkResults(
List<WSSecurityEngineResult> results,
List<Integer> actions
@@ -123,6 +123,6 @@ public class CustomHandler extends WSHan
) throws WSSecurityException {
return checkReceiverResultsAnyOrder(results, actions);
}
-
-
+
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomProcessor.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomProcessor.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomProcessor.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomProcessor.java Tue Dec 15 16:40:37 2015
@@ -30,14 +30,14 @@ import org.apache.wss4j.dom.engine.WSSec
* a custom processor that inserts itself into the results list
*/
public class CustomProcessor implements Processor {
-
- public final java.util.List<WSSecurityEngineResult>
+
+ public final java.util.List<WSSecurityEngineResult>
handleToken(
- final org.w3c.dom.Element elem,
+ final org.w3c.dom.Element elem,
final RequestData data,
- final WSDocInfo wsDocInfo
+ final WSDocInfo wsDocInfo
) throws WSSecurityException {
- final WSSecurityEngineResult result =
+ final WSSecurityEngineResult result =
new WSSecurityEngineResult(WSConstants.UT_SIGN);
result.put("foo", this);
return java.util.Collections.singletonList(result);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomSamlAssertionValidator.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomSamlAssertionValidator.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomSamlAssertionValidator.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/CustomSamlAssertionValidator.java Tue Dec 15 16:40:37 2015
@@ -26,11 +26,11 @@ import org.apache.wss4j.dom.validate.Cre
import org.apache.wss4j.dom.validate.SamlAssertionValidator;
public class CustomSamlAssertionValidator extends SamlAssertionValidator {
-
+
@Override
public Credential validate(Credential credential, RequestData data) throws WSSecurityException {
Credential returnedCredential = super.validate(credential, data);
-
+
//
// Do some custom validation on the assertion
//
@@ -44,12 +44,12 @@ public class CustomSamlAssertionValidato
org.opensaml.saml.saml1.core.Subject samlSubject = null;
for (org.opensaml.saml.saml1.core.Statement stmt : saml1Assertion.getStatements()) {
if (stmt instanceof org.opensaml.saml.saml1.core.AttributeStatement) {
- org.opensaml.saml.saml1.core.AttributeStatement attrStmt =
+ org.opensaml.saml.saml1.core.AttributeStatement attrStmt =
(org.opensaml.saml.saml1.core.AttributeStatement) stmt;
samlSubject = attrStmt.getSubject();
break;
} else if (stmt instanceof org.opensaml.saml.saml1.core.AuthenticationStatement) {
- org.opensaml.saml.saml1.core.AuthenticationStatement authStmt =
+ org.opensaml.saml.saml1.core.AuthenticationStatement authStmt =
(org.opensaml.saml.saml1.core.AuthenticationStatement) stmt;
samlSubject = authStmt.getSubject();
break;
@@ -59,10 +59,10 @@ public class CustomSamlAssertionValidato
samlSubject = authzStmt.getSubject();
}
}
-
+
if (samlSubject == null) {
throw new WSSecurityException(
- WSSecurityException.ErrorCode.FAILURE, "invalidSAMLToken",
+ WSSecurityException.ErrorCode.FAILURE, "invalidSAMLToken",
new Object[] {"for Signature (no Subject)"}
);
}
@@ -78,8 +78,8 @@ public class CustomSamlAssertionValidato
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE, "invalidSAMLsecurity");
}
}
-
+
return returnedCredential;
}
-
+
}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/EncodedPasswordCallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/EncodedPasswordCallbackHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/EncodedPasswordCallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/EncodedPasswordCallbackHandler.java Tue Dec 15 16:40:37 2015
@@ -32,7 +32,7 @@ import java.io.IOException;
* encoded password.
*/
public class EncodedPasswordCallbackHandler implements CallbackHandler {
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/KeystoreCallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/KeystoreCallbackHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/KeystoreCallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/KeystoreCallbackHandler.java Tue Dec 15 16:40:37 2015
@@ -30,13 +30,13 @@ import java.util.HashMap;
import java.util.Map;
/**
- * A Callback Handler implementation for the case of finding a password to access a
+ * A Callback Handler implementation for the case of finding a password to access a
* cert/private key in a keystore.
*/
public class KeystoreCallbackHandler implements CallbackHandler {
-
+
private Map<String, String> users = new HashMap<>();
-
+
public KeystoreCallbackHandler() {
users.put("wss86", "security");
users.put("wss40", "security");
@@ -44,7 +44,7 @@ public class KeystoreCallbackHandler imp
users.put("16c73ab6-b892-458f-abf5-2f875f74882e", "security");
users.put("regexp", "security");
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1AuthnHOKHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1AuthnHOKHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1AuthnHOKHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1AuthnHOKHandler.java Tue Dec 15 16:40:37 2015
@@ -43,25 +43,25 @@ import java.util.Collections;
* Holder of Key.
*/
public class SAML1AuthnHOKHandler implements CallbackHandler {
-
+
private String subjectName = "uid=joe,ou=people,ou=saml-demo,o=example.com";
private String subjectQualifier = "www.example.com";
private X509Certificate[] certs;
-
+
public SAML1AuthnHOKHandler() throws WSSecurityException {
Crypto crypto = CryptoFactory.getInstance("wss40.properties");
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias("wss40");
certs = crypto.getX509Certificates(cryptoType);
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof SAMLCallback) {
SAMLCallback callback = (SAMLCallback) callbacks[i];
callback.setSamlVersion(Version.SAML_11);
- SubjectBean subjectBean =
+ SubjectBean subjectBean =
new SubjectBean(
subjectName, subjectQualifier, SAML1Constants.CONF_HOLDER_KEY
);
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1CallbackHandler.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1CallbackHandler.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1CallbackHandler.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/common/SAML1CallbackHandler.java Tue Dec 15 16:40:37 2015
@@ -39,7 +39,7 @@ import java.io.IOException;
* authentication assertion using Sender Vouches.
*/
public class SAML1CallbackHandler extends AbstractSAMLCallbackHandler {
-
+
public SAML1CallbackHandler() throws Exception {
if (certs == null) {
Crypto crypto = CryptoFactory.getInstance("wss40.properties");
@@ -47,13 +47,13 @@ public class SAML1CallbackHandler extend
cryptoType.setAlias("wss40");
certs = crypto.getX509Certificates(cryptoType);
}
-
+
subjectName = "uid=joe,ou=people,ou=saml-demo,o=example.com";
subjectQualifier = "www.example.com";
confirmationMethod = SAML1Constants.CONF_SENDER_VOUCHES;
issuer = "www.example.com";
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
@@ -67,14 +67,14 @@ public class SAML1CallbackHandler extend
callback.setIssuerCrypto(getIssuerCrypto());
callback.setIssuerKeyName(getIssuerName());
callback.setIssuerKeyPassword(getIssuerPassword());
-
+
if (getAssertionAdviceElement() != null) {
AdviceBean advice = new AdviceBean();
advice.getAssertions().add(getAssertionAdviceElement());
callback.setAdvice(advice);
}
-
- SubjectBean subjectBean =
+
+ SubjectBean subjectBean =
new SubjectBean(
subjectName, subjectQualifier, confirmationMethod
);
@@ -95,5 +95,5 @@ public class SAML1CallbackHandler extend
}
}
}
-
+
}