Buggy code:
private static final String WAITING_STATUS = "waiting" ; private static final String ALIEN_STATUS = "alien" ; private static final String INVITE_ACTION = "Invite" ; private static final String ACCEPT_ACTION = "Accept" ; private static final String DENY_ACTION = "Deny" ; private static final String REVOKE_ACTION = "Revoke" ; private static final String REMOVE_ACTION = "Disconnect" ; private static final String SPACE_MEMBER = "member_of_space" ; private static final String USER_TO_INVITE = "user_to_invite" ; private static final String NO_ACTION = "NoAction" ; private static final String NO_INFO = "NoInfo" ; private static final long SUGGEST_LIMIT = 20 ; private static final String DEFAULT_ACTIVITY = "DEFAULT_ACTIVITY" ; private static final String LINK_ACTIVITY = "LINK_ACTIVITY" ; private static final String DOC_ACTIVITY = "DOC_ACTIVITY" ; private static final Log LOG = ExoLogger . getLogger ( PeopleRestService . class ) ; private IdentityManager identityManager ; private ActivityManager activityManager ; private RelationshipManager relationshipManager ; private SpaceService spaceService ; public PeopleRestService ( ) { } @ RolesAllowed ( "users" ) @ GET @ Path ( "suggest.{format}" ) public Response suggestUsernames ( @ Context UriInfo uriInfo , @ QueryParam ( "nameToSearch" ) String name , @ QueryParam ( "currentUser" ) String currentUser , @ QueryParam ( "typeOfRelation" ) String typeOfRelation , @ QueryParam ( "spaceURL" ) String spaceURL , @ PathParam ( "format" ) String format ) throws Exception { } @ GET @ Path ( "getprofile//data.json" ) public Response suggestUsernames ( @ Context UriInfo uriInfo , @ Context SecurityContext securityContext , @ QueryParam ( "search" ) String query ) throws Exception { } @ GET @ Path ( "{portalName}//getConnections.{format}" ) public Response searchConnection ( @ Context UriInfo uriInfo , @ Context SecurityContext securityContext , @ PathParam ( "portalName" ) String portalName , @ QueryParam ( "nameToSearch" ) String nameToSearch , @ QueryParam ( "offset" ) int offset , @ QueryParam ( "limit" ) int limit , @ QueryParam ( "lang" ) String lang , @ PathParam ( "format" ) String format ) throws Exception { } @ GET @ Path ( "//getPeopleInfo//{userId}.{format}" ) public Response getPeopleInfo ( @ Context UriInfo uriInfo , @ Context SecurityContext securityContext , @ PathParam ( "userId" ) String userId , @ PathParam ( "format" ) String format , @ QueryParam ( "currentUserName" ) String currentUserName , @ QueryParam ( "updatedType" ) String updatedType ) throws Exception { if ( ( format . indexOf ( '.' ) ) > 0 ) { userId = new StringBuffer ( userId ) . append ( "." ) . append ( format . substring ( 0 , format . lastIndexOf ( '.' ) ) ) . toString ( ) ; format = format . substring ( ( ( format . lastIndexOf ( '.' ) ) + 1 ) ) ; } String [ ] mediaTypes = new String [ ] { "json" , "xml" } ; format = ( ArrayUtils . contains ( mediaTypes , format ) ) ? format : mediaTypes [ 0 ] ; if ( ( currentUserName == null ) || ( currentUserName . trim ( ) . isEmpty ( ) ) ) { currentUserName = getUserId ( securityContext , uriInfo ) ; } MediaType mediaType = Util . getMediaType ( format , mediaTypes ) ; PeopleRestService . PeopleInfo peopleInfo = new PeopleRestService . PeopleInfo ( PeopleRestService . NO_INFO ) ; Identity identity = getIdentityManager ( ) . getOrCreateIdentity ( NAME , userId , false ) ; Identity currentIdentity = getIdentityManager ( ) . getOrCreateIdentity ( NAME , currentUserName , false ) ; if ( identity != null ) { peopleInfo . setFullName ( identity . getProfile ( ) . getFullName ( ) ) ; peopleInfo . setPosition ( StringEscapeUtils . unescapeHtml ( identity . getProfile ( ) . getPosition ( ) ) ) ; peopleInfo . setDeleted ( identity . isDeleted ( ) ) ; Profile userProfile = identity . getProfile ( ) ; String avatarURL = userProfile . getAvatarUrl ( ) ; if ( avatarURL == null ) { avatarURL = LinkProvider . PROFILE_DEFAULT_AVATAR_URL ; } peopleInfo . setAvatarURL ( avatarURL ) ; String userType = ConversationState . getCurrent ( ) . getIdentity ( ) . getUserId ( ) ; <START_BUG> boolean isAnonymous = ( ANONIM . equals ( userType ) ) || ( ( securityContext . getUserPrincipal ( ) ) == null ) ; <END_BUG> if ( ! isAnonymous ) { peopleInfo . setProfileUrl ( LinkProvider . getUserActivityUri ( identity . getRemoteId ( ) ) ) ; peopleInfo . setRelationshipType ( PeopleRestService . NO_ACTION ) ; String relationshipType = null ; if ( ( currentUserName != null ) && ( ! ( userId . equals ( currentUserName ) ) ) ) { Relationship relationship = getRelationshipManager ( ) . get ( currentIdentity , identity ) ; if ( currentIdentity != null ) { if ( updatedType != null ) { if ( currentIdentity != null ) { if ( PeopleRestService . ACCEPT_ACTION . equals ( updatedType ) ) { getRelationshipManager ( ) . confirm ( currentIdentity , identity ) ; } else if ( PeopleRestService . DENY_ACTION . equals ( updatedType ) ) { getRelationshipManager ( ) . deny ( currentIdentity , identity ) ; } else if ( PeopleRestService . REVOKE_ACTION . equals ( updatedType ) ) { getRelationshipManager ( ) . deny ( currentIdentity , identity ) ; } else if ( PeopleRestService . INVITE_ACTION . equals ( updatedType ) ) { getRelationshipManager ( ) . inviteToConnect ( currentIdentity , identity ) ; } else if ( PeopleRestService . REMOVE_ACTION . equals ( updatedType ) ) { getRelationshipManager ( ) . delete ( getRelationshipManager ( ) . get ( currentIdentity , identity ) ) ; } } } relationshipType = getRelationshipType ( relationship , currentIdentity ) ; peopleInfo . setRelationshipType ( relationshipType ) ; } } if ( PeopleRestService . CONFIRMED_STATUS . equals ( relationshipType ) ) { String activityTitle = getLatestActivityTitle ( identity , currentIdentity ) ; if ( activityTitle != null ) { peopleInfo . setActivityTitle ( StringEscapeUtils . unescapeHtml ( activityTitle ) ) ; }

Fix:
boolean isAnonymous = ( ( ANONIM . equals ( userType ) ) || ( ( securityContext . getUserPrincipal ( ) ) == null ) ) || ( ! ( userType . equals ( currentIdentity . getRemoteId ( ) ) ) ) ;