JBoss Identity SVN: r475 - in identity-federation/trunk: jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust and 3 other directories.
by jboss-identity-commits@lists.jboss.org
Author: sguilhen(a)redhat.com
Date: 2009-05-03 17:30:15 -0400 (Sun, 03 May 2009)
New Revision: 475
Added:
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/DefaultSecurityToken.java
Modified:
identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/subject/JBossIdentityPrincipal.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/JBossSTSUnitTestCase.java
identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/SpecialTokenProvider.java
identity-federation/trunk/jboss-identity-bindings/src/test/resources/jboss-sts.xml
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/StandardRequestHandler.java
identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/WSTrustUtil.java
identity-federation/trunk/jboss-identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/wstrust/MockSTSConfiguration.java
Log:
JBID-77: Added new tests to JBossSTSUnitTestCase
Modified: identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/subject/JBossIdentityPrincipal.java
===================================================================
--- identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/subject/JBossIdentityPrincipal.java 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-bindings/src/main/java/org/jboss/identity/federation/bindings/jboss/subject/JBossIdentityPrincipal.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -42,6 +42,6 @@
public String getName()
{
- return null;
+ return name;
}
}
\ No newline at end of file
Added: identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/DefaultSecurityToken.java
===================================================================
--- identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/DefaultSecurityToken.java (rev 0)
+++ identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/DefaultSecurityToken.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -0,0 +1,82 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2009, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.identity.federation.bindings.trust;
+
+import java.util.UUID;
+
+import org.jboss.identity.federation.api.wstrust.SecurityToken;
+import org.w3c.dom.Element;
+
+/**
+ * <p>
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a>
+ */
+public class DefaultSecurityToken implements SecurityToken
+{
+
+ private final String tokenType;
+
+ private final String tokenId;
+
+ private final Element token;
+
+ /**
+ *
+ * @param tokenType
+ * @param token
+ */
+ public DefaultSecurityToken(String tokenType, Element token)
+ {
+ this.tokenType = tokenType;
+ this.tokenId = UUID.randomUUID().toString();
+ this.token = token;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.identity.federation.api.wstrust.SecurityToken#getTokenType()
+ */
+ public String getTokenType()
+ {
+ return this.tokenType;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.jboss.identity.federation.api.wstrust.SecurityToken#getTokenValue()
+ */
+ public Object getTokenValue()
+ {
+ return this.token;
+ }
+
+ /**
+ *
+ * @return
+ */
+ public String getTokenId()
+ {
+ return this.tokenId;
+ }
+}
Modified: identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/JBossSTSUnitTestCase.java
===================================================================
--- identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/JBossSTSUnitTestCase.java 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/JBossSTSUnitTestCase.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -21,13 +21,36 @@
*/
package org.jboss.test.identity.federation.bindings.trust;
+import java.net.URI;
+import java.security.Principal;
+
+import javax.xml.transform.Source;
+import javax.xml.ws.EndpointReference;
+import javax.xml.ws.WebServiceContext;
+import javax.xml.ws.WebServiceException;
+import javax.xml.ws.handler.MessageContext;
+
import junit.framework.TestCase;
import org.jboss.identity.federation.api.wstrust.STSConfiguration;
import org.jboss.identity.federation.api.wstrust.SecurityTokenProvider;
import org.jboss.identity.federation.api.wstrust.StandardRequestHandler;
+import org.jboss.identity.federation.api.wstrust.WSTrustException;
+import org.jboss.identity.federation.api.wstrust.WSTrustJAXBFactory;
import org.jboss.identity.federation.api.wstrust.WSTrustRequestHandler;
+import org.jboss.identity.federation.api.wstrust.protocol.BaseRequestSecurityTokenResponse;
+import org.jboss.identity.federation.api.wstrust.protocol.RequestSecurityToken;
+import org.jboss.identity.federation.api.wstrust.protocol.RequestSecurityTokenResponse;
+import org.jboss.identity.federation.api.wstrust.protocol.RequestSecurityTokenResponseCollection;
+import org.jboss.identity.federation.bindings.jboss.subject.JBossIdentityPrincipal;
import org.jboss.identity.federation.bindings.jboss.trust.JBossSTS;
+import org.jboss.identity.federation.ws.addressing.AttributedURIType;
+import org.jboss.identity.federation.ws.addressing.EndpointReferenceType;
+import org.jboss.identity.federation.ws.addressing.ObjectFactory;
+import org.jboss.identity.federation.ws.policy.AppliesTo;
+import org.jboss.identity.federation.ws.trust.LifetimeType;
+import org.jboss.identity.federation.ws.trust.RequestedSecurityTokenType;
+import org.w3c.dom.Element;
/**
* <p>
@@ -86,18 +109,18 @@
assertTrue("Unexpected request handler type", handler instanceof StandardRequestHandler);
// check the token type -> token provider mapping.
- SecurityTokenProvider provider = config.getProviderForTokenType("specialToken");
+ SecurityTokenProvider provider = config.getProviderForTokenType("http://www.tokens.org/SpecialToken");
assertNotNull("Unexpected null token provider", provider);
assertTrue("Unexpected token provider type", provider instanceof SpecialTokenProvider);
- provider = config.getProviderForTokenType("standardToken");
+ provider = config.getProviderForTokenType("http://www.tokens.org/StandardToken");
assertNotNull("Unexpected null token provider", provider);
assertTrue("Unexpected token provider type", provider instanceof StandardTokenProvider);
assertNull(config.getProviderForTokenType("unexistentType"));
// check the service provider -> token type mapping.
- assertEquals("Invalid token type for service provider 1", "specialToken", config
+ assertEquals("Invalid token type for service provider 1", "http://www.tokens.org/SpecialToken", config
.getTokenTypeForService("http://services.testcorp.org/provider1"));
- assertEquals("Invalid token type for service provider 2", "standardToken", config
+ assertEquals("Invalid token type for service provider 2", "http://www.tokens.org/StandardToken", config
.getTokenTypeForService("http://services.testcorp.org/provider2"));
assertNull(config.getTokenTypeForService("http://invalid.service/service"));
@@ -120,6 +143,172 @@
/**
* <p>
+ * This tests sets up some simple token providers and then sends security token requests to JBossSTS. The returned
+ * response is verified to make sure the expected tokens have been returned by the service. The token that is
+ * generated in this test looks as follows:
+ *
+ * <pre>
+ * <token:SpecialToken xmlns:token="http://www.tokens.org" TokenType="http://www.tokens.org/SpecialToken">
+ * Principal:sguilhen
+ * </token:SpecialToken>
+ * </pre>
+ *
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testInvoke() throws Exception
+ {
+ // create a simple token request, asking for a "special" test token.
+ RequestSecurityToken request = new RequestSecurityToken();
+ request.setContext("testcontext");
+ request.setTokenType(new URI("http://www.tokens.org/SpecialToken"));
+ request.setRequestType(new URI("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue"));
+
+ // use the factory to marshall the request.
+ WSTrustJAXBFactory factory = WSTrustJAXBFactory.getInstance();
+ Source requestMessage = factory.marshallRequestSecurityToken(request);
+
+ // set up the security token service, injecting the context.
+ TestSTS tokenService = new TestSTS();
+ TestContext context = new TestContext();
+ context.setUserPrincipal(new JBossIdentityPrincipal("sguilhen"));
+ tokenService.setContext(context);
+
+ // invoke the token service.
+ Source responseMessage = tokenService.invoke(requestMessage);
+ BaseRequestSecurityTokenResponse baseResponse = WSTrustJAXBFactory.getInstance()
+ .parseRequestSecurityTokenResponse(responseMessage);
+
+ // validate the received response.
+ assertNotNull("Unexpected null response", baseResponse);
+ assertTrue("Unexpected response type", baseResponse instanceof RequestSecurityTokenResponseCollection);
+ RequestSecurityTokenResponseCollection collection = (RequestSecurityTokenResponseCollection) baseResponse;
+ assertEquals("Unexpected number of responses", 1, collection.getRequestSecurityTokenResponses().size());
+ RequestSecurityTokenResponse response = collection.getRequestSecurityTokenResponses().get(0);
+ assertEquals("Unexpected response context", "testcontext", response.getContext());
+ assertEquals("Unexpected token type", "http://www.tokens.org/SpecialToken", response.getTokenType().toString());
+ LifetimeType lifetime = response.getLifetime();
+ assertNotNull("Unexpected null token lifetime", lifetime);
+
+ // validate the received token.
+ RequestedSecurityTokenType requestedToken = response.getRequestedSecurityToken();
+ assertNotNull("Unexpected null requested security token", requestedToken);
+ Object token = requestedToken.getAny();
+ assertNotNull("Unexpected null token", token);
+ assertTrue("Unexpected token class", token instanceof Element);
+ Element element = (Element) requestedToken.getAny();
+ assertEquals("Unexpected namespace value", "http://www.tokens.org", element.getNamespaceURI());
+ assertEquals("Unexpected attribute value", "http://www.tokens.org/SpecialToken", element
+ .getAttribute("TokenType"));
+ assertEquals("Unexpected token value", "Principal:sguilhen", element.getFirstChild().getNodeValue());
+ }
+
+ /**
+ * <p>
+ * This test requests a token to the STS using the {@code AppliesTo} to identify the service provider. The STS must
+ * be able to find out the type of the token that must be issued using the service provider URI.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testInvokeAppliesTo() throws Exception
+ {
+ // create a simple token request, this time using the applies to get to the token type.
+ AttributedURIType attributedURI = new AttributedURIType();
+ attributedURI.setValue("http://services.testcorp.org/provider1");
+ EndpointReferenceType reference = new EndpointReferenceType();
+ reference.setAddress(attributedURI);
+ AppliesTo appliesTo = new AppliesTo();
+ appliesTo.getAny().add(new ObjectFactory().createEndpointReference(reference));
+
+ RequestSecurityToken request = new RequestSecurityToken();
+ request.setContext("testcontext");
+ request.setRequestType(new URI("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue"));
+ request.setAppliesTo(appliesTo);
+
+ // use the factory to marshall the request.
+ WSTrustJAXBFactory factory = WSTrustJAXBFactory.getInstance();
+ Source requestMessage = factory.marshallRequestSecurityToken(request);
+
+ // set up the security token service, injecting the context.
+ TestSTS tokenService = new TestSTS();
+ TestContext context = new TestContext();
+ context.setUserPrincipal(new JBossIdentityPrincipal("sguilhen"));
+ tokenService.setContext(context);
+
+ // invoke the token service.
+ Source responseMessage = tokenService.invoke(requestMessage);
+ BaseRequestSecurityTokenResponse baseResponse = WSTrustJAXBFactory.getInstance()
+ .parseRequestSecurityTokenResponse(responseMessage);
+
+ // validate the received response.
+ assertNotNull("Unexpected null response", baseResponse);
+ assertTrue("Unexpected response type", baseResponse instanceof RequestSecurityTokenResponseCollection);
+ RequestSecurityTokenResponseCollection collection = (RequestSecurityTokenResponseCollection) baseResponse;
+ assertEquals("Unexpected number of responses", 1, collection.getRequestSecurityTokenResponses().size());
+ RequestSecurityTokenResponse response = collection.getRequestSecurityTokenResponses().get(0);
+ assertEquals("Unexpected response context", "testcontext", response.getContext());
+ assertEquals("Unexpected token type", "http://www.tokens.org/SpecialToken", response.getTokenType().toString());
+ LifetimeType lifetime = response.getLifetime();
+ assertNotNull("Unexpected null token lifetime", lifetime);
+
+ // validate the received token.
+ RequestedSecurityTokenType requestedToken = response.getRequestedSecurityToken();
+ assertNotNull("Unexpected null requested security token", requestedToken);
+ Object token = requestedToken.getAny();
+ assertNotNull("Unexpected null token", token);
+ assertTrue("Unexpected token class", token instanceof Element);
+ Element element = (Element) requestedToken.getAny();
+ assertEquals("Unexpected namespace value", "http://www.tokens.org", element.getNamespaceURI());
+ assertEquals("Unexpected attribute value", "http://www.tokens.org/SpecialToken", element
+ .getAttribute("TokenType"));
+ assertEquals("Unexpected token value", "Principal:sguilhen", element.getFirstChild().getNodeValue());
+ }
+
+ /**
+ * <p>
+ * This test tries to request a token of an unknown type, checking if an exception is correctly thrown by the
+ * security token service.
+ * </p>
+ *
+ * @throws Exception if an error occurs while running the test.
+ */
+ public void testInvokeUnknownTokenType() throws Exception
+ {
+ // create a simple token request, asking for an "unknown" test token.
+ RequestSecurityToken request = new RequestSecurityToken();
+ request.setContext("testcontext");
+ request.setTokenType(new URI("http://www.tokens.org/UnknownToken"));
+ request.setRequestType(new URI("http://docs.oasis-open.org/ws-sx/ws-trust/200512/Issue"));
+
+ // use the factory to marshall the request.
+ WSTrustJAXBFactory factory = WSTrustJAXBFactory.getInstance();
+ Source requestMessage = factory.marshallRequestSecurityToken(request);
+
+ // set up the security token service, injecting the context.
+ TestSTS tokenService = new TestSTS();
+ TestContext context = new TestContext();
+ context.setUserPrincipal(new JBossIdentityPrincipal("sguilhen"));
+ tokenService.setContext(context);
+
+ // invoke the security token service.
+ try
+ {
+ tokenService.invoke(requestMessage);
+ fail("An exception should have been raised by the security token service");
+ }
+ catch (WebServiceException we)
+ {
+ assertEquals("Unexpected exception message", "Unable to find a token provider for the token request", we
+ .getMessage());
+ assertNotNull("Unexpected null cause", we.getCause());
+ assertTrue("Unexpected cause type", we.getCause() instanceof WSTrustException);
+ }
+ }
+
+ /**
+ * <p>
* Helper class that exposes the JBossSTS methods as public for the tests to work.
* </p>
*
@@ -127,10 +316,91 @@
*/
class TestSTS extends JBossSTS
{
+
@Override
public STSConfiguration getConfiguration()
{
return super.getConfiguration();
}
+
+ public void setContext(WebServiceContext context)
+ {
+ super.context = context;
+ }
}
+
+ /**
+ * <p>
+ * Helper class that mocks a {@code WebServiceContext}. It is used in the JBoss STS test cases.
+ * </p>
+ *
+ * @author <a href="mailto:sguilhen@redhat.com">Stefan Guilhen</a>
+ */
+ class TestContext implements WebServiceContext
+ {
+
+ private Principal principal;
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.xml.ws.WebServiceContext#getEndpointReference(java.lang.Class, org.w3c.dom.Element[])
+ */
+ public <T extends EndpointReference> T getEndpointReference(Class<T> arg0, Element... arg1)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.xml.ws.WebServiceContext#getEndpointReference(org.w3c.dom.Element[])
+ */
+ public EndpointReference getEndpointReference(Element... arg0)
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.xml.ws.WebServiceContext#getMessageContext()
+ */
+ public MessageContext getMessageContext()
+ {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.xml.ws.WebServiceContext#getUserPrincipal()
+ */
+ public Principal getUserPrincipal()
+ {
+ return this.principal;
+ }
+
+ /**
+ * <p>
+ * Sets the principal to be used in the test case.
+ * </p>
+ *
+ * @param principal the {@code Principal} to be set.
+ */
+ public void setUserPrincipal(Principal principal)
+ {
+ this.principal = principal;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see javax.xml.ws.WebServiceContext#isUserInRole(java.lang.String)
+ */
+ public boolean isUserInRole(String arg0)
+ {
+ return false;
+ }
+ }
}
Modified: identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/SpecialTokenProvider.java
===================================================================
--- identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/SpecialTokenProvider.java 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-bindings/src/test/java/org/jboss/test/identity/federation/bindings/trust/SpecialTokenProvider.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -21,9 +21,19 @@
*/
package org.jboss.test.identity.federation.bindings.trust;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.jboss.identity.federation.api.wstrust.SecurityToken;
import org.jboss.identity.federation.api.wstrust.SecurityTokenProvider;
import org.jboss.identity.federation.api.wstrust.WSTrustException;
import org.jboss.identity.federation.api.wstrust.WSTrustRequestContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
/**
* <p>
@@ -51,6 +61,40 @@
*/
public void issueToken(WSTrustRequestContext context) throws WSTrustException
{
+ // create a simple sample token using the info from the request.
+ String caller = context.getCallerPrincipal() == null? "anonymous" : context.getCallerPrincipal().getName();
+ URI tokenType = context.getRequestSecurityToken().getTokenType();
+ if(tokenType == null)
+ {
+ try
+ {
+ tokenType = new URI("http://www.tokens.org/SpecialToken");
+ }
+ catch (URISyntaxException e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ // we will use DOM to create the token.
+ try
+ {
+ DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder = factory.newDocumentBuilder();
+ Document doc = docBuilder.newDocument();
+
+ Element root = doc.createElementNS("http://www.tokens.org", "token:SpecialToken");
+ root.appendChild(doc.createTextNode("Principal:" + caller));
+ root.setAttribute("TokenType", tokenType.toString());
+ doc.appendChild(root);
+
+ SecurityToken token = new DefaultSecurityToken(tokenType.toString(), root);
+ context.setSecurityToken(token);
+ }
+ catch(ParserConfigurationException pce)
+ {
+ pce.printStackTrace();
+ }
}
/*
@@ -70,5 +114,4 @@
public void validateToken(WSTrustRequestContext context) throws WSTrustException
{
}
-
}
Modified: identity-federation/trunk/jboss-identity-bindings/src/test/resources/jboss-sts.xml
===================================================================
--- identity-federation/trunk/jboss-identity-bindings/src/test/resources/jboss-sts.xml 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-bindings/src/test/resources/jboss-sts.xml 2009-05-03 21:30:15 UTC (rev 475)
@@ -11,14 +11,14 @@
<RequestHandler>org.jboss.identity.federation.api.wstrust.StandardRequestHandler</RequestHandler>
<TokenProviders>
<TokenProvider ProviderClass="org.jboss.test.identity.federation.bindings.trust.SpecialTokenProvider"
- TokenType="specialToken"/>
+ TokenType="http://www.tokens.org/SpecialToken"/>
<TokenProvider ProviderClass="org.jboss.test.identity.federation.bindings.trust.StandardTokenProvider"
- TokenType="standardToken"/>
+ TokenType="http://www.tokens.org/StandardToken"/>
</TokenProviders>
<ServiceProviders>
- <ServiceProvider Endpoint="http://services.testcorp.org/provider1" TokenType="specialToken"
+ <ServiceProvider Endpoint="http://services.testcorp.org/provider1" TokenType="http://www.tokens.org/SpecialToken"
TruststoreAlias="service1"/>
- <ServiceProvider Endpoint="http://services.testcorp.org/provider2" TokenType="standardToken"
+ <ServiceProvider Endpoint="http://services.testcorp.org/provider2" TokenType="http://www.tokens.org/StandardToken"
TruststoreAlias="service2"/>
</ServiceProviders>
</JBossSTS>
\ No newline at end of file
Modified: identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/StandardRequestHandler.java
===================================================================
--- identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/StandardRequestHandler.java 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/StandardRequestHandler.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -70,7 +70,10 @@
{
String serviceName = WSTrustUtil.parseAppliesTo(appliesTo);
if (serviceName != null)
+ {
provider = this.configuration.getProviderForService(serviceName);
+ request.setTokenType(WSTrustUtil.getURI(this.configuration.getTokenTypeForService(serviceName)));
+ }
}
// if applies-to is not available or if no provider was found for the service, use the token type.
if (provider == null && request.getTokenType() != null)
@@ -91,10 +94,13 @@
request.setLifetime(lifetime);
}
provider.issueToken(requestContext);
-
+
+ if(requestContext.getSecurityToken() == null)
+ throw new WSTrustException("Token issued by provider " + provider.getClass().getName() + " is null");
+
// construct the ws-trust security token response.
RequestedSecurityTokenType requestedSecurityToken = new RequestedSecurityTokenType();
- requestedSecurityToken.setAny(requestContext.getSecurityToken());
+ requestedSecurityToken.setAny(requestContext.getSecurityToken().getTokenValue());
// TODO: create proof token and encrypt the token if needed
Modified: identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/WSTrustUtil.java
===================================================================
--- identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/WSTrustUtil.java 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-fed-api/src/main/java/org/jboss/identity/federation/api/wstrust/WSTrustUtil.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -21,6 +21,8 @@
*/
package org.jboss.identity.federation.api.wstrust;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;
@@ -67,7 +69,7 @@
}
if (reference != null && reference.getAddress() != null)
- return reference.getAddress().toString();
+ return reference.getAddress().getValue();
}
return null;
}
@@ -122,4 +124,24 @@
// return the UTC/GMT time.
return cal.getTimeInMillis() - offset;
}
+
+ /**
+ * <p>
+ * Utility method for creating URIs without having to deal with the {@code URISyntaxException}.
+ * </p>
+ *
+ * @param text the URI in its {@code String} form.
+ * @return the constructed {@code URI}.
+ */
+ public static URI getURI(String text)
+ {
+ try
+ {
+ return new URI(text);
+ }
+ catch(URISyntaxException use)
+ {
+ throw new RuntimeException(use);
+ }
+ }
}
Modified: identity-federation/trunk/jboss-identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/wstrust/MockSTSConfiguration.java
===================================================================
--- identity-federation/trunk/jboss-identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/wstrust/MockSTSConfiguration.java 2009-05-01 16:47:01 UTC (rev 474)
+++ identity-federation/trunk/jboss-identity-fed-api/src/test/java/org/jboss/test/identity/federation/api/wstrust/MockSTSConfiguration.java 2009-05-03 21:30:15 UTC (rev 475)
@@ -109,21 +109,33 @@
return null;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.identity.federation.api.wstrust.STSConfiguration#getSTSName()
+ */
public String getSTSName()
{
- // TODO Auto-generated method stub
return null;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.identity.federation.api.wstrust.STSConfiguration#getSigningKey()
+ */
public PrivateKey getSigningKey()
{
- // TODO Auto-generated method stub
return null;
}
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.jboss.identity.federation.api.wstrust.STSConfiguration#getTokenTypeForService(java.lang.String)
+ */
public String getTokenTypeForService(String serviceName)
{
- // TODO Auto-generated method stub
return null;
}
15 years, 8 months
JBoss Identity SVN: r474 - authz.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-05-01 12:47:01 -0400 (Fri, 01 May 2009)
New Revision: 474
Added:
authz/trunk/
Log:
create authz
15 years, 8 months
JBoss Identity SVN: r473 - /.
by jboss-identity-commits@lists.jboss.org
Author: anil.saldhana(a)jboss.com
Date: 2009-05-01 12:46:54 -0400 (Fri, 01 May 2009)
New Revision: 473
Added:
authz/
Log:
create authz
15 years, 8 months