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;
}
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;
}
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;
}
Aggregations