Package com.sshtools.common.configuration

Examples of com.sshtools.common.configuration.Authorization


* @throws IOException
* @throws InvalidSshKeyException
*/
    public byte[] format(AuthorizedKeys keys, AuthorizedKeysFileSaver saver)
        throws IOException, InvalidSshKeyException {
        Authorization authorization = new Authorization();
        SshPublicKeyFile pubfile;
        SECSHPublicKeyFormat secsh = new SECSHPublicKeyFormat();
        Map.Entry entry;

        for (Iterator it = keys.getAuthorizedKeys().entrySet().iterator();
                (it != null) && it.hasNext();) {
            entry = (Map.Entry) it.next();

            // Write out the public key file
            String username = (String) entry.getValue();
            String filename = username + ".pub";
            secsh.setComment(username);
            pubfile = SshPublicKeyFile.create((SshPublicKey) entry.getKey(),
                    secsh);
            saver.saveFile(filename, pubfile.toString().getBytes("US-ASCII"));

            // Write out the key entry
            authorization.addKey(filename);
        }

        return authorization.toString().getBytes("US-ASCII");
    }
View Full Code Here


    public AuthorizedKeys unformat(byte[] formatted,
        AuthorizedKeysFileLoader loader)
        throws IOException, InvalidSshKeyException {
        try {
            AuthorizedKeys keys = new AuthorizedKeys();
            Authorization authorization = new Authorization(new ByteArrayInputStream(
                        formatted));
            List keyfiles = authorization.getAuthorizedKeys();
            Iterator it = keyfiles.iterator();
            String filename;
            SshPublicKeyFile pubfile;
            String username;
View Full Code Here

* @throws IOException
* @throws InvalidSshKeyException
*/
    public byte[] format(AuthorizedKeys keys, AuthorizedKeysFileSaver saver)
        throws IOException, InvalidSshKeyException {
        Authorization authorization = new Authorization();
        SshPublicKeyFile pubfile;
        SECSHPublicKeyFormat secsh = new SECSHPublicKeyFormat();
        Map.Entry entry;

        for (Iterator it = keys.getAuthorizedKeys().entrySet().iterator();
                (it != null) && it.hasNext();) {
            entry = (Map.Entry) it.next();

            // Write out the public key file
            String username = (String) entry.getValue();
            String filename = username + ".pub";
            secsh.setComment(username);
            pubfile = SshPublicKeyFile.create((SshPublicKey) entry.getKey(),
                    secsh);
            saver.saveFile(filename, pubfile.toString().getBytes("US-ASCII"));

            // Write out the key entry
            authorization.addKey(filename);
        }

        return authorization.toString().getBytes("US-ASCII");
    }
View Full Code Here

    public AuthorizedKeys unformat(byte[] formatted,
        AuthorizedKeysFileLoader loader)
        throws IOException, InvalidSshKeyException {
        try {
            AuthorizedKeys keys = new AuthorizedKeys();
            Authorization authorization = new Authorization(new ByteArrayInputStream(
                        formatted));
            List keyfiles = authorization.getAuthorizedKeys();
            Iterator it = keyfiles.iterator();
            String filename;
            SshPublicKeyFile pubfile;
            String username;
View Full Code Here

TOP

Related Classes of com.sshtools.common.configuration.Authorization

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.