Package org.jboss.seam.security

Examples of org.jboss.seam.security.Identity


     * This will return a auto login user name if it has been configured.
     * Autologin means that its not really logged in, but a generic username will be used.
     * Basically means security is bypassed.
     */
    private String checkAutoLogin() {
        Identity id = Identity.instance();
        id.getCredentials().setUsername( GUEST_LOGIN );
        try {
            id.authenticate();
        } catch ( LoginException e ) {
            return null;
        }
        if ( id.isLoggedIn() ) {
            return id.getCredentials().getUsername();
        } else {
            return null;
        }

    }
View Full Code Here


            //If the request is from same session, the user should be logged already.
            if ( Identity.instance().isLoggedIn() ) {
                return true;
            }

            Identity ids = Identity.instance();
            if ( auth != null && auth.toUpperCase( Locale.ENGLISH ).startsWith( "BASIC " ) ) {
                String[] a = unpack( auth );
                usr = a[0];
                pwd = a[1];
                ids.getCredentials().setUsername( usr );
                ids.getCredentials().setPassword( pwd );
            }
            try {
                ids.authenticate();
                log.info( usr + " authenticated for rest api" );

                return true;
            } catch ( LoginException e ) {
                log.warn( "Unable to authenticate for rest api: " + usr );
View Full Code Here

            // default to get content as json
            action = "json";
        }
       
        // log in
        Identity ids = Identity.instance();
        ids.getCredentials().setUsername(usr);
        ids.getCredentials().setPassword(pwd);
       
        try {
            ids.authenticate();
        } catch (LoginException e) {
            throw new ServletException(new IllegalArgumentException("Unable to authenticate user."));
        }
       
        log.debug("Successful login");
View Full Code Here

     * Autologin means that its not really logged in, but a generic username will be used.
     * Basically means security is bypassed.
     *
     */
    private String checkAutoLogin() {
        Identity id = Identity.instance();
        id.getCredentials().setUsername( GUEST_LOGIN );
        try {
            id.authenticate();
        } catch ( LoginException e ) {
            return null;
        }
        if ( id.isLoggedIn() ) {
            return id.getCredentials().getUsername();
        } else {
            return null;
        }

    }
View Full Code Here

          //If the request is from same session, the user should be logged already.
          if (Identity.instance().isLoggedIn()) {
            return true;
          }
         
            Identity ids = Identity.instance();
            if(auth != null && auth.toUpperCase(Locale.ENGLISH).startsWith("BASIC ")) {
                String[] a = unpack(auth);
                usr = a[0];
                pwd = a[1];
                ids.getCredentials().setUsername(usr);
                ids.getCredentials().setPassword(pwd);
            }
            try {
                ids.authenticate();
                log.info(usr + " authenticated for rest api");
              
                return true;
            } catch (LoginException e) {
                log.warn("Unable to authenticate for rest api: " + usr);
View Full Code Here

public class CXFAuthenticationHandler implements RequestHandler {

    public Response handleRequest(Message m, ClassResourceInfo resourceClass) {
        if (Contexts.isApplicationContextActive()) {
            //If the request is from same session, the user should be logged already.
            Identity ids = Identity.instance();
            if (ids.isLoggedIn()) {
                return null;
            }

            AuthorizationPolicy policy = (AuthorizationPolicy) m
                    .get(AuthorizationPolicy.class);

            // The policy can be null when the user did not specify credentials
            if (policy != null) {
                String username = policy.getUserName();
                String password = policy.getPassword();

                ids.getCredentials().setUsername(username);
                ids.getCredentials().setPassword(password);
            }

            try {
                ids.authenticate();
                return null;
            } catch (LoginException e) {
                e.printStackTrace();
                throw new WebApplicationException(getErrorResponse());
            }
View Full Code Here

            //If the request is from same session, the user should be logged already.
            if (Identity.instance().isLoggedIn()) {
                return true;
            }

            Identity ids = Identity.instance();
            if (auth != null && auth.toUpperCase(Locale.ENGLISH).startsWith("BASIC ")) {
                String[] a = unpack(auth);
                usr = a[0];
                pwd = a[1];
                ids.getCredentials().setUsername(usr);
                ids.getCredentials().setPassword(pwd);
            }
            try {
                ids.authenticate();
                log.info(usr + " authenticated for rest api");

                return true;
            } catch (LoginException e) {
                log.warn("Unable to authenticate for rest api: " + usr);
View Full Code Here

        /*if (action == null) {
            action = "json";
        } */

        // log in
        Identity ids = Identity.instance();
        ids.getCredentials().setUsername(usr);
        ids.getCredentials().setPassword(pwd);

        try {
            ids.authenticate();
        } catch (LoginException e) {
            throw new ServletException(new IllegalArgumentException("Unable to authenticate user."));
        }

        log.debug("Successful login");
View Full Code Here

     * This will return a auto login user name if it has been configured.
     * Autologin means that its not really logged in, but a generic username will be used.
     * Basically means security is bypassed.
     */
    private String checkAutoLogin() {
        Identity id = Identity.instance();
        id.getCredentials().setUsername( GUEST_LOGIN );
        try {
            id.authenticate();
        } catch ( LoginException e ) {
            return null;
        }
        if ( id.isLoggedIn() ) {
            return id.getCredentials().getUsername();
        } else {
            return null;
        }

    }
View Full Code Here

        localeMemberDAO.makePersistent(newMember);
    }

    @Test
    public void testSave() throws Exception {
        Identity identity = Identity.instance();
        identity.getCredentials().setUsername("admin");
        identity.getCredentials().setPassword("admin");
        identity.login();

        HLocale locale = entityManager.find(HLocale.class, new Long(1));
        HAccount account = entityManager.find(HAccount.class, new Long(1));

        assertThat(locale, notNullValue());
View Full Code Here

TOP

Related Classes of org.jboss.seam.security.Identity

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.