You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by co...@apache.org on 2017/02/13 11:36:32 UTC
[16/18] cxf-fediz git commit: Whitespace cleanup
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/samlsso/SamlpRequestComponentBuilder.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/samlsso/SamlpRequestComponentBuilder.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/samlsso/SamlpRequestComponentBuilder.java
index 342f404..b56d558 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/samlsso/SamlpRequestComponentBuilder.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/samlsso/SamlpRequestComponentBuilder.java
@@ -42,27 +42,27 @@ import org.opensaml.saml.saml2.core.SessionIndex;
* A set of utility methods to construct SAMLP Request statements
*/
public final class SamlpRequestComponentBuilder {
-
+
private static volatile SAMLObjectBuilder<AuthnRequest> authnRequestBuilder;
-
+
private static volatile SAMLObjectBuilder<LogoutRequest> logoutRequestBuilder;
-
+
private static volatile SAMLObjectBuilder<SessionIndex> sessionIndexBuilder;
-
+
private static volatile SAMLObjectBuilder<Issuer> issuerBuilder;
-
+
private static volatile SAMLObjectBuilder<NameIDPolicy> nameIDBuilder;
-
+
private static volatile SAMLObjectBuilder<RequestedAuthnContext> requestedAuthnCtxBuilder;
-
+
private static volatile SAMLObjectBuilder<AuthnContextClassRef> requestedAuthnCtxClassRefBuilder;
-
- private static volatile XMLObjectBuilderFactory builderFactory =
+
+ private static volatile XMLObjectBuilderFactory builderFactory =
XMLObjectProviderRegistrySupport.getBuilderFactory();
-
+
private SamlpRequestComponentBuilder() {
}
-
+
@SuppressWarnings("unchecked")
//CHECKSTYLE:OFF
public static AuthnRequest createAuthnRequest(
@@ -75,7 +75,7 @@ public final class SamlpRequestComponentBuilder {
NameIDPolicy nameIDPolicy,
RequestedAuthnContext requestedAuthnCtx
) {
- //CHECKSTYLE:ON
+ //CHECKSTYLE:ON
if (authnRequestBuilder == null) {
authnRequestBuilder = (SAMLObjectBuilder<AuthnRequest>)
builderFactory.getBuilder(AuthnRequest.DEFAULT_ELEMENT_NAME);
@@ -88,14 +88,14 @@ public final class SamlpRequestComponentBuilder {
authnRequest.setIssueInstant(new DateTime());
authnRequest.setProtocolBinding(protocolBinding);
authnRequest.setVersion(version);
-
+
authnRequest.setIssuer(issuer);
authnRequest.setNameIDPolicy(nameIDPolicy);
authnRequest.setRequestedAuthnContext(requestedAuthnCtx);
-
+
return authnRequest;
}
-
+
@SuppressWarnings("unchecked")
public static LogoutRequest createLogoutRequest(
Issuer issuer,
@@ -111,19 +111,19 @@ public final class SamlpRequestComponentBuilder {
sessionIndexBuilder = (SAMLObjectBuilder<SessionIndex>)
builderFactory.getBuilder(SessionIndex.DEFAULT_ELEMENT_NAME);
}
-
+
LogoutRequest logoutRequest = logoutRequestBuilder.buildObject();
-
+
logoutRequest.setID(UUID.randomUUID().toString());
logoutRequest.setIssueInstant(new DateTime());
-
+
if (reason != null) {
logoutRequest.setReason(reason);
}
if (nameId != null) {
logoutRequest.setNameID(nameId);
}
-
+
if (sessionIndices != null && !sessionIndices.isEmpty()) {
for (String sessionIndex : sessionIndices) {
SessionIndex sessionIndexObj = sessionIndexBuilder.buildObject();
@@ -136,7 +136,7 @@ public final class SamlpRequestComponentBuilder {
return logoutRequest;
}
-
+
@SuppressWarnings("unchecked")
public static Issuer createIssuer(
String issuerValue
@@ -147,10 +147,10 @@ public final class SamlpRequestComponentBuilder {
}
Issuer issuer = issuerBuilder.buildObject();
issuer.setValue(issuerValue);
-
+
return issuer;
}
-
+
@SuppressWarnings("unchecked")
public static NameIDPolicy createNameIDPolicy(
boolean allowCreate,
@@ -165,10 +165,10 @@ public final class SamlpRequestComponentBuilder {
nameId.setAllowCreate(allowCreate);
nameId.setFormat(format);
nameId.setSPNameQualifier(spNameQualifier);
-
+
return nameId;
}
-
+
@SuppressWarnings("unchecked")
public static RequestedAuthnContext createRequestedAuthnCtxPolicy(
AuthnContextComparisonTypeEnumeration comparison,
@@ -181,20 +181,20 @@ public final class SamlpRequestComponentBuilder {
}
RequestedAuthnContext authnCtx = requestedAuthnCtxBuilder.buildObject();
authnCtx.setComparison(comparison);
-
+
if (authnCtxClassRefList != null) {
List<AuthnContextClassRef> classRefList = authnCtx.getAuthnContextClassRefs();
classRefList.addAll(authnCtxClassRefList);
}
-
+
if (authnCtxDeclRefList != null) {
List<AuthnContextDeclRef> declRefList = authnCtx.getAuthnContextDeclRefs();
declRefList.addAll(authnCtxDeclRefList);
}
-
+
return authnCtx;
}
-
+
@SuppressWarnings("unchecked")
public static AuthnContextClassRef createAuthnCtxClassRef(
String authnCtxClassRefValue
@@ -205,8 +205,8 @@ public final class SamlpRequestComponentBuilder {
}
AuthnContextClassRef authnCtxClassRef = requestedAuthnCtxClassRefBuilder.buildObject();
authnCtxClassRef.setAuthnContextClassRef(authnCtxClassRefValue);
-
+
return authnCtxClassRef;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CertsUtils.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CertsUtils.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CertsUtils.java
index 24d6be1..f1a2882 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CertsUtils.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CertsUtils.java
@@ -43,13 +43,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class CertsUtils {
-
+
private static final Logger LOG = LoggerFactory.getLogger(CertsUtils.class);
-
+
private CertsUtils() {
super();
}
-
+
/**
* Load an X.509 Certificate from a certificate file
*/
@@ -57,16 +57,16 @@ public final class CertsUtils {
return getX509CertificateFromFile(filename,
Thread.currentThread().getContextClassLoader());
}
-
+
/**
* Load an X.509 Certificate from a certificate file
*/
- public static X509Certificate getX509CertificateFromFile(String filename, ClassLoader classLoader)
+ public static X509Certificate getX509CertificateFromFile(String filename, ClassLoader classLoader)
throws CertificateException {
if (filename == null) {
return null;
}
-
+
ClassLoader cl = classLoader;
if (cl == null) {
cl = Thread.currentThread().getContextClassLoader();
@@ -87,7 +87,7 @@ public final class CertsUtils {
if (bis.available() > 0) {
LOG.warn("There are more certificates configured in " + filename + ". Only first is parsed");
}
- return (X509Certificate)cert;
+ return (X509Certificate)cert;
} else {
LOG.error("No bytes can be read in certificate file " + filename);
throw new RuntimeException("No bytes can be read in certificate file " + filename);
@@ -100,20 +100,20 @@ public final class CertsUtils {
throw new RuntimeException("Failed to read keystore");
}
}
-
+
/**
* Load an X.509 Certificate from a WSS4J Crypto instance using a keystore alias
*/
- public static X509Certificate getX509CertificateFromCrypto(Crypto crypto, String keyAlias)
+ public static X509Certificate getX509CertificateFromCrypto(Crypto crypto, String keyAlias)
throws WSSecurityException {
if (keyAlias == null || "".equals(keyAlias)) {
keyAlias = crypto.getDefaultX509Identifier();
}
-
+
if (keyAlias == null) {
throw new RuntimeException("No keystore alias was specified to sign the metadata");
}
-
+
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias(keyAlias);
X509Certificate[] issuerCerts = crypto.getX509Certificates(cryptoType);
@@ -124,17 +124,17 @@ public final class CertsUtils {
}
return issuerCerts[0];
}
-
+
/**
* Parse a String parameter into an X.509 Certificate. The parameter can be either the encoded cert, or else
* a filename containing the certificate.
*/
- public static X509Certificate parseX509Certificate(String certificate)
+ public static X509Certificate parseX509Certificate(String certificate)
throws CertificateException, WSSecurityException, ProcessingException, Base64DecodingException, IOException {
if (certificate == null) {
return null;
}
-
+
boolean isCertificateLocation = !certificate.startsWith("-----BEGIN CERTIFICATE");
if (isCertificateLocation) {
try {
@@ -146,8 +146,8 @@ public final class CertsUtils {
return CertsUtils.getX509CertificateFromCrypto(crypto, null);
}
}
- }
-
+ }
+
// Here the certificate is encoded in the configuration file
try {
return CertsUtils.parseCertificate(certificate);
@@ -156,7 +156,7 @@ public final class CertsUtils {
throw new ProcessingException("Failed to parse trusted certificate");
}
}
-
+
/**
* Get a Crypto instance from a file
*/
@@ -177,7 +177,7 @@ public final class CertsUtils {
}
return crypto;
}
-
+
/**
* Get a crypto instance using a certificate
*/
@@ -185,7 +185,7 @@ public final class CertsUtils {
if (certificate == null) {
return null;
}
-
+
boolean isCertificateLocation = !certificate.startsWith("-----BEGIN CERTIFICATE");
if (isCertificateLocation) {
try {
@@ -198,8 +198,8 @@ public final class CertsUtils {
// Maybe it's a WSS4J properties file...
return CertsUtils.getCryptoFromFile(certificate);
}
- }
-
+ }
+
// Here the certificate is encoded in the configuration file
X509Certificate cert;
try {
@@ -210,10 +210,10 @@ public final class CertsUtils {
}
return new CertificateStore(Collections.singletonList(cert).toArray(new X509Certificate[0]));
}
-
+
private static X509Certificate parseCertificate(String certificate)
throws CertificateException, Base64DecodingException, IOException {
-
+
//before decoding we need to get rid off the prefix and suffix
byte[] decoded = Base64.decode(certificate.replaceAll("-----BEGIN CERTIFICATE-----", "").
replaceAll("-----END CERTIFICATE-----", ""));
@@ -222,5 +222,5 @@ public final class CertsUtils {
return (X509Certificate)CertificateFactory.getInstance("X.509").generateCertificate(is);
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/ClassLoaderUtils.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/ClassLoaderUtils.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/ClassLoaderUtils.java
index 6803ef2..d2611f0 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/ClassLoaderUtils.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/ClassLoaderUtils.java
@@ -34,20 +34,20 @@ import java.util.List;
* tolerant manner that works across different applications servers. Do not
* touch this unless you're a grizzled classloading guru veteran who is going to
* verify any change on 6 different application servers.
- *
+ *
* Original: org.apache.cxf.common.classloader.ClassLoaderUtils
*/
public final class ClassLoaderUtils {
-
+
private ClassLoaderUtils() {
}
-
+
public static class ClassLoaderHolder {
ClassLoader loader;
ClassLoaderHolder(ClassLoader c) {
loader = c;
}
-
+
public void reset() {
ClassLoaderUtils.setThreadContextClassloader(loader);
}
@@ -61,7 +61,7 @@ public final class ClassLoaderUtils {
}
});
}
-
+
public static ClassLoader getURLClassLoader(
final URL[] urls, final ClassLoader parent
) {
@@ -77,7 +77,7 @@ public final class ClassLoaderUtils {
) {
return getURLClassLoader(urlList.toArray(new URL[urlList.size()]), parent);
}
-
+
/**
* Load a given resource. This method will try to load the resource
* using the following methods (in order):
@@ -86,7 +86,7 @@ public final class ClassLoaderUtils {
* <li>From ClassLoaderUtil.class.getClassLoader()
* <li>callingClass.getClassLoader()
* </ul>
- *
+ *
* @param resourceName The name of the resource to load
* @param callingClass The Class object of the calling object
*/
@@ -121,14 +121,14 @@ public final class ClassLoaderUtils {
if (url == null) {
url = callingClass.getResource(resourceName);
}
-
+
if ((url == null) && (resourceName != null) && (resourceName.charAt(0) != '/')) {
return getResource('/' + resourceName, callingClass);
}
return url;
}
-
+
/**
* Load a given resources. <p/> This method will try to load the resources
* using the following methods (in order):
@@ -137,7 +137,7 @@ public final class ClassLoaderUtils {
* <li>From ClassLoaderUtil.class.getClassLoader()
* <li>callingClass.getClassLoader()
* </ul>
- *
+ *
* @param resourceName The name of the resource to load
* @param callingClass The Class object of the calling object
*/
@@ -150,7 +150,7 @@ public final class ClassLoaderUtils {
public URL nextElement() {
return null;
}
-
+
};
try {
urls = Thread.currentThread().getContextClassLoader()
@@ -210,7 +210,7 @@ public final class ClassLoaderUtils {
ret.add(urls.nextElement());
}
-
+
if (ret.isEmpty() && (resourceName != null) && (resourceName.charAt(0) != '/')) {
return getResources('/' + resourceName, callingClass);
}
@@ -221,7 +221,7 @@ public final class ClassLoaderUtils {
/**
* This is a convenience method to load a resource as a stream. <p/> The
* algorithm used to find the resource is given in getResource()
- *
+ *
* @param resourceName The name of the resource to load
* @param callingClass The Class object of the calling object
*/
@@ -244,7 +244,7 @@ public final class ClassLoaderUtils {
* <li>From ClassLoaderUtil.class.getClassLoader()
* <li>From the callingClass.getClassLoader()
* </ul>
- *
+ *
* @param className The name of the class to load
* @param callingClass The Class object of the calling object
* @throws ClassNotFoundException If the class cannot be found anywhere.
@@ -256,7 +256,7 @@ public final class ClassLoaderUtils {
if (cl != null) {
return cl.loadClass(className);
- }
+ }
} catch (ClassNotFoundException e) {
//ignore
}
@@ -269,7 +269,7 @@ public final class ClassLoaderUtils {
if (cl != null) {
return cl.loadClass(className).asSubclass(type);
- }
+ }
} catch (ClassNotFoundException e) {
//ignore
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CookieUtils.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CookieUtils.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CookieUtils.java
index 232514d..e8b5edd 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CookieUtils.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/CookieUtils.java
@@ -28,17 +28,17 @@ import java.util.TimeZone;
* Some Utility methods for manipulating cookies
*/
public final class CookieUtils {
-
+
private CookieUtils() {
// complete
}
- public static String createCookie(String name,
- String value,
+ public static String createCookie(String name,
+ String value,
String path,
String domain,
- long stateTimeToLive) {
-
+ long stateTimeToLive) {
+
String contextCookie = name + "=" + value;
// Setting a specific path restricts the browsers
// to return a cookie only to the web applications
@@ -46,25 +46,25 @@ public final class CookieUtils {
if (path != null) {
contextCookie += ";Path=" + path;
}
-
+
// Setting a specific domain further restricts the browsers
// to return a cookie only to the web applications
// listening on the specific context path within a particular domain
if (domain != null) {
contextCookie += ";Domain=" + domain;
}
-
+
// Keep the cookie across the browser restarts until it actually expires.
- // Note that the Expires property has been deprecated but apparently is
- // supported better than 'max-age' property by different browsers
+ // Note that the Expires property has been deprecated but apparently is
+ // supported better than 'max-age' property by different browsers
// (Firefox, IE, etc)
Date expiresDate = new Date(System.currentTimeMillis() + stateTimeToLive);
String cookieExpires = getHttpDateFormat().format(expiresDate);
contextCookie += ";Expires=" + cookieExpires;
-
+
return contextCookie;
}
-
+
public static SimpleDateFormat getHttpDateFormat() {
SimpleDateFormat dateFormat =
new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
@@ -72,15 +72,15 @@ public final class CookieUtils {
dateFormat.setTimeZone(tZone);
return dateFormat;
}
-
+
public static boolean isStateExpired(long stateCreatedAt, boolean detectExpiredTokens,
long expiresAt, long stateTTL) {
Date currentTime = new Date();
if (currentTime.after(new Date(stateCreatedAt + stateTTL))) {
return true;
}
-
+
return detectExpiredTokens && expiresAt > 0 && currentTime.after(new Date(expiresAt));
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/DOMUtils.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/DOMUtils.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/DOMUtils.java
index 6d66e8e..31120e2 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/DOMUtils.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/DOMUtils.java
@@ -57,7 +57,7 @@ import org.xml.sax.SAXException;
/**
* Few simple utils to read DOM. This is originally from the Jakarta Commons Modeler.
- *
+ *
* @author Costin Manolache
*/
public final class DOMUtils {
@@ -89,7 +89,7 @@ public final class DOMUtils {
/**
* This function is much like getAttribute, but returns null, not "", for a nonexistent attribute.
- *
+ *
* @param e
* @param attributeName
*/
@@ -143,7 +143,7 @@ public final class DOMUtils {
/**
* Get the first element child.
- *
+ *
* @param parent lookup direct childs
* @param name name of the element. If null return the first element.
*/
@@ -223,7 +223,7 @@ public final class DOMUtils {
/**
* Find the first direct child with a given attribute.
- *
+ *
* @param parent
* @param elemName name of the element, or null for any
* @param attName attribute we're looking for
@@ -295,7 +295,7 @@ public final class DOMUtils {
/**
* Return the first element child with the specified qualified name.
- *
+ *
* @param parent
* @param q
*/
@@ -307,7 +307,7 @@ public final class DOMUtils {
/**
* Return the first element child with the specified qualified name.
- *
+ *
* @param parent
* @param ns
* @param lp
@@ -327,7 +327,7 @@ public final class DOMUtils {
/**
* Return child elements with specified name.
- *
+ *
* @param parent
* @param ns
* @param localName
@@ -348,7 +348,7 @@ public final class DOMUtils {
/**
* Returns all child elements with specified namespace.
- *
+ *
* @param parent the element to search under
* @param ns the namespace to find elements in
* @return all child elements with specified namespace
@@ -369,7 +369,7 @@ public final class DOMUtils {
/**
* Get the first child of the specified type.
- *
+ *
* @param parent
* @param type
*/
@@ -423,7 +423,7 @@ public final class DOMUtils {
return new InputSource(new StringReader(""));
}
}
-
+
private static DocumentBuilderFactory createDocumentBuilderFactory() throws ParserConfigurationException {
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
@@ -434,7 +434,7 @@ public final class DOMUtils {
dbf.setNamespaceAware(true);
// dbf.setCoalescing(true);
// dbf.setExpandEntityReferences(true);
-
+
return dbf;
}
@@ -512,7 +512,7 @@ public final class DOMUtils {
/**
* Get all prefixes defined, up to the root, for a namespace URI.
- *
+ *
* @param element
* @param namespaceUri
* @param prefixes
@@ -527,7 +527,7 @@ public final class DOMUtils {
/**
* Get all prefixes defined on this element for the specified namespace.
- *
+ *
* @param element
* @param namespaceUri
* @param prefixes
@@ -558,7 +558,7 @@ public final class DOMUtils {
/**
* Starting from a node, find the namespace declaration for a prefix. for a matching namespace
* declaration.
- *
+ *
* @param node search up from here to search for namespace definitions
* @param searchPrefix the prefix we are searching for
* @return the namespace if found.
@@ -648,7 +648,7 @@ public final class DOMUtils {
* Set a namespace/prefix on an element if it is not set already. First off, it searches for the element
* for the prefix associated with the specified namespace. If the prefix isn't null, then this is
* returned. Otherwise, it creates a new attribute using the namespace/prefix passed as parameters.
- *
+ *
* @param element
* @param namespace
* @param prefix
@@ -665,7 +665,7 @@ public final class DOMUtils {
/**
* Add a namespace prefix definition to an element.
- *
+ *
* @param element
* @param namespaceUri
* @param prefix
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/SignatureUtils.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/SignatureUtils.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/SignatureUtils.java
index 5ea2b12..26263a9 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/SignatureUtils.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/SignatureUtils.java
@@ -49,12 +49,12 @@ import org.slf4j.LoggerFactory;
public final class SignatureUtils {
private static final Logger LOG = LoggerFactory.getLogger(SignatureUtils.class);
-
+
private static final XMLSignatureFactory XML_SIGNATURE_FACTORY = XMLSignatureFactory.getInstance("DOM");
-
+
private SignatureUtils() {
}
-
+
public static Document signMetaInfo(Crypto crypto, String keyAlias, String keyPassword,
Document doc, String referenceID) throws Exception {
if (keyAlias == null || "".equals(keyAlias)) {
@@ -62,17 +62,17 @@ public final class SignatureUtils {
}
X509Certificate cert = CertsUtils.getX509CertificateFromCrypto(crypto, keyAlias);
// }
-
+
/* public static ByteArrayOutputStream signMetaInfo(FederationContext config, InputStream metaInfo,
String referenceID)
throws Exception {
KeyManager keyManager = config.getSigningKey();
String keyAlias = keyManager.getKeyAlias();
- String keypass = keyManager.getKeyPassword();
-
+ String keypass = keyManager.getKeyPassword();
+
// in case we did not specify the key alias, we assume there is only one key in the keystore ,
- // we use this key's alias as default.
+ // we use this key's alias as default.
if (keyAlias == null || "".equals(keyAlias)) {
//keyAlias = getDefaultX509Identifier(ks);
keyAlias = keyManager.getCrypto().getDefaultX509Identifier();
@@ -86,7 +86,7 @@ public final class SignatureUtils {
+ keyAlias);
}
X509Certificate cert = issuerCerts[0];
-*/
+*/
String signatureMethod = null;
if ("SHA1withDSA".equals(cert.getSigAlgName())) {
signatureMethod = SignatureMethod.DSA_SHA1;
@@ -98,12 +98,12 @@ public final class SignatureUtils {
LOG.error("Unsupported signature method: " + cert.getSigAlgName());
throw new RuntimeException("Unsupported signature method: " + cert.getSigAlgName());
}
-
+
List<Transform> transformList = new ArrayList<>();
transformList.add(XML_SIGNATURE_FACTORY.newTransform(Transform.ENVELOPED, (TransformParameterSpec)null));
transformList.add(XML_SIGNATURE_FACTORY.newCanonicalizationMethod(CanonicalizationMethod.EXCLUSIVE,
(C14NMethodParameterSpec)null));
-
+
// Create a Reference to the enveloped document (in this case,
// you are signing the whole document, so a URI of "" signifies
// that, and also specify the SHA1 digest algorithm and
@@ -123,9 +123,9 @@ public final class SignatureUtils {
// step 2
// Load the KeyStore and get the signing key and certificate.
-
+
PrivateKey keyEntry = crypto.getPrivateKey(keyAlias, keyPassword);
-
+
// Create the KeyInfo containing the X509Data.
KeyInfoFactory kif = XML_SIGNATURE_FACTORY.getKeyInfoFactory();
List<Object> x509Content = new ArrayList<>();
@@ -151,8 +151,8 @@ public final class SignatureUtils {
// step 4
// Output the resulting document.
-
+
return doc;
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/StringUtils.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/StringUtils.java b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/StringUtils.java
index 04f2112..f23ee74 100644
--- a/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/StringUtils.java
+++ b/plugins/core/src/main/java/org/apache/cxf/fediz/core/util/StringUtils.java
@@ -208,7 +208,7 @@ public final class StringUtils {
/**
* Return input string with first character in upper case.
- *
+ *
* @param name
* input string.
* @return capitalized form.
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/common/STSUtil.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/common/STSUtil.java b/plugins/core/src/test/java/org/apache/cxf/fediz/common/STSUtil.java
index 3698672..273f2c1 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/common/STSUtil.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/common/STSUtil.java
@@ -26,9 +26,9 @@ import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
public class STSUtil {
-
-
- public static final String SAMPLE_RSTR_COLL_MSG =
+
+
+ public static final String SAMPLE_RSTR_COLL_MSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<RequestSecurityTokenResponseCollection "
+ "xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\"> "
@@ -37,34 +37,34 @@ public class STSUtil {
+ "</RequestedSecurityToken>"
+ "</RequestSecurityTokenResponse>"
+ "</RequestSecurityTokenResponseCollection>";
-
- public static final String SAMPLE_RSTR_MSG =
+
+ public static final String SAMPLE_RSTR_MSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<RequestSecurityTokenResponse "
+ "xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\"> "
+ "<RequestedSecurityToken>"
+ "</RequestedSecurityToken>"
+ "</RequestSecurityTokenResponse>";
-
- public static final String SAMPLE_RSTR_2005_02_MSG =
+
+ public static final String SAMPLE_RSTR_2005_02_MSG =
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<RequestSecurityTokenResponse "
+ "xmlns=\"http://schemas.xmlsoap.org/ws/2005/02/trust\"> "
+ "<RequestedSecurityToken>"
+ "</RequestedSecurityToken>"
+ "</RequestSecurityTokenResponse>";
-
-
+
+
private static DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-
+
static {
factory.setNamespaceAware(true);
}
-
+
protected STSUtil() {
-
+
}
-
+
/**
* Convert an XML document as a String to a org.w3c.dom.Document.
*/
@@ -74,5 +74,5 @@ public class STSUtil {
return builder.parse(in);
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java b/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
index 62997e0..d63fdd8 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/common/SecurityTestUtil.java
@@ -24,11 +24,11 @@ import java.io.File;
* A utility class for security tests
*/
public final class SecurityTestUtil {
-
+
private SecurityTestUtil() {
// complete
}
-
+
public static void cleanup() {
String tmpDir = System.getProperty("java.io.tmpdir");
if (tmpDir != null) {
@@ -42,5 +42,5 @@ public final class SecurityTestUtil {
}
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/AbstractSAMLCallbackHandler.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/AbstractSAMLCallbackHandler.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/AbstractSAMLCallbackHandler.java
index bd69b14..b4b926f 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/AbstractSAMLCallbackHandler.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/AbstractSAMLCallbackHandler.java
@@ -56,18 +56,18 @@ import org.apache.wss4j.dom.message.WSSecEncryptedKey;
* authentication assertion.
*/
public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
-
+
public enum Statement {
AUTHN, ATTR, AUTHZ
};
-
+
public enum MultiValue {
MULTI_VALUE, MULTI_ATTR, ENC_VALUE
};
-
- public static final URI CLAIM_TYPE_LANGUAGE =
+
+ public static final URI CLAIM_TYPE_LANGUAGE =
URI.create("http://schemas.mycompany.com/claims/language");
-
+
protected String subjectName;
protected String subjectQualifier;
protected String confirmationMethod;
@@ -93,60 +93,60 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
protected String customClaimName = CLAIM_TYPE_LANGUAGE.toString();
protected String attributeNameFormat = "urn:oasis:names:tc:SAML:2.0:attrname-format:unspecified";
protected boolean useNameFormatAsNamespace;
-
+
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 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 setSubjectNameIDFormat(String subjectNameIDFormat) {
this.subjectNameIDFormat = subjectNameIDFormat;
}
-
+
public void setSubjectName(String subjectName) {
this.subjectName = subjectName;
}
-
+
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<?> customAttributeValues) {
this.customAttributeValues = customAttributeValues;
}
-
+
public void setRoles(List<String> roles) {
this.roles = roles;
}
@@ -158,19 +158,19 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
public void setMultiValueType(MultiValue multiValueType) {
this.multiValueType = multiValueType;
}
-
+
public void setRoleAttributeName(String roleAttributeName) {
this.roleAttributeName = roleAttributeName;
}
-
+
public String getRoleAttributeName() {
return this.roleAttributeName;
}
-
+
public void setCountryClaimName(String countryClaimName) {
this.countryClaimName = countryClaimName;
}
-
+
public String getCountryClaimName() {
return this.countryClaimName;
}
@@ -178,7 +178,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
public void setCustomClaimName(String customClaimName) {
this.customClaimName = customClaimName;
}
-
+
public String getCustomClaimName() {
return this.customClaimName;
}
@@ -186,11 +186,11 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
public void setAttributeNameFormat(String attributeNameFormat) {
this.attributeNameFormat = attributeNameFormat;
}
-
+
public String getAttributeNameFormat() {
return this.attributeNameFormat;
}
-
+
public boolean isUseNameFormatAsNamespace() {
return useNameFormatAsNamespace;
}
@@ -218,13 +218,13 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
authBean.setAuthenticationMethod("Password");
callback.setAuthenticationStatementData(Collections.singletonList(authBean));
}
-
+
if (statement == Statement.ATTR) {
AttributeStatementBean attrStateBean = new AttributeStatementBean();
if (subjectBean != null) {
attrStateBean.setSubject(subjectBean);
}
-
+
if (this.roles == null) {
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
@@ -238,9 +238,9 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
callback.setAttributeStatementData(Collections.singletonList(attrStateBean));
return;
}
-
+
List<AttributeBean> attributeList = new ArrayList<>();
-
+
if (this.multiValueType.equals(MultiValue.MULTI_VALUE)
|| this.multiValueType.equals(MultiValue.ENC_VALUE)) {
// <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
@@ -248,7 +248,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
// <saml:AttributeValue>Value1</saml:AttributeValue>
// <saml:AttributeValue>Value2</saml:AttributeValue>
// </saml:Attribute>
-// or
+// or
// <saml:Attribute xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion"
// AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="roles">
// <saml:AttributeValue>Value1,Value2</saml:AttributeValue>
@@ -293,7 +293,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
// AttributeNamespace="http://schemas.xmlsoap.org/claims" AttributeName="roles">
// <saml:AttributeValue>Value2</saml:AttributeValue>
// </saml:Attribute>
-
+
//List<AttributeBean> attrBeans = new ArrayList<>();
for (String role: roles) {
AttributeBean attributeBean = new AttributeBean();
@@ -318,7 +318,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
attributeList.add(attributeBean);
}
}
-
+
//ClaimTypes.COUNTRY
AttributeBean attributeBean = new AttributeBean();
if (subjectBean != null) {
@@ -326,7 +326,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
attributeBean.setSimpleName(getNameOfClaimType(this.countryClaimName));
//QualifiedName maps to AttributeNamespace in SAML1ComponentBuilder.createSamlv1Attribute()
attributeBean.setQualifiedName(getNamespaceOfClaimType(this.countryClaimName));
-
+
} else {
//SAML 2.0
attributeBean.setQualifiedName(this.countryClaimName);
@@ -334,7 +334,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
}
attributeBean.addAttributeValue("CH");
attributeList.add(attributeBean);
-
+
//custom claim language
AttributeBean attributeBean2 = new AttributeBean();
if (subjectBean != null) {
@@ -362,10 +362,10 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
attributeBean2.addAttributeValue("CH");
}
attributeList.add(attributeBean2);
-
+
attrStateBean.setSamlAttributes(attributeList);
callback.setAttributeStatementData(Collections.singletonList(attrStateBean));
-
+
} else if (statement == Statement.AUTHZ) {
AuthDecisionStatementBean authzBean = new AuthDecisionStatementBean();
if (subjectBean != null) {
@@ -380,7 +380,7 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
callback.setAuthDecisionStatementData(Collections.singletonList(authzBean));
}
}
-
+
protected KeyInfoBean createKeyInfo() throws Exception {
KeyInfoBean keyInfo = new KeyInfoBean();
if (alsoAddAuthnStatement || statement == Statement.AUTHN) {
@@ -388,12 +388,12 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
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);
@@ -401,9 +401,9 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
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
);
@@ -411,22 +411,22 @@ public abstract class AbstractSAMLCallbackHandler implements CallbackHandler {
WSConstants.XMLNS_NS, "xmlns:" + WSConstants.SIG_PREFIX, WSConstants.SIG_NS
);
keyInfoElement.appendChild(encryptedKeyElement);
-
+
keyInfo.setElement(keyInfoElement);
}
return keyInfo;
}
-
+
protected String getNamespaceOfClaimType(String claimType) {
int i = claimType.lastIndexOf("/");
return claimType.substring(0, i);
}
-
+
protected String getNameOfClaimType(String claimType) {
int i = claimType.lastIndexOf("/");
return claimType.substring(i + 1);
}
-
+
public boolean isAlsoAddAuthnStatement() {
return alsoAddAuthnStatement;
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/KeystoreCallbackHandler.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/KeystoreCallbackHandler.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/KeystoreCallbackHandler.java
index 880c94d..d80fdee 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/KeystoreCallbackHandler.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/KeystoreCallbackHandler.java
@@ -30,20 +30,20 @@ import javax.security.auth.callback.UnsupportedCallbackException;
import org.apache.wss4j.common.ext.WSPasswordCallback;
/**
- * 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("mystskey", "stskpass");
users.put("myclientkey", "ckpass");
users.put("realma", "realma");
users.put("realmb", "realmb");
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML1CallbackHandler.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML1CallbackHandler.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML1CallbackHandler.java
index 10fb4ce..73fdb36 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML1CallbackHandler.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML1CallbackHandler.java
@@ -36,7 +36,7 @@ import org.apache.wss4j.common.saml.builder.SAML2Constants;
* authentication assertion using Sender Vouches.
*/
public class SAML1CallbackHandler extends AbstractSAMLCallbackHandler {
-
+
public SAML1CallbackHandler() throws Exception {
// Required for Holder-Of-Key. Commented out.
/*
@@ -47,12 +47,12 @@ public class SAML1CallbackHandler extends AbstractSAMLCallbackHandler {
certs = crypto.getX509Certificates(cryptoType);
}
*/
-
+
subjectName = "uid=joe,ou=people,ou=saml-demo,o=example.com";
subjectQualifier = "www.example.com";
confirmationMethod = SAML2Constants.CONF_BEARER;
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
@@ -63,8 +63,8 @@ public class SAML1CallbackHandler extends AbstractSAMLCallbackHandler {
if (conditions != null) {
callback.setConditions(conditions);
}
-
- SubjectBean subjectBean =
+
+ SubjectBean subjectBean =
new SubjectBean(
subjectName, subjectQualifier, confirmationMethod
);
@@ -85,6 +85,6 @@ public class SAML1CallbackHandler extends AbstractSAMLCallbackHandler {
}
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML2CallbackHandler.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML2CallbackHandler.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML2CallbackHandler.java
index 754d430..b590cec 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML2CallbackHandler.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/SAML2CallbackHandler.java
@@ -35,7 +35,7 @@ import org.apache.wss4j.common.saml.builder.SAML2Constants;
* authentication assertion using Bearer.
*/
public class SAML2CallbackHandler extends AbstractSAMLCallbackHandler {
-
+
public SAML2CallbackHandler() throws Exception {
// Required for Holder-Of-Key. Commented out.
/*
@@ -46,12 +46,12 @@ public class SAML2CallbackHandler extends AbstractSAMLCallbackHandler {
certs = crypto.getX509Certificates(cryptoType);
}
*/
-
+
subjectName = "uid=joe,ou=people,ou=saml-demo,o=example.com";
subjectQualifier = "www.example.com";
confirmationMethod = SAML2Constants.CONF_BEARER;
}
-
+
public void handle(Callback[] callbacks)
throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
@@ -62,8 +62,8 @@ public class SAML2CallbackHandler extends AbstractSAMLCallbackHandler {
if (conditions != null) {
callback.setConditions(conditions);
}
-
- SubjectBean subjectBean =
+
+ SubjectBean subjectBean =
new SubjectBean(
subjectName, subjectQualifier, confirmationMethod
);
@@ -86,5 +86,5 @@ public class SAML2CallbackHandler extends AbstractSAMLCallbackHandler {
}
}
}
-
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/CallbackHandlerTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/CallbackHandlerTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/CallbackHandlerTest.java
index 1699691..58267c8 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/CallbackHandlerTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/CallbackHandlerTest.java
@@ -68,19 +68,19 @@ public class CallbackHandlerTest {
private static final String KEYSTORE_PASSWORD = "passw0rd1";
private static final String KEYSTORE_RESOURCE_PATH = "org.apache.fediz.kestore1";
private static final String AUDIENCE_URI = "http://host_one:port/url";
-
+
private static final String ROLE_DELIMITER = ";";
private static final String ROLE_URI = "http://someserver:8080/path/roles.uri";
private static final String CLAIM_TYPE = "a particular claim type";
private static final String SUBJECT_VALUE = ".*CN=www.sts1.com.*";
private static final String TEST_SIGNIN_QUERY = "pubid=myid";
-
-
+
+
@AfterClass
public static void cleanup() {
SecurityTestUtil.cleanup();
}
-
+
private FedizConfig createConfiguration(boolean federation) throws JAXBException {
FedizConfig rootConfig = new FedizConfig();
@@ -91,16 +91,16 @@ public class CallbackHandlerTest {
config.setMaximumClockSkew(new BigInteger(CLOCK_SKEW));
CertificateStores certStores = new CertificateStores();
-
- TrustManagersType tm0 = new TrustManagersType();
+
+ TrustManagersType tm0 = new TrustManagersType();
KeyStoreType ks0 = new KeyStoreType();
ks0.setType("JKS");
ks0.setPassword(KEYSTORE_PASSWORD);
ks0.setResource(KEYSTORE_RESOURCE_PATH);
tm0.setKeyStore(ks0);
- certStores.getTrustManager().add(tm0);
+ certStores.getTrustManager().add(tm0);
config.setCertificateStores(certStores);
-
+
TrustedIssuers trustedIssuers = new TrustedIssuers();
TrustedIssuerType ti0 = new TrustedIssuerType();
ti0.setCertificateValidation(ValidationType.CHAIN_TRUST);
@@ -108,24 +108,24 @@ public class CallbackHandlerTest {
ti0.setSubject(SUBJECT_VALUE);
trustedIssuers.getIssuer().add(ti0);
config.setTrustedIssuers(trustedIssuers);
-
+
AudienceUris audienceUris = new AudienceUris();
audienceUris.getAudienceItem().add(AUDIENCE_URI);
config.setAudienceUris(audienceUris);
ProtocolType protocol = null;
-
+
if (federation) {
protocol = new FederationProtocolType();
-
+
CallbackType freshness = new CallbackType();
freshness.setValue(FRESHNESS_VALUE);
((FederationProtocolType)protocol).setFreshness(freshness);
-
+
CallbackType realm = new CallbackType();
realm.setValue(TARGET_REALM);
protocol.setRealm(freshness);
-
+
CallbackType reply = new CallbackType();
reply.setValue(REPLY);
((FederationProtocolType)protocol).setReply(reply);
@@ -134,7 +134,7 @@ public class CallbackHandlerTest {
protocol = new SamlProtocolType();
}
config.setProtocol(protocol);
-
+
protocol.setRoleDelimiter(ROLE_DELIMITER);
protocol.setRoleURI(ROLE_URI);
@@ -144,106 +144,106 @@ public class CallbackHandlerTest {
claimType.setType(CLAIM_TYPE);
claimTypeReq.getClaimType().add(claimType);
protocol.setClaimTypesRequested(claimTypeReq);
-
+
return rootConfig;
}
-
+
private FedizConfig createConfigWithoutCB(boolean federation) throws JAXBException {
-
+
FedizConfig config = createConfiguration(federation);
ProtocolType protocol = config.getContextConfig().get(0).getProtocol();
-
+
CallbackType issuer = new CallbackType();
issuer.setType(ArgumentType.STRING);
issuer.setValue(TestCallbackHandler.TEST_IDP);
protocol.setIssuer(issuer);
-
+
if (protocol instanceof FederationProtocolType) {
CallbackType homeRealm = new CallbackType();
homeRealm.setType(ArgumentType.STRING);
homeRealm.setValue(TestCallbackHandler.TEST_HOME_REALM);
((FederationProtocolType)protocol).setHomeRealm(homeRealm);
-
+
CallbackType authType = new CallbackType();
authType.setType(ArgumentType.STRING);
authType.setValue(TestCallbackHandler.TEST_WAUTH);
((FederationProtocolType)protocol).setAuthenticationType(authType);
-
+
CallbackType tokenRequest = new CallbackType();
tokenRequest.setType(ArgumentType.STRING);
tokenRequest.setValue(TestCallbackHandler.TEST_WREQ);
((FederationProtocolType)protocol).setRequest(tokenRequest);
-
+
CallbackType signInQueryType = new CallbackType();
signInQueryType.setType(ArgumentType.STRING);
signInQueryType.setValue(TEST_SIGNIN_QUERY);
((FederationProtocolType)protocol).setSignInQuery(signInQueryType);
}
-
+
return config;
}
-
+
private FedizConfig createConfigCB(boolean federation) throws JAXBException {
-
+
FedizConfig config = createConfiguration(federation);
ProtocolType protocol = config.getContextConfig().get(0).getProtocol();
-
+
CallbackType realmType = new CallbackType();
realmType.setType(ArgumentType.CLASS);
realmType.setValue(CALLBACKHANDLER_CLASS);
protocol.setRealm(realmType);
-
+
CallbackType issuer = new CallbackType();
issuer.setType(ArgumentType.CLASS);
issuer.setValue(CALLBACKHANDLER_CLASS);
protocol.setIssuer(issuer);
-
+
if (protocol instanceof FederationProtocolType) {
CallbackType homeRealm = new CallbackType();
homeRealm.setType(ArgumentType.CLASS);
homeRealm.setValue(CALLBACKHANDLER_CLASS);
((FederationProtocolType)protocol).setHomeRealm(homeRealm);
-
+
CallbackType authType = new CallbackType();
authType.setType(ArgumentType.CLASS);
authType.setValue(CALLBACKHANDLER_CLASS);
((FederationProtocolType)protocol).setAuthenticationType(authType);
-
+
CallbackType tokenRequest = new CallbackType();
tokenRequest.setType(ArgumentType.CLASS);
tokenRequest.setValue(CALLBACKHANDLER_CLASS);
((FederationProtocolType)protocol).setRequest(tokenRequest);
-
+
CallbackType signInQueryType = new CallbackType();
signInQueryType.setType(ArgumentType.CLASS);
signInQueryType.setValue(CALLBACKHANDLER_CLASS);
((FederationProtocolType)protocol).setSignInQuery(signInQueryType);
-
+
CallbackType replyType = new CallbackType();
replyType.setType(ArgumentType.CLASS);
replyType.setValue(CALLBACKHANDLER_CLASS);
((FederationProtocolType)protocol).setReply(replyType);
}
-
+
return config;
}
-
+
@org.junit.Test
public void testParamsWithCallbackHandlerFederation() throws Exception {
-
+
final JAXBContext jaxbContext = JAXBContext.newInstance(FedizConfig.class);
FedizConfig configOut = createConfigCB(true);
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
-
+
FedizContext ctx = configurator.getFedizContext(CONFIG_NAME);
-
+
FederationProtocol fp = (FederationProtocol)ctx.getProtocol();
-
+
Object issuerObj = fp.getIssuer();
Assert.assertTrue(issuerObj instanceof CallbackHandler);
CallbackHandler issuerCB = (CallbackHandler)issuerObj;
@@ -251,7 +251,7 @@ public class CallbackHandlerTest {
issuerCB.handle(new Callback[] {callbackIDP});
String issuerURL = callbackIDP.getIssuerUrl().toString();
Assert.assertEquals(TestCallbackHandler.TEST_IDP, issuerURL);
-
+
Object wAuthObj = fp.getAuthenticationType();
Assert.assertTrue(wAuthObj instanceof CallbackHandler);
CallbackHandler wauthCB = (CallbackHandler)wAuthObj;
@@ -259,7 +259,7 @@ public class CallbackHandlerTest {
wauthCB.handle(new Callback[] {callbackWA});
String wAuth = callbackWA.getWauth();
Assert.assertEquals(TestCallbackHandler.TEST_WAUTH, wAuth);
-
+
Object wReqObj = fp.getRequest();
Assert.assertTrue(wReqObj instanceof CallbackHandler);
CallbackHandler wreqCB = (CallbackHandler)wReqObj;
@@ -267,7 +267,7 @@ public class CallbackHandlerTest {
wreqCB.handle(new Callback[] {callbackReq});
String wReq = callbackReq.getWreq();
Assert.assertEquals(TestCallbackHandler.TEST_WREQ, wReq);
-
+
Object homeRealmObj = fp.getHomeRealm();
Assert.assertTrue(homeRealmObj instanceof CallbackHandler);
CallbackHandler hrCB = (CallbackHandler)homeRealmObj;
@@ -275,7 +275,7 @@ public class CallbackHandlerTest {
hrCB.handle(new Callback[] {callbackHR});
String hr = callbackHR.getHomeRealm();
Assert.assertEquals(TestCallbackHandler.TEST_HOME_REALM, hr);
-
+
Object wtRealmObj = fp.getRealm();
Assert.assertTrue(wtRealmObj instanceof CallbackHandler);
CallbackHandler wtrCB = (CallbackHandler)wtRealmObj;
@@ -283,7 +283,7 @@ public class CallbackHandlerTest {
wtrCB.handle(new Callback[]{callbackWTR});
String wtr = callbackWTR.getRealm();
Assert.assertEquals(TestCallbackHandler.TEST_WTREALM, wtr);
-
+
Object signInQueryObj = fp.getSignInQuery();
Assert.assertTrue(signInQueryObj instanceof CallbackHandler);
CallbackHandler siqCB = (CallbackHandler)signInQueryObj;
@@ -293,7 +293,7 @@ public class CallbackHandlerTest {
Assert.assertEquals(2, signinQueryMap.size());
Assert.assertEquals("myid", signinQueryMap.get("pubid"));
Assert.assertEquals("<=>", signinQueryMap.get("testenc"));
-
+
Object replyObj = fp.getReply();
Assert.assertTrue(replyObj instanceof CallbackHandler);
CallbackHandler replyCB = (CallbackHandler)replyObj;
@@ -301,25 +301,25 @@ public class CallbackHandlerTest {
replyCB.handle(new Callback[] {callbackReply});
String reply = callbackReply.getReply();
Assert.assertEquals(TestCallbackHandler.TEST_REPLY, reply);
-
+
}
-
+
@org.junit.Test
public void testParamsWithCallbackHandlerSAML() throws Exception {
-
+
final JAXBContext jaxbContext = JAXBContext.newInstance(FedizConfig.class);
FedizConfig configOut = createConfigCB(false);
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
-
+
FedizContext ctx = configurator.getFedizContext(CONFIG_NAME);
-
+
SAMLProtocol protocol = (SAMLProtocol)ctx.getProtocol();
-
+
Object issuerObj = protocol.getIssuer();
Assert.assertTrue(issuerObj instanceof CallbackHandler);
CallbackHandler issuerCB = (CallbackHandler)issuerObj;
@@ -328,70 +328,70 @@ public class CallbackHandlerTest {
String issuerURL = callbackIDP.getIssuerUrl().toString();
Assert.assertEquals(TestCallbackHandler.TEST_IDP, issuerURL);
}
-
+
@org.junit.Test
public void testParamsWithoutCallbackHandlerFederation() throws Exception {
-
+
final JAXBContext jaxbContext = JAXBContext.newInstance(FedizConfig.class);
FedizConfig configOut = createConfigWithoutCB(true);
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
-
+
FedizContext ctx = configurator.getFedizContext(CONFIG_NAME);
-
+
FederationProtocol fp = (FederationProtocol)ctx.getProtocol();
-
+
Object issuerObj = fp.getIssuer();
Assert.assertTrue(issuerObj instanceof String);
String issuerURL = (String)issuerObj;
Assert.assertEquals(TestCallbackHandler.TEST_IDP, issuerURL);
-
+
Object wAuthObj = fp.getAuthenticationType();
Assert.assertTrue(wAuthObj instanceof String);
String wAuth = (String)wAuthObj;
Assert.assertEquals(TestCallbackHandler.TEST_WAUTH, wAuth);
-
+
Object wReqObj = fp.getRequest();
Assert.assertTrue(wReqObj instanceof String);
String wReq = (String)wReqObj;
Assert.assertEquals(TestCallbackHandler.TEST_WREQ, wReq);
-
+
Object homeRealmObj = fp.getHomeRealm();
Assert.assertTrue(homeRealmObj instanceof String);
String hr = (String)homeRealmObj;
Assert.assertEquals(TestCallbackHandler.TEST_HOME_REALM, hr);
-
+
Object signInQueryObj = fp.getSignInQuery();
Assert.assertTrue(signInQueryObj instanceof String);
String signInQuery = (String)signInQueryObj;
Assert.assertEquals(TestCallbackHandler.TEST_SIGNIN_QUERY, signInQuery);
}
-
+
@org.junit.Test
public void testParamsWithoutCallbackHandlerSAML() throws Exception {
-
+
final JAXBContext jaxbContext = JAXBContext.newInstance(FedizConfig.class);
FedizConfig configOut = createConfigWithoutCB(false);
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
-
+
FedizContext ctx = configurator.getFedizContext(CONFIG_NAME);
-
+
Protocol protocol = ctx.getProtocol();
-
+
Object issuerObj = protocol.getIssuer();
Assert.assertTrue(issuerObj instanceof String);
String issuerURL = (String)issuerObj;
Assert.assertEquals(TestCallbackHandler.TEST_IDP, issuerURL);
}
-
-
+
+
}
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java
index 7d05960..9b25e26 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationTest.java
@@ -83,10 +83,10 @@ public class FedizConfigurationTest {
private static final String SUBJECT_VALUE_1 = ".*CN=www.sts1.com.*";
private static final String SUBJECT_VALUE_2 = ".*CN=www.sts2.com.*";
private static final String SUBJECT_VALUE_3 = ".*CN=www.sts3.com.*";
-
+
private static final String CONFIG_FILE = "./target/fedizconfig.xml";
-
+
@AfterClass
public static void cleanup() {
SecurityTestUtil.cleanup();
@@ -103,68 +103,68 @@ public class FedizConfigurationTest {
config.setMaximumClockSkew(new BigInteger(CLOCK_SKEW));
CertificateStores certStores = new CertificateStores();
-
- TrustManagersType tm0 = new TrustManagersType();
+
+ TrustManagersType tm0 = new TrustManagersType();
KeyStoreType ks0 = new KeyStoreType();
ks0.setType("JKS");
ks0.setPassword(KEYSTORE_PASSWORD_1);
ks0.setResource(KEYSTORE_RESOURCE_PATH_1);
tm0.setKeyStore(ks0);
-
+
certStores.getTrustManager().add(tm0);
-
+
TrustManagersType tm1 = new TrustManagersType();
KeyStoreType ks1 = new KeyStoreType();
ks1.setType("JKS");
ks1.setPassword(KEYSTORE_PASSWORD_2);
ks1.setResource(KEYSTORE_RESOURCE_PATH_2);
tm1.setKeyStore(ks1);
-
+
certStores.getTrustManager().add(tm1);
-
+
TrustManagersType tm2 = new TrustManagersType();
KeyStoreType ks2 = new KeyStoreType();
ks2.setType("JKS");
ks2.setPassword(KEYSTORE_PASSWORD_3);
ks2.setResource(KEYSTORE_RESOURCE_PATH_3);
tm2.setKeyStore(ks2);
-
+
certStores.getTrustManager().add(tm2);
-
+
config.setCertificateStores(certStores);
-
+
TrustedIssuers trustedIssuers = new TrustedIssuers();
-
+
TrustedIssuerType ti0 = new TrustedIssuerType();
ti0.setCertificateValidation(ValidationType.CHAIN_TRUST);
ti0.setName("issuer1");
ti0.setSubject(SUBJECT_VALUE_1);
trustedIssuers.getIssuer().add(ti0);
-
+
TrustedIssuerType ti1 = new TrustedIssuerType();
ti1.setCertificateValidation(ValidationType.CHAIN_TRUST);
ti1.setName("issuer1");
ti1.setSubject(SUBJECT_VALUE_2);
trustedIssuers.getIssuer().add(ti1);
-
+
TrustedIssuerType ti2 = new TrustedIssuerType();
ti2.setCertificateValidation(ValidationType.CHAIN_TRUST);
ti2.setName("issuer1");
ti2.setSubject(SUBJECT_VALUE_3);
trustedIssuers.getIssuer().add(ti2);
-
+
config.setTrustedIssuers(trustedIssuers);
-
+
ProtocolType protocol = null;
-
+
if (federation) {
protocol = new FederationProtocolType();
-
+
CallbackType authType = new CallbackType();
authType.setType(ArgumentType.STRING);
authType.setValue(AUTH_TYPE_VALUE);
((FederationProtocolType)protocol).setAuthenticationType(authType);
-
+
CallbackType freshness = new CallbackType();
freshness.setValue(FRESHNESS_VALUE);
((FederationProtocolType)protocol).setFreshness(freshness);
@@ -173,7 +173,7 @@ public class FedizConfigurationTest {
homeRealm.setType(ArgumentType.CLASS);
homeRealm.setValue(HOME_REALM_CLASS);
((FederationProtocolType)protocol).setHomeRealm(homeRealm);
-
+
CallbackType reply = new CallbackType();
reply.setValue(REPLY);
((FederationProtocolType)protocol).setReply(reply);
@@ -182,7 +182,7 @@ public class FedizConfigurationTest {
protocol = new SamlProtocolType();
}
config.setProtocol(protocol);
-
+
AudienceUris audienceUris = new AudienceUris();
audienceUris.getAudienceItem().add(AUDIENCE_URI_1);
audienceUris.getAudienceItem().add(AUDIENCE_URI_2);
@@ -208,7 +208,7 @@ public class FedizConfigurationTest {
CallbackType realm = new CallbackType();
realm.setValue(TARGET_REALM);
protocol.setRealm(realm);
-
+
CallbackType issuer = new CallbackType();
issuer.setValue(ISSUER);
protocol.setIssuer(issuer);
@@ -226,11 +226,11 @@ public class FedizConfigurationTest {
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
-
+
StringReader reader = new StringReader(writer.toString());
jaxbContext.createUnmarshaller().unmarshal(reader);
}
-
+
@org.junit.Test
public void readWriteConfigSAML() throws JAXBException {
@@ -240,7 +240,7 @@ public class FedizConfigurationTest {
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
-
+
StringReader reader = new StringReader(writer.toString());
jaxbContext.createUnmarshaller().unmarshal(reader);
}
@@ -254,7 +254,7 @@ public class FedizConfigurationTest {
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
@@ -262,12 +262,12 @@ public class FedizConfigurationTest {
f.createNewFile();
configurator.saveConfiguration(f);
-
+
configurator = new FedizConfigurator();
f = new File(CONFIG_FILE);
configurator.loadConfig(f);
}
-
+
@org.junit.Test
public void testSaveAndLoadConfigSAML() throws JAXBException, IOException {
final JAXBContext jaxbContext = JAXBContext
@@ -277,7 +277,7 @@ public class FedizConfigurationTest {
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(configOut, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
@@ -285,7 +285,7 @@ public class FedizConfigurationTest {
f.createNewFile();
configurator.saveConfiguration(f);
-
+
configurator = new FedizConfigurator();
f = new File(CONFIG_FILE);
configurator.loadConfig(f);
@@ -315,7 +315,7 @@ public class FedizConfigurationTest {
Assert.assertEquals(HOME_REALM_CLASS, fp.getHomeRealm().getValue());
}
-
+
@org.junit.Test
public void verifyConfigSAML() throws JAXBException {
@@ -336,74 +336,74 @@ public class FedizConfigurationTest {
Assert.assertTrue(config.getProtocol() instanceof SamlProtocolType);
}
-
+
@org.junit.Test
public void testTokenReplayCacheFederation() throws JAXBException, IOException {
FedizConfig config = createConfiguration(true);
-
+
// Test the default TokenReplayCache
ReplayCache defaultReplayCache = parseConfigAndReturnTokenReplayCache(config);
Assert.assertNotNull(defaultReplayCache);
Assert.assertTrue(defaultReplayCache instanceof EHCacheReplayCache);
-
+
// Now test setting another TokenReplayCache
ContextConfig contextConfig = config.getContextConfig().get(0);
contextConfig.setTokenReplayCache("org.apache.wss4j.common.cache.MemoryReplayCache");
-
+
ReplayCache newReplayCache = parseConfigAndReturnTokenReplayCache(config);
Assert.assertNotNull(newReplayCache);
Assert.assertTrue(newReplayCache instanceof MemoryReplayCache);
-
+
// Now test setting another TokenReplayCache
contextConfig.setTokenReplayCache("org.apache.wss4j.common.cache.EHCacheReplayCache");
-
+
newReplayCache = parseConfigAndReturnTokenReplayCache(config);
Assert.assertNotNull(newReplayCache);
Assert.assertTrue(newReplayCache instanceof EHCacheReplayCache);
}
-
+
@org.junit.Test
public void testTokenReplayCacheSAML() throws JAXBException, IOException {
FedizConfig config = createConfiguration(false);
-
+
// Test the default TokenReplayCache
ReplayCache defaultReplayCache = parseConfigAndReturnTokenReplayCache(config);
Assert.assertNotNull(defaultReplayCache);
Assert.assertTrue(defaultReplayCache instanceof EHCacheReplayCache);
-
+
// Now test setting another TokenReplayCache
ContextConfig contextConfig = config.getContextConfig().get(0);
contextConfig.setTokenReplayCache("org.apache.wss4j.common.cache.MemoryReplayCache");
-
+
ReplayCache newReplayCache = parseConfigAndReturnTokenReplayCache(config);
Assert.assertNotNull(newReplayCache);
Assert.assertTrue(newReplayCache instanceof MemoryReplayCache);
-
+
// Now test setting another TokenReplayCache
contextConfig.setTokenReplayCache("org.apache.wss4j.common.cache.EHCacheReplayCache");
-
+
newReplayCache = parseConfigAndReturnTokenReplayCache(config);
Assert.assertNotNull(newReplayCache);
Assert.assertTrue(newReplayCache instanceof EHCacheReplayCache);
}
-
- private ReplayCache parseConfigAndReturnTokenReplayCache(FedizConfig config)
+
+ private ReplayCache parseConfigAndReturnTokenReplayCache(FedizConfig config)
throws JAXBException {
final JAXBContext jaxbContext = JAXBContext.newInstance(FedizConfig.class);
-
+
StringWriter writer = new StringWriter();
jaxbContext.createMarshaller().marshal(config, writer);
StringReader reader = new StringReader(writer.toString());
-
+
FedizConfigurator configurator = new FedizConfigurator();
configurator.loadConfig(reader);
FedizContext fedContext = configurator.getFedizContext(CONFIG_NAME);
Assert.assertNotNull(fedContext);
-
+
return fedContext.getTokenReplayCache();
}
-
+
@org.junit.Test
public void testDefaultValues() throws JAXBException, IOException {
ContextConfig config = new ContextConfig();
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java
index 4b60206..d4d4bf3 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/FedizConfigurationWriterTest.java
@@ -74,7 +74,7 @@ public class FedizConfigurationWriterTest {
private static final String KEYSTORE_PASSWORD = "storepass";
private static final String KEY_PASSWORD = "stskpass";
private static final String KEY_ALIAS = "mystskey";
-
+
private static final String AUDIENCE_URI_1 = "http://host_one:port/url";
private static final String AUTH_TYPE_VALUE = "some auth type";
@@ -83,14 +83,14 @@ public class FedizConfigurationWriterTest {
private static final String CLAIM_TYPE_2 = "another claim type";
private static final String CONFIG_FILE = "./target/fediz_test_config.xml";
-
- private static final String TEST_WREQ =
+
+ private static final String TEST_WREQ =
"<RequestSecurityToken xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\">"
+ "<t:TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</t:TokenType>"
+ "</RequestSecurityToken>";
-
-
-
+
+
+
@AfterClass
public static void cleanup() {
SecurityTestUtil.cleanup();
@@ -109,17 +109,17 @@ public class FedizConfigurationWriterTest {
KeyManagersType sigManager = new KeyManagersType();
sigManager.setKeyPassword(KEY_PASSWORD);
sigManager.setKeyAlias(KEY_ALIAS);
-
+
KeyStoreType sigStore = new KeyStoreType();
sigStore.setType(JKS_TYPE);
sigStore.setPassword(KEYSTORE_PASSWORD);//integrity password
sigStore.setFile(KEYSTORE_FILE);
sigManager.setKeyStore(sigStore);
-
+
config.setSigningKey(sigManager);
-
+
TrustedIssuers trustedIssuers = new TrustedIssuers();
-
+
TrustedIssuerType trustedIssuer = new TrustedIssuerType();
trustedIssuer.setCertificateValidation(ValidationType.CHAIN_TRUST);
trustedIssuer.setName(TRUST_ISSUER_NAME);
@@ -129,7 +129,7 @@ public class FedizConfigurationWriterTest {
CertificateStores certStores = new CertificateStores();
TrustManagersType truststore = new TrustManagersType();
-
+
KeyStoreType ks1 = new KeyStoreType();
ks1.setType(JKS_TYPE);
ks1.setPassword(KEYSTORE_PASSWORD);
@@ -141,7 +141,7 @@ public class FedizConfigurationWriterTest {
CallbackType authType = new CallbackType();
authType.setType(ArgumentType.STRING);
authType.setValue(AUTH_TYPE_VALUE);
-
+
CallbackType tokenRequest = new CallbackType();
tokenRequest.setType(ArgumentType.STRING);
tokenRequest.setValue(TEST_WREQ);
@@ -149,15 +149,15 @@ public class FedizConfigurationWriterTest {
AudienceUris audienceUris = new AudienceUris();
audienceUris.getAudienceItem().add(AUDIENCE_URI_1);
config.setAudienceUris(audienceUris);
-
+
ProtocolType protocol = null;
-
+
if (federation) {
protocol = new FederationProtocolType();
-
+
((FederationProtocolType)protocol).setAuthenticationType(authType);
((FederationProtocolType)protocol).setRequest(tokenRequest);
-
+
CallbackType freshness = new CallbackType();
freshness.setValue(FRESHNESS_VALUE);
((FederationProtocolType)protocol).setFreshness(freshness);
@@ -166,7 +166,7 @@ public class FedizConfigurationWriterTest {
homeRealm.setType(ArgumentType.CLASS);
homeRealm.setValue(HOME_REALM_CLASS);
((FederationProtocolType)protocol).setHomeRealm(homeRealm);
-
+
CallbackType reply = new CallbackType();
reply.setValue(REPLY);
((FederationProtocolType)protocol).setReply(reply);
@@ -194,11 +194,11 @@ public class FedizConfigurationWriterTest {
CallbackType realm = new CallbackType();
realm.setValue(TARGET_REALM);
protocol.setRealm(realm);
-
+
CallbackType issuer = new CallbackType();
issuer.setValue(ISSUER);
protocol.setIssuer(issuer);
-
+
TokenValidators x = new TokenValidators();
x.getValidator().add("org.apache.cxf.fediz.CustomValidator");
x.getValidator().add("org.apache.cxf.fediz.core.NonexistentCustomValidator");
@@ -221,7 +221,7 @@ public class FedizConfigurationWriterTest {
StringReader reader = new StringReader(writer.toString());
jaxbContext.createUnmarshaller().unmarshal(reader);
}
-
+
@org.junit.Test
public void readWriteConfigSAML() throws JAXBException {
@@ -252,12 +252,12 @@ public class FedizConfigurationWriterTest {
f.createNewFile();
configurator.saveConfiguration(f);
-
+
configurator = new FedizConfigurator();
f = new File(CONFIG_FILE);
configurator.loadConfig(f);
}
-
+
@org.junit.Test
public void testSaveAndLoadConfigSAML() throws JAXBException, IOException {
final JAXBContext jaxbContext = JAXBContext
@@ -274,7 +274,7 @@ public class FedizConfigurationWriterTest {
f.createNewFile();
configurator.saveConfiguration(f);
-
+
configurator = new FedizConfigurator();
f = new File(CONFIG_FILE);
configurator.loadConfig(f);
@@ -285,7 +285,7 @@ public class FedizConfigurationWriterTest {
final JAXBContext jaxbContext = JAXBContext
.newInstance(FedizConfig.class);
-
+
/**
* Test JAXB part
*/
@@ -306,7 +306,7 @@ public class FedizConfigurationWriterTest {
Assert.assertEquals(HOME_REALM_CLASS, fp.getHomeRealm().getValue());
//Assert.assertEquals(config.getCertificateValidation(),ValidationType.CHAIN_TRUST);
-
+
/**
* Check Runtime configuration
*/
@@ -315,15 +315,15 @@ public class FedizConfigurationWriterTest {
Assert.assertTrue(protocol instanceof FederationProtocol);
FederationProtocol fedProtocol = (FederationProtocol) protocol;
Assert.assertEquals(TARGET_REALM, fedProtocol.getRealm());
-
+
Object auth = fedProtocol.getAuthenticationType();
Assert.assertTrue(auth instanceof String);
Assert.assertEquals((String)auth, AUTH_TYPE_VALUE);
-
+
Object wreq = fedProtocol.getRequest();
Assert.assertTrue(wreq instanceof String);
Assert.assertEquals((String)wreq, TEST_WREQ);
-
+
//Assert.assertEquals(ValidationMethod.CHAIN_TRUST, fedContext.getCertificateValidation());
List<String> audienceUris = fedContext.getAudienceUris();
Assert.assertEquals(1, audienceUris.size());
@@ -333,18 +333,18 @@ public class FedizConfigurationWriterTest {
Assert.assertEquals(TRUST_ISSUER_NAME, issuer.getName());
Assert.assertEquals(CertificateValidationMethod.CHAIN_TRUST, issuer.getCertificateValidationMethod());
Assert.assertEquals(TRUST_ISSUER_CERT_CONSTRAINT, issuer.getSubject());
-
+
List<TrustManager> trustManagers = fedContext.getCertificateStores();
Assert.assertEquals(1, trustManagers.size());
}
-
+
@org.junit.Test
public void verifyConfigSAML() throws JAXBException {
final JAXBContext jaxbContext = JAXBContext
.newInstance(FedizConfig.class);
-
+
/**
* Test JAXB part
*/
@@ -370,7 +370,7 @@ public class FedizConfigurationWriterTest {
Assert.assertTrue(protocol instanceof SAMLProtocol);
SAMLProtocol samlProtocol = (SAMLProtocol) protocol;
Assert.assertEquals(TARGET_REALM, samlProtocol.getRealm());
-
+
List<String> audienceUris = fedContext.getAudienceUris();
Assert.assertEquals(1, audienceUris.size());
List<TrustedIssuer> trustedIssuers = fedContext.getTrustedIssuers();
@@ -379,7 +379,7 @@ public class FedizConfigurationWriterTest {
Assert.assertEquals(TRUST_ISSUER_NAME, issuer.getName());
Assert.assertEquals(CertificateValidationMethod.CHAIN_TRUST, issuer.getCertificateValidationMethod());
Assert.assertEquals(TRUST_ISSUER_CERT_CONSTRAINT, issuer.getSubject());
-
+
List<TrustManager> trustManagers = fedContext.getCertificateStores();
Assert.assertEquals(1, trustManagers.size());
http://git-wip-us.apache.org/repos/asf/cxf-fediz/blob/2ca31863/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/TestCallbackHandler.java
----------------------------------------------------------------------
diff --git a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/TestCallbackHandler.java b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/TestCallbackHandler.java
index 4302c32..a4af63c 100644
--- a/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/TestCallbackHandler.java
+++ b/plugins/core/src/test/java/org/apache/cxf/fediz/core/config/TestCallbackHandler.java
@@ -44,11 +44,11 @@ public class TestCallbackHandler implements CallbackHandler {
static final String TEST_WAUTH = "up";
static final String TEST_SIGNIN_QUERY = "pubid=myid";
static final String TEST_REPLY = "http://apache.org/reply";
- static final String TEST_WREQ =
+ static final String TEST_WREQ =
"<RequestSecurityToken xmlns=\"http://docs.oasis-open.org/ws-sx/ws-trust/200512\">"
+ "<TokenType>http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</TokenType>"
+ "</RequestSecurityToken>";
-
+
public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
if (callbacks[i] instanceof HomeRealmCallback) {