Package org.camunda.bpm.engine.impl.identity

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


  @Test
  public void testIsUserAuthorizedFalse() {

    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(false);
   
    given()
View Full Code Here

  @Test
  public void testIsUserAuthorizedResourceIdTrue() {
   
    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, MockProvider.EXAMPLE_RESOURCE_ID)).thenReturn(true);
   
    given()
View Full Code Here

  @Test
  public void testIsUserAuthorizedResourceIdFalse() {
   
    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, MockProvider.EXAMPLE_RESOURCE_ID)).thenReturn(false);
   
    given()
View Full Code Here

    AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
    when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
    when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
    when(authorizationQuery.singleResult()).thenReturn(authorization);

    Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, null);   
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(false);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, UPDATE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(false);
   
    given()
View Full Code Here

    AuthorizationQuery authorizationQuery = mock(AuthorizationQuery.class);
    when(authorizationServiceMock.createAuthorizationQuery()).thenReturn(authorizationQuery);
    when(authorizationQuery.authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(authorizationQuery);
    when(authorizationQuery.singleResult()).thenReturn(authorization);

    Authentication authentication = new Authentication(MockProvider.EXAMPLE_USER_ID, null);   
    when(identityServiceMock.getCurrentAuthentication()).thenReturn(authentication);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, DELETE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(true);
    when(authorizationServiceMock.isUserAuthorized(MockProvider.EXAMPLE_USER_ID, null, UPDATE, AUTHORIZATION, MockProvider.EXAMPLE_AUTHORIZATION_ID)).thenReturn(false);
   
    given()
View Full Code Here

  }

  public void updateCredentials(UserCredentialsDto account) {
    ensureNotReadOnly();

    Authentication currentAuthentication = identityService.getCurrentAuthentication();
    if(currentAuthentication != null && currentAuthentication.getUserId() != null) {
      if(!identityService.checkPassword(currentAuthentication.getUserId(), account.getAuthenticatedUserPassword())) {
        throw new InvalidRequestException(Status.BAD_REQUEST, "The given authenticated user password is not valid.");
      }
    }

    User dbUser = findUserObject();
View Full Code Here

  protected boolean isAuthorized(Permission permission, Resource resource, String resourceId) {

    final IdentityService identityService = processEngine.getIdentityService();
    final AuthorizationService authorizationService = processEngine.getAuthorizationService();

    Authentication authentication = identityService.getCurrentAuthentication();
    if(authentication == null) {
      return true;

    } else {
      return authorizationService
         .isUserAuthorized(authentication.getUserId(), authentication.getGroupIds(), permission, resource, resourceId);
    }
  }
View Full Code Here

  public void deleteUserPicture(String userId) {
    commandExecutor.execute(new DeleteUserPictureCmd(userId));
  }

  public void setAuthenticatedUserId(String authenticatedUserId) {
    currentAuthentication.set(new Authentication(authenticatedUserId, null));
  }
View Full Code Here

      currentAuthentication.set(auth);
    }
  }

  public void setAuthentication(String userId, List<String> groups) {
    currentAuthentication.set(new Authentication(userId, groups));
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.impl.identity.Authentication

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.