summaryrefslogtreecommitdiff
path: root/src/com/p4square/grow/ccb/CCBUser.java
blob: 7313172f652fe52e8662100ff59b20faf5b755fe (plain)
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
package com.p4square.grow.ccb;

import com.p4square.ccbapi.model.IndividualProfile;
import org.restlet.security.User;

/**
 * CCBUser is an adapter between a CCB IndividualProfile and a Restlet User.
 *
 * Note: CCBUser prefixes the user's identifier with "CCB-". This is done to
 *       ensure the identifier does not collide with identifiers from other
 *       systems.
 */
public class CCBUser extends User {

    private final IndividualProfile mProfile;

    /**
     * Wrap an IndividualProfile inside a User object.
     *
     * @param profile The CCB IndividualProfile for the user.
     */
    public CCBUser(final IndividualProfile profile) {
        mProfile = profile;

        setIdentifier("CCB-" + mProfile.getId());
        setFirstName(mProfile.getFirstName());
        setLastName(mProfile.getLastName());
        setEmail(mProfile.getEmail());
    }

    /**
     * @return The IndividualProfile of the user.
     */
    public IndividualProfile getProfile() {
        return mProfile;
    }
}