Package org.jdesktop.wonderland.modules.securitysession.weblib

Examples of org.jdesktop.wonderland.modules.securitysession.weblib.UserRecord


                                        Response.Status.INTERNAL_SERVER_ERROR);
        }


        // get or create the record
        UserRecord rec = sm.get(username);
        if (rec == null) {
            // no record exists for this user -- login in
            try {
                rec = sm.login(username, fullname, email);
            } catch (SessionLoginException sle) {
                logger.log(Level.WARNING, "Login error", sle);
                throw new WebApplicationException(sle,
                                         Response.Status.INTERNAL_SERVER_ERROR);
            }
        }
       
        // return the token
        String res = "string=" + rec.getToken();
        return Response.ok(res).build();
    }
View Full Code Here


        if (credentials.length > 1) {
            email = (String) credentials[1];
        }
       
        // create the userrecord
        UserRecord rec = new UserRecord(userId, newToken(userId));
       
        // set values in the record
        rec.getAttributes().put(new BasicAttribute("uid", userId));
        rec.getAttributes().put(new BasicAttribute("cn", fullname));
        rec.getAttributes().put(new BasicAttribute("mail", email));

        // add to our internal maps
        byUserId.put(userId, rec);
        byToken.put(rec.getToken(), rec);
    
        return rec;
    }
View Full Code Here

    }

    public String getUserId(String token) {
        String out = null;

        UserRecord rec = getByToken(token);
        if (rec != null) {
            out = rec.getUserId();
        }

        return out;
    }
View Full Code Here

        return out;
    }

    public synchronized UserRecord logout(String token) {
        UserRecord rec = byToken.remove(token);
        if (rec != null) {
            byUserId.remove(rec.getUserId());
        }

        return rec;
    }
View Full Code Here

    @POST
    @Consumes("application/x-www-form-urlencoded")
    public Response post(@FormParam("attribute_names") List<String> attrNames,
                         @FormParam("subjectid") String subjectId)
    {
        UserRecord rec = sm.getByToken(subjectId);
        if (rec == null) {
            throw new NotFoundException("No such token " + subjectId);
        }

        StringBuffer res = new StringBuffer(PREFIX + "token.id=" + subjectId + "\n");

        Attributes attrs = rec.getAttributes();
       
        logger.fine("Found " + attrs.size() +
                    " attributes for " + rec.getUserId());

        NamingEnumeration attrEnum = attrs.getAll();
        try {
            while (attrEnum.hasMore()) {
                Attribute attr = (Attribute) attrEnum.next();
View Full Code Here

    @Consumes("application/x-www-form-urlencoded")
    public Response post(@FormParam("name") String name,
                         @FormParam("attribute_names") List<String> attrNames,
                         @FormParam("admin") String adminId)
    {
        UserRecord admin = sm.getByToken(adminId);
        if (admin == null) {
            throw new NotFoundException("Invalid token " + adminId);
        }

        // check that the admin user is actually in the admin group
        if (!isAdmin(admin.getUserId())) {
            return Response.status(Response.Status.FORBIDDEN)
                           .entity("Only administrators can read")
                           .type("text/plain").build();
        }

        // now look up the user
        UserRecord rec = sm.get(name);
        if (rec == null) {
            throw new NotFoundException("Unknown name " + name);
        }

        StringBuffer res = new StringBuffer(PREFIX + "name=" + name + "\n");
        res.append(PREFIX + "type=user\n");
        res.append(PREFIX + "attribute=\n");

        Attributes attrs = rec.getAttributes();

        logger.fine("Found " + attrs.size() +
                    " attributes for " + rec.getUserId());

        NamingEnumeration attrEnum = attrs.getAll();
        try {
            while (attrEnum.hasMore()) {
                Attribute attr = (Attribute) attrEnum.next();
View Full Code Here

TOP

Related Classes of org.jdesktop.wonderland.modules.securitysession.weblib.UserRecord

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.