001/** 002 * Copyright (c) 2015-2022, Michael Yang 杨福海 (fuhai999@gmail.com). 003 * <p> 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * <p> 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * <p> 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package io.jboot.support.shiro.processer; 017 018import java.io.Serializable; 019 020/** 021 * 认证处理器 执行后的认证结果。 022 */ 023public class AuthorizeResult implements Serializable { 024 025 public static final int CODE_SUCCESS = 0; 026 027 /** 028 * 未进行身份认证 029 */ 030 public static final int ERROR_CODE_UNAUTHENTICATED = 1; 031 032 033 /** 034 * 没有权限访问 035 */ 036 public static final int ERROR_CODE_UNAUTHORIZATION = 2; 037 038 039 040 private int errorCode = CODE_SUCCESS; 041 042 043 public int getErrorCode() { 044 return errorCode; 045 } 046 047 public AuthorizeResult setErrorCode(int errorCode) { 048 this.errorCode = errorCode; 049 return this; 050 } 051 052 public boolean isOk() { 053 return errorCode == CODE_SUCCESS; 054 } 055 056 057 public static AuthorizeResult ok() { 058 return new AuthorizeResult(); 059 } 060 061 062 public static AuthorizeResult fail(int errorCode) { 063 return new AuthorizeResult().setErrorCode(errorCode); 064 } 065 066 067}