use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class AccessTokenServlet method verifyAndGet.
@Override
public ServiceTransaction verifyAndGet(IssuerResponse iResponse) throws IOException {
ATResponse atResponse = (ATResponse) iResponse;
Verifier verifier = atResponse.getVerifier();
debug("5.a. verifier = " + atResponse.getVerifier());
checkTimestamp(verifier.getToken());
ServiceTransaction transaction = (ServiceTransaction) getTransactionStore().get(verifier);
if (transaction == null) {
throw new TransactionNotFoundException("No transaction found for verifier " + verifier);
}
checkClientApproval(transaction.getClient());
String cc = "client=" + transaction.getClient().getIdentifierString();
info("5.a. " + cc);
debug("5.a. grant valid=" + transaction.isAuthGrantValid() + ", at valid=" + transaction.isAccessTokenValid());
if (!transaction.isAuthGrantValid() || transaction.isAccessTokenValid()) {
String msg = "Error: the state of the transaction is invalid for auth grant " + transaction.getAuthorizationGrant();
warn(msg);
throw new GeneralException(msg);
}
return transaction;
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class CertServlet method verifyAndGet.
public ServiceTransaction verifyAndGet(IssuerResponse iResponse) throws IOException {
PAResponse par = (PAResponse) iResponse;
AccessToken accessToken = par.getAccessToken();
ServiceTransaction t = (ServiceTransaction) getTransactionStore().get(accessToken);
if (t == null) {
throw new GeneralException("Error: no transaction found for access token \"" + accessToken + "\"");
}
if (!t.isAccessTokenValid()) {
throw new GeneralException("Error: invalid access token. Request refused");
}
checkClientApproval(t.getClient());
checkTimestamp(accessToken.getToken());
return t;
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class InitServlet method verifyAndGet.
@Override
public ServiceTransaction verifyAndGet(IssuerResponse iResponse) throws IOException {
AGResponse agResponse = (AGResponse) iResponse;
Map<String, String> params = agResponse.getParameters();
ServiceTransaction transaction = newTransaction();
transaction.setAuthorizationGrant(agResponse.getGrant());
debug("creating transaction for trans id=" + transaction.getIdentifierString());
transaction.setAuthGrantValid(false);
transaction.setAccessTokenValid(false);
transaction.setCallback(URI.create(params.get(OAUTH_CALLBACK)));
MyPKCS10CertRequest certReq = null;
// Fix for CIL-409
if (!params.containsKey(CERT_REQUEST)) {
throw new GeneralException("Error: missing cert request parameter.");
}
String rawCR = params.get(CERT_REQUEST);
if (isEmpty(rawCR)) {
throw new GeneralException("Error: empty cert request.");
}
try {
certReq = CertUtil.fromStringToCertReq(rawCR);
} catch (Throwable throwable) {
throwable.printStackTrace();
throw new GeneralException("Error: cert request is bad/not understandable:" + (rawCR == null ? "(null)" : rawCR), throwable);
}
transaction.setCertReq(certReq);
// Assumption here is that the cert lifetime is in milliseconds
transaction.setLifetime(Long.parseLong(params.get(CERT_LIFETIME)));
return transaction;
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class JGlobusUtil method createProxyCertificate.
public static X509Certificate createProxyCertificate(X509Certificate baseCert, PrivateKey generatedPrivateKey, PublicKey publicKey, int certLifetimeInSeconds) {
// Sign a cert req from OAuth client using a cert obtained from MyProxy server
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
ProxyPolicy policy = new ProxyPolicy(ProxyPolicy.LIMITED);
ProxyCertInfo proxyCertInfo = new ProxyCertInfo(policy);
X509ExtensionSet extSet = new X509ExtensionSet();
extSet.add(new ProxyCertInfoExtension(proxyCertInfo));
BouncyCastleCertProcessingFactory factory = BouncyCastleCertProcessingFactory.getDefault();
try {
// add the cert afterwards so there is no issue with modifying the list early.
X509Certificate x = factory.createProxyCertificate(baseCert, generatedPrivateKey, publicKey, certLifetimeInSeconds, GSI_4_LIMITED_PROXY, extSet, null);
return x;
} catch (GeneralSecurityException e) {
String errMsg = "3.c. Error: signing a limited proxy credential: " + e.getMessage();
// throw it.
throw new GeneralException(errMsg, e);
}
}
use of edu.uiuc.ncsa.security.core.exceptions.GeneralException in project OA4MP by ncsa.
the class AdminClientServer method get.
public AbstractACResponse get(ACGetRequest request) {
if (request.getAdminClient().getIdentifierString().length() == 0) {
throw new GeneralException("Error: No supplied admin client identifier.");
}
AdminClient adminClient = getAdminClientStore().get(request.getAdminClient().getIdentifier());
// do not return the secret or its hash
adminClient.setSecret("");
return new ACGetResponse(adminClient, cose.getClientApprovalStore().isApproved(adminClient.getIdentifier()));
}
Aggregations