Package org.gatein.wci.security

Examples of org.gatein.wci.security.Credentials


     login(credentials, request, response, validityMillis, null);
  }

  public void login(Credentials credentials, HttpServletRequest request, HttpServletResponse response, long validityMillis, String initialURI) throws IOException
  {
     String ticket = TICKET_SERVICE.createTicket(new Credentials(credentials.getUsername(), credentials.getPassword()), validityMillis);

     request.getSession().removeAttribute(Credentials.CREDENTIALS);

     if (initialURI == null) {
        initialURI = request.getRequestURI();
View Full Code Here


      if (propertyMap.containsKey(WSHandlerConstants.USER) && propertyMap.get(WSHandlerConstants.USER).equals(GTN_CURRENT_USER))
      {
         CredentialsAccessor credentialsAccessor = CredentialsAccess.getInstance().getCredentialsAccessor();
         if (credentialsAccessor != null && credentialsAccessor.getCredentials() != null)
         {
            Credentials credentials = credentialsAccessor.getCredentials();
            propertyMap.put(WSHandlerConstants.USER, credentials.getUsername());

            String actionProperty = (String)propertyMap.get(WSHandlerConstants.ACTION);
            //Note: the action property can contain a space separated list of multiple actions
            if (actionProperty != null && actionProperty.contains(GTN_USERNAME_TOKEN_IF_AUTHENTICATED))
            {
               if (credentials.getPassword() != null)
               {
                  actionProperty = actionProperty.replace(GTN_USERNAME_TOKEN_IF_AUTHENTICATED, WSHandlerConstants.USERNAME_TOKEN);
               }
               else
               {
View Full Code Here

         // Processing request with wciLoginController
         wciLoginController.service(req, resp);

         // Test that credentials are set at this moment and are equalst to "root"/"gtn"
         Credentials credentials = wciLoginController.getCredentials(req);
         testCredentials(credentials, "root", "gtn");

         // Test that we can change credentials by invoke of setCredentials
         Credentials johnCredentials = new Credentials("john", "johnPassword");
         wciLoginController.setCredentials(req, johnCredentials);
         testCredentials(wciLoginController.getCredentials(req), "john", "johnPassword");

         // Use mary credentials for next request
         Map<String, String[]> params = new HashMap<String, String[]>();
View Full Code Here

      }
      catch (ServletException se)
      {
         try
         {
            String ticket = GenericAuthentication.TICKET_SERVICE.createTicket(new Credentials(credentials.getUsername(), credentials.getPassword()), TicketService.DEFAULT_VALIDITY);
            String url = "j_security_check?j_username=" + credentials.getUsername() + "&j_password=" + ticket + "&initialURI=" + initialURI;
            url = response.encodeRedirectURL(url);
            response.sendRedirect(url);
            response.flushBuffer();
         }
View Full Code Here

            email = user.getEmail();

            // Create token
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
            Credentials credentials = new Credentials(user.getUserName(), "");
            tokenId = tokenService.createToken(credentials);

            String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

            ResourceBundle res = requestContext.getApplicationResourceBundle();
View Full Code Here

   private WCIController wciController = new TestController();

   @Override
   public DriverResponse service(TestServlet testServlet, WebRequest req, WebResponse resp) throws ServletException, IOException
   {
      Credentials credentials = wciController.getCredentials(req, resp);
     
      if (getRequestCount() == 0)
      {
         assertEquals("/home", wciController.getInitialURI(req));
         req.setAttribute("javax.servlet.forward.request_uri", "/foo");
         assertEquals("/foo", wciController.getInitialURI(req));

         // Test Ticket Expiration
         String expireTicket = GenericAuthentication.TICKET_SERVICE.createTicket(new Credentials("foo", "bar"), 5);
         boolean expired = false;
         try
         {
            Thread.sleep(5);
            GenericAuthentication.TICKET_SERVICE.validateTicket(expireTicket, true);
         }
         catch (InterruptedException ignore)
         {
         }
         catch (AuthenticationException ae)
         {
            expired = true;
         }
         if (!expired) return new FailureResponse(Failure.createAssertionFailure(""));

         assertNull(req.getUserPrincipal());
         container = DefaultServletContainerFactory.getInstance().getServletContainer();
         container.addAuthenticationListener(new TestListener(v));
         assertEquals("", v.value);
         container.login(req, resp, credentials, TicketService.DEFAULT_VALIDITY);

         if ("Tomcat/7.x".equals(container.getContainerInfo()) || "JBossas/6.x".equals(container.getContainerInfo()))
         {
            assertEquals("login", v.value);
            assertNotNull(req.getUserPrincipal());
            assertTrue(req.isUserInRole("test"));
         }
         else
         {
            // Test Ticket Service
            String ticket = GenericAuthentication.TICKET_SERVICE.createTicket(credentials, TicketService.DEFAULT_VALIDITY);
            Credentials resultCredentials = GenericAuthentication.TICKET_SERVICE.validateTicket(ticket, false);
            assertEquals(credentials.getUsername(), resultCredentials.getUsername());
            assertEquals(credentials.getPassword(), resultCredentials.getPassword());
            assertNotNull(GenericAuthentication.TICKET_SERVICE.validateTicket(ticket, true));
            assertNull(GenericAuthentication.TICKET_SERVICE.validateTicket(ticket, true));

            // Test login Event
            assertEquals("login", v.value);
View Full Code Here

   }

   @Override
   public Credentials getCredentials(final HttpServletRequest req, final HttpServletResponse resp)
   {
      return new Credentials("foo", "bar");
   }
View Full Code Here

   protected void saveSSOCredentials(String username, HttpServletRequest httpRequest)
   {
      //Use empty password....it shouldn't be needed...this is a SSO login. The password has
      //already been presented with the SSO server. It should not be passed around for
      //better security
      Credentials credentials = new Credentials(username, "");

      httpRequest.getSession().setAttribute(Credentials.CREDENTIALS, credentials);
      httpRequest.getSession().setAttribute("username", username);

      // This is needed for using default login module stack instead of SSOLoginModule. In this case, GateIn authentication is done thanks to PortalLoginModule.
View Full Code Here

         CommonMessageContext ctx = (CommonMessageContext) soapMessageContext;
        
         HttpServletRequest request = ServletAccess.getRequest();
         if (request != null && request.getSession() != null)
         {
             Credentials credentials  = (Credentials)request.getSession().getAttribute(Credentials.CREDENTIALS);
             if (credentials != null)
             {
                 ctx.put(BindingProvider.USERNAME_PROPERTY, credentials.getUsername());
                 ctx.put(BindingProvider.PASSWORD_PROPERTY, credentials.getPassword());
             }
             else
             {
                 log.debug("Could not find credentials to put in WS-Security header");
                 return true;
View Full Code Here

            email = user.getEmail();

            // Create token
            RemindPasswordTokenService tokenService = uiForm.getApplicationComponent(RemindPasswordTokenService.class);
            Credentials credentials = new Credentials(user.getUserName(), "");
            tokenId = tokenService.createToken(credentials);

            String portalName = URLEncoder.encode(Util.getUIPortal().getName(), "UTF-8");

            ResourceBundle res = requestContext.getApplicationResourceBundle();
View Full Code Here

TOP

Related Classes of org.gatein.wci.security.Credentials

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.