Package org.apache.tuscany.sca.host.http

Examples of org.apache.tuscany.sca.host.http.UserContext


        while (true) {
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();
                    if(USER_QNAME.equals(name)) {
                        UserContext user = new UserContext();
                        //<tuscany:user username="user1" password="tuscany" roles="admin, user"/>
                        String username = reader.getAttributeValue(null, "username");
                        if(username == null) {
                            error("RequiredAttributeUsernameMissing", reader);
                        } else {
                            user.setUsername(username);   
                        }
                       
                        String password = reader.getAttributeValue(null, "password");
                        if(password == null) {
                            error("RequiredAttributePasswordMissing", reader);
                        } else {
                            user.setPassword(password);
                        }
                       
                        String roles = reader.getAttributeValue(null, "roles");
                        if(roles == null) {
                            error("RequiredAttributeRolesMissing", reader);
                        } else {
                            for (StringTokenizer tokens = new StringTokenizer(roles, ","); tokens.hasMoreTokens();) {
                                user.getRoles().add(tokens.nextToken());   
                            }
                        }
                       
                        authenticationConfiguration.getUsers().add(user);
                    }
View Full Code Here


        return REALM_NAME;
    }

    @Override
    protected String getPassword(String username) {
        UserContext userContext = userMap.get(username);
       
        if (userContext != null) {
            return userContext.getPassword();
        }
       
        return null;
    }
View Full Code Here

        return null;
    }

    @Override
    protected Principal getPrincipal(String username) {
        UserContext userContext = userMap.get(username);
       
        if (userContext != null) {
            Principal principal = new TuscanyPrincipal(userContext.getUsername());
            return principal;
        }
       
        return null;
    }
View Full Code Here

        return null;
    }
   
    @Override
    public boolean hasRole(java.security.Principal principal, java.lang.String role) {
        UserContext userContext = userMap.get(principal.getName());
       
        if (userContext != null) {
            if (userContext.getRoles().contains(role)) {
                return true;
            }
        }
       
        return false;       
View Full Code Here

        while (true) {
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();
                    if(USER_QNAME.equals(name)) {
                        UserContext user = new UserContext();
                        //<tuscany:user username="user1" password="tuscany" roles="admin, user"/>
                        String username = reader.getAttributeValue(null, "username");
                        if(username == null) {
                            error("RequiredAttributeUsernameMissing", reader);
                        } else {
                            user.setUsername(username);   
                        }
                       
                        String password = reader.getAttributeValue(null, "password");
                        if(password == null) {
                            error("RequiredAttributePasswordMissing", reader);
                        } else {
                            user.setPassword(password);
                        }
                       
                        String roles = reader.getAttributeValue(null, "roles");
                        if(roles == null) {
                            error("RequiredAttributeRolesMissing", reader);
                        } else {
                            for (StringTokenizer tokens = new StringTokenizer(roles, ","); tokens.hasMoreTokens();) {
                                user.getRoles().add(tokens.nextToken());   
                            }
                        }
                       
                        authenticationConfiguration.getUsers().add(user);
                    }
View Full Code Here

        while (true) {
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();
                    if(USER_QNAME.equals(name)) {
                        UserContext user = new UserContext();
                        //<tuscany:user username="user1" password="tuscany" roles="admin, user"/>
                        String username = reader.getAttributeValue(null, "username");
                        if(username == null) {
                            error("RequiredAttributeUsernameMissing", reader);
                        } else {
                            user.setUsername(username);   
                        }
                       
                        String password = reader.getAttributeValue(null, "password");
                        if(password == null) {
                            error("RequiredAttributePasswordMissing", reader);
                        } else {
                            user.setPassword(password);
                        }
                       
                        String roles = reader.getAttributeValue(null, "roles");
                        if(roles == null) {
                            error("RequiredAttributeRolesMissing", reader);
                        } else {
                            for (StringTokenizer tokens = new StringTokenizer(roles, ","); tokens.hasMoreTokens();) {
                                user.getRoles().add(tokens.nextToken());   
                            }
                        }
                       
                        authenticationConfiguration.getUsers().add(user);
                    }
View Full Code Here

        while (true) {
            switch (event) {
                case START_ELEMENT:
                    name = reader.getName();
                    if(USER_QNAME.equals(name)) {
                        UserContext user = new UserContext();
                        //<tuscany:user username="user1" password="tuscany" roles="admin, user"/>
                        String username = reader.getAttributeValue(null, "username");
                        if(username == null) {
                            error("RequiredAttributeUsernameMissing", reader);
                        } else {
                            user.setUsername(username);   
                        }
                       
                        String password = reader.getAttributeValue(null, "password");
                        if(password == null) {
                            error("RequiredAttributePasswordMissing", reader);
                        } else {
                            user.setPassword(password);
                        }
                       
                        String roles = reader.getAttributeValue(null, "roles");
                        if(roles == null) {
                            error("RequiredAttributeRolesMissing", reader);
                        } else {
                            for (StringTokenizer tokens = new StringTokenizer(roles, ","); tokens.hasMoreTokens();) {
                                user.getRoles().add(tokens.nextToken());   
                            }
                        }
                       
                        authenticationConfiguration.getUsers().add(user);
                    }
View Full Code Here

TOP

Related Classes of org.apache.tuscany.sca.host.http.UserContext

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.