-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #98 from bnicholesdell/moveto6.11-version
Add APIs for connecting to SPS. Update the dependency versions. Move to 6.11 and sync with SafeguardDotnet.
- Loading branch information
Showing
13 changed files
with
567 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/com/oneidentity/safeguard/safeguardjava/ISafeguardSessionsConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package com.oneidentity.safeguard.safeguardjava; | ||
|
||
import com.oneidentity.safeguard.safeguardjava.data.FullResponse; | ||
import com.oneidentity.safeguard.safeguardjava.data.Method; | ||
import com.oneidentity.safeguard.safeguardjava.exceptions.ArgumentException; | ||
import com.oneidentity.safeguard.safeguardjava.exceptions.ObjectDisposedException; | ||
import com.oneidentity.safeguard.safeguardjava.exceptions.SafeguardForJavaException; | ||
|
||
/** | ||
* This is the reusable connection interface that can be used to call SPS API. | ||
*/ | ||
public interface ISafeguardSessionsConnection { | ||
|
||
/** | ||
* Call a Safeguard for Privileged Sessions API method and get any response as a string. | ||
* If there is a failure a SafeguardDotNetException will be thrown. | ||
* | ||
* @param method Safeguard method type to use. | ||
* @param relativeUrl Relative URL of the service to use. | ||
* @param body Request body to pass to the method. | ||
* @return Response body as a string. | ||
* @throws ObjectDisposedException Object has already been disposed. | ||
* @throws SafeguardForJavaException General Safeguard for Java exception. | ||
* @throws ArgumentException Invalid argument. | ||
*/ | ||
String InvokeMethod(Method method, String relativeUrl, String body) | ||
throws ObjectDisposedException, SafeguardForJavaException, ArgumentException; | ||
|
||
/** | ||
* Call a Safeguard for Privileged Sessions API method and get a detailed response | ||
* with status code, headers, and body. If there is a failure a SafeguardDotNetException | ||
* will be thrown. | ||
* | ||
* @param method Safeguard method type to use. | ||
* @param relativeUrl Relative URL of the service to use. | ||
* @param body Request body to pass to the method. | ||
* @return Response with status code, headers, and body as string. | ||
* @throws ObjectDisposedException Object has already been disposed. | ||
* @throws SafeguardForJavaException General Safeguard for Java exception. | ||
* @throws ArgumentException Invalid argument. | ||
*/ | ||
FullResponse InvokeMethodFull(Method method, String relativeUrl, String body) | ||
throws ObjectDisposedException, SafeguardForJavaException, ArgumentException; | ||
|
||
} |
86 changes: 86 additions & 0 deletions
86
src/main/java/com/oneidentity/safeguard/safeguardjava/PersistentSafeguardConnection.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
package com.oneidentity.safeguard.safeguardjava; | ||
|
||
import com.oneidentity.safeguard.safeguardjava.data.FullResponse; | ||
import com.oneidentity.safeguard.safeguardjava.data.Method; | ||
import com.oneidentity.safeguard.safeguardjava.data.Service; | ||
import com.oneidentity.safeguard.safeguardjava.event.ISafeguardEventListener; | ||
import com.oneidentity.safeguard.safeguardjava.event.SafeguardEventListener; | ||
import com.oneidentity.safeguard.safeguardjava.exceptions.ArgumentException; | ||
import com.oneidentity.safeguard.safeguardjava.exceptions.ObjectDisposedException; | ||
import com.oneidentity.safeguard.safeguardjava.exceptions.SafeguardForJavaException; | ||
import java.util.Map; | ||
|
||
class PersistentSafeguardConnection implements ISafeguardConnection { | ||
|
||
private final ISafeguardConnection _connection; | ||
private boolean disposed; | ||
|
||
public PersistentSafeguardConnection(ISafeguardConnection connection) { | ||
_connection = connection; | ||
} | ||
|
||
public IStreamingRequest getStreamingRequest() { | ||
return _connection.getStreamingRequest(); | ||
} | ||
|
||
@Override | ||
public void dispose() | ||
{ | ||
_connection.dispose(); | ||
} | ||
|
||
public FullResponse JoinSps(ISafeguardSessionsConnection spsConnection, String certificateChain, String sppAddress) | ||
throws ObjectDisposedException, SafeguardForJavaException, ArgumentException | ||
{ | ||
if (_connection.getAccessTokenLifetimeRemaining() <= 0) | ||
_connection.refreshAccessToken(); | ||
return _connection.JoinSps(spsConnection, certificateChain, sppAddress); | ||
} | ||
|
||
@Override | ||
public int getAccessTokenLifetimeRemaining() throws ObjectDisposedException, SafeguardForJavaException { | ||
return _connection.getAccessTokenLifetimeRemaining(); | ||
} | ||
|
||
@Override | ||
public void refreshAccessToken() throws ObjectDisposedException, SafeguardForJavaException { | ||
_connection.refreshAccessToken(); | ||
} | ||
|
||
@Override | ||
public String invokeMethod(Service service, Method method, String relativeUrl, String body, Map<String, String> parameters, Map<String, String> additionalHeaders, Integer timeout) throws ObjectDisposedException, SafeguardForJavaException, ArgumentException { | ||
if(_connection.getAccessTokenLifetimeRemaining() <= 0) | ||
_connection.refreshAccessToken(); | ||
return _connection.invokeMethod(service, method, relativeUrl, body, parameters, additionalHeaders, timeout); | ||
} | ||
|
||
@Override | ||
public FullResponse invokeMethodFull(Service service, Method method, String relativeUrl, String body, Map<String, String> parameters, Map<String, String> additionalHeaders, Integer timeout) throws ObjectDisposedException, SafeguardForJavaException, ArgumentException { | ||
if (_connection.getAccessTokenLifetimeRemaining() <= 0) | ||
_connection.refreshAccessToken(); | ||
return _connection.invokeMethodFull(service, method, relativeUrl, body, parameters, additionalHeaders, timeout); | ||
} | ||
|
||
@Override | ||
public String invokeMethodCsv(Service service, Method method, String relativeUrl, String body, Map<String, String> parameters, Map<String, String> additionalHeaders, Integer timeout) throws ObjectDisposedException, SafeguardForJavaException, ArgumentException { | ||
if (_connection.getAccessTokenLifetimeRemaining() <= 0) | ||
_connection.refreshAccessToken(); | ||
return _connection.invokeMethodCsv(service, method, relativeUrl, body, parameters, additionalHeaders, timeout); | ||
} | ||
|
||
@Override | ||
public SafeguardEventListener getEventListener() throws ObjectDisposedException, ArgumentException { | ||
return _connection.getEventListener(); | ||
} | ||
|
||
@Override | ||
public ISafeguardEventListener getPersistentEventListener() throws ObjectDisposedException, SafeguardForJavaException { | ||
return _connection.getPersistentEventListener(); | ||
} | ||
|
||
@Override | ||
public void logOut() throws ObjectDisposedException { | ||
_connection.logOut(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
src/main/java/com/oneidentity/safeguard/safeguardjava/SafeguardForPrivilegedSessions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.oneidentity.safeguard.safeguardjava; | ||
|
||
import com.oneidentity.safeguard.safeguardjava.exceptions.SafeguardForJavaException; | ||
|
||
/** | ||
* This static class provides static methods for connecting to Safeguard for Privileged Sessions API. | ||
*/ | ||
public class SafeguardForPrivilegedSessions { | ||
/** | ||
* Connect to Safeguard for Privileged Sessions API using a user name and password. | ||
* | ||
* @param networkAddress Network address of Safeguard for Privileged Sessions appliance. | ||
* @param username User name to use for authentication. | ||
* @param password User password to use for authentication. | ||
* @param ignoreSsl Ignore server certificate validation. | ||
* | ||
* @return Reusable Safeguard for Privileged Sessions API connection. | ||
* @throws SafeguardForJavaException General Safeguard for Java exception. | ||
*/ | ||
public static ISafeguardSessionsConnection Connect(String networkAddress, String username, | ||
char[] password, boolean ignoreSsl) | ||
throws SafeguardForJavaException | ||
{ | ||
return new SafeguardSessionsConnection(networkAddress, username, password, ignoreSsl, null); | ||
} | ||
|
||
//TODO: This class should provide an Connect API with a validationCallback parameter | ||
// public static ISafeguardSessionsConnection Connect(String networkAddress, String username, | ||
// char[] password, HostnameVerifier validationCallback) | ||
// throws SafeguardForJavaException | ||
// { | ||
// return new SafeguardSessionsConnection(networkAddress, username, password, ignoreSsl); | ||
// } | ||
} |
Oops, something went wrong.