Examples of Authentication


Examples of org.beangle.security.core.Authentication

  }

  public void testNormalOperation() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest("GET", "/demo/any-path");
    request.addParameter("ticket", "ST-0-ER94xMJmn6pha35CQRoZ");
    Authentication result = filter.getPreauthAuthentication(request, new MockHttpServletResponse());
    assertTrue(result != null);
  }
View Full Code Here

Examples of org.beangle.security.core.Authentication

  @Test
  public void statefulAuthenticationIsSuccessful() throws Exception {
    CasAuthentication token = new CasAuthentication(CasAuthentication.STATEFUL_ID, "ST-123", null);
    token.setDetails("details");
    Authentication result = cap.authenticate(token);

    // Confirm ST-123 was NOT added to the cache
    assertTrue(cache.get("ST-456") == null);
    if (!(result instanceof CasAuthentication)) {
      fail("Should have returned a CasAuthentication");
    }
    CasAuthentication casResult = (CasAuthentication) result;
    assertEquals(makeUserDetailsFromAuthoritiesPopulator(), casResult.getPrincipal());
    assertEquals("ST-123", casResult.getCredentials());
    assertTrue(casResult.getAuthorities().contains(new GrantedAuthorityBean("ROLE_A")));
    assertTrue(casResult.getAuthorities().contains(new GrantedAuthorityBean("ROLE_B")));
    assertEquals(cap.getKey().hashCode(), casResult.getKeyHash());
    assertEquals("details", casResult.getDetails());

    // Now confirm the CasAuthentication is automatically re-accepted.
    // To ensure TicketValidator not called again, set it to deliver an
    // exception...
    cap.setTicketValidator(new MockTicketValidator(false));

    Authentication laterResult = cap.authenticate(result);
    assertEquals(result, laterResult);
  }
View Full Code Here

Examples of org.beangle.security.core.Authentication

  @Test
  public void statelessAuthenticationIsSuccessful() throws Exception {
    CasAuthentication token = new CasAuthentication(CasAuthentication.STATELESS_ID, "ST-456", null);
    token.setDetails("details");
    Authentication result = cap.authenticate(token);
    // Confirm ST-456 was added to the cache
    assertTrue(cache.get("ST-456") != null);

    if (!(result instanceof CasAuthentication)) {
      fail("Should have returned a CasAuthentication");
    }

    assertEquals(makeUserDetailsFromAuthoritiesPopulator(), result.getPrincipal());
    assertEquals("ST-456", result.getCredentials());
    assertEquals("details", result.getDetails());

    // Now try to authenticate again. To ensure TicketValidator not
    // called again, set it to deliver an exception...
    cap.setTicketValidator(new MockTicketValidator(false));

    // Previously created UsernamePasswordAuthenticationToken is OK
    Authentication newResult = cap.authenticate(token);
    assertEquals(makeUserDetailsFromAuthoritiesPopulator(), newResult.getPrincipal());
    assertEquals("ST-456", newResult.getCredentials());
  }
View Full Code Here

Examples of org.beangle.security.core.Authentication

  public void onApplicationEvent(BusinessEvent event) {
    BusinessLogBean log = new BusinessLogBean();
    log.setOperateAt(event.getIssueAt());
    log.setOperation(StringUtils.defaultIfBlank(event.getDescription(), "  "));
    log.setResource(StringUtils.defaultIfBlank(event.getResource(), "  "));
    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    if (null == auth) return;
    log.setOperater(auth.getName());
    Object details = auth.getDetails();
    if ((details instanceof WebAuthenticationDetails)) {
      WebAuthenticationDetails webDetails = (WebAuthenticationDetails) details;
      log.setIp(webDetails.getAgent().getIp());
      log.setAgent(webDetails.getAgent().getOs()+" "+webDetails.getAgent().getBrowser());
      log.setEntry(sessionRegistry.getResource(webDetails.getSessionId()));
View Full Code Here

Examples of org.beangle.security.monitor.Authentication

    // 避免login没有权限,出现死循环
    if (!freeResources.contains(resource) && !manager.isPublicResource(resource)) {
      OnlineActivity info = manager.getAuthenticationManager().getSessionController()
          .getOnlineActivity(session.getId());
      if (null == info) {
        Authentication auth = null;
        // remember me
//        if (manager.isEnableRememberMe()) {
//          auth = manager.getRememberMeService().autoLogin(httpRequest);
//        }
        if (null == auth) {
          auth = new SsoAuthentication(httpRequest);
          auth.setDetails(userDetailsSource.buildDetails(httpRequest));
        }
        try {
          manager.authenticate(auth);
        } catch (AuthenticationException e) {
          // 记录访问失败的URL
View Full Code Here

Examples of org.camunda.bpm.engine.impl.identity.Authentication

  @Test
  public void testIsUserAuthorizedTrue() {
   
    List<String> exampleGroups = new ArrayList<String>();

    Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, exampleGroups);   
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);   
    AuthorizationUtil authorizationUtil = new AuthorizationUtil(MockProvider.EXAMPLE_RESOURCE_TYPE_NAME, MockProvider.EXAMPLE_RESOURCE_TYPE_ID, MockProvider.EXAMPLE_PERMISSION_NAME);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, exampleGroups, authorizationUtil, authorizationUtil)).thenReturn(true);
   
    given()
View Full Code Here

Examples of org.eclipse.aether.repository.Authentication

   public static org.eclipse.aether.repository.Proxy convertFromMavenProxy(org.apache.maven.settings.Proxy proxy)
   {
      org.eclipse.aether.repository.Proxy result = null;
      if (proxy != null)
      {
         Authentication auth = new AuthenticationBuilder().addUsername(proxy.getUsername())
                  .addPassword(proxy.getPassword()).build();
         result = new org.eclipse.aether.repository.Proxy(proxy.getProtocol(), proxy.getHost(), proxy.getPort(), auth);
      }
      return result;
   }
View Full Code Here

Examples of org.eclipse.jetty.client.api.Authentication

                    LOG.debug("Authentication challenge without {} header", header);
                forwardFailureComplete(request, null, response, new HttpResponseException("HTTP protocol violation: Authentication challenge without " + header + " header", response));
                return;
            }

            Authentication authentication = null;
            Authentication.HeaderInfo headerInfo = null;
            URI uri = getAuthenticationURI(request);
            if (uri != null)
            {
                for (Authentication.HeaderInfo element : headerInfos)
                {
                    authentication = client.getAuthenticationStore().findAuthentication(element.getType(), uri, element.getRealm());
                    if (authentication != null)
                    {
                        headerInfo = element;
                        break;
                    }
                }
            }
            if (authentication == null)
            {
                if (LOG.isDebugEnabled())
                    LOG.debug("No authentication available for {}", request);
                forwardSuccessComplete(request, response);
                return;
            }

            final Authentication.Result authnResult = authentication.authenticate(request, response, headerInfo, conversation);
            if (LOG.isDebugEnabled())
                LOG.debug("Authentication result {}", authnResult);
            if (authnResult == null)
            {
                forwardSuccessComplete(request, response);
View Full Code Here

Examples of org.eclipse.jetty.server.Authentication

    //TODO: hardcoded to jetty - rewrite
    //*******************************************************
    DefaultIdentityService _identityService = new DefaultIdentityService();
    UserIdentity user = _identityService.newUserIdentity(subject, principal, new String[0]);
       
    Authentication cached=new HttpSessionAuthentication(session, user);
        session.setAttribute(HttpSessionAuthentication.__J_AUTHENTICATED, cached);
    //*******************************************************
     
     
    request.getSession().setAttribute(FACEBOOK_ACCESS_TOKEN_SESSION, accessToken);
View Full Code Here

Examples of org.expressme.openid.Authentication

            manager.setReturnTo(callbackUrl)
           
            checkNonce(request.getParameter("openid.response_nonce"));
            byte[] mac_key = (byte[])session.getAttribute(ATTR_MAC);
            String alias = (String)session.getAttribute(ATTR_ALIAS);
            Authentication authentication = manager.getAuthentication(request,mac_key,alias);
            identity = authentication.getIdentity();
            email = authentication.getEmail();
            username = email;
          } catch (Exception e) {
            err = "Openid authentication suceeded, creating local user reference failed.";
            LOGGER.log(Level.WARNING,err,e);
          }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.