Package org.picketlink.identity.federation.api.wstrust

Examples of org.picketlink.identity.federation.api.wstrust.WSTrustClient


       
        String userName = (args.length > 0 ? args[0] : "tomcat");
        String password = (args.length > 1 ? args[1] : "tomcat");
       
        // Step 1: Create a WS Trust Client
        WSTrustClient client = new WSTrustClient("PicketLinkSTS", "PicketLinkSTSPort", "http://localhost:8080/picketlink-sts/PicketLinkSTS",
                new SecurityInfo(userName, password));
        Element assertionElement = null;
        try {
            System.out.println("Invoking token service to get SAML assertion for user:" + userName + " with password:" + password);
            // Step 2: Get a SAML2 Assertion Token from the PicketLink STS
            assertionElement = client.issueToken(SAMLUtil.SAML2_TOKEN_TYPE);
            System.out.println("SAML assertion for user:" + userName + " successfully obtained!");
        } catch (WSTrustException wse) {
            System.out.println("Unable to issue assertion: " + wse.getMessage());
            wse.printStackTrace();
            System.exit(1);
View Full Code Here


  }

  public Element testSTS() throws Exception
  {
    // create a WSTrustClient instance.
    WSTrustClient client = new WSTrustClient("PicketLinkSTS", "PicketLinkSTSPort",
      "http://localhost:8080/picketlink-sts/PicketLinkSTS",
      new SecurityInfo("admin", "admin"));
   
    // issue a SAML assertion using the client API.
    Element assertion = null;
    try
    {
      assertion = client.issueToken(SAMLUtil.SAML2_TOKEN_TYPE);
    }
    catch (WSTrustException wse)
    {
      log.error("Unable to issue assertion: ", wse);
    }
View Full Code Here

    }
  }

  public Element testSTS() throws Exception
  {
    WSTrustClient client = new WSTrustClient("PicketLinkSTS", "PicketLinkSTSPort",
      "http://localhost:8080/picketlink-sts/PicketLinkSTS",
      new SecurityInfo("UserB", "PassB"));
   
    Element assertion = null;
    try
    {
      RequestSecurityToken request = new RequestSecurityToken();
      request.setTokenType(URI.create(SAMLUtil.SAML2_TOKEN_TYPE));
      AttributedString as = new AttributedString();
      as.setValue("UserA");
      as.setId("UserA");
      UsernameTokenType utt = new UsernameTokenType();
      utt.setUsername(as);
      utt.setId("UserA");
      OnBehalfOfType obot = new OnBehalfOfType();
      obot.add(utt);
      request.setOnBehalfOf(obot);
      assertion = client.issueToken(request);
    }
    catch (WSTrustException wse)
    {
      log.error("Unable to issue assertion: ", wse);
    }
View Full Code Here

                if (propertiesFile != null) {
                    builder = new Builder(propertiesFile);
                } else
                    throw logger.optionNotSet("propertiesFile");
            }
            WSTrustClient client = new WSTrustClient(builder.getServiceName(), builder.getPortName(),
                    builder.getEndpointAddress(), new SecurityInfo(principal.getName(), credential));
            Element assertion = null;
            try {
                logger.trace("Invoking token service to get SAML assertion for " + principal.getName());
                // create the token
                assertion = client.issueToken(SAMLUtil.SAML2_TOKEN_TYPE);

                logger.trace("SAML assertion for " + principal.getName() + " successfully obtained");
            } catch (WSTrustException wse) {
                logger.authSAMLAssertionIssuingFailed(wse);
            }
View Full Code Here

            http.uninitialize();
        }
    }

    private static Element getAssertion() throws Exception {
        WSTrustClient client = new WSTrustClient("PicketLinkSTS", "PicketLinkSTSPort",
            "http://localhost:8080/picketlink-sts/PicketLinkSTS", new SecurityInfo("admin", "admin"));
        //Element assertion = client.issueTokenForEndpoint("urn:switchyard-quickstart-demo:policy-security-saml:0.1.0");
        Element assertion = client.issueToken(SAMLUtil.SAML2_TOKEN_TYPE);
        /*
        boolean valid = client.validateToken(assertion);
        if (valid) {
            LOGGER.info("Token is valid.");
        } else {
View Full Code Here

TOP

Related Classes of org.picketlink.identity.federation.api.wstrust.WSTrustClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.