agave-common/common-core/src/main/java/org/iplantc/service/common/auth/AgaveMyProxyLogon.java
/**
	 * Logs on to the MyProxy server by issuing the MyProxy GET command.
	 */
Logs on to the MyProxy server by issuing the MyProxy GET command.
Logs on to the MyProxy server by issuing the MyProxy GET command .
public void logon() throws IOException, GeneralSecurityException {
		String line;
		char response;
		if (this.state != State.CONNECTED) {
				this.connect();
		}
		this.socketOut.write('0');
		this.socketOut.flush();
		this.socketOut.write(VERSION.getBytes());
		this.socketOut.write('\n');
		this.socketOut.write(GETCOMMAND.getBytes());
		this.socketOut.write('\n');
		this.socketOut.write(USERNAME.getBytes());
		this.socketOut.write(this.username.getBytes());
		this.socketOut.write('\n');
		this.socketOut.write(PASSPHRASE.getBytes());
		this.socketOut.write(this.passphrase.getBytes());
		this.socketOut.write('\n');
		this.socketOut.write(LIFETIME.getBytes());
		this.socketOut.write(Integer.toString(this.lifetime).getBytes());
		this.socketOut.write('\n');
		if (this.credname != null) {
			this.socketOut.write(CREDNAME.getBytes());
			this.socketOut.write(this.credname.getBytes());
			this.socketOut.write('\n');
		}
		if (this.requestTrustRoots) {
			this.socketOut.write(TRUSTROOTS.getBytes());
			this.socketOut.write("1\n".getBytes());
		}
		this.socketOut.flush();
		line = readLine(this.socketIn);
		if (line == null) {
			throw new EOFException();
		}
		if (!line.equals(VERSION)) {
			throw new ProtocolException("bad MyProxy protocol VERSION string: "
					+ line);
		}
		line = readLine(this.socketIn);
		if (line == null) {
			throw new EOFException();
		}
		if (!line.startsWith(RESPONSE)
				|| line.length() != RESPONSE.length() + 1) {
			throw new ProtocolException(
					"bad MyProxy protocol RESPONSE string: " + line);
		}
		response = line.charAt(RESPONSE.length());
		if (response == '1') {
			StringBuffer errString;
			errString = new StringBuffer("MyProxy logon failed");
			while ((line = readLine(this.socketIn)) != null) {
				if (line.startsWith(ERROR)) {
					errString.append('\n');
					errString.append(line.substring(ERROR.length()));
				}
			}
			throw new FailedLoginException(errString.toString());
		} else if (response == '2') {
			throw new ProtocolException(
					"MyProxy authorization RESPONSE not implemented");
		} else if (response != '0') {
			throw new ProtocolException(
					"unknown MyProxy protocol RESPONSE string: " + line);
		}
		while ((line = readLine(this.socketIn)) != null) {
			if (line.startsWith(TRUSTROOTS)) {
				String filenameList = line.substring(TRUSTROOTS.length());
				this.trustrootFilenames = filenameList.split(",");
				this.trustrootData = new String[this.trustrootFilenames.length];
				for (int i = 0; i < this.trustrootFilenames.length; i++) {
					String lineStart = "FILEDATA_" + this.trustrootFilenames[i]
							+ "=";
					line = readLine(this.socketIn);
					if (line == null) {
						throw new EOFException();
					}
					if (!line.startsWith(lineStart)) {
						throw new ProtocolException(
								"bad MyProxy protocol RESPONSE: expecting "
										+ lineStart + " but received " + line);
					}
					this.trustrootData[i] = new String(Base64.decode(line
							.substring(lineStart.length())));
				}
			}
		}
		this.state = State.LOGGEDON;
	}
public void logon ( ) throws IOException , GeneralSecurityException { String line ; char response ; if ( this . state != State . CONNECTED ) { this . connect ( ) ; } this . socketOut . write ( '0' ) ; this . socketOut . flush ( ) ; this . socketOut . write ( VERSION . getBytes ( ) ) ; this . socketOut . write ( '\n' ) ; this . socketOut . write ( GETCOMMAND . getBytes ( ) ) ; this . socketOut . write ( '\n' ) ; this . socketOut . write ( USERNAME . getBytes ( ) ) ; this . socketOut . write ( this . username . getBytes ( ) ) ; this . socketOut . write ( '\n' ) ; this . socketOut . write ( PASSPHRASE . getBytes ( ) ) ; this . socketOut . write ( this . passphrase . getBytes ( ) ) ; this . socketOut . write ( '\n' ) ; this . socketOut . write ( LIFETIME . getBytes ( ) ) ; this . socketOut . write ( Integer . toString ( this . lifetime ) . getBytes ( ) ) ; this . socketOut . write ( '\n' ) ; if ( this . credname != null ) { this . socketOut . write ( CREDNAME . getBytes ( ) ) ; this . socketOut . write ( this . credname . getBytes ( ) ) ; this . socketOut . write ( '\n' ) ; } if ( this . requestTrustRoots ) { this . socketOut . write ( TRUSTROOTS . getBytes ( ) ) ; this . socketOut . write ( "1\n" . getBytes ( ) ) ; } this . socketOut . flush ( ) ; line = readLine ( this . socketIn ) ; if ( line == null ) { throw new EOFException ( ) ; } if ( ! line . equals ( VERSION ) ) { throw new ProtocolException ( "bad MyProxy protocol VERSION string: " + line ) ; } line = readLine ( this . socketIn ) ; if ( line == null ) { throw new EOFException ( ) ; } if ( ! line . startsWith ( RESPONSE ) || line . length ( ) != RESPONSE . length ( ) + 1 ) { throw new ProtocolException ( "bad MyProxy protocol RESPONSE string: " + line ) ; } response = line . charAt ( RESPONSE . length ( ) ) ; if ( response == '1' ) { StringBuffer errString ; errString = new StringBuffer ( "MyProxy logon failed" ) ; while ( ( line = readLine ( this . socketIn ) ) != null ) { if ( line . startsWith ( ERROR ) ) { errString . append ( '\n' ) ; errString . append ( line . substring ( ERROR . length ( ) ) ) ; } } throw new FailedLoginException ( errString . toString ( ) ) ; } else if ( response == '2' ) { throw new ProtocolException ( "MyProxy authorization RESPONSE not implemented" ) ; } else if ( response != '0' ) { throw new ProtocolException ( "unknown MyProxy protocol RESPONSE string: " + line ) ; } while ( ( line = readLine ( this . socketIn ) ) != null ) { if ( line . startsWith ( TRUSTROOTS ) ) { String filenameList = line . substring ( TRUSTROOTS . length ( ) ) ; this . trustrootFilenames = filenameList . split ( "," ) ; this . trustrootData = new String [ this . trustrootFilenames . length ] ; for ( int i = 0 ; i < this . trustrootFilenames . length ; i ++ ) { String lineStart = "FILEDATA_" + this . trustrootFilenames [ i ] + "=" ; line = readLine ( this . socketIn ) ; if ( line == null ) { throw new EOFException ( ) ; } if ( ! line . startsWith ( lineStart ) ) { throw new ProtocolException ( "bad MyProxy protocol RESPONSE: expecting " + lineStart + " but received " + line ) ; } this . trustrootData [ i ] = new String ( Base64 . decode ( line . substring ( lineStart . length ( ) ) ) ) ; } } } this . state = State . LOGGEDON ; }
Logs on to the MyProxy server by issuing the MyProxy GET command.
Logs on to the MyProxy server by issuing the MyProxy GET command .