/** * Creates a SAML Assertion that can be used as a bearer token when invoking REST services. The * REST service must be configured to accept SAML Assertion bearer tokens. * * <p>In JBoss this means protecting the REST services with {@link SAMLBearerTokenLoginModule}. In * Tomcat7 this means protecting the REST services with {@link SAMLBearerTokenAuthenticator}. * * @param issuerName the issuer name (typically the context of the calling web app) * @param forService the web context of the REST service being invoked * @param timeValidInMillis how long the saml assertion should be valid for (in milliseconds) */ public static String createSAMLAssertion( String issuerName, String forService, int timeValidInMillis) { SAMLAssertionFactory factory = getSAMLAssertionFactory(); if (factory == null) { throw new RuntimeException( "Failed to create SAML Assertion: Unsupported/undetected platform."); //$NON-NLS-1$ } else { return factory.createSAMLAssertion(issuerName, forService, timeValidInMillis); } }