Package org.apache.marmotta.platform.user.model

Examples of org.apache.marmotta.platform.user.model.UserAccount


     * @HTTP 404 if no such user exists
     */
    @DELETE
    @Path("/{login}")
    public Response deleteUser(@PathParam("login") String login, @QueryParam("deleteFoaf") @DefaultValue("false") boolean delFoaf) {
        UserAccount account = accountService.getAccount(login);
        if (account == null) return Response.status(Status.NOT_FOUND).entity(String.format("No login for '%s' found!", login)).build();

        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                if (delFoaf && account.getWebId() != null) {
                    // TODO: Remove only users foaf profile?
                    conn.remove(conn.getValueFactory().createURI(account.getWebId()),null,null);
                }

                accountService.deleteAccount(account);
                return Response.status(Status.OK).entity(String.format("login removed")).build();
            } finally {
View Full Code Here


     * @HTTP 404 if no such account exists.
     */
    @POST
    @Path("/{login}/roles")
    public Response setUserRoles(@PathParam("login") String login, @QueryParam("role") String[] roles, @QueryParam("role[]") String[] roles2) {
        UserAccount account = accountService.getAccount(login);
        if (account == null) return Response.status(Status.NOT_FOUND).entity(String.format("No login for '%s' found!", login)).build();

        HashSet<String> roleSet = new HashSet<String>();
        for (String role : roles) {
            roleSet.add(role);
View Full Code Here

     * @HTTP 404 if no such account exists
     */
    @POST
    @Path("/{login}/password")
    public Response setUserPassword(@PathParam("login") String login, @FormParam("password") String passwd) {
        UserAccount account = accountService.getAccount(login);
        if (account == null) return Response.status(Status.NOT_FOUND).entity(String.format("No login for '%s' found!", login)).build();

        accountService.setPassword(account, passwd);

        return Response.ok("Password updated").build();
View Full Code Here

     * @HTTP 404 if no such user exists.
     */
    @POST
    @Path("/{login}/profile")
    public Response setUserProfile(@PathParam("login") String login, MultivaluedMap<String, String> formParams) {
        UserAccount account = accountService.getAccount(login);
        if (account == null) return Response.status(Status.NOT_FOUND).entity(String.format("No login for '%s' found!", login)).build();

        try {
            RepositoryConnection conn = sesameService.getConnection();

            try {
                String currentUser = account.getWebId();
                for (String prop : formParams.keySet()) {
                    if (!acceptedFoafProperties.contains(prop)) {
                        continue;
                    }

View Full Code Here

    }

    @Override
    public void createDefaultAccounts() {
        // Currently there is only one default account: admin
        UserAccount account = getAccount(Namespaces.ADMIN_LOGIN);
        if (account == null) {
            Set<String> roles = new HashSet<String>(configurationService.getListConfiguration("user." + Namespaces.ADMIN_LOGIN + ".roles"));
            account = createAccount(Namespaces.ADMIN_LOGIN);
            account.setRoles(roles);
            account.setPasswd(hashAlgo, configurationService.getStringConfiguration("user." + Namespaces.ADMIN_LOGIN + ".password"));
            save(account);
        }
    }
View Full Code Here

                log.warn("User {} exists. This should not happen as it was checked 3 lines before!", login);
                webid = userService.getUser(login);
            }
        }

        UserAccount account = new UserAccount(login, webid.stringValue());

        save(account);

        return account;
    }
View Full Code Here

    }

    @Override
    public UserAccount getAccount(String login) {
        if (StringUtils.isBlank(login)) return null;
        UserAccount account = null;
        if (userCache != null && userCache.get(login) != null) {
            account = (UserAccount) userCache.get(login);
        } else {
            if (configurationService.isConfigurationSet("user."+login+".webid")) {
                account = new UserAccount();

                account.setLogin(login);
                account.setPasswdHash(configurationService.getStringConfiguration("user."+login+".pwhash"));
                account.setRoles(new HashSet<String>(configurationService.getListConfiguration("user."+login+".roles")));
                account.setWebId(configurationService.getStringConfiguration("user."+login+".webid"));

                userCache.put(account.getLogin(), account);
                userCache.put(account.getWebId(), account);
            } else {
                log.info("UserAccount {} not found", login);
            }
        }
        return account;
View Full Code Here

    @Override
    public UserAccount getAccount(URI resource) {
        Preconditions.checkArgument(resource != null);

        UserAccount account = null;
        if (userCache != null && userCache.get(resource) != null) {
            account = (UserAccount) userCache.get(resource);
        } else {
            for(UserAccount a : listAccounts()) {
                if(a.getWebId().equals(resource.stringValue())) {
                    account = a;
                    break;
                }
            }
            if (account != null) {
                userCache.put(account.getLogin(), account);
                userCache.put(account.getWebId(), account);
            } else {
                log.warn("UserAccount {} not found", resource);
            }
        }
        return account;
View Full Code Here

     * @param password
     * @return
     */
    @Override
    public void setUserPassword(String login, String password) {
        final UserAccount a = accountService.getAccount(login);
        authenticationProvider.updatePassword(a, password);
    }
View Full Code Here

     * @param login the login name of the user with whom to associate roles
     * @param role  the role name to associate with the user
     */
    @Override
    public void addUserRole(String login, String role) {
        final UserAccount a = accountService.getAccount(login);
        accountService.addRole(a, role);
    }
View Full Code Here

TOP

Related Classes of org.apache.marmotta.platform.user.model.UserAccount

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.