Search in sources :

Example 6 with Asset

use of edu.uiuc.ncsa.myproxy.oa4mp.client.Asset in project OA4MP by ncsa.

the class SQLAssetStore method getByToken.

@Override
public Asset getByToken(Identifier token) {
    if (token == null) {
        return null;
    }
    Connection c = getConnection();
    Asset t = null;
    try {
        PreparedStatement stmt = c.prepareStatement(getAST().getByTokenStatement());
        stmt.setString(1, token.toString());
        stmt.executeQuery();
        ResultSet rs = stmt.getResultSet();
        // Now we have to pull in all the values.
        if (!rs.next()) {
            rs.close();
            stmt.close();
            // returning a null fulfills contract for this being a map.
            return null;
        }
        ColumnMap map = rsToMap(rs);
        rs.close();
        stmt.close();
        t = create();
        populate(map, t);
    } catch (SQLException e) {
        destroyConnection(c);
        throw new GeneralException("Error getting object with identifier \"" + token + "\"", e);
    } finally {
        releaseConnection(c);
    }
    return t;
}
Also used : ColumnMap(edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap) GeneralException(edu.uiuc.ncsa.security.core.exceptions.GeneralException) SQLException(java.sql.SQLException) Connection(java.sql.Connection) ResultSet(java.sql.ResultSet) Asset(edu.uiuc.ncsa.myproxy.oa4mp.client.Asset) PreparedStatement(java.sql.PreparedStatement)

Aggregations

Asset (edu.uiuc.ncsa.myproxy.oa4mp.client.Asset)6 Identifier (edu.uiuc.ncsa.security.core.Identifier)4 BasicIdentifier (edu.uiuc.ncsa.security.core.util.BasicIdentifier)3 URI (java.net.URI)3 PrivateKey (java.security.PrivateKey)3 GeneralException (edu.uiuc.ncsa.security.core.exceptions.GeneralException)2 MyPKCS10CertRequest (edu.uiuc.ncsa.security.util.pkcs.MyPKCS10CertRequest)2 KeyPair (java.security.KeyPair)2 SecureRandom (java.security.SecureRandom)2 SQLException (java.sql.SQLException)2 AssetResponse (edu.uiuc.ncsa.myproxy.oa4mp.client.AssetResponse)1 ClientEnvironment (edu.uiuc.ncsa.myproxy.oa4mp.client.ClientEnvironment)1 ValidTimestampPolicy (edu.uiuc.ncsa.security.core.cache.ValidTimestampPolicy)1 UnregisteredObjectException (edu.uiuc.ncsa.security.core.exceptions.UnregisteredObjectException)1 MyLoggingFacade (edu.uiuc.ncsa.security.core.util.MyLoggingFacade)1 SQLStore (edu.uiuc.ncsa.security.storage.sql.SQLStore)1 ColumnMap (edu.uiuc.ncsa.security.storage.sql.internals.ColumnMap)1 X509Certificate (java.security.cert.X509Certificate)1 Connection (java.sql.Connection)1 PreparedStatement (java.sql.PreparedStatement)1