/**
 * Licensed to the Austrian Association for Software Tool Integration (AASTI)
 * under one or more contributor license agreements. See the NOTICE file
 * distributed with this work for additional information regarding copyright
 * ownership. The AASTI licenses this file to you under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except in compliance
 * with the License. You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.openengsb.core.common.util;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;

public final class Users {

    public static User create(String username, String password, Collection<GrantedAuthority> authorities) {
        return new User(username, password, true, true, true, true, authorities);
    }

    public static User create(String username, String password, GrantedAuthority... authorities) {
        return create(username, password, Arrays.asList(authorities));
    }

    public static User create(String username, String password) {
        List<GrantedAuthority> emptyList = Collections.emptyList();
        return create(username, password, emptyList);
    }

    private Users() {
    }
}

@@ -864,16 +864,44 @@
 .util;%0A%0A
+import java.util.ArrayList;%0A
 import j
@@ -949,61 +949,8 @@
 ion;
-%0Aimport java.util.Collections;%0Aimport java.util.List;
 %0A%0Aim
@@ -1070,35 +1070,184 @@
 r;%0A%0A
-public final class Users %7B%0A
+/**%0A * contains util-methods that help with creating spring %7B@link User%7D objects%0A */%0Apublic final class Users %7B%0A%0A    /**%0A     * create a user with the given authorities%0A     */
 %0A   
@@ -1432,32 +1432,96 @@
 rities);%0A    %7D%0A%0A
+    /**%0A     * create a user with the given authorities%0A     */%0A
     public stati
@@ -1615,55 +1615,11 @@
     
-return create(username, password, Arrays.asList
+if 
 (aut
@@ -1630,49 +1630,46 @@
 ties
-));
+ == null) %7B
 %0A    
-%7D%0A%0A
     
-public static User
+    return
  create(
 Stri
@@ -1656,39 +1656,32 @@
   return create(
-String 
 username, String
@@ -1665,39 +1665,32 @@
 create(username,
- String
  password) %7B%0A   
@@ -1682,28 +1682,27 @@
 password
-) %7B%0A        
+, new Array
 List%3CGra
@@ -1719,46 +1719,34 @@
 ity%3E
- emptyList = Collections.emptyList();%0A
+());%0A        %7D else %7B%0A    
     
@@ -1787,19 +1787,46 @@
 rd, 
-emptyList);
+Arrays.asList(authorities));%0A        %7D
 %0A   

refactor Users-util-class and add some doc