Bit Masks in Mask Attribute Mapping
The purpose of a bit mask in mask attribute mapping is to test the value of one or more bits by masking the values of the other bits in a user attribute.
A mask attribute mapping is defined as follows:
user_attribute_name:bit_mask
For example, assume that the user attribute is named AccountStatus and that AccountStatus stores the states of the following three flags in a bit pattern, as follows:
Bit Pattern |
Flag |
---|---|
00? |
account disabled? |
0?0 |
password expired? |
?00 |
gold member? |
When a bit equals one, the flag is TRUE, as follows:
Bit Pattern |
Account Status |
---|---|
000 (0) |
no flags are TRUE |
001 (1) |
account disabled |
010 (2) |
password expired |
100 (4) |
gold member |
011 (3) |
password expired, account disabled |
101 (5) |
gold member, account disabled |
110 (6) |
gold member, password expired |
111 (7) |
gold member, password expired, account disabled |
Note: Equivalent decimal values are shown in parentheses.
Assume that you only want to test whether a user is a gold member. To test this bit, select the bit pattern that corresponds to a gold member as the bit mask or 100 (binary) and specify it as 4 (decimal). The resulting mask attribute mapping is defined as follows:
AccountStatus:4
SiteMinder performs a bitwise AND operation on AccountStatus and the bit mask and tests whether the result is equal to the bit mask. If they are equal, the value of the tested bit is one, and the flag is TRUE, as shown in the following table:
Account Status |
Bit Mask |
Result of Bitwise AND |
Gold Member? |
---|---|---|---|
000 (0) |
100 (4) |
000 (0) |
FALSE |
001 (1) |
100 (4) |
000 (0) |
FALSE |
010 (2) |
100 (4) |
000 (0) |
FALSE |
011 (3) |
100 (4) |
000 (0) |
FALSE |
100 (4) |
100 (4) |
100 (4) |
TRUE |
101 (5) |
100 (4) |
100 (4) |
TRUE |
110 (6) |
100 (4) |
100 (4) |
TRUE |
111 (7) |
100 (4) |
100 (4) |
TRUE |
Note: Equivalent decimal values are shown in parentheses.
You can also use a bit mask to test the value of a bit set or more than one bit at a time. Assume that you want to know whether the account is disabled and the password has expired. To test these bits, specify a bit mask of 011 (binary) or 3 (decimal). The resulting mask attribute mapping is defined as follows:
AccountStatus:3
SiteMinder performs a bitwise AND operation on AccountStatus and the bit mask and tests whether the result is equal to the bit mask. If they are equal, the value of both tested bits is one, and both flags are TRUE, as shown in the following table:
Account Status |
Bit Mask |
Result of Bitwise AND |
Both Flags Set? |
---|---|---|---|
000 (0) |
011 (3) |
000 (0) |
FALSE |
001 (1) |
011 (3) |
001 (1) |
FALSE |
010 (2) |
011 (3) |
010 (2) |
FALSE |
011 (3) |
011 (3) |
011 (3) |
TRUE |
100 (4) |
011 (3) |
000 (0) |
FALSE |
101 (5) |
011 (3) |
001 (1) |
FALSE |
110 (6) |
011 (3) |
010 (2) |
FALSE |
111 (7) |
011 (3) |
011 (3) |
TRUE |
Note: Equivalent decimal values are shown in parentheses.
Copyright © 2010 CA. All rights reserved. | Email CA about this topic |