Class InternalSecurityClientRest
- java.lang.Object
-
- fr.gouv.vitam.common.client.DefaultClient
-
- fr.gouv.vitam.security.internal.client.InternalSecurityClientRest
-
- All Implemented Interfaces:
BasicClient,MockOrRestClient,VitamAutoCloseable,InternalSecurityClient,java.lang.AutoCloseable
public class InternalSecurityClientRest extends DefaultClient implements InternalSecurityClient
-
-
Field Summary
-
Fields inherited from interface fr.gouv.vitam.common.client.BasicClient
STATUS_URL
-
-
Constructor Summary
Constructors Constructor Description InternalSecurityClientRest(VitamClientFactoryInterface<?> factory)Constructor using given scheme (http)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckIdentityExpiration()voidcheckPersonalCertificate(byte[] certificate, java.lang.String permission)Check certificate with a permissionvoidcheckPersonalCertificateExpiration()voidcheckStatus()Check the status from the servicevoidcheckStatus(javax.ws.rs.core.MultivaluedHashMap<java.lang.String,java.lang.Object> headers)Check the status from the service used to passe "X-SSL-CLIENT-CERT" header that contain a pem certificatevoidclose()Close the underneath http clientvoidconsumeAnyEntityAndClose(javax.ws.rs.core.Response response)Helper when an error occurs on client usage side to consume response howeverbooleancontextIsUsed(java.lang.String contextId)Check if a context is used in certificatesjava.util.Optional<IdentityModel>findIdentity(byte[] certificate)Find Identityjavax.ws.rs.client.ClientgetChunkedClient()javax.ws.rs.client.ClientgetClient()VitamClientFactory<?>getClientFactory()java.lang.StringgetResourcePath()Get the resource path of the server.java.lang.StringgetServiceUrl()Get the service URLIsPersonalCertificateRequiredModelisPersonalCertificateRequiredByPermission(java.lang.String permission)Check if a personal certificate is required for this permissionjavax.ws.rs.core.Responsemake(VitamRequestBuilder request)javax.ws.rs.core.ResponsemakeSpecifyingUrl(VitamRequestBuilder request)static voidstaticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)This method consume everything (in particular InputStream) and close the response.java.lang.StringtoString()-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface fr.gouv.vitam.common.client.MockOrRestClient
checkStatus, checkStatus, close, consumeAnyEntityAndClose, getResourcePath, getServiceUrl
-
-
-
-
Constructor Detail
-
InternalSecurityClientRest
public InternalSecurityClientRest(VitamClientFactoryInterface<?> factory)
Constructor using given scheme (http)- Parameters:
factory- The client factory
-
-
Method Detail
-
findIdentity
public java.util.Optional<IdentityModel> findIdentity(byte[] certificate) throws VitamClientInternalException, InternalSecurityException
Description copied from interface:InternalSecurityClientFind Identity- Specified by:
findIdentityin interfaceInternalSecurityClient- Returns:
- an Optional describing the IdentityModel, otherwise return an empty Optional.
- Throws:
VitamClientInternalException- in case of client exceptionInternalSecurityException- in case of internal security exception
-
checkIdentityExpiration
public void checkIdentityExpiration() throws VitamClientInternalException, InternalSecurityException- Specified by:
checkIdentityExpirationin interfaceInternalSecurityClient- Throws:
VitamClientInternalExceptionInternalSecurityException
-
checkPersonalCertificateExpiration
public void checkPersonalCertificateExpiration() throws VitamClientInternalException, InternalSecurityException- Specified by:
checkPersonalCertificateExpirationin interfaceInternalSecurityClient- Throws:
VitamClientInternalExceptionInternalSecurityException
-
contextIsUsed
public boolean contextIsUsed(java.lang.String contextId) throws VitamClientInternalException, InternalSecurityExceptionDescription copied from interface:InternalSecurityClientCheck if a context is used in certificates- Specified by:
contextIsUsedin interfaceInternalSecurityClient- Returns:
- true if the context is used by an identity.
- Throws:
VitamClientInternalExceptionInternalSecurityException
-
isPersonalCertificateRequiredByPermission
public IsPersonalCertificateRequiredModel isPersonalCertificateRequiredByPermission(java.lang.String permission) throws VitamClientInternalException, InternalSecurityException
Description copied from interface:InternalSecurityClientCheck if a personal certificate is required for this permission- Specified by:
isPersonalCertificateRequiredByPermissionin interfaceInternalSecurityClient- Parameters:
permission- the permission to be checkd- Returns:
- IsPersonalCertificateRequiredModel
- Throws:
VitamClientInternalExceptionInternalSecurityException
-
checkPersonalCertificate
public void checkPersonalCertificate(byte[] certificate, java.lang.String permission) throws VitamClientInternalException, InternalSecurityExceptionDescription copied from interface:InternalSecurityClientCheck certificate with a permission- Specified by:
checkPersonalCertificatein interfaceInternalSecurityClient- Parameters:
certificate- the certificate to be checkedpermission- the permission to be checked- Throws:
VitamClientInternalExceptionInternalSecurityException
-
staticConsumeAnyEntityAndClose
public static void staticConsumeAnyEntityAndClose(javax.ws.rs.core.Response response)
This method consume everything (in particular InputStream) and close the response.- Parameters:
response-
-
consumeAnyEntityAndClose
public final void consumeAnyEntityAndClose(javax.ws.rs.core.Response response)
Description copied from interface:MockOrRestClientHelper when an error occurs on client usage side to consume response however- Specified by:
consumeAnyEntityAndClosein interfaceMockOrRestClient
-
checkStatus
public void checkStatus() throws VitamApplicationServerExceptionDescription copied from interface:MockOrRestClientCheck the status from the service- Specified by:
checkStatusin interfaceMockOrRestClient- Throws:
VitamApplicationServerException- if the Server is unavailable
-
checkStatus
public void checkStatus(javax.ws.rs.core.MultivaluedHashMap<java.lang.String,java.lang.Object> headers) throws VitamApplicationServerExceptionDescription copied from interface:MockOrRestClientCheck the status from the service used to passe "X-SSL-CLIENT-CERT" header that contain a pem certificate- Specified by:
checkStatusin interfaceMockOrRestClient- Throws:
VitamApplicationServerException- if the Server is unavailable
-
getResourcePath
public java.lang.String getResourcePath()
Description copied from interface:MockOrRestClientGet the resource path of the server.- Specified by:
getResourcePathin interfaceMockOrRestClient- Returns:
- the resource path as string
-
getServiceUrl
public java.lang.String getServiceUrl()
Description copied from interface:MockOrRestClientGet the service URL- Specified by:
getServiceUrlin interfaceMockOrRestClient- Returns:
- the service URL
-
close
public void close()
Description copied from interface:MockOrRestClientClose the underneath http client- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfaceMockOrRestClient- Specified by:
closein interfaceVitamAutoCloseable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
makeSpecifyingUrl
public javax.ws.rs.core.Response makeSpecifyingUrl(VitamRequestBuilder request) throws VitamClientInternalException
- Throws:
VitamClientInternalException
-
make
public javax.ws.rs.core.Response make(VitamRequestBuilder request) throws VitamClientInternalException
- Throws:
VitamClientInternalException
-
getClientFactory
public VitamClientFactory<?> getClientFactory()
-
getClient
public javax.ws.rs.client.Client getClient()
-
getChunkedClient
public javax.ws.rs.client.Client getChunkedClient()
-
-