use of edu.uiuc.ncsa.security.core.Identifier in project OA4MP by ncsa.
the class TransactionConverter method fromMap.
@Override
public V fromMap(ConversionMap<String, Object> map, V v) {
V t = super.fromMap(map, v);
String CertReqString = map.getString(getDSTK().certReq());
if (CertReqString != null && 0 < CertReqString.length())
t.setCertReq(CertUtil.fromStringToCertReq(CertReqString));
String y = map.getString(getDSTK().cert());
if (y != null && 0 < y.length()) {
try {
ByteArrayInputStream baos = new ByteArrayInputStream(y.getBytes("UTF-8"));
MyX509Certificates myCert = new MyX509Certificates(fromPEM(baos));
t.setProtectedAsset(myCert);
} catch (CertificateException e) {
throw new GeneralException("Error decoding certificate", e);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
Identifier clientKey = BasicIdentifier.newID(map.getString(getDSTK().clientKey()));
if (clientKey != null) {
t.setClient(clientStore.get(clientKey));
}
String uName = map.getString(getDSTK().username());
if (uName != null) {
t.setUsername(uName);
}
String myproxyUsername = map.getString(getDSTK().myproxyUsername());
if (myproxyUsername != null) {
t.setMyproxyUsername(myproxyUsername);
}
return t;
}
use of edu.uiuc.ncsa.security.core.Identifier in project OA4MP by ncsa.
the class SQLPermissionStore method getAdmins.
@Override
public List<Identifier> getAdmins(Identifier clientID) {
ArrayList<Identifier> admins = new ArrayList<>();
if (clientID == null)
return admins;
Connection c = getConnection();
PermissionKeys permissionKeys = new PermissionKeys();
try {
PreparedStatement stmt = c.prepareStatement("select " + permissionKeys.adminID() + " from " + getTable().getFQTablename() + " where " + permissionKeys.clientID() + "=?");
stmt.setString(1, clientID.toString());
// just execute() since executeQuery(x) would throw an exception regardless of content per JDBC spec.
stmt.execute();
ResultSet rs = stmt.getResultSet();
while (rs.next()) {
String adminID = rs.getString(permissionKeys.adminID());
admins.add(BasicIdentifier.newID(adminID));
}
rs.close();
stmt.close();
} catch (SQLException e) {
destroyConnection(c);
throw new GeneralException("Error: could not get database object", e);
} finally {
releaseConnection(c);
}
return admins;
}
use of edu.uiuc.ncsa.security.core.Identifier in project OA4MP by ncsa.
the class OA2StartRequest method doIt.
@Override
protected void doIt(HttpServletRequest request, HttpServletResponse response) throws Throwable {
info("1.a. Starting transaction");
OA4MPResponse gtwResp = null;
// Drumroll please: here is the work for this call.
Identifier id = AssetStoreUtil.createID();
gtwResp = getOA4MPService().requestCert(id);
// if there is a store, store something in it.
Cookie cookie = new Cookie(OA4MP_CLIENT_REQUEST_ID, id.getUri().toString());
// 15 minutes
cookie.setMaxAge(15 * 60);
cookie.setSecure(true);
debug("id = " + id.getUri());
response.addCookie(cookie);
info("1.b. Got response. Creating page with redirect for " + gtwResp.getRedirect().getHost());
if (getCE().isShowRedirectPage()) {
request.setAttribute(REDIR, REDIR);
request.setAttribute("redirectUrl", gtwResp.getRedirect().toString());
request.setAttribute(ACTION_KEY, ACTION_KEY);
request.setAttribute("action", ACTION_REDIRECT_VALUE);
// Normally, we'd just do a redirect, but we will put up a page and show the redirect to the user.
// The client response contains the generated private key as well
// In a real application, the private key would be stored. This, however, exceeds the scope of this
// sample application -- all we need to do to complete the process is send along the redirect url.
info("1.b. Showing redirect page.");
JSPUtil.fwd(request, response, getCE().getRedirectPagePath());
return;
}
response.sendRedirect(gtwResp.getRedirect().toString());
}
use of edu.uiuc.ncsa.security.core.Identifier in project OA4MP by ncsa.
the class AbstractOA4MPService method makeb64Uri.
protected Identifier makeb64Uri(String x) {
Base64String b64 = new Base64String(x.getBytes());
Identifier id = BasicIdentifier.newID(BASE64_URI_CAPUT + b64);
return id;
}
use of edu.uiuc.ncsa.security.core.Identifier in project OA4MP by ncsa.
the class AssetStoreTest method testAsset.
@Test
public void testAsset() throws Exception {
Identifier id = BasicIdentifier.newID("asset:id:/" + ClientTestStoreUtil.getRandomString());
Asset asset = new Asset(id);
PrivateKey privateKey = KeyUtil.generateKeyPair().getPrivate();
String username = "testUser-" + ClientTestStoreUtil.getRandomString(8);
URI redirect = URI.create("http://test.foo/test" + ClientTestStoreUtil.getRandomString(8));
asset.setPrivateKey(privateKey);
asset.setUsername(username);
asset.setRedirect(redirect);
assert asset.getPrivateKey().equals(privateKey);
assert asset.getUsername().equals(username);
assert asset.getRedirect().equals(redirect);
}
Aggregations