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

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


     * @param login the login name of the user from whom to remove the role
     * @param role  the role name to remove from the list of roles of the user
     */
    @Override
    public void removeUserRole(String login, String role) {
        final UserAccount a = accountService.getAccount(login);
        accountService.removeRole(a, role);
    }
View Full Code Here


            return Response.ok(apj, Namespaces.MIME_TYPE_JSON).location(java.net.URI.create(user.stringValue())).build();
        }
        try {
            RepositoryConnection conn = sesameService.getConnection();
            try {
                final UserAccount a = accountService.getAccount(user);
                if (a != null) {
                    AccountPoJo apj = new AccountPoJo(a.getLogin(), a.getWebId());
                    apj.setRoles(a.getRoles());

                    for (Statement t : ResourceUtils.listOutgoing(conn,conn.getValueFactory().createURI(a.getWebId()))) {
                        String prop = t.getPredicate().stringValue();
                        if (prop.startsWith(Namespaces.NS_FOAF)) {
                            Value object = t.getObject();
                            if (object instanceof org.openrdf.model.URI) {
                                apj.setFoaf(prop, String.format("<%s>", object));
View Full Code Here

     */
    @POST
    @Path("/me/passwd")
    public Response passwd(@FormParam("oldPasswd") String oldPwd, @FormParam("newPasswd") String newPwd) {
        final org.openrdf.model.URI currentUser = userService.getCurrentUser();
        final UserAccount a = accountService.getAccount(currentUser);

        if (a == null) return Response.status(Status.NOT_FOUND).entity(String.format("No account found for <%s>", currentUser)).build();

        if (accountService.checkPassword(a, oldPwd)) {
            accountService.setPassword(a, newPwd);
View Full Code Here

        // Must not create an account with a reserved username!
        if (RESERVED_LOGINS.contains(login))
            return Response.status(Status.BAD_REQUEST).entity(String.format("The following usernames are not allowed: %s", RESERVED_LOGINS)).build();

        UserAccount a = accountService.createAccount(login);
        if (a != null)
            return getUser(login);

        log.error("Creating an account for {} failed", login);
        return Response.status(Status.INTERNAL_SERVER_ERROR).entity("Sorry, don't know why").build();
View Full Code Here

     */
    @GET
    @Path("/{login}")
    @Produces(Namespaces.MIME_TYPE_JSON)
    public Response getUser(@PathParam("login") String login) {
        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 {
                UserWebService.AccountPoJo apj = new UserWebService.AccountPoJo(account.getLogin(), account.getWebId());
                apj.setRoles(account.getRoles());

                RepositoryResult<Statement> triples = conn.getStatements(conn.getValueFactory().createURI(account.getWebId()),null,null,true);

                while(triples.hasNext()) {
                    Statement t = triples.next();

                    String prop = t.getPredicate().stringValue();
View Full Code Here

     * @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

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.