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

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


            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

    }

    @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

                webid = userService.getUser(login);
            }
        }

        if(webid instanceof KiWiUriResource) {
            UserAccount account = new UserAccount(login, webid.stringValue());

            save(account);

            return account;
        } else {
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).getObjectValue();
        } 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(new Element(account.getLogin(), account));
                userCache.put(new Element(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).getObjectValue();
        } else {
            for(UserAccount a : listAccounts()) {
                if(a.getWebId().equals(resource.stringValue())) {
                    account = a;
                    break;
                }
            }
            if (account != null) {
                userCache.put(new Element(account.getLogin(), account));
                userCache.put(new Element(account.getWebId(), account));
            } else {
                log.warn("UserAccount {} not found", resource);
            }
        }
        return account;
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

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.