Search in sources :

Example 1 with SrmPingResponse

use of org.dcache.srm.v2_2.SrmPingResponse in project dcache by dCache.

the class SrmHandler method handleRequest.

public Object handleRequest(String requestName, Object request) throws RemoteException {
    long startTimeStamp = System.currentTimeMillis();
    // requestName values all start "srm".  This is redundant, so may
    // be removed when creating the session id.  The initial character is
    // converted to lowercase, so "srmPrepareToPut" becomes "prepareToPut".
    String session = "srm2:" + Character.toLowerCase(requestName.charAt(3)) + requestName.substring(4);
    try (JDC ignored = JDC.createSession(session)) {
        for (RequestLogger logger : loggers) {
            logger.request(requestName, request);
        }
        Subject user = Subject.getSubject(AccessController.getContext());
        Object response;
        if (requestName.equals("srmPing")) {
            // Ping is special as it isn't authenticated and unable to return a failure
            response = new SrmPingResponse("v2.2", pingExtraInfo);
        } else {
            try {
                response = dispatch(user, requestName, request);
            } catch (SRMInternalErrorException e) {
                LOGGER.error(e.getMessage());
                response = getFailedResponse(requestName, e.getStatusCode(), "Authentication failed (server log contains additional information).");
            } catch (SRMAuthorizationException e) {
                LOGGER.info(e.getMessage());
                response = getFailedResponse(requestName, e.getStatusCode(), "Permission denied.");
            } catch (SRMAuthenticationException e) {
                LOGGER.warn(e.getMessage());
                response = getFailedResponse(requestName, e.getStatusCode(), "Authentication failed (server log contains additional information).");
            } catch (SRMException e) {
                response = getFailedResponse(requestName, e.getStatusCode(), e.getMessage());
            } catch (PermissionDeniedCacheException e) {
                response = getFailedResponse(requestName, TStatusCode.SRM_AUTHORIZATION_FAILURE, e.getMessage());
            } catch (CacheException e) {
                response = getFailedResponse(requestName, TStatusCode.SRM_INTERNAL_ERROR, e.getMessage());
            } catch (InterruptedException e) {
                response = getFailedResponse(requestName, TStatusCode.SRM_FATAL_INTERNAL_ERROR, "Server shutdown.");
            } catch (NoRouteToCellException e) {
                LOGGER.error(e.getMessage());
                response = getFailedResponse(requestName, TStatusCode.SRM_INTERNAL_ERROR, "SRM backend serving this request is currently offline.");
            }
        }
        long time = System.currentTimeMillis() - startTimeStamp;
        for (RequestLogger logger : loggers) {
            logger.response(requestName, request, response, user, time);
        }
        return response;
    }
}
Also used : SRMAuthorizationException(org.dcache.srm.SRMAuthorizationException) CacheException(diskCacheV111.util.CacheException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) JDC(org.dcache.srm.util.JDC) ArrayOfString(org.dcache.srm.v2_2.ArrayOfString) SrmPingResponse(org.dcache.srm.v2_2.SrmPingResponse) Subject(javax.security.auth.Subject) SRMInternalErrorException(org.dcache.srm.SRMInternalErrorException) SRMAuthenticationException(org.dcache.srm.SRMAuthenticationException) PermissionDeniedCacheException(diskCacheV111.util.PermissionDeniedCacheException) SRMException(org.dcache.srm.SRMException) NoRouteToCellException(dmg.cells.nucleus.NoRouteToCellException)

Example 2 with SrmPingResponse

use of org.dcache.srm.v2_2.SrmPingResponse in project dcache by dCache.

the class SRMPingClientV2 method start.

@Override
public void start() throws IOException {
    SrmPingRequest request = new SrmPingRequest();
    SrmPingResponse response = srm.srmPing(request);
    say("received response");
    if (response == null) {
        throw new IOException(" null response");
    }
    StringBuilder sb = new StringBuilder();
    sb.append("VersionInfo : ").append(response.getVersionInfo()).append("\n");
    if (response.getOtherInfo() != null) {
        ArrayOfTExtraInfo info = response.getOtherInfo();
        if (info.getExtraInfoArray() != null) {
            for (int i = 0; i < info.getExtraInfoArray().length; i++) {
                TExtraInfo extraInfo = info.getExtraInfoArray()[i];
                sb.append(extraInfo.getKey()).append(":").append(extraInfo.getValue()).append("\n");
            }
        }
    }
    System.out.println(sb.toString());
}
Also used : ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo) TExtraInfo(org.dcache.srm.v2_2.TExtraInfo) SrmPingRequest(org.dcache.srm.v2_2.SrmPingRequest) SrmPingResponse(org.dcache.srm.v2_2.SrmPingResponse) IOException(java.io.IOException) ArrayOfTExtraInfo(org.dcache.srm.v2_2.ArrayOfTExtraInfo)

Aggregations

SrmPingResponse (org.dcache.srm.v2_2.SrmPingResponse)2 CacheException (diskCacheV111.util.CacheException)1 PermissionDeniedCacheException (diskCacheV111.util.PermissionDeniedCacheException)1 NoRouteToCellException (dmg.cells.nucleus.NoRouteToCellException)1 IOException (java.io.IOException)1 Subject (javax.security.auth.Subject)1 SRMAuthenticationException (org.dcache.srm.SRMAuthenticationException)1 SRMAuthorizationException (org.dcache.srm.SRMAuthorizationException)1 SRMException (org.dcache.srm.SRMException)1 SRMInternalErrorException (org.dcache.srm.SRMInternalErrorException)1 JDC (org.dcache.srm.util.JDC)1 ArrayOfString (org.dcache.srm.v2_2.ArrayOfString)1 ArrayOfTExtraInfo (org.dcache.srm.v2_2.ArrayOfTExtraInfo)1 SrmPingRequest (org.dcache.srm.v2_2.SrmPingRequest)1 TExtraInfo (org.dcache.srm.v2_2.TExtraInfo)1