当前位置: 首页>>代码示例>>Java>>正文


Java AuthenticationUtil.getCurrentSubject方法代码示例

本文整理汇总了Java中ca.nrc.cadc.auth.AuthenticationUtil.getCurrentSubject方法的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationUtil.getCurrentSubject方法的具体用法?Java AuthenticationUtil.getCurrentSubject怎么用?Java AuthenticationUtil.getCurrentSubject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca.nrc.cadc.auth.AuthenticationUtil的用法示例。


在下文中一共展示了AuthenticationUtil.getCurrentSubject方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: init

import ca.nrc.cadc.auth.AuthenticationUtil; //导入方法依赖的package包/类
private void init() {
    Subject s = AuthenticationUtil.getCurrentSubject();
    AuthMethod meth = AuthenticationUtil.getAuthMethodFromCredentials(s);
    if (meth == null) {
        meth = AuthMethod.ANON;
    }
    this.baseServiceURL = rc.getServiceURL(this.resourceID, Standards.CAOM2REPO_OBS_23, meth);
    if (baseServiceURL == null) {
        throw new RuntimeException("not found: " + resourceID + " + " + Standards.CAOM2REPO_OBS_23 + " + " + meth);
    }
    log.debug("observation list URL: " + baseServiceURL.toString());
    log.debug("AuthMethod:  " + meth);
}
 
开发者ID:opencadc,项目名称:caom2db,代码行数:14,代码来源:RepoClient.java

示例2: initDel

import ca.nrc.cadc.auth.AuthenticationUtil; //导入方法依赖的package包/类
private void initDel() {
    Subject s = AuthenticationUtil.getCurrentSubject();
    AuthMethod meth = AuthenticationUtil.getAuthMethodFromCredentials(s);
    if (meth == null) {
        meth = AuthMethod.ANON;
    }
    this.baseDeletionURL = rc.getServiceURL(resourceID, Standards.CAOM2REPO_DEL_23, meth);
    if (baseDeletionURL == null) {
        throw new RuntimeException("not found: " + resourceID + " + " + Standards.CAOM2REPO_DEL_23 + " + " + meth);
    }
    log.debug("deletion list URL: " + baseDeletionURL.toString());
    log.debug("AuthMethod:  " + meth);
}
 
开发者ID:opencadc,项目名称:caom2db,代码行数:14,代码来源:RepoClient.java

示例3: get

import ca.nrc.cadc.auth.AuthenticationUtil; //导入方法依赖的package包/类
public ObservationResponse get(ObservationURI uri) {
    init();
    if (uri == null) {
        throw new IllegalArgumentException("uri cannot be null");
    }

    ObservationState os = new ObservationState(uri);

    // see comment above in getList
    Subject subjectForWorkerThread = AuthenticationUtil.getCurrentSubject();
    Worker wt = new Worker(os, subjectForWorkerThread, baseServiceURL.toExternalForm());
    return wt.getObservation();
}
 
开发者ID:opencadc,项目名称:caom2db,代码行数:14,代码来源:RepoClient.java

示例4: toURL

import ca.nrc.cadc.auth.AuthenticationUtil; //导入方法依赖的package包/类
@Override
public URL toURL(URI uri) {
    if (!SCHEME.equals(uri.getScheme())) {
        throw new IllegalArgumentException("invalid scheme in " + uri);
    }

    try {
        Subject subject = AuthenticationUtil.getCurrentSubject();
        AuthMethod authMethod = AuthenticationUtil.getAuthMethodFromCredentials(subject);
        if (authMethod == null) {
            authMethod = AuthMethod.ANON;
        }
        RegistryClient rc = new RegistryClient();
        Capabilities caps = rc.getCapabilities(DATA_RESOURCE_ID);
        Capability dataCap = caps.findCapability(Standards.DATA_10);
        URI securityMethod = Standards.getSecurityMethod(authMethod);
        Interface ifc = dataCap.findInterface(securityMethod);
        if (ifc == null) {
            throw new IllegalArgumentException("No interface for security method " + securityMethod);
        }
        String baseDataURL = ifc.getAccessURL().getURL().toString();
        URL url = new URL(baseDataURL + "/MAST/" + uri.getSchemeSpecificPart());
        log.debug(uri + " --> " + url);
        return url;
    } catch (MalformedURLException ex) {
        throw new RuntimeException("BUG", ex);
    } catch (Throwable t) {
        String message = "Failed to convert to data URL";
        throw new RuntimeException(message, t);
    }
}
 
开发者ID:opencadc,项目名称:caom2,代码行数:32,代码来源:CadcMastResolver.java

示例5: getList

import ca.nrc.cadc.auth.AuthenticationUtil; //导入方法依赖的package包/类
public List<ObservationResponse> getList(String collection, Date startDate, Date end, Integer numberOfObservations)
        throws InterruptedException, ExecutionException {
    init();

    // startDate = null;
    // end = df.parse("2017-06-20T09:03:15.360");
    List<ObservationResponse> list = new ArrayList<>();

    List<ObservationState> stateList = getObservationList(collection, startDate, end, numberOfObservations);

    // Create tasks for each file
    List<Callable<ObservationResponse>> tasks = new ArrayList<>();

    // the current subject usually gets propagated into a thread pool, but
    // gets attached
    // when the thread is created so we explicitly pass it it and do another
    // Subject.doAs in
    // case
    // thread pool management is changed
    Subject subjectForWorkerThread = AuthenticationUtil.getCurrentSubject();
    for (ObservationState os : stateList) {
        tasks.add(new Worker(os, subjectForWorkerThread, baseServiceURL.toExternalForm()));
    }

    ExecutorService taskExecutor = null;
    try {
        // Run tasks in a fixed thread pool
        taskExecutor = Executors.newFixedThreadPool(nthreads);
        List<Future<ObservationResponse>> futures;

        futures = taskExecutor.invokeAll(tasks);

        for (Future<ObservationResponse> f : futures) {
            ObservationResponse res = null;
            res = f.get();

            if (f.isDone()) {
                list.add(res);
            }
        }
    } catch (InterruptedException | ExecutionException e) {
        log.error("Error when executing thread in ThreadPool: " + e.getMessage() + " caused by: " + e.getCause().toString());
        throw e;
    } finally {
        if (taskExecutor != null) {
            taskExecutor.shutdown();
        }
    }

    return list;
}
 
开发者ID:opencadc,项目名称:caom2db,代码行数:52,代码来源:RepoClient.java


注:本文中的ca.nrc.cadc.auth.AuthenticationUtil.getCurrentSubject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。