summaryrefslogtreecommitdiffstats
path: root/dozentenmodul/src/main/java/util/CheckIntegrity.java
blob: bb5becbd16b841c0af8e26bbfb3e21a8491762ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package util;

public class CheckIntegrity {

	//private static boolean isFine = false;

	// integrity check on permissions put by user
	public static boolean[] isIntegre(boolean isRead, boolean isWrite,boolean isLink, boolean isAdmin) 
	{
		
		// boolean array for the correct result values
		boolean[] rights = new boolean[4];
		rights[0] = isRead;
		rights[1] = isWrite;
		rights[2] = isLink;
		rights[3] = isAdmin;
				
		System.out.println("*****************************");
		System.out.println(isRead+" "+isWrite+" "+isLink+" "+isAdmin);


		if(isRead) //if read is allowed, only read is allowed 
		{
			rights[0] = true; //read allowed
		}
		else //if read is not allowed, nothing is allowed
		{
			rights[0] = false;
			rights[1] = false;
			rights[2] = false;
			rights[3] = false;
		}
		
		if(isWrite) //if write was selected
		{
			rights[0] = true;
			rights[1] = true;
		}
		else //if write was unselected
		{
			//rights[0] = false;
			rights[1] = false;
		}
		
		if(isLink) //if link was selected, read and link are allowed
		{
			rights[0] = true;
			rights[2] = true;
		}
		else //if link is unselected, link is not allowed
		{
			rights[2] = false;
		}
		
		if(isAdmin) //if admin is selected, anything is allowed
		{
			rights[0] = true;
			rights[1] = true;
			rights[2] = true;
			rights[3] = true;
		}
		else //if admin is unselected, admin is not allowed
		{
			rights[3] = false;
		}
		
		System.out.println(">-------------<");
		System.out.println(rights[0]+" "+rights[1]+" "+rights[2]+" "+rights[3]);
		
		return rights;
		
	}

}