Search in sources :

Example 16 with User

use of pl.plajer.villagedefense3.User in project oxTrust by GluuFederation.

the class Scim2UserService method replaceUserPatch.

private void replaceUserPatch(Operation operation, String id) throws Exception {
    User user = operation.getValue();
    GluuCustomPerson updatedGluuPerson = patchUtil.replacePatch(user, validUsernameByInum(user, id));
    log.info(" Setting meta: replaceUserPatch update user ");
    setMeta(updatedGluuPerson);
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) User(org.gluu.oxtrust.model.scim2.User) ScimPatchUser(org.gluu.oxtrust.model.scim2.ScimPatchUser)

Example 17 with User

use of pl.plajer.villagedefense3.User in project oxTrust by GluuFederation.

the class Scim2UserService method patchUser.

public User patchUser(String id, ScimPatchUser patchUser) throws Exception {
    for (Operation operation : patchUser.getOperatons()) {
        String val = operation.getOperationName();
        if (val.equalsIgnoreCase("replace")) {
            replaceUserPatch(operation, id);
        }
        if (val.equalsIgnoreCase("remove")) {
            removeUserPatch(operation, id);
        }
        if (val.equalsIgnoreCase("add")) {
            addUserPatch(operation, id);
        }
    }
    GluuCustomPerson gluuPerson = personService.getPersonByInum(id);
    User updatedUser = copyUtils2.copy(gluuPerson, null);
    return updatedUser;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) User(org.gluu.oxtrust.model.scim2.User) ScimPatchUser(org.gluu.oxtrust.model.scim2.ScimPatchUser) Operation(org.gluu.oxtrust.model.scim2.Operation)

Example 18 with User

use of pl.plajer.villagedefense3.User in project oxTrust by GluuFederation.

the class Scim2UserService method updateUser.

public User updateUser(String id, User user) throws Exception {
    GluuCustomPerson gluuPerson = personService.getPersonByInum(id);
    if (gluuPerson == null) {
        throw new EntryPersistenceException("Scim2UserService.updateUser(): " + "Resource " + id + " not found");
    } else {
        // Validate if attempting to update userName of a different id
        if (user.getUserName() != null) {
            GluuCustomPerson personToFind = new GluuCustomPerson();
            personToFind.setUid(user.getUserName());
            List<GluuCustomPerson> foundPersons = personService.findPersons(personToFind, 2);
            if (foundPersons != null && foundPersons.size() > 0) {
                for (GluuCustomPerson foundPerson : foundPersons) {
                    if (foundPerson != null && !foundPerson.getInum().equalsIgnoreCase(gluuPerson.getInum())) {
                        throw new DuplicateEntryException("Cannot update userName of a different id: " + user.getUserName());
                    }
                }
            }
        }
    }
    GluuCustomPerson updatedGluuPerson = copyUtils2.copy(user, gluuPerson, true);
    if (user.getGroups().size() > 0) {
        serviceUtil.groupMembersAdder(updatedGluuPerson, personService.getDnForPerson(id));
    }
    log.info(" Setting meta: update user ");
    // Date should be in UTC format
    DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC();
    Date dateLastModified = DateTime.now().toDate();
    updatedGluuPerson.setAttribute("oxTrustMetaLastModified", dateTimeFormatter.print(dateLastModified.getTime()));
    if (updatedGluuPerson.getAttribute("oxTrustMetaLocation") == null || (updatedGluuPerson.getAttribute("oxTrustMetaLocation") != null && updatedGluuPerson.getAttribute("oxTrustMetaLocation").isEmpty())) {
        String relativeLocation = "/scim/v2/Users/" + id;
        updatedGluuPerson.setAttribute("oxTrustMetaLocation", relativeLocation);
    }
    // Sync email, forward ("oxTrustEmail" -> "mail")
    updatedGluuPerson = serviceUtil.syncEmailForward(updatedGluuPerson, true);
    // For custom script: update user
    if (externalScimService.isEnabled()) {
        externalScimService.executeScimUpdateUserMethods(updatedGluuPerson);
    }
    personService.updatePerson(updatedGluuPerson);
    log.debug(" person updated ");
    User updatedUser = copyUtils2.copy(updatedGluuPerson, null);
    return updatedUser;
}
Also used : GluuCustomPerson(org.gluu.oxtrust.model.GluuCustomPerson) User(org.gluu.oxtrust.model.scim2.User) ScimPatchUser(org.gluu.oxtrust.model.scim2.ScimPatchUser) EntryPersistenceException(org.gluu.site.ldap.persistence.exception.EntryPersistenceException) DuplicateEntryException(org.gluu.site.ldap.exception.DuplicateEntryException) DateTimeFormatter(org.joda.time.format.DateTimeFormatter) Date(java.util.Date)

Example 19 with User

use of pl.plajer.villagedefense3.User in project openstack4j by ContainX.

the class KeystoneUserServiceTests method getUser_byName_byDomainId_NotExist_Test.

/**
     * returns null for an non-existing user when the user specified by name and domain.
     *
     * @throws Exception
     */
public void getUser_byName_byDomainId_NotExist_Test() throws Exception {
    respondWith(JSON_USER_GET_BYNAME_BYDOMAINID_NOT_EXIST);
    User user = osv3().identity().users().getByName(USER_NAME, USER_DOMAIN_ID);
    assertNull(user);
}
Also used : KeystoneUser(org.openstack4j.openstack.identity.v3.domain.KeystoneUser) User(org.openstack4j.model.identity.v3.User)

Example 20 with User

use of pl.plajer.villagedefense3.User in project Village_Defense by Plajer.

the class ArenaEvents method onRespawn.

private void onRespawn(Player player, Arena arena) {
    User user = UserManager.getUser(player.getUniqueId());
    if (user.isFakeDead()) {
        arena.teleportToStartLocation(player);
        player.setAllowFlight(true);
        player.setFlying(true);
    } else {
        arena.teleportToStartLocation(player);
        user.setSpectator(true);
        player.setGameMode(GameMode.SURVIVAL);
        player.removePotionEffect(PotionEffectType.NIGHT_VISION);
        user.setFakeDead(true);
        player.setAllowFlight(true);
        player.setFlying(true);
        user.setInt("orbs", 0);
    }
}
Also used : User(pl.plajer.villagedefense3.User)

Aggregations

User (pl.plajer.villagedefense3.User)30 Player (org.bukkit.entity.Player)19 User (org.gluu.oxtrust.model.scim2.User)17 EventHandler (org.bukkit.event.EventHandler)11 GluuCustomPerson (org.gluu.oxtrust.model.GluuCustomPerson)10 ScimPatchUser (org.gluu.oxtrust.model.scim2.ScimPatchUser)10 User (org.openstack4j.model.identity.v3.User)10 Arena (pl.plajer.villagedefense3.arena.Arena)9 DuplicateEntryException (org.gluu.site.ldap.exception.DuplicateEntryException)8 ArrayList (java.util.ArrayList)7 EntryPersistenceException (org.gluu.site.ldap.persistence.exception.EntryPersistenceException)7 Date (java.util.Date)6 SimpleUser (me.zhanghai.android.douya.network.api.info.apiv2.SimpleUser)6 User (me.zhanghai.android.douya.network.api.info.apiv2.User)6 ItemStack (org.bukkit.inventory.ItemStack)5 PersonRequiredFieldsException (org.gluu.oxtrust.exception.PersonRequiredFieldsException)5 Test (org.junit.Test)5 ApiOperation (com.wordnik.swagger.annotations.ApiOperation)4 BigDecimal (java.math.BigDecimal)4 URI (java.net.URI)4