Search in sources :

Example 16 with OSystemException

use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.

the class OTokenHandlerImpl method deserializeWebPayload.

protected OJwtPayload deserializeWebPayload(final String type, final byte[] decodedPayload) {
    if (!"OrientDB".equals(type)) {
        throw new OSystemException("Payload class not registered:" + type);
    }
    final ODocument doc = new ODocument();
    try {
        doc.fromJSON(new String(decodedPayload, "UTF-8"));
    } catch (UnsupportedEncodingException e) {
        throw OException.wrapException(new OSystemException("Payload encoding format differs from UTF-8"), e);
    }
    final OrientJwtPayload payload = new OrientJwtPayload();
    payload.setIssuer((String) doc.field("iss"));
    payload.setExpiry((Long) doc.field("exp"));
    payload.setIssuedAt((Long) doc.field("iat"));
    payload.setNotBefore((Long) doc.field("nbf"));
    payload.setDatabase((String) doc.field("sub"));
    payload.setAudience((String) doc.field("aud"));
    payload.setTokenId((String) doc.field("jti"));
    final int cluster = (Integer) doc.field("uidc");
    final long pos = (Long) doc.field("uidp");
    payload.setUserRid(new ORecordId(cluster, pos));
    payload.setDatabaseType((String) doc.field("bdtyp"));
    return payload;
}
Also used : OSystemException(com.orientechnologies.common.exception.OSystemException) ORecordId(com.orientechnologies.orient.core.id.ORecordId) ODocument(com.orientechnologies.orient.core.record.impl.ODocument)

Example 17 with OSystemException

use of com.orientechnologies.common.exception.OSystemException in project orientdb by orientechnologies.

the class OConsoleDatabaseApp method displayRecord.

@ConsoleCommand(aliases = { "display" }, description = "Display current record attributes", onlineHelp = "Console-Command-Display-Record")
public void displayRecord(@ConsoleParameter(name = "number", description = "The number of the record in the most recent result set") final String iRecordNumber) {
    checkForDatabase();
    if (iRecordNumber == null || currentResultSet == null)
        checkCurrentObject();
    else {
        int recNumber = Integer.parseInt(iRecordNumber);
        if (currentResultSet.size() == 0)
            throw new OSystemException("No result set where to find the requested record. Execute a query first.");
        if (currentResultSet.size() <= recNumber)
            throw new OSystemException("The record requested is not part of current result set (0" + (currentResultSet.size() > 0 ? "-" + (currentResultSet.size() - 1) : "") + ")");
        setCurrentRecord(recNumber);
    }
    dumpRecordDetails();
}
Also used : OSystemException(com.orientechnologies.common.exception.OSystemException) ConsoleCommand(com.orientechnologies.common.console.annotation.ConsoleCommand)

Aggregations

OSystemException (com.orientechnologies.common.exception.OSystemException)17 OException (com.orientechnologies.common.exception.OException)6 OTokenException (com.orientechnologies.orient.core.metadata.security.OTokenException)4 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)4 ConsoleCommand (com.orientechnologies.common.console.annotation.ConsoleCommand)3 OBinaryToken (com.orientechnologies.orient.server.binary.impl.OBinaryToken)3 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)3 OIOException (com.orientechnologies.common.io.OIOException)2 ORecordId (com.orientechnologies.orient.core.id.ORecordId)2 ONetworkProtocolException (com.orientechnologies.orient.enterprise.channel.binary.ONetworkProtocolException)2 OResponseProcessingException (com.orientechnologies.orient.enterprise.channel.binary.OResponseProcessingException)2 IOException (java.io.IOException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 OTimeoutException (com.orientechnologies.common.concur.OTimeoutException)1 OInterruptedException (com.orientechnologies.common.concur.lock.OInterruptedException)1 OLockException (com.orientechnologies.common.concur.lock.OLockException)1 OConsoleDatabaseApp (com.orientechnologies.orient.console.OConsoleDatabaseApp)1 ODatabaseDocumentTx (com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx)1 OIdentifiable (com.orientechnologies.orient.core.db.record.OIdentifiable)1 ORidBag (com.orientechnologies.orient.core.db.record.ridbag.ORidBag)1