Search in sources :

Example 1 with TransactionStore

use of edu.uiuc.ncsa.security.delegation.storage.TransactionStore in project OA4MP by ncsa.

the class OA2ConfigurationLoader method getTSP.

protected Provider<TransactionStore> getTSP(IdentifiableProvider tp, OA2TConverter<? extends OA2ServiceTransaction> tc) {
    if (tsp == null) {
        // since this is referenced in an inner class below.
        final IdentifiableProvider tp1 = tp;
        OA2MultiTypeProvider storeProvider = new OA2MultiTypeProvider(cn, isDefaultStoreDisabled(), loggerProvider.get(), tp);
        storeProvider.addListener(createSQLTSP(cn, getMySQLConnectionPoolProvider(), OA4MPConfigTags.MYSQL_STORE, getCSP(), tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(createSQLTSP(cn, getMariaDBConnectionPoolProvider(), OA4MPConfigTags.MARIADB_STORE, getCSP(), tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(createSQLTSP(cn, getPgConnectionPoolProvider(), OA4MPConfigTags.POSTGRESQL_STORE, getCSP(), tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(new OA2FSTStoreProvider(cn, tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(new TypedProvider<TransactionStore>(cn, OA4MPConfigTags.MEMORY_STORE, OA4MPConfigTags.TRANSACTIONS_STORE) {

            @Override
            public Object componentFound(CfgEvent configurationEvent) {
                if (checkEvent(configurationEvent)) {
                    return get();
                }
                return null;
            }

            @Override
            public TransactionStore get() {
                return new OA2MTStore(tp1);
            }
        });
        tsp = storeProvider;
    }
    return tsp;
}
Also used : TransactionStore(edu.uiuc.ncsa.security.delegation.storage.TransactionStore) CfgEvent(edu.uiuc.ncsa.security.core.configuration.provider.CfgEvent) IdentifiableProvider(edu.uiuc.ncsa.security.core.IdentifiableProvider)

Example 2 with TransactionStore

use of edu.uiuc.ncsa.security.delegation.storage.TransactionStore in project OA4MP by ncsa.

the class OA2ATServlet method verifyAndGet.

@Override
public ServiceTransaction verifyAndGet(IssuerResponse iResponse) throws IOException {
    ATIResponse2 atResponse = (ATIResponse2) iResponse;
    TransactionStore transactionStore = getTransactionStore();
    BasicIdentifier basicIdentifier = new BasicIdentifier(atResponse.getParameters().get(OA2Constants.AUTHORIZATION_CODE));
    DebugUtil.dbg(this, "getting transaction for identifier=" + basicIdentifier);
    OA2ServiceTransaction transaction = (OA2ServiceTransaction) transactionStore.get(basicIdentifier);
    if (transaction == null) {
        // Then this request does not correspond to an previous one and must be rejected asap.
        throw new OA2ATException(OA2Errors.INVALID_REQUEST, "No pending transaction found for id=" + basicIdentifier);
    }
    if (!transaction.isAuthGrantValid()) {
        String msg = "Error: Attempt to use invalid authorization code.  Request rejected.";
        warn(msg);
        throw new GeneralException(msg);
    }
    URI uri = URI.create(atResponse.getParameters().get(OA2Constants.REDIRECT_URI));
    if (!transaction.getCallback().equals(uri)) {
        String msg = "Attempt to use alternate redirect uri rejected.";
        warn(msg);
        throw new OA2ATException(OA2Errors.INVALID_REQUEST, msg);
    }
    /* Now we have to determine which scopes to return
           The spec says we don't have to return anything if the requested scopes are the same as the
           supported scopes. Otherwise, return what scopes *are* supported.
         */
    ArrayList<String> targetScopes = new ArrayList<>();
    OA2SE oa2SE = (OA2SE) getServiceEnvironment();
    // set true if something is requested we don't support
    boolean returnScopes = false;
    for (String s : transaction.getScopes()) {
        if (oa2SE.getScopes().contains(s)) {
            targetScopes.add(s);
        } else {
            returnScopes = true;
        }
    }
    if (returnScopes) {
        atResponse.setSupportedScopes(targetScopes);
    }
    atResponse.setScopeHandlers(setupScopeHandlers(transaction, oa2SE));
    atResponse.setServiceTransaction(transaction);
    atResponse.setJsonWebKey(oa2SE.getJsonWebKeys().getDefault());
    // return null;
    return transaction;
}
Also used : TransactionStore(edu.uiuc.ncsa.security.delegation.storage.TransactionStore) OA2SE(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE) OA2ServiceTransaction(edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2ServiceTransaction) BasicIdentifier(edu.uiuc.ncsa.security.core.util.BasicIdentifier) ArrayList(java.util.ArrayList) URI(java.net.URI)

Example 3 with TransactionStore

use of edu.uiuc.ncsa.security.delegation.storage.TransactionStore in project OA4MP by ncsa.

the class AbstractConfigurationLoader method getTSP.

protected Provider<TransactionStore> getTSP() {
    if (tsp == null) {
        final DSTransactionProvider tp = new DSTransactionProvider<OA4MPServiceTransaction>();
        TransactionConverter<OA4MPServiceTransaction> tc = new TransactionConverter(tp, getTokenForgeProvider().get(), (ClientStore<? extends Client>) getCSP().get());
        MultiDSTransactionStoreProvider storeProvider = new MultiDSTransactionStoreProvider(cn, isDefaultStoreDisabled(), loggerProvider.get(), tp);
        storeProvider.addListener(new DSSQLTransactionStoreProvider(cn, getMySQLConnectionPoolProvider(), OA4MPConfigTags.MYSQL_STORE, getCSP(), tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(new DSSQLTransactionStoreProvider(cn, getMariaDBConnectionPoolProvider(), OA4MPConfigTags.MARIADB_STORE, getCSP(), tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(new DSSQLTransactionStoreProvider(cn, getPgConnectionPoolProvider(), OA4MPConfigTags.POSTGRESQL_STORE, getCSP(), tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(new DSFSTransactionStoreProvider(cn, tp, getTokenForgeProvider(), tc));
        storeProvider.addListener(new TypedProvider<TransactionStore>(cn, OA4MPConfigTags.MEMORY_STORE, OA4MPConfigTags.TRANSACTIONS_STORE) {

            @Override
            public Object componentFound(CfgEvent configurationEvent) {
                if (checkEvent(configurationEvent)) {
                    return get();
                }
                return null;
            }

            @Override
            public TransactionStore get() {
                return new TransactionMemoryStore(tp);
            }
        });
        tsp = storeProvider;
    }
    return tsp;
}
Also used : OA4MPServiceTransaction(edu.uiuc.ncsa.myproxy.oa4mp.server.OA4MPServiceTransaction) CfgEvent(edu.uiuc.ncsa.security.core.configuration.provider.CfgEvent) TransactionMemoryStore(edu.uiuc.ncsa.security.delegation.storage.impl.TransactionMemoryStore) TransactionStore(edu.uiuc.ncsa.security.delegation.storage.TransactionStore)

Aggregations

TransactionStore (edu.uiuc.ncsa.security.delegation.storage.TransactionStore)3 CfgEvent (edu.uiuc.ncsa.security.core.configuration.provider.CfgEvent)2 OA2SE (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2SE)1 OA2ServiceTransaction (edu.uiuc.ncsa.myproxy.oa4mp.oauth2.OA2ServiceTransaction)1 OA4MPServiceTransaction (edu.uiuc.ncsa.myproxy.oa4mp.server.OA4MPServiceTransaction)1 IdentifiableProvider (edu.uiuc.ncsa.security.core.IdentifiableProvider)1 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)1 TransactionMemoryStore (edu.uiuc.ncsa.security.delegation.storage.impl.TransactionMemoryStore)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1