Example usage for org.springframework.security.oauth2.provider.approval Approval Approval

List of usage examples for org.springframework.security.oauth2.provider.approval Approval Approval

Introduction

In this page you can find the example usage for org.springframework.security.oauth2.provider.approval Approval Approval.

Prototype

public Approval(String userId, String clientId, String scope, Date expiresAt, ApprovalStatus status,
            Date lastUpdatedAt) 

Source Link

Usage

From source file:oauth2.authentication.approvals.ApprovalServiceImpl.java

static Approval fromEntity(oauth2.entities.Approval entity) {
    return new Approval(entity.getUserId(), entity.getClientId(), entity.getScope(),
            toDate(entity.getExpiresAt()), entity.getStatus(), toDate(entity.getLastUpdateAt()));
}

From source file:org.meruvian.yama.web.security.oauth.DefaultOauthApplicationApprovalService.java

@Override
public Collection<Approval> getApprovals(String userId, String clientId) {
    List<Approval> approvals = new ArrayList<Approval>();
    userId = userRepository.findByUsername(userId).getId();

    for (OauthApplicationApproval a : approvalRepository
            .findByLogInformationCreateByAndApplicationId(userId, clientId, null).getContent()) {
        userId = a.getLogInformation().getCreateBy();
        clientId = a.getApplication().getId();
        String scope = a.getScope();
        Date expiresAt = a.getExpiresAt();
        org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus status = org.springframework.security.oauth2.provider.approval.Approval.ApprovalStatus
                .valueOf(a.getStatus().name());
        Date lastUpdatedAt = a.getLogInformation().getLastUpdateDate();

        Approval approval = new Approval(userId, clientId, scope, expiresAt, status, lastUpdatedAt);
        approvals.add(approval);/*w  ww .j  a v  a2  s  . com*/
    }

    return approvals;
}

From source file:com.cedac.security.oauth2.provider.approval.MongoApprovalStore.java

@Override
public List<Approval> getApprovals(String userName, String clientId) {
    BasicDBObject query = new BasicDBObject(userIdFieldName, userName).append(clientIdFieldName, clientId);
    DBCursor cursor = null;// w  w w.j  av a 2 s  .  c o  m
    try {
        List<Approval> approvals = new ArrayList<Approval>();
        cursor = getApprovalsCollection().find(query);
        while (cursor.hasNext()) {
            DBObject dbo = cursor.next();
            approvals.add(new Approval((String) dbo.get(userIdFieldName), (String) dbo.get(clientIdFieldName),
                    (String) dbo.get(scopeFieldName), (Date) dbo.get(expiresAtFieldName),
                    Approval.ApprovalStatus.valueOf((String) dbo.get(statusFieldName)),
                    (Date) dbo.get(lastModifiedAtFieldName)));
        }
        return approvals;
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
}