Package org.exolab.jms.common.security

Examples of org.exolab.jms.common.security.BasicPrincipal


                PRINCIPAL, _connectURI, properties);
        assertNotNull(connection);

        // make sure can't connect without a valid principal
        try {
            connection = clientCF.getConnection(new BasicPrincipal("x", "y"),
                                               _connectURI, properties);
            fail("Expected ResourceException to be thrown");
        } catch (ResourceException expected) {
            // no-op
        }
View Full Code Here


     * @param uri the URI to get the user info from
     * @return a new BasicPrincipal containing the user info, or
     *         <code>null</code> if none was specified
     */
    public static BasicPrincipal getPrincipal(URI uri) {
        BasicPrincipal principal = null;
        String userinfo = uri.getUserinfo();
        if (userinfo != null && userinfo.length() != 0) {
            int index = userinfo.indexOf(":");
            String user;
            String password = "";
            if (index != -1) {
                user = userinfo.substring(0, index);
                password = userinfo.substring(index + 1);
            } else {
                user = userinfo;
            }
            principal = new BasicPrincipal(user, password);
        }
        return principal;
    }
View Full Code Here

     * an unauthenticated connection.
     *
     * @throws Exception for any error
     */
    public void testCreateUnauthenticatedManagedConnection() throws Exception {
        Principal invalid = new BasicPrincipal("foo", "bar");
        checkCreateManagedConnection(null, invalid);
    }
View Full Code Here

     * an authenticated connection.
     *
     * @throws Exception for any error
     */
    public void testCreateAuthenticatedManagedConnection() throws Exception {
        Principal principal = new BasicPrincipal("foo", "bar");
        checkCreateManagedConnection(principal, null);
    }
View Full Code Here

     *
     * @throws Exception for any error
     */
    public void testMatchManagedConnections() throws Exception {
        ManagedConnection match = null;
        Principal first = new BasicPrincipal("first", "password");
        Principal second = new BasicPrincipal("second", "password");
        Principal[] principals = new Principal[] {first, second};

        ConnectionRequestInfo info = getManagedConnectionRequestInfo();

        // set up an acceptor to handle connection requests
View Full Code Here

     */
    public void testGetRegistryWithAuth() throws Exception {
        getORB().shutdown(); // default ORB setup withouth auth

        // set up the orb
        BasicPrincipal principal = new BasicPrincipal("user", "password");
        Authenticator authenticator = new TestAuthenticator(principal);
        ORB orb = createORB(authenticator);

        // set up the echo service
        EchoService service = new EchoServiceImpl();
View Full Code Here

    public ServerConnection createConnection(String clientID, String userName,
                                             String password)
            throws JMSException {
        Principal principal = null;
        if (userName != null) {
            principal = new BasicPrincipal(userName, password);
        }
        try {
            if (!_authenticator.authenticate(principal)) {
                throw new JMSSecurityException("Failed to authenticate user: " +
                                               userName);
View Full Code Here

     */
    public AdminConnection createConnection(String username, String password)
        throws JMSSecurityException, JMSException {
        Principal principal = null;
        if (username != null) {
            principal = new BasicPrincipal(username, password);
        }
        try {
            if (!_authenticator.authenticate(principal)) {
                throw new JMSSecurityException("Failed to authenticate user " +
                                               username);
View Full Code Here

     */
    public boolean authenticate(Principal principal) {
        String user = null;
        String password = null;
        if (principal instanceof BasicPrincipal) {
            BasicPrincipal basic = (BasicPrincipal) principal;
            user = basic.getName();
            password = basic.getPassword();
        } else {
            // treat everything else as an unauthenticated/unknown user
        }
        return validateUser(user, password);
    }
View Full Code Here

     * object exported via {@link ORB#exportObject(Object)}.
     *
     * @throws Exception for any error
     */
    public void testExportObjectWithAuth() throws Exception {
        BasicPrincipal principal = new BasicPrincipal("first", "secret");
        checkExportObject(principal);
    }
View Full Code Here

TOP

Related Classes of org.exolab.jms.common.security.BasicPrincipal

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.